ui: startscreen
startscreen with recent projects, "recent" projects are the xml files in the projects folder
This commit is contained in:
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
@@ -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
|
||||
|
||||
+2
-1
@@ -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();
|
||||
|
||||
@@ -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<QtStartScreen>(this);
|
||||
startScreen->setWindowModality(Qt::WindowModal);
|
||||
startScreen->show();
|
||||
}
|
||||
|
||||
QtMainWindow::~QtMainWindow()
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#ifndef QT_MAIN_WINDOW_H
|
||||
#define QT_MAIN_WINDOW_H
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <QShortcut>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
#include "QtStartScreen.h"
|
||||
|
||||
class QDockWidget;
|
||||
class View;
|
||||
|
||||
@@ -53,6 +56,7 @@ private:
|
||||
void setupShortcuts();
|
||||
|
||||
QDockWidget* getDockWidgetForView(View* view) const;
|
||||
std::shared_ptr<QtStartScreen> startScreen;
|
||||
|
||||
std::vector<std::pair<View*, QDockWidget*>> m_dockWidgets;
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#include <QtWidgets/qlabel.h>
|
||||
#include "QtStartScreen.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#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<std::string> extensions;
|
||||
extensions.push_back(".xml");
|
||||
std::vector<std::string> 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();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef STARTSCREEN_H
|
||||
#define STARTSCREEN_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QWidget>
|
||||
#include <QtWidgets/qpushbutton.h>
|
||||
|
||||
|
||||
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<QPushButton*> m_recentProjects;
|
||||
};
|
||||
|
||||
|
||||
#endif //STARTSCREEN_H
|
||||
@@ -25,17 +25,6 @@ std::shared_ptr<Application> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user