diff --git a/bin/app/data/gui/about/about.css b/bin/app/data/gui/about/about.css index be45f6dc..c9ebfe62 100644 --- a/bin/app/data/gui/about/about.css +++ b/bin/app/data/gui/about/about.css @@ -4,10 +4,6 @@ font-weight: 100; } -#small { - font-size: 12px; -} - #closeButton { background: transparent; border: none; diff --git a/bin/app/data/gui/setting_window/window.css b/bin/app/data/gui/setting_window/window.css deleted file mode 100644 index fc04aa4e..00000000 --- a/bin/app/data/gui/setting_window/window.css +++ /dev/null @@ -1,82 +0,0 @@ -#titleLabel { - color: black; - font-size: 16pt; - font-weight: bold; -} - -QLineEdit { - background-color: rgba(255, 255, 255, 200); - border-radius: 10px; - border: 1px solid lightgrey; - height: 20px; - padding-left: 5px; - padding-right: 5px; -} - -QLineEdit:disabled { - border: 1px solid lightgrey; -} - -#formArea { - background-color: transparent; - border: none; - border-top: 1px solid lightgrey; - border-bottom: 1px solid lightgrey; -} - -#form { - background-color: rgba(255, 255, 255, 150); -} - -#form #label { - font-weight: bold; -} - -#form #help { - background: transparent; - border: 1px solid #575656; - border-radius: 9px; - color: #575656; - height: 16px; - width: 16px; -} - -#form #help:hover { - border-color: black; - color: black; -} - -#moreButton { - background-color: rgba(255, 255, 255, 200); - border: 1px solid lightgray; - border-radius: 10px; - color: gray; - font-size: 15px; - height: 20px; - margin-left: 5px; - width: 28px; -} - -#moreButton:hover { - color: white; - background: #2D3F85; -} - -#windowButton { - background: white; - border: 1px solid lightgray; - border-radius: 8px; - color: black; - padding: 3px 5px 2px; - font-size: 14pt; - min-width: 5em; -} - -#windowButton:hover { - color: white; - background: #2D3F85; -} - -#windowButton:disabled { - color: lightgray; -} diff --git a/bin/app/data/gui/setting_window/dots.png b/bin/app/data/gui/window/dots.png similarity index 100% rename from bin/app/data/gui/setting_window/dots.png rename to bin/app/data/gui/window/dots.png diff --git a/bin/app/data/gui/setting_window/dots_hover.png b/bin/app/data/gui/window/dots_hover.png similarity index 100% rename from bin/app/data/gui/setting_window/dots_hover.png rename to bin/app/data/gui/window/dots_hover.png diff --git a/bin/app/data/gui/setting_window/help.png b/bin/app/data/gui/window/help.png similarity index 100% rename from bin/app/data/gui/setting_window/help.png rename to bin/app/data/gui/window/help.png diff --git a/bin/app/data/gui/setting_window/help_hover.png b/bin/app/data/gui/window/help_hover.png similarity index 100% rename from bin/app/data/gui/setting_window/help_hover.png rename to bin/app/data/gui/window/help_hover.png diff --git a/bin/app/data/gui/setting_window/listbox.css b/bin/app/data/gui/window/listbox.css similarity index 66% rename from bin/app/data/gui/setting_window/listbox.css rename to bin/app/data/gui/window/listbox.css index 42df6ce4..e9d84e63 100644 --- a/bin/app/data/gui/setting_window/listbox.css +++ b/bin/app/data/gui/window/listbox.css @@ -47,27 +47,27 @@ QtListItemWidget #field { } #plusButton { - border-image: url(setting_window/plus.png); + border-image: url(window/plus.png); } #plusButton:hover { - border-image: url(setting_window/plus_hover.png); + border-image: url(window/plus_hover.png); } #minusButton { - border-image: url(setting_window/minus.png); + border-image: url(window/minus.png); } #minusButton:hover { - border-image: url(setting_window/minus_hover.png); + border-image: url(window/minus_hover.png); } #dotsButton { - border-image: url(setting_window/dots.png); + border-image: url(window/dots.png); } #dotsButton:hover { - border-image: url(setting_window/dots_hover.png); + border-image: url(window/dots_hover.png); } #dropInfo { diff --git a/bin/app/data/gui/startscreen/logo.png b/bin/app/data/gui/window/logo.png similarity index 100% rename from bin/app/data/gui/startscreen/logo.png rename to bin/app/data/gui/window/logo.png diff --git a/bin/app/data/gui/setting_window/minus.png b/bin/app/data/gui/window/minus.png similarity index 100% rename from bin/app/data/gui/setting_window/minus.png rename to bin/app/data/gui/window/minus.png diff --git a/bin/app/data/gui/setting_window/minus_hover.png b/bin/app/data/gui/window/minus_hover.png similarity index 100% rename from bin/app/data/gui/setting_window/minus_hover.png rename to bin/app/data/gui/window/minus_hover.png diff --git a/bin/app/data/gui/setting_window/plus.png b/bin/app/data/gui/window/plus.png similarity index 100% rename from bin/app/data/gui/setting_window/plus.png rename to bin/app/data/gui/window/plus.png diff --git a/bin/app/data/gui/setting_window/plus_hover.png b/bin/app/data/gui/window/plus_hover.png similarity index 100% rename from bin/app/data/gui/setting_window/plus_hover.png rename to bin/app/data/gui/window/plus_hover.png diff --git a/bin/app/data/gui/setting_window/refresh.png b/bin/app/data/gui/window/refresh.png similarity index 100% rename from bin/app/data/gui/setting_window/refresh.png rename to bin/app/data/gui/window/refresh.png diff --git a/bin/app/data/gui/setting_window/refresh_hover.png b/bin/app/data/gui/window/refresh_hover.png similarity index 100% rename from bin/app/data/gui/setting_window/refresh_hover.png rename to bin/app/data/gui/window/refresh_hover.png diff --git a/bin/app/data/gui/project_wizzard/window.css b/bin/app/data/gui/window/window.css similarity index 83% rename from bin/app/data/gui/project_wizzard/window.css rename to bin/app/data/gui/window/window.css index 729a4212..ce9a5056 100644 --- a/bin/app/data/gui/project_wizzard/window.css +++ b/bin/app/data/gui/window/window.css @@ -53,27 +53,27 @@ } #helpButton { - border-image: url(setting_window/help.png); + border-image: url(window/help.png); } #helpButton:hover { - border-image: url(setting_window/help_hover.png); + border-image: url(window/help_hover.png); } #dotsButton { - border-image: url(setting_window/dots.png); + border-image: url(window/dots.png); } #dotsButton:hover { - border-image: url(setting_window/dots_hover.png); + border-image: url(window/dots_hover.png); } #refreshButton { - border-image: url(setting_window/refresh.png); + border-image: url(window/refresh.png); } #refreshButton:hover { - border-image: url(setting_window/refresh_hover.png); + border-image: url(window/refresh_hover.png); } #name, #picker { diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index c699b8f8..a41c2512 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -135,12 +135,12 @@ add_files( qt/window/QtLicense.h qt/window/QtMainWindow.cpp qt/window/QtMainWindow.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 + qt/window/QtWindow.cpp + qt/window/QtWindow.h qt/window/QtWindowStack.cpp qt/window/QtWindowStack.h diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index 2474cf15..38d27194 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -109,7 +109,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent) m_list->setAttribute(Qt::WA_MacShowFocusRect, 0); m_list->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "setting_window/listbox.css").c_str()); + setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/listbox.css").c_str()); layout->addWidget(m_list); QWidget* buttonContainer = new QWidget(this); diff --git a/src/lib_gui/qt/window/QtAbout.cpp b/src/lib_gui/qt/window/QtAbout.cpp index 7aff1d99..cf41c654 100644 --- a/src/lib_gui/qt/window/QtAbout.cpp +++ b/src/lib_gui/qt/window/QtAbout.cpp @@ -1,9 +1,8 @@ #include "qt/window/QtAbout.h" -#include -#include -#include #include +#include +#include #include #include "qt/utility/QtDeviceScaledPixmap.h" @@ -12,7 +11,7 @@ #include "utility/ResourcePaths.h" QtAbout::QtAbout(QWidget *parent) - : QtSettingsWindow(parent) + : QtWindow(parent) { } @@ -21,11 +20,11 @@ QSize QtAbout::sizeHint() const return QSize(500, 520); } -void QtAbout::setup() +void QtAbout::setupAbout() { m_window->setStyleSheet( m_window->styleSheet() + - "#SettingWindow { " + "#window { " "background: qlineargradient( x1:0 y1:0.4, x2:0 y2:1, stop:0 #2F3F86, stop:1 #1C7BBC );" "border: none;" "}" @@ -143,21 +142,19 @@ void QtAbout::setup() windowLayout->addStretch(); + QtDeviceScaledPixmap closePixmap((ResourcePaths::getGuiPath() + "about/icon_close.png").c_str()); closePixmap.scaleToHeight(20); QPushButton* closeButton = new QPushButton(this); closeButton->setIcon(QIcon(closePixmap.pixmap())); closeButton->setObjectName("closeButton"); closeButton->move(450, 20); + closeButton->show(); - connect(closeButton, SIGNAL(clicked()), this, SLOT(handleUpdateButtonPress())); + connect(closeButton, SIGNAL(clicked()), this, SLOT(handleCloseButtonPress())); } -void QtAbout::handleCancelButtonPress() +void QtAbout::handleCloseButtonPress() { -} - -void QtAbout::handleUpdateButtonPress() -{ - emit finished(); + emit canceled(); } diff --git a/src/lib_gui/qt/window/QtAbout.h b/src/lib_gui/qt/window/QtAbout.h index c059469e..f9d96cd2 100644 --- a/src/lib_gui/qt/window/QtAbout.h +++ b/src/lib_gui/qt/window/QtAbout.h @@ -1,25 +1,21 @@ #ifndef QT_ABOUT_H #define QT_ABOUT_H -#include -#include - -#include "qt/window/QtSettingsWindow.h" +#include "qt/window/QtWindow.h" class QtAbout - : public QtSettingsWindow + : public QtWindow { Q_OBJECT public: QtAbout(QWidget* parent = 0); - QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; - virtual void setup() override; + void setupAbout(); private slots: - void handleCancelButtonPress(); - void handleUpdateButtonPress(); + void handleCloseButtonPress(); }; -#endif //QT_ABOUT_H +#endif // QT_ABOUT_H diff --git a/src/lib_gui/qt/window/QtAboutLicense.cpp b/src/lib_gui/qt/window/QtAboutLicense.cpp index 1b1317f7..c25b2730 100644 --- a/src/lib_gui/qt/window/QtAboutLicense.cpp +++ b/src/lib_gui/qt/window/QtAboutLicense.cpp @@ -12,8 +12,10 @@ #include "isTrial.h" QtAboutLicense::QtAboutLicense(QWidget *parent) - : QtSettingsWindow(parent) + : QtWindow(parent) { + setScrollAble(true); + raise(); } @@ -22,15 +24,6 @@ QSize QtAboutLicense::sizeHint() const return QSize(600,600); } -void QtAboutLicense::setup() -{ - setupForm(); - - updateTitle("3rd Party Licenses"); - updateDoneButton("Ok"); - hideCancelButton(true); -} - void QtAboutLicense::populateWindow(QWidget* widget) { QVBoxLayout* layout = new QVBoxLayout(widget); @@ -63,11 +56,11 @@ void QtAboutLicense::populateWindow(QWidget* widget) widget->setLayout(layout); } -void QtAboutLicense::handleCancelButtonPress() +void QtAboutLicense::windowReady() { -} + updateTitle("3rd Party Licenses"); + updateCloseButton("Close"); -void QtAboutLicense::handleUpdateButtonPress() -{ - emit finished(); + setNextVisible(false); + setPreviousVisible(false); } diff --git a/src/lib_gui/qt/window/QtAboutLicense.h b/src/lib_gui/qt/window/QtAboutLicense.h index 1fa515e8..d5fd7bd5 100644 --- a/src/lib_gui/qt/window/QtAboutLicense.h +++ b/src/lib_gui/qt/window/QtAboutLicense.h @@ -1,28 +1,19 @@ #ifndef QT_ABOUT_LICENSE_H #define QT_ABOUT_LICENSE_H -#include -#include - -#include "qt/window/QtSettingsWindow.h" +#include "qt/window/QtWindow.h" class QtAboutLicense - : public QtSettingsWindow + : public QtWindow { - Q_OBJECT - public: QtAboutLicense(QWidget* parent = 0); - QSize sizeHint() const Q_DECL_OVERRIDE; - - virtual void setup() override; + QSize sizeHint() const override; protected: + // QtWindow implementation virtual void populateWindow(QWidget* widget) override; - -private slots: - void handleCancelButtonPress(); - void handleUpdateButtonPress(); + virtual void windowReady() override; }; #endif //QT_ABOUT_LICENSE_H diff --git a/src/lib_gui/qt/window/QtLicense.cpp b/src/lib_gui/qt/window/QtLicense.cpp index 063ef208..5acc0ddf 100644 --- a/src/lib_gui/qt/window/QtLicense.cpp +++ b/src/lib_gui/qt/window/QtLicense.cpp @@ -1,11 +1,7 @@ #include "qt/window/QtLicense.h" -#include -#include #include #include -#include -#include #include #include "License.h" @@ -18,7 +14,7 @@ #include "utility/ResourcePaths.h" QtLicense::QtLicense(QWidget *parent) - : QtSettingsWindow(parent, 68) + : QtWindow(parent, 68) { raise(); } @@ -59,34 +55,24 @@ void QtLicense::load() } } -void QtLicense::setup() +void QtLicense::populateWindow(QWidget* widget) { - setStyleSheet(( - utility::getStyleSheet(ResourcePaths::getGuiPath() + "setting_window/window.css") + - utility::getStyleSheet(ResourcePaths::getGuiPath() + "license/license.css") - ).c_str()); - - addLogo(); - - QVBoxLayout* layout = new QVBoxLayout(this); - layout->setContentsMargins(25, 100, 25, 30); - QVBoxLayout* subLayout = new QVBoxLayout(); subLayout->setContentsMargins(200, 0, 0, 0); - QLabel* licenseName = new QLabel(this); + QLabel* licenseName = new QLabel(); licenseName->setText(QString::fromLatin1("Enter Licence")); - licenseName->setObjectName("titleLabel"); + licenseName->setObjectName("title"); subLayout->addWidget(licenseName); subLayout->addSpacing(10); - QLabel* licenseIntro = new QLabel(this); + QLabel* licenseIntro = new QLabel(); licenseIntro->setText(QString::fromLatin1("Please enter a licence key to activate Coati:")); licenseIntro->setObjectName("licenseIntro"); subLayout->addWidget(licenseIntro); - m_licenseText = new QTextEdit(this); + m_licenseText = new QTextEdit(); m_licenseText->setObjectName("licenseField"); m_licenseText->setPlaceholderText( "-----BEGIN LICENSE-----\n" @@ -119,21 +105,35 @@ void QtLicense::setup() linkLabel->setGeometry(275, 300, 300, 50); subLayout->addWidget(linkLabel); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); layout->addLayout(subLayout); layout->addSpacing(20); - showButtons(layout); - updateDoneButton("Activate"); + widget->setLayout(layout); resize(750, 550); } -void QtLicense::handleCancelButtonPress() +void QtLicense::windowReady() +{ + setStyleSheet(styleSheet() + utility::getStyleSheet(ResourcePaths::getGuiPath() + "license/license.css").c_str()); + + addLogo(); + + updateNextButton("Activate"); + setPreviousVisible(false); + + m_title->hide(); +} + +void QtLicense::handleClose() { emit canceled(); } -void QtLicense::handleUpdateButtonPress() +void QtLicense::handleNext() { std::string licenseString = m_licenseText->toPlainText().toStdString(); if (licenseString.size() == 0) diff --git a/src/lib_gui/qt/window/QtLicense.h b/src/lib_gui/qt/window/QtLicense.h index 1afc3f76..8d6d88c8 100644 --- a/src/lib_gui/qt/window/QtLicense.h +++ b/src/lib_gui/qt/window/QtLicense.h @@ -1,36 +1,35 @@ #ifndef QT_LICENSE_H #define QT_LICENSE_H -#include -#include -#include +#include "qt/window/QtWindow.h" -#include "qt/window/QtSettingsWindow.h" +class QLabel; +class QPushButton; +class QTextEdit; class QtLicense - : public QtSettingsWindow + : public QtWindow { Q_OBJECT public: QtLicense(QWidget* parent = 0); - QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; void clear(); void load(); - virtual void setup() override; +protected: + // QtWindow implementation + virtual void populateWindow(QWidget* widget) override; + virtual void windowReady() override; -private slots: - void handleCancelButtonPress(); - void handleUpdateButtonPress(); + virtual void handleNext() override; + virtual void handleClose() override; private: - QPushButton* m_cancelButton; - QPushButton* m_updateButton; - QTextEdit* m_licenseText; QLabel* m_errorLabel; }; -#endif //QT_LICENSE_H +#endif // QT_LICENSE_H diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 8ed30931..0048106c 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -252,7 +252,14 @@ void QtMainWindow::saveLayout() void QtMainWindow::forceEnterLicense() { - QtLicense* enterLicenseWindow = dynamic_cast(enterLicense()); + enterLicense(); + + QtLicense* enterLicenseWindow = dynamic_cast(m_windowStack.getTopWindow()); + if (!enterLicenseWindow) + { + LOG_ERROR("No enter license window on top of stack"); + return; + } enterLicenseWindow->clear(); enterLicenseWindow->setCancelAble(false); @@ -291,16 +298,10 @@ void QtMainWindow::activateWindow() m_windowStack.popWindow(); } -QtSettingsWindow* QtMainWindow::about() +void QtMainWindow::about() { - QtAbout* aboutWindow = new QtAbout(this); - aboutWindow->setup(); - - connect(aboutWindow, SIGNAL(finished()), &m_windowStack, SLOT(popWindow())); - connect(aboutWindow, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow())); - - m_windowStack.pushWindow(aboutWindow); - return aboutWindow; + QtAbout* aboutWindow = createWindow(); + aboutWindow->setupAbout(); } void QtMainWindow::openSettings() @@ -314,47 +315,30 @@ void QtMainWindow::showDocumentation() QDesktopServices::openUrl(QUrl("https://coati.io/documentation/")); } -QtSettingsWindow* QtMainWindow::showLicenses() +void QtMainWindow::showLicenses() { - QtAboutLicense* licenseWindow = new QtAboutLicense(this); + QtAboutLicense* licenseWindow = createWindow(); licenseWindow->setup(); - - connect(licenseWindow, SIGNAL(finished()), &m_windowStack, SLOT(popWindow())); - connect(licenseWindow, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow())); - - m_windowStack.pushWindow(licenseWindow); - - return licenseWindow; } -QtSettingsWindow* QtMainWindow::enterLicense() +void QtMainWindow::enterLicense() { - QtLicense* enterLicenseWindow = new QtLicense(this); + QtLicense* enterLicenseWindow = createWindow(); enterLicenseWindow->setup(); + disconnect(enterLicenseWindow, SIGNAL(finished()), &m_windowStack, SLOT(clearWindows())); connect(enterLicenseWindow, SIGNAL(finished()), this, SLOT(activateWindow())); - connect(enterLicenseWindow, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow())); enterLicenseWindow->load(); - m_windowStack.pushWindow(enterLicenseWindow); - - return enterLicenseWindow; } -QtSettingsWindow* QtMainWindow::showStartScreen() +void QtMainWindow::showStartScreen() { - QtStartScreen* startScreen = new QtStartScreen(this); - startScreen->setup(); - - connect(startScreen, SIGNAL(finished()), &m_windowStack, SLOT(popWindow())); - connect(startScreen, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow())); + QtStartScreen* startScreen = createWindow(); + startScreen->setupStartScreen(); connect(startScreen, SIGNAL(openOpenProjectDialog()), this, SLOT(openProject())); connect(startScreen, SIGNAL(openNewProjectDialog()), this, SLOT(newProject())); - - m_windowStack.pushWindow(startScreen); - - return startScreen; } void QtMainWindow::hideStartScreen() diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h index 0c935bc8..40ea00e8 100644 --- a/src/lib_gui/qt/window/QtMainWindow.h +++ b/src/lib_gui/qt/window/QtMainWindow.h @@ -96,13 +96,13 @@ protected: public slots: void activateWindow(); - QtSettingsWindow* about(); + void about(); void openSettings(); void showDocumentation(); - QtSettingsWindow* showLicenses(); - QtSettingsWindow* enterLicense(); + void showLicenses(); + void enterLicense(); - QtSettingsWindow* showStartScreen(); + void showStartScreen(); void hideStartScreen(); void newProject(); diff --git a/src/lib_gui/qt/window/QtSettingsWindow.cpp b/src/lib_gui/qt/window/QtSettingsWindow.cpp deleted file mode 100644 index b56d49ee..00000000 --- a/src/lib_gui/qt/window/QtSettingsWindow.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include "qt/window/QtSettingsWindow.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "qt/utility/QtDeviceScaledPixmap.h" -#include "qt/utility/utilityQt.h" -#include "utility/messaging/type/MessageInterruptTasks.h" -#include "utility/ResourcePaths.h" - -QtSettingsWindow::QtSettingsWindow(QWidget *parent, int displacement) - : QtWindowStackElement(parent) - , m_title(nullptr) - , m_cancelButton(nullptr) - , m_doneButton(nullptr) - , m_mousePressedInWindow(false) - , m_cancelAble(true) -{ - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); - - QSize windowSize = sizeHint(); - move(parent->pos().x() + parent->width() / 2 - 250, parent->pos().y() + parent->height() / 2 - 250); - - setAttribute(Qt::WA_TranslucentBackground, true); - m_displacment = displacement; - - m_window = new QWidget(this); - windowSize.setHeight(windowSize.height() - displacement - 10); - windowSize.setWidth(windowSize.width() - 10); - m_window->move(0, displacement); - m_window->resize(windowSize); - - std::string frameStyle = - "#SettingWindow {" - "font-size: 17pt; " - "border: 1px solid lightgray;" - "border-radius: 15px; " - "background: white; " - "}"; - m_window->setStyleSheet(frameStyle.c_str()); - m_window->setObjectName("SettingWindow"); - - // window shadow - if (QSysInfo::macVersion() == QSysInfo::MV_None) - { - QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; - effect->setBlurRadius(5); - effect->setXOffset(2); - effect->setYOffset(2); - effect->setColor(Qt::darkGray); - m_window->setGraphicsEffect(effect); - } - - this->raise(); -} - -QSize QtSettingsWindow::sizeHint() const -{ - return QSize(500, 500); -} - -void QtSettingsWindow::setCancelAble(bool cancelable) -{ - if (m_cancelButton) - { - m_cancelButton->setEnabled(cancelable); - } - - m_cancelAble = cancelable; -} - -void QtSettingsWindow::keyPressEvent(QKeyEvent *event) -{ - if (m_cancelAble && event->key() == Qt::Key_Escape) - { - emit canceled(); - } - - QWidget::keyPressEvent(event); -} - -void QtSettingsWindow::resizeEvent(QResizeEvent *event) -{ - QSize windowSize = event->size()-QSize(10, 10 + m_displacment); - m_window->resize(windowSize); - m_window->move(0, m_displacment); -} - -void QtSettingsWindow::mouseMoveEvent(QMouseEvent *event) -{ - if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow) - { - move(event->globalPos() - m_dragPosition); - event->accept(); - } -} - -void QtSettingsWindow::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - m_dragPosition = event->globalPos() - frameGeometry().topLeft(); - event->accept(); - m_mousePressedInWindow = true; - } -} - -void QtSettingsWindow::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - m_dragPosition = event->globalPos() - frameGeometry().topLeft(); - event->accept(); - m_mousePressedInWindow = false; - } -} - -void QtSettingsWindow::setupForm() -{ - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "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); - - populateWindow(form); - - windowLayout->addWidget(scrollArea); - windowLayout->addSpacing(25); - - showButtons(windowLayout); - - m_window->setLayout(windowLayout); - resize(QSize(600, 620)); - - scrollArea->raise(); -} - -void QtSettingsWindow::populateWindow(QWidget* widget) -{ -} - -void QtSettingsWindow::addLogo() -{ - QtDeviceScaledPixmap coatiLogo((ResourcePaths::getGuiPath() + "startscreen/logo.png").c_str()); - coatiLogo.scaleToWidth(150); - - QLabel* coatiLogoLabel = new QLabel(this); - coatiLogoLabel->setPixmap(coatiLogo.pixmap()); - coatiLogoLabel->resize(coatiLogo.width(), coatiLogo.height()); - coatiLogoLabel->move(30, 25); -} - -void QtSettingsWindow::showButtons(QVBoxLayout* 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(handleUpdateButtonPress())); - - QHBoxLayout* buttons = new QHBoxLayout(); - buttons->addWidget(m_cancelButton); - buttons->addStretch(); - buttons->addWidget(m_doneButton); - m_buttonsLayout = buttons; - - layout->addLayout(buttons); -} - -void QtSettingsWindow::updateTitle(QString title) -{ - if (m_title) - { - m_title->setText(title); - } -} - -void QtSettingsWindow::updateDoneButton(QString text) -{ - if (m_doneButton) - { - m_doneButton->setText(text); - } -} - -void QtSettingsWindow::showWindow() -{ - show(); -} - -void QtSettingsWindow::hideWindow() -{ - hide(); -} - -void QtSettingsWindow::hideCancelButton(bool hidden) -{ - if(m_cancelButton) - { - m_cancelButton->setVisible(!hidden); - } -} diff --git a/src/lib_gui/qt/window/QtSettingsWindow.h b/src/lib_gui/qt/window/QtSettingsWindow.h deleted file mode 100644 index f800d9ab..00000000 --- a/src/lib_gui/qt/window/QtSettingsWindow.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef QT_SETTINGS_WINDOW_H -#define QT_SETTINGS_WINDOW_H - -#include -#include -#include - -#include "qt/window/QtWindowStack.h" - -class QFormLayout; -class QLabel; -class QPushButton; -class QVBoxLayout; - -class QtSettingsWindow - : public QtWindowStackElement -{ - Q_OBJECT - -public: - QtSettingsWindow(QWidget* parent = 0, int displacement = 0); - - QSize sizeHint() const Q_DECL_OVERRIDE; - - virtual void setup() = 0; - - void setCancelAble(bool cancelAble); - - void updateTitle(QString title); - void updateDoneButton(QString text); - - // QtWindowStackElement implementation - virtual void showWindow() override; - virtual void hideWindow() override; - -signals: - void finished(); - void canceled(); - -protected: - void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - - void setupForm(); - virtual void populateWindow(QWidget* widget); - - void addLogo(); - void showButtons(QVBoxLayout* layout); - - void hideCancelButton(bool hidden); - - QWidget* m_window; - - QLabel* m_title; - - QPushButton* m_cancelButton; - QPushButton* m_doneButton; - - QHBoxLayout* m_buttonsLayout; - -private: - int m_displacment; - QPoint m_dragPosition; - bool m_mousePressedInWindow; - bool m_cancelAble; -}; - -#endif //QT_SETTINGS_WINDOW_H diff --git a/src/lib_gui/qt/window/QtStartScreen.cpp b/src/lib_gui/qt/window/QtStartScreen.cpp index 9516abd1..a95f0e84 100644 --- a/src/lib_gui/qt/window/QtStartScreen.cpp +++ b/src/lib_gui/qt/window/QtStartScreen.cpp @@ -27,35 +27,38 @@ void QtRecentProjectButton::handleButtonClick() }; QtStartScreen::QtStartScreen(QWidget *parent) - : QtSettingsWindow(parent, 68) + : QtWindow(parent, 68) { this->raise(); } -void QtStartScreen::setup() +void QtStartScreen::setupStartScreen() { setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str()); addLogo(); - if(!isTrial()) + if (!isTrial()) { m_newProjectButton = new QPushButton("New Project", this); m_newProjectButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_newProjectButton->move(30, 505); m_newProjectButton->setObjectName("projectButton"); + m_newProjectButton->show(); connect(m_newProjectButton, SIGNAL(clicked()), this, SLOT(handleNewProjectButton())); m_openProjectButton = new QPushButton("Open Project", this); m_openProjectButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_openProjectButton->move(30, 540); m_openProjectButton->setObjectName("projectButton"); + m_openProjectButton->show(); connect(m_openProjectButton, SIGNAL(clicked()), this, SLOT(handleOpenProjectButton())); } QLabel* recentProjectsLabel = new QLabel("Recent Projects: ", this); recentProjectsLabel->setGeometry(300, 234, 300, 50); recentProjectsLabel->setObjectName("recentLabel"); + recentProjectsLabel->show(); int position = 290; QIcon cpp_icon((ResourcePaths::getGuiPath() + "icon/project_256_256.png").c_str()); @@ -69,6 +72,7 @@ void QtStartScreen::setup() button->setObjectName("recentButton"); button->minimumSizeHint(); // force font loading button->setGeometry(292, position, button->fontMetrics().width(button->text()) + 45, 40); + button->show(); connect(button, SIGNAL(clicked()), button, SLOT(handleButtonClick())); connect(button, SIGNAL(clicked()), this, SLOT(handleRecentButton())); position += 40; diff --git a/src/lib_gui/qt/window/QtStartScreen.h b/src/lib_gui/qt/window/QtStartScreen.h index 512dccd9..34344874 100644 --- a/src/lib_gui/qt/window/QtStartScreen.h +++ b/src/lib_gui/qt/window/QtStartScreen.h @@ -3,7 +3,7 @@ #include -#include "qt/window/QtSettingsWindow.h" +#include "qt/window/QtWindow.h" #include "utility/file/FilePath.h" class QtRecentProjectButton @@ -23,14 +23,15 @@ private: class QtStartScreen - : public QtSettingsWindow + : public QtWindow { Q_OBJECT public: QtStartScreen(QWidget* parent = 0); - QSize sizeHint() const Q_DECL_OVERRIDE; - virtual void setup() override; + QSize sizeHint() const override; + + void setupStartScreen(); signals: void openOpenProjectDialog(); diff --git a/src/lib_gui/qt/window/QtWindow.cpp b/src/lib_gui/qt/window/QtWindow.cpp new file mode 100644 index 00000000..6484d842 --- /dev/null +++ b/src/lib_gui/qt/window/QtWindow.cpp @@ -0,0 +1,340 @@ +#include "qt/window/QtWindow.h" + +#include +#include +#include +#include +#include + +#include "qt/utility/QtDeviceScaledPixmap.h" +#include "qt/utility/utilityQt.h" +#include "utility/ResourcePaths.h" + +QtWindow::QtWindow(QWidget* parent, int displacement) + : QtWindowStackElement(parent) + , m_window(nullptr) + , m_title(nullptr) + , m_nextButton(nullptr) + , m_previousButton(nullptr) + , m_closeButton(nullptr) + , m_displacement(displacement) + , m_cancelAble(true) + , m_scrollAble(false) + , m_showAsPopup(false) + , m_mousePressedInWindow(false) +{ + setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); + setAttribute(Qt::WA_TranslucentBackground, true); + + move(parent->pos().x() + parent->width() / 2 - 250, parent->pos().y() + parent->height() / 2 - 250); + + QSize windowSize = sizeHint(); + + m_window = new QWidget(this); + windowSize.setHeight(windowSize.height() - displacement - 10); + windowSize.setWidth(windowSize.width() - 10); + m_window->move(0, displacement); + m_window->resize(windowSize); + + std::string frameStyle = + "#window {" + "font-size: 17pt; " + "border: 1px solid lightgray;" + "border-radius: 15px; " + "background: white; " + "}"; + m_window->setStyleSheet(frameStyle.c_str()); + m_window->setObjectName("window"); + + // window shadow + if (QSysInfo::macVersion() == QSysInfo::MV_None) + { + QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; + effect->setBlurRadius(5); + effect->setXOffset(2); + effect->setYOffset(2); + effect->setColor(Qt::darkGray); + m_window->setGraphicsEffect(effect); + } + + this->raise(); +} + +QSize QtWindow::sizeHint() const +{ + return QSize(500, 500); +} + +void QtWindow::setup() +{ + setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css").c_str()); + QVBoxLayout* layout = new QVBoxLayout(); + layout->setContentsMargins(25, 30, 25, 20); + + m_title = new QLabel(); + m_title->setObjectName("title"); + layout->addWidget(m_title); + layout->addSpacing(10); + + QWidget* contentWidget = new QWidget(); + contentWidget->setObjectName("form"); + + populateWindow(contentWidget); + + QScrollArea* scrollArea = new QScrollArea(); + scrollArea->setFrameShadow(QFrame::Plain); + scrollArea->setObjectName("formArea"); + scrollArea->setWidgetResizable(true); + + scrollArea->setWidget(contentWidget); + layout->addWidget(scrollArea); + + if (!m_scrollAble) + { + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + } + else + { + scrollArea->setObjectName("scrollArea"); + } + + { + m_nextButton = new QPushButton("Next"); + m_nextButton->setObjectName("windowButton"); + connect(m_nextButton, SIGNAL(clicked()), this, SLOT(handleNextPress())); + + m_previousButton = new QPushButton("Previous"); + m_previousButton->setObjectName("windowButton"); + connect(m_previousButton, SIGNAL(clicked()), this, SLOT(handlePreviousPress())); + + m_closeButton = new QPushButton("Cancel"); + m_closeButton->setObjectName("windowButton"); + connect(m_closeButton, SIGNAL(clicked()), this, SLOT(handleClosePress())); + + QHBoxLayout* buttons = new QHBoxLayout(); + buttons->addWidget(m_closeButton); + buttons->addStretch(); + buttons->addWidget(m_previousButton); + buttons->addSpacing(3); + buttons->addWidget(m_nextButton); + + layout->addLayout(buttons); + } + + m_window->setLayout(layout); + + if (m_showAsPopup) + { + updateNextButton("Ok"); + setCloseVisible(false); + setPreviousVisible(false); + } + + windowReady(); +} + +void QtWindow::setCancelAble(bool cancelable) +{ + setCloseEnabled(cancelable); + + m_cancelAble = cancelable; +} + +void QtWindow::setScrollAble(bool scrollAble) +{ + m_scrollAble = scrollAble; +} + +void QtWindow::setShowAsPopup(bool showAsPopup) +{ + m_showAsPopup = showAsPopup; +} + +bool QtWindow::isScrollAble() const +{ + return m_scrollAble; +} + +bool QtWindow::isPopup() const +{ + return m_showAsPopup; +} + +void QtWindow::updateTitle(QString title) +{ + if (m_title) + { + m_title->setText(title); + } +} + +void QtWindow::updateNextButton(QString text) +{ + if (m_nextButton) + { + m_nextButton->setText(text); + } +} + +void QtWindow::updateCloseButton(QString text) +{ + if (m_closeButton) + { + m_closeButton->setText(text); + } +} + +void QtWindow::setNextEnabled(bool enabled) +{ + if (m_nextButton) + { + m_nextButton->setEnabled(enabled); + } +} + +void QtWindow::setPreviousEnabled(bool enabled) +{ + if (m_previousButton) + { + m_previousButton->setEnabled(enabled); + } +} + +void QtWindow::setCloseEnabled(bool enabled) +{ + if (m_closeButton) + { + m_closeButton->setEnabled(enabled); + } +} + +void QtWindow::setNextVisible(bool visible) +{ + if (m_nextButton) + { + m_nextButton->setVisible(visible); + } +} + +void QtWindow::setPreviousVisible(bool visible) +{ + if (m_previousButton) + { + m_previousButton->setVisible(visible); + } +} + +void QtWindow::setCloseVisible(bool visible) +{ + if (m_closeButton) + { + m_closeButton->setVisible(visible); + } +} + +void QtWindow::showWindow() +{ + show(); +} + +void QtWindow::hideWindow() +{ + hide(); +} + +void QtWindow::resizeEvent(QResizeEvent *event) +{ + QSize windowSize = event->size() - QSize(10, 10 + m_displacement); + m_window->resize(windowSize); + m_window->move(0, m_displacement); +} + +void QtWindow::keyPressEvent(QKeyEvent *event) +{ + if (m_cancelAble && event->key() == Qt::Key_Escape) + { + emit canceled(); + } + + QWidget::keyPressEvent(event); +} + +void QtWindow::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow) + { + move(event->globalPos() - m_dragPosition); + event->accept(); + } +} + +void QtWindow::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + m_dragPosition = event->globalPos() - frameGeometry().topLeft(); + event->accept(); + m_mousePressedInWindow = true; + } +} + +void QtWindow::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + m_dragPosition = event->globalPos() - frameGeometry().topLeft(); + event->accept(); + m_mousePressedInWindow = false; + } +} + +void QtWindow::populateWindow(QWidget* widget) +{ +} + +void QtWindow::windowReady() +{ +} + +void QtWindow::handleNext() +{ + emit finished(); +} + +void QtWindow::handlePrevious() +{ + emit previous(); +} + +void QtWindow::handleClose() +{ + emit canceled(); +} + +void QtWindow::addLogo() +{ + QtDeviceScaledPixmap coatiLogo((ResourcePaths::getGuiPath() + "window/logo.png").c_str()); + coatiLogo.scaleToWidth(150); + + QLabel* coatiLogoLabel = new QLabel(this); + coatiLogoLabel->setPixmap(coatiLogo.pixmap()); + coatiLogoLabel->resize(coatiLogo.width(), coatiLogo.height()); + coatiLogoLabel->move(30, 25); + coatiLogoLabel->show(); +} + +void QtWindow::handleNextPress() +{ + handleNext(); +} + +void QtWindow::handlePreviousPress() +{ + handlePrevious(); +} + +void QtWindow::handleClosePress() +{ + handleClose(); +} diff --git a/src/lib_gui/qt/window/QtWindow.h b/src/lib_gui/qt/window/QtWindow.h new file mode 100644 index 00000000..efbedc74 --- /dev/null +++ b/src/lib_gui/qt/window/QtWindow.h @@ -0,0 +1,96 @@ +#ifndef QT_WINDOW_H +#define QT_WINDOW_H + +#include +#include +#include + +#include "qt/window/QtWindowStack.h" + +class QLabel; +class QPushButton; +class QVBoxLayout; + +class QtWindow + : public QtWindowStackElement +{ + Q_OBJECT + +public: + QtWindow(QWidget* parent = nullptr, int displacement = 0); + + QSize sizeHint() const override; + + void setup(); + + void setCancelAble(bool cancelAble); + void setScrollAble(bool scrollAble); + void setShowAsPopup(bool showAsPopup); + + bool isScrollAble() const; + bool isPopup() const; + + void updateTitle(QString title); + void updateNextButton(QString text); + void updateCloseButton(QString text); + + void setNextEnabled(bool enabled); + void setPreviousEnabled(bool enabled); + void setCloseEnabled(bool enabled); + + void setNextVisible(bool visible); + void setPreviousVisible(bool visible); + void setCloseVisible(bool visible); + + // QtWindowStackElement implementation + virtual void showWindow() override; + virtual void hideWindow() override; + +signals: + void finished(); + void canceled(); + + void next(); + void previous(); + +protected: + void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + + virtual void populateWindow(QWidget* widget); + virtual void windowReady(); + + virtual void handleNext(); + virtual void handlePrevious(); + virtual void handleClose(); + + void addLogo(); + + QWidget* m_window; + + QLabel* m_title; + + QPushButton* m_nextButton; + QPushButton* m_previousButton; + QPushButton* m_closeButton; + +private slots: + void handleNextPress(); + void handlePreviousPress(); + void handleClosePress(); + +private: + int m_displacement; + + bool m_cancelAble; + bool m_scrollAble; + bool m_showAsPopup; + + QPoint m_dragPosition; + bool m_mousePressedInWindow; +}; + +#endif //QT_WINDOW_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index da0b70ec..41099baa 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -54,8 +54,8 @@ void QtProjectWizzard::newProject() SIGNAL(selected(QtProjectWizzardContentSelect::ProjectType)), this, SLOT(selectedProjectType(QtProjectWizzardContentSelect::ProjectType))); - window->disableNext(); - window->disablePrevious(); + window->setNextEnabled(false); + window->setPreviousEnabled(false); } void QtProjectWizzard::newProjectFromVisualStudioSolution(const std::string& visualStudioSolutionPath) @@ -140,9 +140,9 @@ void QtProjectWizzard::editProject(const ProjectSettings& settings) } window->updateTitle("EDIT PROJECT"); - window->updateDoneButton("Save"); + window->updateNextButton("Save"); - window->hidePrevious(); + window->setPreviousVisible(false); connect(window, SIGNAL(next()), this, SLOT(createProject())); } @@ -180,7 +180,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createPopupWithContent() window->move(window->pos() + QPoint(50, 50)); window->show(); - connect(window, SIGNAL(closed()), this, SLOT(popupClosed())); + connect(window, SIGNAL(next()), this, SLOT(popupClosed())); if (m_popup) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index 8bf8de06..83739693 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -37,8 +37,8 @@ void QtProjectWizzardContentPreferences::populateWindow(QGridLayout* layout) void QtProjectWizzardContentPreferences::windowReady() { m_window->updateTitle("PREFERENCES"); - m_window->updateDoneButton("Save"); - m_window->hidePrevious(); + m_window->updateNextButton("Save"); + m_window->setPreviousVisible(false); } void QtProjectWizzardContentPreferences::load() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index 6738280a..310cb0d3 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -43,7 +43,7 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout) } m_buttons->setExclusive(true); - m_window->disableNext(); + m_window->setNextEnabled(false); m_title->setText("Project Types - " + m_languages->checkedButton()->text()); m_description->setText(""); } @@ -97,7 +97,7 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout) ); break; } - m_window->enableNext(); + m_window->setNextEnabled(true); } ); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp index c7f4e085..59dfe274 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp @@ -44,7 +44,7 @@ void QtProjectWizzardContentSimple::populateWindow(QGridLayout* layout) connect(m_buttons, static_cast(&QButtonGroup::buttonClicked), [this](int id) { - m_window->enableNext(); + m_window->setNextEnabled(true); } ); @@ -79,7 +79,7 @@ void QtProjectWizzardContentSimple::windowReady() { if (!m_isForm) { - m_window->disableNext(); + m_window->setNextEnabled(false); } } @@ -92,7 +92,7 @@ void QtProjectWizzardContentSimple::load() else if (m_buttons && m_settings->isUseSourcePathsForHeaderSearchDefined()) { m_buttons->button(m_settings->getUseSourcePathsForHeaderSearch() ? 0 : 1)->setChecked(true); - m_window->enableNext(); + m_window->setNextEnabled(true); } } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp index efa5b303..63754dcf 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp @@ -72,7 +72,7 @@ void QtProjectWizzardContentSummary::populateWindow(QGridLayout* layout) void QtProjectWizzardContentSummary::windowReady() { m_window->updateTitle("NEW PROJECT - SUMMARY"); - m_window->updateDoneButton("Create"); + m_window->updateNextButton("Create"); } void QtProjectWizzardContentSummary::load() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp index 0dd79ec3..b94a7fa7 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp @@ -10,11 +10,8 @@ #include "utility/ResourcePaths.h" QtProjectWizzardWindow::QtProjectWizzardWindow(QWidget *parent) - : QtSettingsWindow(parent) + : QtWindow(parent) , m_content(nullptr) - , m_previousButton(nullptr) - , m_showAsPopup(false) - , m_scrollAble(false) { } @@ -26,68 +23,7 @@ QtProjectWizzardContent* QtProjectWizzardWindow::content() const void QtProjectWizzardWindow::setContent(QtProjectWizzardContent* content) { m_content = content; - m_scrollAble = content->isScrollAble(); -} - -void QtProjectWizzardWindow::setup() -{ - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "project_wizzard/window.css").c_str()); - QVBoxLayout* windowLayout = new QVBoxLayout(); - windowLayout->setContentsMargins(25, 30, 25, 20); - - m_title = new QLabel(); - m_title->setObjectName("title"); - windowLayout->addWidget(m_title); - windowLayout->addSpacing(10); - - QWidget* contentWidget = new QWidget(); - contentWidget->setObjectName("form"); - - populateWindow(contentWidget); - - QScrollArea* scrollArea = new QScrollArea(); - scrollArea->setFrameShadow(QFrame::Plain); - scrollArea->setObjectName("formArea"); - scrollArea->setWidgetResizable(true); - - scrollArea->setWidget(contentWidget); - windowLayout->addWidget(scrollArea); - - if (!m_scrollAble) - { - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - } - else - { - scrollArea->setObjectName("scrollArea"); - } - - showButtons(windowLayout); - - m_window->setLayout(windowLayout); - - resize(content()->preferredWindowSize()); - - - updateTitle("NEW PROJECT"); - updateDoneButton("Next"); - - m_previousButton = new QPushButton("Previous"); - m_previousButton->setObjectName("windowButton"); - connect(m_previousButton, SIGNAL(clicked()), this, SLOT(handlePreviousButtonPress())); - - m_buttonsLayout->insertWidget(2, m_previousButton); - m_buttonsLayout->insertSpacing(3, 3); - - if (m_showAsPopup) - { - updateDoneButton("Ok"); - hideCancelButton(true); - hidePrevious(); - } - - m_content->windowReady(); + setScrollAble(content->isScrollAble()); } void QtProjectWizzardWindow::populateWindow(QWidget* widget) @@ -115,7 +51,7 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget) layout->setColumnStretch(HELP_COL, 0); layout->setColumnStretch(LINE_COL, 0); - if (m_scrollAble) + if (isScrollAble()) { layout->setColumnMinimumWidth(BACK_COL + 1, 10); } @@ -124,67 +60,21 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget) } } -void QtProjectWizzardWindow::enableNext() +void QtProjectWizzardWindow::windowReady() { - if (m_doneButton) - { - m_doneButton->setEnabled(true); - } + updateTitle("NEW PROJECT"); + + m_content->windowReady(); + + resize(content()->preferredWindowSize()); } -void QtProjectWizzardWindow::disableNext() +void QtProjectWizzardWindow::handleNext() { - if (m_doneButton) - { - m_doneButton->setEnabled(false); - } -} - -void QtProjectWizzardWindow::hideNext() -{ - if (m_doneButton) - { - m_doneButton->hide(); - } -} - -void QtProjectWizzardWindow::disablePrevious() -{ - if (m_previousButton) - { - m_previousButton->setEnabled(false); - } -} - -void QtProjectWizzardWindow::hidePrevious() -{ - if (m_previousButton) - { - m_previousButton->hide(); - } -} - -void QtProjectWizzardWindow::setShowAsPopup(bool showAsPopup) -{ - m_showAsPopup = showAsPopup; -} - -void QtProjectWizzardWindow::setScrollAble(bool scrollAble) -{ - m_scrollAble = scrollAble; -} - -void QtProjectWizzardWindow::handleCancelButtonPress() -{ - emit canceled(); -} - -void QtProjectWizzardWindow::handleUpdateButtonPress() -{ - if (m_showAsPopup) + if (isPopup()) { hide(); - emit closed(); + emit next(); } if (m_content->check()) @@ -194,7 +84,7 @@ void QtProjectWizzardWindow::handleUpdateButtonPress() } } -void QtProjectWizzardWindow::handlePreviousButtonPress() +void QtProjectWizzardWindow::handlePrevious() { m_content->save(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h index 029eaefe..dfb9c3d5 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h @@ -1,57 +1,37 @@ #ifndef QT_PROJECT_WIZZARD_WINDOW_H #define QT_PROJECT_WIZZARD_WINDOW_H -#include "qt/window/QtSettingsWindow.h" +#include "qt/window/QtWindow.h" #include "settings/ProjectSettings.h" -class QPushButton; class QtProjectWizzardContent; class QtProjectWizzardWindow - : public QtSettingsWindow + : public QtWindow { Q_OBJECT -signals: - void next(); - void previous(); - void closed(); - public: QtProjectWizzardWindow(QWidget *parent); QtProjectWizzardContent* content() const; void setContent(QtProjectWizzardContent* content); - // QtSettingsWindow implementation - virtual void setup() override; - virtual void populateWindow(QWidget* widget) override; - - void enableNext(); - void disableNext(); - void hideNext(); - void disablePrevious(); - void hidePrevious(); - - void setShowAsPopup(bool showAsPopup); - void setScrollAble(bool scrollAble); - static const int FRONT_COL = 0; static const int HELP_COL = 1; static const int LINE_COL = 2; static const int BACK_COL = 3; -private slots: - void handleCancelButtonPress(); - void handleUpdateButtonPress(); - void handlePreviousButtonPress(); +protected: + // QtWindow implementation + virtual void populateWindow(QWidget* widget) override; + virtual void windowReady() override; + + virtual void handleNext() override; + virtual void handlePrevious() override; private: QtProjectWizzardContent* m_content; - QPushButton* m_previousButton; - - bool m_showAsPopup; - bool m_scrollAble; }; #endif // QT_PROJECT_WIZZARD_WINDOW_H