diff --git a/bin/app/data/gui/startscreen/cpluspluss_icon.png b/bin/app/data/gui/startscreen/cpluspluss_icon.png new file mode 100755 index 00000000..d2736e26 Binary files /dev/null and b/bin/app/data/gui/startscreen/cpluspluss_icon.png differ diff --git a/bin/app/data/gui/startscreen/file_icon.png b/bin/app/data/gui/startscreen/file_icon.png new file mode 100755 index 00000000..74c283d3 Binary files /dev/null and b/bin/app/data/gui/startscreen/file_icon.png differ diff --git a/bin/app/data/gui/startscreen/logo_white.png b/bin/app/data/gui/startscreen/logo_white.png new file mode 100644 index 00000000..6692fe78 Binary files /dev/null and b/bin/app/data/gui/startscreen/logo_white.png differ diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 65271b59..120d0f89 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -25,6 +25,8 @@ add_files( qt/element/QtSmartSearchBox.h qt/element/QtSplashScreen.cpp qt/element/QtSplashScreen.h + qt/element/QtStartScreen.cpp + qt/element/QtStartScreen.h qt/element/QtStatusBar.cpp qt/element/QtStatusBar.h qt/element/QtUndoRedo.cpp diff --git a/src/app/main.cpp b/src/app/main.cpp index 9d135f5b..8b243d95 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -34,7 +34,7 @@ public: void run(void) { //min Time the Splash screen is displayed - //QThread::msleep(1000); + QThread::msleep(500); } }; @@ -59,6 +59,7 @@ int main(int argc, char *argv[]) splash->show(); splash->repaint(); + qtApp.processEvents(); if (splash) splash->message( "Starting GUI" ); qtApp.processEvents(); diff --git a/src/app/qt/element/QtMainWindow.cpp b/src/app/qt/element/QtMainWindow.cpp index d1aabb71..a88fd46d 100644 --- a/src/app/qt/element/QtMainWindow.cpp +++ b/src/app/qt/element/QtMainWindow.cpp @@ -9,6 +9,7 @@ #include "component/view/View.h" #include "component/view/CompositeView.h" +#include "qt/element/QtStartScreen.h" #include "qt/view/QtViewWidgetWrapper.h" #include "utility/logging/logging.h" #include "utility/messaging/type/MessageFind.h" @@ -40,6 +41,11 @@ QtMainWindow::QtMainWindow() // Need to call loadLayout here for right DockWidget size on Linux // Seconde call is in Application.cpp loadLayout(); + + //startScreen + startScreen = std::make_shared(this); + startScreen->setWindowModality(Qt::WindowModal); + startScreen->show(); } QtMainWindow::~QtMainWindow() diff --git a/src/app/qt/element/QtMainWindow.h b/src/app/qt/element/QtMainWindow.h index f2fc1667..7bb14556 100644 --- a/src/app/qt/element/QtMainWindow.h +++ b/src/app/qt/element/QtMainWindow.h @@ -1,12 +1,15 @@ #ifndef QT_MAIN_WINDOW_H #define QT_MAIN_WINDOW_H +#include #include #include #include #include +#include "QtStartScreen.h" + class QDockWidget; class View; @@ -53,6 +56,7 @@ private: void setupShortcuts(); QDockWidget* getDockWidgetForView(View* view) const; + std::shared_ptr startScreen; std::vector> m_dockWidgets; diff --git a/src/app/qt/element/QtStartScreen.cpp b/src/app/qt/element/QtStartScreen.cpp new file mode 100644 index 00000000..dc53918c --- /dev/null +++ b/src/app/qt/element/QtStartScreen.cpp @@ -0,0 +1,117 @@ +#include +#include "QtStartScreen.h" + +#include +#include + +#include "utility/file/FileSystem.h" +#include "utility/messaging/type/MessageLoadProject.h" + +QtRecentProjectButton::QtRecentProjectButton(const QString &text, QWidget *parent) + : QPushButton(text, parent) +{ + m_projectFile = text.toStdString(); + this->setText(FileSystem::fileName(FileSystem::filePathWithoutExtension(text.toStdString())).c_str()); +} + +void QtRecentProjectButton::handleButtonClick() +{ + MessageLoadProject(m_projectFile).dispatch(); + parentWidget()->hide(); +}; + +QtStartScreen::QtStartScreen(QWidget *parent) + : QWidget(parent, Qt::Dialog | Qt::Popup | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint ) +{ + setGeometry(parent->pos().x()+parent->width()/2-350,parent->pos().y()+parent->height()/2-250,600,500); + + QPalette palette; + QLinearGradient linearGradient(QPointF(0, 0), QPointF(0, 500)); + linearGradient.setColorAt(0, QColor(46,61,135)); + linearGradient.setColorAt(1, QColor(0,120,195)); + palette.setBrush(QPalette::Window,*(new QBrush(linearGradient))); + this->setPalette(palette); + + //QPixmap coati_logo("data/gui/logo_coati.png"); + QPixmap coati_logo("data/gui/startscreen/logo_white.png"); + QPixmap cpp_icon("data/gui/startscreen/cpluspluss_icon.png"); + + QLabel* coatiLogoLabel = new QLabel(this); + coatiLogoLabel->setPixmap(coati_logo); + coatiLogoLabel->setGeometry(30,30,100,138); + + std::string buttonStyle = + "QPushButton{font-family: " + "Source Code Pro; " + "font-size: 17pt; " + "border-radius: 15px; " + "background: white} " + "QPushButton:hover {background:lightgrey;}"; + + m_newProjectButton = new QPushButton("New Project", this); + m_newProjectButton->setGeometry(20,350, 200, 50); + m_newProjectButton->setStyleSheet(buttonStyle.c_str()); + connect(m_newProjectButton, SIGNAL(clicked()), this, SLOT(handleNewProjectButton())); + m_openProjectButton = new QPushButton("Open Project", this); + m_openProjectButton->setGeometry(20,420, 200, 50); + m_openProjectButton->setStyleSheet(buttonStyle.c_str()); + connect(m_openProjectButton, SIGNAL(clicked()), this, SLOT(handleOpenProjectButton())); + + connect(this, SIGNAL(openOpenProjectDialog()), parent, SLOT(openProject())); + connect(this, SIGNAL(openNewProjectDialog()), parent, SLOT(newProject())); + + QLabel* recentProjectsLabel = new QLabel("RECENT PROJECTS: ", this); + QFont font("Helvetica", 20); + recentProjectsLabel->setFont(font); + recentProjectsLabel->setStyleSheet("QLabel{font-family: Source Code Pro; font-size: 20pt; color: white;}"); + recentProjectsLabel->setGeometry(250, 100, 300, 50); + + std::vector extensions; + extensions.push_back(".xml"); + std::vector recentProjects = FileSystem::getFileNamesFromDirectory("data/projects", extensions); + + int position = 150; + for(std::string project : recentProjects) + { + QtRecentProjectButton* button = new QtRecentProjectButton(project.c_str(), this); + button->setGeometry(250, position, 400, 40); + button->setIcon(cpp_icon); + button->setIconSize(QSize(40,40)); + button->setStyleSheet( + "QPushButton{" + "font-family: Source Code Pro; " + "font-size: 12pt; " + "Text-align:left; " + "color: white; " + "background:none; " + "border:none;} " + "QPushButton:hover{color:lightgrey;}"); + connect(button, SIGNAL(clicked()), button, SLOT(handleButtonClick())); + position +=50; + } + + this->raise(); + +} + +QSize QtStartScreen::sizeHint() const +{ + return QSize(500,500); +} + +void QtStartScreen::paintEvent(QPaintEvent *event) +{ + QPainter* painter = new QPainter(this); +} + +void QtStartScreen::handleNewProjectButton() +{ + this->hide(); + emit openNewProjectDialog(); +} + +void QtStartScreen::handleOpenProjectButton() +{ + this->hide(); + emit openOpenProjectDialog(); +} diff --git a/src/app/qt/element/QtStartScreen.h b/src/app/qt/element/QtStartScreen.h new file mode 100644 index 00000000..0ab499bc --- /dev/null +++ b/src/app/qt/element/QtStartScreen.h @@ -0,0 +1,44 @@ +#ifndef STARTSCREEN_H +#define STARTSCREEN_H + +#include +#include +#include + + +class QtRecentProjectButton : public QPushButton +{ +Q_OBJECT +public: + QtRecentProjectButton(const QString& text, QWidget* parent); +public slots: + void handleButtonClick(); +private: + std::string m_projectFile; +}; + +class QtStartScreen : public QWidget +{ + Q_OBJECT + +public: + QtStartScreen(QWidget* parent = 0); + QSize sizeHint() const Q_DECL_OVERRIDE; + + void paintEvent(QPaintEvent* event); + +signals: + void openOpenProjectDialog(); + void openNewProjectDialog(); + +private slots: + void handleNewProjectButton(); + void handleOpenProjectButton(); +private: + QPushButton* m_openProjectButton; + QPushButton* m_newProjectButton; + std::vector m_recentProjects; +}; + + +#endif //STARTSCREEN_H diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 2a5c7d08..15157d3a 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -25,17 +25,6 @@ std::shared_ptr Application::create(ViewFactory* viewFactory) ptr->m_componentManager->setup(ptr->m_mainView.get()); ptr->m_mainView->loadLayout(); - std::string startupProjectFilePath = ApplicationSettings::getInstance()->getStartupProjectFilePath(); - if (startupProjectFilePath.size()) - { - MessageLoadProject(startupProjectFilePath).dispatch(); - } - else - { - MessageStatus("StartupProject was not defined in the ApplicationSettings", true).dispatch(); - LOG_WARNING("No StartupProject defined in ApplicationSettings"); - } - return ptr; }