ui: added ApplicationSettingsScreen

* opens on first start autmatically
* open from the menu under Preferences
* show version number on splash screen
* added recent projects markup to app settings template
* moved all qt window classes to qt/window
* put common form stuff from project setup and app settings into QtSettingsWindow
This commit is contained in:
Eberhard Graether
2015-09-04 14:38:30 +02:00
parent 5ab627b735
commit 1ba802dd9b
25 changed files with 450 additions and 196 deletions
@@ -38,4 +38,12 @@
<expand_range><!-- INTEGER: amount of lines that the snippet range (not snapped) will be extended --></expand_range>
</snippet>
</code>
<user>
<has_seen_settings><!-- BOOL: if the user was already asked to enter app settings --></has_seen_settings>
<recent_projects>
<recent_project><!-- STRING: recent project path --></recent_project>
</recent_projects>
</user>
</config>
+14 -10
View File
@@ -19,22 +19,13 @@ add_files(
qt/element/QtDirectoryListBox.h
qt/element/QtLineEdit.cpp
qt/element/QtLineEdit.h
qt/element/QtMainWindow.cpp
qt/element/QtMainWindow.h
qt/element/QtProjectSetupScreen.cpp
qt/element/QtProjectSetupScreen.h
qt/element/QtRefreshBar.cpp
qt/element/QtRefreshBar.h
qt/element/QtSearchBar.cpp
qt/element/QtSearchBar.h
qt/element/QtSettingsWindow.cpp
qt/element/QtSettingsWindow.h
qt/element/QtSmartSearchBox.cpp
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
@@ -98,5 +89,18 @@ add_files(
qt/view/QtViewWidgetWrapper.cpp
qt/view/QtViewWidgetWrapper.h
qt/window/QtApplicationSettingsScreen.cpp
qt/window/QtApplicationSettingsScreen.h
qt/window/QtMainWindow.cpp
qt/window/QtMainWindow.h
qt/window/QtProjectSetupScreen.cpp
qt/window/QtProjectSetupScreen.h
qt/window/QtSettingsWindow.cpp
qt/window/QtSettingsWindow.h
qt/window/QtSplashScreen.cpp
qt/window/QtSplashScreen.h
qt/window/QtStartScreen.cpp
qt/window/QtStartScreen.h
main.cpp
)
+3 -2
View File
@@ -8,9 +8,10 @@
#include "Application.h"
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
#include "qt/element/QtSplashScreen.h"
#include "qt/window/QtSplashScreen.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewFactory.h"
#include "version.h"
void init()
{
@@ -37,7 +38,7 @@ int main(int argc, char *argv[])
QtSplashScreen* splash = new QtSplashScreen(whitePixmap, Qt::WindowStaysOnTopHint);
splash->setMessage("Loading UI");
splash->setVersion("0.1");
splash->setVersion(GIT_VERSION_NUMBER);
splash->exec(qtApp);
init();
+1 -1
View File
@@ -81,7 +81,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent)
m_list->setObjectName("list");
m_list->setAttribute(Qt::WA_MacShowFocusRect, 0);
setStyleSheet(utility::getStyleSheet("data/gui/settingwindows/listbox.css").c_str());
setStyleSheet(utility::getStyleSheet("data/gui/setting_window/listbox.css").c_str());
layout->addWidget(m_list);
QWidget* buttonContainer = new QWidget(this);
+1 -1
View File
@@ -2,7 +2,7 @@
#include "utility/logging/logging.h"
#include "qt/element/QtMainWindow.h"
#include "qt/window/QtMainWindow.h"
QtMainView::QtMainView()
{
@@ -0,0 +1,82 @@
#include "qt/window/QtApplicationSettingsScreen.h"
#include <QComboBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QSysInfo>
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "settings/ApplicationSettings.h"
QtApplicationSettingsScreen::QtApplicationSettingsScreen(QWidget *parent)
: QtSettingsWindow(parent)
{
raise();
}
QSize QtApplicationSettingsScreen::sizeHint() const
{
return QSize(600,600);
}
void QtApplicationSettingsScreen::setup()
{
setupForm();
updateTitle("PREFERENCES");
updateDoneButton("Save");
}
void QtApplicationSettingsScreen::load()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_includePaths->setList(appSettings->getHeaderSearchPaths());
if (m_frameworkPaths)
{
m_frameworkPaths->setList(appSettings->getFrameworkSearchPaths());
}
}
void QtApplicationSettingsScreen::populateForm(QFormLayout* layout)
{
int minimumWidthForSecondCol = 360;
QLabel* includePathsLabel = new QLabel("Include Paths");
m_includePaths = new QtDirectoryListBox(this);
m_includePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(includePathsLabel, m_includePaths);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
QLabel* frameworkPathsLabel = new QLabel("Framework Paths");
m_frameworkPaths = new QtDirectoryListBox(this);
m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(frameworkPathsLabel, m_frameworkPaths);
}
}
void QtApplicationSettingsScreen::handleCancelButtonPress()
{
emit canceled();
}
void QtApplicationSettingsScreen::handleUpdateButtonPress()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->setHeaderSearchPaths(m_includePaths->getList());
if (m_frameworkPaths)
{
appSettings->setFrameworkSearchPaths(m_frameworkPaths->getList());
}
appSettings->save();
MessageRefresh().dispatch();
emit finished();
}
@@ -0,0 +1,40 @@
#ifndef QT_APPLICATION_SETTINGS_SCREEN_H
#define QT_APPLICATION_SETTINGS_SCREEN_H
#include <QPushButton>
#include <QWidget>
#include "utility/file/FilePath.h"
#include "qt/element/QtDirectoryListBox.h"
#include "qt/window/QtSettingsWindow.h"
class QtApplicationSettingsScreen
: public QtSettingsWindow
{
Q_OBJECT
public:
QtApplicationSettingsScreen(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setup() override;
void load();
protected:
virtual void populateForm(QFormLayout* layout);
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
private:
QPushButton* m_cancelButton;
QPushButton* m_updateButton;
QtDirectoryListBox* m_includePaths;
QtDirectoryListBox* m_frameworkPaths;
};
#endif //QT_APPLICATION_SETTINGS_SCREEN_H
@@ -1,4 +1,4 @@
#include "qt/element/QtMainWindow.h"
#include "qt/window/QtMainWindow.h"
#include <QApplication>
#include <QFileDialog>
@@ -7,11 +7,10 @@
#include <QMessageBox>
#include <QSettings>
#include "version.h"
#include "component/view/View.h"
#include "component/view/CompositeView.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "settings/ApplicationSettings.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageFind.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
@@ -23,6 +22,7 @@
#include "utility/messaging/type/MessageUndo.h"
#include "utility/messaging/type/MessageWindowFocus.h"
#include "utility/messaging/type/MessageZoom.h"
#include "version.h"
QtMainWindow::QtMainWindow()
: m_startScreenWasVisible(false)
@@ -50,9 +50,21 @@ QtMainWindow::QtMainWindow()
void QtMainWindow::init()
{
showStartScreen();
}
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
if (appSettings->getUserHasSeenSettings())
{
showStartScreen();
}
else
{
openSettings();
m_startScreenWasVisible = true;
appSettings->setUserHasSeenSettings(true);
appSettings->save();
}
}
QtMainWindow::~QtMainWindow()
{
@@ -156,6 +168,11 @@ void QtMainWindow::about()
void QtMainWindow::hideScreens()
{
if (m_applicationSettingsScreen)
{
m_applicationSettingsScreen->hide();
}
if (m_startScreen)
{
m_startScreen->hide();
@@ -167,49 +184,69 @@ void QtMainWindow::hideScreens()
}
}
void QtMainWindow::closeScreens()
{
hideScreens();
m_startScreenWasVisible = false;
}
void QtMainWindow::restoreScreens()
{
if (m_startScreenWasVisible)
{
showStartScreen();
}
else
{
closeScreens();
}
}
void QtMainWindow::openSettings()
{
hideScreens();
if (m_startScreen && m_startScreenWasVisible)
if (!m_applicationSettingsScreen)
{
m_startScreen->show();
m_applicationSettingsScreen = std::make_shared<QtApplicationSettingsScreen>(this);
m_applicationSettingsScreen->setup();
connect(m_applicationSettingsScreen.get(), SIGNAL(finished()), this, SLOT(restoreScreens()));
connect(m_applicationSettingsScreen.get(), SIGNAL(canceled()), this, SLOT(restoreScreens()));
}
m_startScreenWasVisible = false;
m_applicationSettingsScreen->load();
m_applicationSettingsScreen->show();
}
void QtMainWindow::showStartScreen()
{
hideScreens();
if (!m_startScreen)
{
m_startScreen = std::make_shared<QtStartScreen>(this);
m_startScreen->setup();
connect(m_startScreen.get(), SIGNAL(finished()), this, SLOT(hideScreens()));
connect(m_startScreen.get(), SIGNAL(finished()), this, SLOT(closeScreens()));
connect(m_startScreen.get(), SIGNAL(canceled()), this, SLOT(closeScreens()));
connect(m_startScreen.get(), SIGNAL(openOpenProjectDialog()), this, SLOT(openProject()));
connect(m_startScreen.get(), SIGNAL(openNewProjectDialog()), this, SLOT(newProject()));
}
m_startScreen->show();
m_startScreenWasVisible = true;
if (m_newProjectDialog)
{
m_newProjectDialog->hide();
}
}
void QtMainWindow::newProject()
{
if (m_startScreen)
{
m_startScreen->hide();
}
hideScreens();
if (!m_newProjectDialog)
{
m_newProjectDialog = std::make_shared<QtProjectSetupScreen>(this);
m_newProjectDialog->setup();
connect(m_newProjectDialog.get(), SIGNAL(finished()), this, SLOT(hideScreens()));
connect(m_newProjectDialog.get(), SIGNAL(finished()), this, SLOT(closeScreens()));
connect(m_newProjectDialog.get(), SIGNAL(canceled()), this, SLOT(restoreScreens()));
}
@@ -229,6 +266,7 @@ void QtMainWindow::openProject(const QString &path)
if (!fileName.isEmpty())
{
MessageLoadProject(fileName.toStdString()).dispatch();
closeScreens();
}
}
@@ -307,6 +345,7 @@ void QtMainWindow::switchColorScheme()
void QtMainWindow::handleEscapeShortcut()
{
closeScreens();
MessageInterruptTasks().dispatch();
}
@@ -362,6 +401,7 @@ void QtMainWindow::setupHelpMenu()
menu->addAction(tr("&About"), this, SLOT(about()));
menu->addAction(tr("About &Qt"), QCoreApplication::instance(), SLOT(aboutQt()));
//menu->addAction(tr("Licences"), QCoreApplication::instance(), SLOT(showLicences()));
menu->addAction(tr("Preferences..."), this, SLOT(openSettings()));
}
void QtMainWindow::setupShortcuts()
@@ -5,11 +5,12 @@
#include <utility>
#include <vector>
#include <QMainWindow>
#include <QShortcut>
#include <QtWidgets/QMainWindow>
#include "QtStartScreen.h"
#include "QtProjectSetupScreen.h"
#include "qt/window/QtApplicationSettingsScreen.h"
#include "qt/window/QtStartScreen.h"
#include "qt/window/QtProjectSetupScreen.h"
class QDockWidget;
class View;
@@ -39,9 +40,11 @@ protected:
public slots:
void about();
void hideScreens();
void closeScreens();
void restoreScreens();
void showStartScreen();
void openSettings();
void showStartScreen();
void newProject();
void openProject(const QString &path = QString());
void editProject();
@@ -73,6 +76,7 @@ private:
QDockWidget* getDockWidgetForView(View* view) const;
std::shared_ptr<QtApplicationSettingsScreen> m_applicationSettingsScreen;
std::shared_ptr<QtStartScreen> m_startScreen;
std::shared_ptr<QtProjectSetupScreen> m_newProjectDialog;
@@ -1,19 +1,15 @@
#include "qt/element/QtProjectSetupScreen.h"
#include "qt/window/QtProjectSetupScreen.h"
#include <QComboBox>
#include <QFileDialog>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QScrollArea>
#include <QSysInfo>
#include "settings/ProjectSettings.h"
#include "utility/logging/logging.h"
#include "qt/utility/QtDeviceScaledPixmap.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "qt/utility/utilityQt.h"
#include "settings/ProjectSettings.h"
QtTextLine::QtTextLine(QWidget *parent)
: QWidget(parent)
@@ -59,43 +55,50 @@ void QtTextLine::handleButtonPress()
}
}
QtProjectSetupScreen::QtProjectSetupScreen(QWidget *parent)
: QtSettingsWindow(parent)
{
raise();
}
QSize QtProjectSetupScreen::sizeHint() const
{
return QSize(600,600);
}
void QtProjectSetupScreen::setup()
{
QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo.png");
coati_logo.scaleToWidth(400);
QLabel* coatiLogoLabel = new QLabel(m_window);
coatiLogoLabel->setPixmap(coati_logo.pixmap());
coatiLogoLabel->resize(coati_logo.width(), coati_logo.height());
coatiLogoLabel->move(100, 100);
setupForm();
}
setStyleSheet(utility::getStyleSheet("data/gui/settingwindows/projectsetup.css").c_str());
QVBoxLayout* windowLayout = new QVBoxLayout();
windowLayout->setContentsMargins(25, 30, 25, 20);
void QtProjectSetupScreen::loadEmpty()
{
updateTitle("NEW PROJECT");
updateDoneButton("Create");
}
m_title = new QLabel();
m_title->setObjectName("titleLabel");
windowLayout->addWidget(m_title);
windowLayout->addSpacing(30);
void QtProjectSetupScreen::loadProjectSettings()
{
updateTitle("EDIT PROJECT");
updateDoneButton("Save");
QScrollArea* scrollArea = new QScrollArea();
scrollArea->setObjectName("formArea");
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setWidgetResizable(true);
ProjectSettings* projSettings = ProjectSettings::getInstance().get();
QWidget* form = new QWidget();
form->setObjectName("form");
scrollArea->setWidget(form);
m_projectName->setText(QString::fromStdString(projSettings->getFilePath().withoutExtension().fileName()));
m_projectFileLocation->setText(QString::fromStdString(projSettings->getFilePath().parentDirectory().str()));
QFormLayout *layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
m_sourcePaths->setList(projSettings->getSourcePaths());
m_includePaths->setList(projSettings->getHeaderSearchPaths());
if (m_frameworkPaths)
{
m_frameworkPaths->setList(projSettings->getFrameworkSearchPaths());
}
}
void QtProjectSetupScreen::populateForm(QFormLayout* layout)
{
int minimumWidthForSecondCol = 360;
QLabel* nameLabel = new QLabel("Name");
@@ -132,62 +135,14 @@ void QtProjectSetupScreen::setup()
m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(frameworkPathsLabel, m_frameworkPaths);
}
form->setLayout(layout);
m_createButton = new QPushButton("Create");
m_createButton->setObjectName("windowButton");
m_cancelButton = new QPushButton("Cancel");
m_cancelButton->setObjectName("windowButton");
m_updateButton = new QPushButton("Update");
m_updateButton->setObjectName("windowButton");
connect(m_createButton, SIGNAL(clicked()), this, SLOT(handleCreateButtonPress()));
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(handleCancelButtonPress()));
connect(m_updateButton, SIGNAL(clicked()), this, SLOT(handleUpdateButtonPress()));
QHBoxLayout* buttons = new QHBoxLayout();
buttons->addWidget(m_cancelButton);
buttons->addStretch();
buttons->addWidget(m_createButton);
buttons->addWidget(m_updateButton);
windowLayout->addWidget(scrollArea);
windowLayout->addSpacing(20);
windowLayout->addLayout(buttons);
m_window->setLayout(windowLayout);
resize(QSize(600, 620));
scrollArea->raise();
}
void QtProjectSetupScreen::loadEmpty()
void QtProjectSetupScreen::handleCancelButtonPress()
{
m_updateButton->hide();
m_createButton->show();
m_title->setText("NEW PROJECT");
emit canceled();
}
void QtProjectSetupScreen::loadProjectSettings()
{
m_updateButton->show();
m_createButton->hide();
m_title->setText("EDIT PROJECT");
ProjectSettings* projSettings = ProjectSettings::getInstance().get();
m_projectName->setText(QString::fromStdString(projSettings->getFilePath().withoutExtension().fileName()));
m_projectFileLocation->setText(QString::fromStdString(projSettings->getFilePath().parentDirectory().str()));
m_sourcePaths->setList(projSettings->getSourcePaths());
m_includePaths->setList(projSettings->getHeaderSearchPaths());
m_frameworkPaths->setList(projSettings->getFrameworkSearchPaths());
}
void QtProjectSetupScreen::handleCreateButtonPress()
void QtProjectSetupScreen::handleDoneButtonPress()
{
if (m_projectName->text().isEmpty())
{
@@ -232,18 +187,3 @@ void QtProjectSetupScreen::handleCreateButtonPress()
MessageLoadProject(projectFile).dispatch();
emit finished();
}
void QtProjectSetupScreen::handleCancelButtonPress()
{
emit canceled();
}
void QtProjectSetupScreen::handleUpdateButtonPress()
{
handleCreateButtonPress();
}
QSize QtProjectSetupScreen::sizeHint() const
{
return QSize(600,600);
}
@@ -1,16 +1,14 @@
#ifndef QT_PROJECT_SETUP_SCREEN_H
#define QT_PROJECT_SETUP_SCREEN_H
#include <QListWidget>
#include <QPushButton>
#include <QWidget>
#include "QtSettingsWindow.h"
#include "utility/file/FilePath.h"
#include "qt/element/QtDirectoryListBox.h"
#include "qt/element/QtLineEdit.h"
#include "qt/window/QtSettingsWindow.h"
class QtTextLine
: public QWidget
@@ -45,21 +43,17 @@ public:
void loadEmpty();
void loadProjectSettings();
signals:
void finished();
void canceled();
protected:
virtual void populateForm(QFormLayout* layout);
private slots:
void handleCreateButtonPress();
void handleCancelButtonPress();
void handleUpdateButtonPress();
void handleDoneButtonPress();
private:
QLineEdit* m_projectName;
QtTextLine* m_projectFileLocation;
QLabel* m_title;
QPushButton* m_createButton;
QPushButton* m_cancelButton;
QPushButton* m_updateButton;
@@ -1,12 +1,21 @@
#include "qt/element/QtSettingsWindow.h"
#include "qt/window/QtSettingsWindow.h"
#include <QFormLayout>
#include <QGraphicsDropShadowEffect>
#include <QLabel>
#include <QPushButton>
#include <QScrollArea>
#include <QSysInfo>
#include "qt/utility/QtDeviceScaledPixmap.h"
#include "qt/utility/utilityQt.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
QtSettingsWindow::QtSettingsWindow(QWidget *parent, int displacement)
: QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint)
, m_title(nullptr)
, m_cancelButton(nullptr)
, m_doneButton(nullptr)
, m_mousePressedInWindow(false)
{
QSize windowSize = sizeHint();
@@ -46,19 +55,19 @@ QtSettingsWindow::QtSettingsWindow(QWidget *parent, int displacement)
this->raise();
}
QSize QtSettingsWindow::sizeHint() const
{
return QSize(500, 500);
}
void QtSettingsWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape)
{
this->hide();
emit canceled();
}
}
QSize QtSettingsWindow::sizeHint() const
{
return QSize(500, 500);
}
void QtSettingsWindow::resizeEvent(QResizeEvent *event)
{
QSize windowSize = event->size()-QSize(10, 10 + m_displacment);
@@ -94,3 +103,81 @@ void QtSettingsWindow::mouseReleaseEvent(QMouseEvent *event)
m_mousePressedInWindow = false;
}
}
void QtSettingsWindow::setupForm()
{
QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo.png");
coati_logo.scaleToWidth(400);
QLabel* coatiLogoLabel = new QLabel(m_window);
coatiLogoLabel->setPixmap(coati_logo.pixmap());
coatiLogoLabel->resize(coati_logo.width(), coati_logo.height());
coatiLogoLabel->move(100, 100);
setStyleSheet(utility::getStyleSheet("data/gui/setting_window/window.css").c_str());
QVBoxLayout* windowLayout = new QVBoxLayout();
windowLayout->setContentsMargins(25, 30, 25, 20);
m_title = new QLabel();
m_title->setObjectName("titleLabel");
windowLayout->addWidget(m_title);
windowLayout->addSpacing(30);
QScrollArea* scrollArea = new QScrollArea();
scrollArea->setObjectName("formArea");
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setWidgetResizable(true);
QWidget* form = new QWidget();
form->setObjectName("form");
scrollArea->setWidget(form);
QFormLayout* layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
populateForm(layout);
form->setLayout(layout);
m_cancelButton = new QPushButton("Cancel");
m_cancelButton->setObjectName("windowButton");
m_doneButton = new QPushButton("Done");
m_doneButton->setObjectName("windowButton");
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(handleCancelButtonPress()));
connect(m_doneButton, SIGNAL(clicked()), this, SLOT(handleDoneButtonPress()));
QHBoxLayout* buttons = new QHBoxLayout();
buttons->addWidget(m_cancelButton);
buttons->addStretch();
buttons->addWidget(m_doneButton);
windowLayout->addWidget(scrollArea);
windowLayout->addSpacing(20);
windowLayout->addLayout(buttons);
m_window->setLayout(windowLayout);
resize(QSize(600, 620));
scrollArea->raise();
}
void QtSettingsWindow::populateForm(QFormLayout* layout)
{
}
void QtSettingsWindow::updateTitle(QString title)
{
if (m_title)
{
m_title->setText(title);
}
}
void QtSettingsWindow::updateDoneButton(QString text)
{
if (m_doneButton)
{
m_doneButton->setText(text);
}
}
@@ -4,6 +4,10 @@
#include <QResizeEvent>
#include <QWidget>
class QFormLayout;
class QLabel;
class QPushButton;
class QtSettingsWindow
: public QWidget
{
@@ -16,6 +20,10 @@ public:
virtual void setup() = 0;
signals:
void finished();
void canceled();
protected:
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
@@ -23,8 +31,19 @@ protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void setupForm();
virtual void populateForm(QFormLayout* layout);
void updateTitle(QString title);
void updateDoneButton(QString text);
QWidget* m_window;
QLabel* m_title;
QPushButton* m_cancelButton;
QPushButton* m_doneButton;
private:
int m_displacment;
QPoint m_dragPosition;
@@ -1,4 +1,4 @@
#include "qt/element/QtSplashScreen.h"
#include "qt/window/QtSplashScreen.h"
#include <QApplication>
#include <QThread>
@@ -88,7 +88,6 @@ void QtSplashScreen::drawContents(QPainter *painter)
QRect r = rect();
r.setRect(r.x() + 5, r.height() - 20, r.width() - 10, 20);
// TODO: automated Version number
painter->drawText(r, Qt::AlignRight, QString("Coati v").append(m_version));
// Draw message at given position, limited to 43 chars
@@ -1,4 +1,4 @@
#include "qt/element/QtStartScreen.h"
#include "qt/window/QtStartScreen.h"
#include <QLabel>
#include <QHBoxLayout>
@@ -33,7 +33,6 @@ QtStartScreen::QtStartScreen(QWidget *parent)
void QtStartScreen::setup()
{
setStyleSheet(utility::getStyleSheet("data/gui/startscreen/startscreen.css").c_str());
std::vector<std::string> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo_schriftzug.png");
coati_logo.scaleToWidth(200);
@@ -54,20 +53,19 @@ void QtStartScreen::setup()
m_openProjectButton->setObjectName("projectButton");
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);
recentProjectsLabel->setGeometry(300, 234, 300, 50);
recentProjectsLabel->setObjectName("recentLabel");
int position = 290;
QIcon cpp_icon("data/gui/startscreen/Icon_CPP.png");
for (std::string project : recentProjects)
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
for (size_t i = 0; i < recentProjects.size() && i < 7; i++)
{
if (FileSystem::exists(project.c_str()))
FilePath project = recentProjects[i];
if (project.exists())
{
QtRecentProjectButton* button = new QtRecentProjectButton(project.c_str(), this);
QtRecentProjectButton* button = new QtRecentProjectButton(project.str().c_str(), this);
button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
button->setIcon(cpp_icon);
button->setIconSize(QSize(25, 25));
@@ -1,21 +1,26 @@
#ifndef STARTSCREEN_H
#define STARTSCREEN_H
#ifndef QT_START_SCREEN_H
#define QT_START_SCREEN_H
#include <QtWidgets/qpushbutton.h>
#include "QtSettingsWindow.h"
#include <QPushButton>
#include "qt/window/QtSettingsWindow.h"
class QtRecentProjectButton
: public QPushButton
{
Q_OBJECT
Q_OBJECT
public:
QtRecentProjectButton(const QString& text, QWidget* parent);
public slots:
void handleButtonClick();
private:
std::string m_projectFile;
};
class QtStartScreen
: public QtSettingsWindow
{
@@ -29,7 +34,6 @@ public:
signals:
void openOpenProjectDialog();
void openNewProjectDialog();
void finished();
private slots:
void handleNewProjectButton();
@@ -42,4 +46,4 @@ private:
std::vector<QPushButton*> m_recentProjects;
};
#endif //STARTSCREEN_H
#endif // QT_START_SCREEN_H
+8 -6
View File
@@ -27,6 +27,8 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
ptr->m_componentManager->setup(ptr->m_mainView.get());
ptr->m_mainView->loadLayout();
ptr->m_project = Project::create(ptr->m_storageCache.get());
return ptr;
}
@@ -53,9 +55,9 @@ Application::~Application()
m_mainView->saveLayout();
}
void Application::loadProject(const std::string& projectSettingsFilePath)
void Application::loadProject(const FilePath& projectSettingsFilePath)
{
MessageStatus("Loading Project: " + projectSettingsFilePath).dispatch();
MessageStatus("Loading Project: " + projectSettingsFilePath.str()).dispatch();
m_storageCache->clear();
m_componentManager->refreshViews();
@@ -78,7 +80,7 @@ void Application::reloadProject()
m_project->parseCode();
}
void Application::saveProject(const std::string& projectSettingsFilePath)
void Application::saveProject(const FilePath& projectSettingsFilePath)
{
if (!m_project->saveProjectSettings(projectSettingsFilePath))
{
@@ -140,13 +142,13 @@ void Application::handleMessage(MessageSaveProject* message)
saveProject(message->projectSettingsFilePath);
}
void Application::updateRecentProjects(const std::string& projectSettingsFilePath)
void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
std::vector<std::string> recentProjects = appSettings->getRecentProjects();
std::vector<FilePath> recentProjects = appSettings->getRecentProjects();
if (recentProjects.size())
{
std::vector<std::string>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
std::vector<FilePath>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
if (it != recentProjects.end())
{
recentProjects.erase(it);
+3 -4
View File
@@ -27,10 +27,9 @@ public:
~Application();
void loadProject(const std::string& projectSettingsFilePath);
void loadSource(const std::string& sourceDirectoryPath);
void saveProject(const std::string& projectSettingsFilePath);
void loadProject(const FilePath& projectSettingsFilePath);
void reloadProject();
void saveProject(const FilePath& projectSettingsFilePath);
private:
Application();
@@ -40,7 +39,7 @@ private:
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSaveProject* message);
void updateRecentProjects(const std::string& projectSettingsFilePath);
void updateRecentProjects(const FilePath& projectSettingsFilePath);
std::shared_ptr<Project> m_project;
std::shared_ptr<StorageCache> m_storageCache;
+12 -7
View File
@@ -21,7 +21,7 @@ Project::~Project()
{
}
bool Project::loadProjectSettings(const std::string& projectSettingsFile)
bool Project::loadProjectSettings(const FilePath& projectSettingsFile)
{
bool success = ProjectSettings::getInstance()->load(projectSettingsFile);
if (success)
@@ -34,28 +34,28 @@ bool Project::loadProjectSettings(const std::string& projectSettingsFile)
return success;
}
bool Project::saveProjectSettings(const std::string& projectSettingsFile)
bool Project::saveProjectSettings(const FilePath& projectSettingsFile)
{
if (projectSettingsFile.size())
if (!projectSettingsFile.empty())
{
m_projectSettingsFilepath = projectSettingsFile;
}
if (!m_projectSettingsFilepath.size())
if (m_projectSettingsFilepath.empty())
{
return false;
}
ProjectSettings::getInstance()->save(m_projectSettingsFilepath);
LOG_INFO_STREAM(<< "ProjectSettings saved to file: " << m_projectSettingsFilepath);
LOG_INFO_STREAM(<< "ProjectSettings saved to file: " << m_projectSettingsFilepath.str());
return true;
}
void Project::clearProjectSettings()
{
m_projectSettingsFilepath.clear();
m_projectSettingsFilepath = FilePath();
ProjectSettings::getInstance()->clear();
m_fileManager.reset();
@@ -63,7 +63,7 @@ void Project::clearProjectSettings()
void Project::reloadProjectSettings()
{
if (m_projectSettingsFilepath.size())
if (!m_projectSettingsFilepath.empty())
{
ProjectSettings::getInstance()->load(m_projectSettingsFilepath);
updateFileManager();
@@ -78,6 +78,11 @@ void Project::clearStorage()
void Project::parseCode()
{
if (m_projectSettingsFilepath.empty())
{
return;
}
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
m_fileManager.fetchFilePaths();
+3 -3
View File
@@ -17,8 +17,8 @@ public:
~Project();
bool loadProjectSettings(const std::string& projectSettingsFile);
bool saveProjectSettings(const std::string& projectSettingsFile);
bool loadProjectSettings(const FilePath& projectSettingsFile);
bool saveProjectSettings(const FilePath& projectSettingsFile);
void clearProjectSettings();
void reloadProjectSettings();
@@ -38,7 +38,7 @@ private:
StorageAccessProxy* const m_storageAccessProxy;
std::string m_projectSettingsFilepath;
FilePath m_projectSettingsFilepath;
FileManager m_fileManager;
std::shared_ptr<Storage> m_storage;
+26 -5
View File
@@ -26,11 +26,21 @@ std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
return getPathValues("source/HeaderSearchPaths/HeaderSearchPath");
}
bool ApplicationSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
{
return setPathValues("source/HeaderSearchPaths/HeaderSearchPath", headerSearchPaths);
}
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
{
return getPathValues("source/FrameworkSearchPaths/FrameworkSearchPath");
}
bool ApplicationSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
{
return setPathValues("source/FrameworkSearchPaths/FrameworkSearchPath", frameworkSearchPaths);
}
std::vector<std::string> ApplicationSettings::getCompilerFlags() const
{
std::vector<std::string> defaultValues;
@@ -101,11 +111,22 @@ ApplicationSettings::ApplicationSettings()
{
}
std::vector<std::string> ApplicationSettings::getRecentProjects() const {
std::vector<std::string> recentProjects;
return getValues("recentProjects/projectFilePath", recentProjects);
std::vector<FilePath> ApplicationSettings::getRecentProjects() const
{
return getPathValues("user/recent_projects/recent_project");
}
bool ApplicationSettings::setRecentProjects(const std::vector<std::string> &recentProjects) {
return setValues("recentProjects/projectFilePath", recentProjects);
bool ApplicationSettings::setRecentProjects(const std::vector<FilePath> &recentProjects)
{
return setPathValues("user/recent_projects/recent_project", recentProjects);
}
bool ApplicationSettings::getUserHasSeenSettings() const
{
return getValue<bool>("user/has_seen_settings", false);
}
void ApplicationSettings::setUserHasSeenSettings(bool hasSeenSettings)
{
setValue<bool>("user/has_seen_settings", hasSeenSettings);
}
+11 -4
View File
@@ -16,7 +16,11 @@ public:
// source
std::vector<FilePath> getHeaderSearchPaths() const;
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
std::vector<FilePath> getFrameworkSearchPaths() const;
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
std::vector<std::string> getCompilerFlags() const;
// application
@@ -29,10 +33,6 @@ public:
std::string getColorSchemePath() const;
void setColorSchemePath(const std::string& colorSchemePath);
//recent projects
std::vector<std::string> getRecentProjects() const;
bool setRecentProjects(const std::vector<std::string>& recentProjects);
// code
int getCodeTabWidth() const;
void setCodeTabWidth(int codeTabWidth);
@@ -43,6 +43,13 @@ public:
int getCodeSnippetExpandRange() const;
void setCodeSnippetExpandRange(int range);
// user
bool getUserHasSeenSettings() const;
void setUserHasSeenSettings(bool hasSeenSettings);
std::vector<FilePath> getRecentProjects() const;
bool setRecentProjects(const std::vector<FilePath>& recentProjects);
private:
ApplicationSettings();
ApplicationSettings(const ApplicationSettings&);