ui: Refactored windows to QtWindow base class
* renamed QtSettingsWindow to QtWindow * moved functionality from QtProjectWizzardWindow to QtWindow * use common createWindow method in QtMainWindow
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user