ui: Rewrote project setup to wizzard

* QtProjectWizzard handles window managment logic of project setup
* QtProjectWizzardWindow is used in every step and displays QtProjectWizzardContent
* QtProjectWizzardContent is the base class for all differnt content types
* Removed Singleton from ProjectSettings
* ProjectSettings are created by wizzard and QtProjectWizzardContent can access and load
* added project type selection at start of wizzard
* added summary at end of wizzard
* show global search paths in setup and summary
* fixed layout problems after font switch
* fixed scrolling and resizing of QtDirectoryListBox
* separated QtLocationPicker to own class
This commit is contained in:
Eberhard Graether
2016-02-14 15:42:30 +01:00
parent 50a94bf108
commit 2d48f0a663
38 changed files with 1784 additions and 716 deletions
+2 -2
View File
@@ -11,6 +11,7 @@ QListWidget {
}
QListWidget::item {
height: 20px;
border-bottom: 1px solid lightgray;
}
@@ -29,8 +30,7 @@ QtListItemWidget #button {
border: 1px solid lightgray;
border-radius: 7px;
font-size: 12px;
margin-bottom: 2px;
margin-top: 2px;
height: 14px;
margin-right: 2px;
width: 20px;
}
+3 -2
View File
@@ -8,6 +8,7 @@ QLineEdit {
background-color: rgba(255, 255, 255, 200);
border-radius: 10px;
border: 1px solid lightgrey;
height: 20px;
padding-left: 5px;
padding-right: 5px;
}
@@ -27,7 +28,7 @@ QLineEdit:disabled {
background-color: rgba(255, 255, 255, 150);
}
#form QLabel {
#form #label {
font-weight: bold;
}
@@ -52,7 +53,7 @@ QLineEdit:disabled {
color: gray;
font-size: 15px;
height: 20px;
margin-left: 10px;
margin-left: 5px;
width: 28px;
}
+34 -1
View File
@@ -40,6 +40,9 @@ ProjectSettings::~ProjectSettings()
void ProjectSettings::save(const FilePath& filePath)
{
m_projectName = "";
m_projectFileLocation = "";
moveRelativePathValues("source/source_paths/source_path", filePath);
moveRelativePathValues("source/header_search_paths/header_search_path", filePath);
moveRelativePathValues("source/framework_search_paths/framework_search_path", filePath);
@@ -59,7 +62,7 @@ bool ProjectSettings::setLanguage(const std::string& language)
std::string ProjectSettings::getStandard() const
{
return getValue<std::string>("language_settings/standard", "11");
return getValue<std::string>("language_settings/standard", "1z");
}
bool ProjectSettings::setStandard(const std::string& standard)
@@ -127,3 +130,33 @@ std::string ProjectSettings::getDescription() const
{
return getValue<std::string>("info/description", "");
}
std::string ProjectSettings::getProjectName() const
{
if (m_projectName.size())
{
return m_projectName;
}
return getFilePath().withoutExtension().fileName();
}
void ProjectSettings::setProjectName(const std::string& name)
{
m_projectName = name;
}
std::string ProjectSettings::getProjectFileLocation() const
{
if (m_projectFileLocation.size())
{
return m_projectFileLocation;
}
return getFilePath().parentDirectory().str();
}
void ProjectSettings::setProjectFileLocation(const std::string& location)
{
m_projectFileLocation = location;
}
+10 -3
View File
@@ -14,6 +14,7 @@ public:
static std::vector<std::string> getDefaultSourceExtensions();
static std::shared_ptr<ProjectSettings> getInstance();
ProjectSettings();
~ProjectSettings();
virtual void save(const FilePath& filePath);
@@ -47,10 +48,16 @@ public:
bool setHeaderExtensions(const std::vector<std::string>& headerExtensions);
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
// used in project wizzard
std::string getProjectName() const;
void setProjectName(const std::string& name);
std::string getProjectFileLocation() const;
void setProjectFileLocation(const std::string& location);
private:
ProjectSettings();
ProjectSettings(const ProjectSettings&);
void operator=(const ProjectSettings&);
std::string m_projectName;
std::string m_projectFileLocation;
static std::shared_ptr<ProjectSettings> s_instance;
};
+21 -2
View File
@@ -22,6 +22,8 @@ add_files(
qt/element/QtDirectoryListBox.h
qt/element/QtLineEdit.cpp
qt/element/QtLineEdit.h
qt/element/QtLocationPicker.cpp
qt/element/QtLocationPicker.h
qt/element/QtRefreshBar.cpp
qt/element/QtRefreshBar.h
qt/element/QtSearchBar.cpp
@@ -101,6 +103,23 @@ add_files(
qt/view/QtViewWidgetWrapper.cpp
qt/view/QtViewWidgetWrapper.h
qt/window/project_wizzard/QtProjectWizzard.cpp
qt/window/project_wizzard/QtProjectWizzard.h
qt/window/project_wizzard/QtProjectWizzardContent.cpp
qt/window/project_wizzard/QtProjectWizzardContent.h
qt/window/project_wizzard/QtProjectWizzardContentData.cpp
qt/window/project_wizzard/QtProjectWizzardContentData.h
qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
qt/window/project_wizzard/QtProjectWizzardContentPaths.h
qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp
qt/window/project_wizzard/QtProjectWizzardContentSelect.h
qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp
qt/window/project_wizzard/QtProjectWizzardContentSimple.h
qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp
qt/window/project_wizzard/QtProjectWizzardContentSummary.h
qt/window/project_wizzard/QtProjectWizzardWindow.cpp
qt/window/project_wizzard/QtProjectWizzardWindow.h
qt/window/QtAbout.cpp
qt/window/QtAbout.h
qt/window/QtAboutLicense.cpp
@@ -111,14 +130,14 @@ add_files(
qt/window/QtLicense.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
qt/window/QtWindowStack.cpp
qt/window/QtWindowStack.h
qt/QtApplication.cpp
qt/QtApplication.h
+51 -9
View File
@@ -1,9 +1,10 @@
#include "qt/element/QtDirectoryListBox.h"
#include <QBoxLayout>
#include <QTreeView>
#include <QFileDialog>
#include <QMimeData>
#include <QScrollBar>
#include <QTreeView>
#include "utility/ResourcePaths.h"
@@ -96,6 +97,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent)
m_list = new QListWidget(this);
m_list->setObjectName("list");
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());
layout->addWidget(m_list);
@@ -128,6 +130,8 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent)
dropInfoText->setAlignment(Qt::AlignRight);
innerLayout->addWidget(dropInfoText);
layout->addStretch();
buttonContainer->setLayout(innerLayout);
layout->addWidget(buttonContainer);
setLayout(layout);
@@ -136,14 +140,44 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent)
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeListBoxItem()));
setAcceptDrops(true);
setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Minimum);
setMaximumHeight(200);
resize();
}
QSize QtDirectoryListBox::sizeHint() const
{
return QSize(QFrame::sizeHint().width(), 100);
}
void QtDirectoryListBox::clear()
{
m_list->clear();
}
bool QtDirectoryListBox::event(QEvent* event)
{
// Prevent nested ScrollAreas to scroll at the same time;
if (event->type() == QEvent::Wheel)
{
QRect rect = m_list->viewport()->rect();
QPoint pos = m_list->mapFromGlobal( dynamic_cast<QWheelEvent*>(event)->globalPos());
QScrollBar* bar = m_list->verticalScrollBar();
if (bar->minimum() != bar->maximum() && rect.contains(pos))
{
bool down = dynamic_cast<QWheelEvent*>(event)->angleDelta().y() < 0;
if ((down && bar->value() != bar->maximum()) || (!down && bar->value() != bar->minimum()))
{
return true;
}
}
}
return QFrame::event(event);
}
void QtDirectoryListBox::dropEvent(QDropEvent *event)
{
QFileInfo fileInfo;
@@ -188,19 +222,14 @@ void QtDirectoryListBox::selectItem(QListWidgetItem* item)
void QtDirectoryListBox::resize()
{
int height = 25;
int height = m_list->height() - m_list->viewport()->height();
if (m_list->count() > 0)
{
height += (m_list->itemWidget(m_list->item(0))->height() + 1) * m_list->count() + 8;
height += (m_list->itemWidget(m_list->item(0))->height() + 1) * m_list->count() + 7;
}
if (height < 150)
{
height = 150;
}
setMinimumHeight(height);
m_list->setMaximumHeight(height);
}
QtListItemWidget* QtDirectoryListBox::addListBoxItem()
@@ -220,8 +249,21 @@ QtListItemWidget* QtDirectoryListBox::addListBoxItem()
void QtDirectoryListBox::removeListBoxItem()
{
if (!m_list->selectedItems().size())
{
return;
}
int rowIndex = m_list->row(m_list->selectedItems().first()) - 1;
qDeleteAll(m_list->selectedItems());
resize();
if (rowIndex >= 0)
{
m_list->setCurrentRow(rowIndex);
}
}
void QtDirectoryListBox::dragEnterEvent(QDragEnterEvent *event)
+6 -2
View File
@@ -48,6 +48,8 @@ class QtDirectoryListBox
public:
QtDirectoryListBox(QWidget *parent);
virtual QSize sizeHint() const override;
void clear();
std::vector<FilePath> getList();
@@ -56,8 +58,10 @@ public:
void selectItem(QListWidgetItem* item);
protected:
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent* event);
bool event(QEvent* event) override;
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
private:
void resize();
@@ -0,0 +1,53 @@
#include "qt/element/QtLocationPicker.h"
#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
QtLocationPicker::QtLocationPicker(QWidget *parent)
: QWidget(parent)
{
QBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setContentsMargins(1, 1, 1, 1);
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
m_data = new QtLineEdit(this);
m_data->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_data->setObjectName("locationField");
m_button = new QPushButton("...");
m_button->setObjectName("moreButton");
m_button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
layout->addWidget(m_data);
layout->addWidget(m_button);
connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress()));
}
QString QtLocationPicker::getText()
{
return m_data->text();
}
void QtLocationPicker::setText(QString text)
{
m_data->setText(text);
}
void QtLocationPicker::clearText()
{
m_data->clear();
}
void QtLocationPicker::handleButtonPress()
{
QString file = QFileDialog::getExistingDirectory(this, tr("Select Directory"), "");
if (!file.isEmpty())
{
m_data->setText(file);
}
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef QT_LOCATION_PICKER_H
#define QT_LOCATION_PICKER_H
#include <QPushButton>
#include "qt/element/QtLineEdit.h"
class QtLocationPicker
: public QWidget
{
Q_OBJECT
public:
QtLocationPicker(QWidget *parent);
QString getText();
void setText(QString text);
void clearText();
private slots:
void handleButtonPress();
private:
QPushButton* m_button;
QtLineEdit* m_data;
};
#endif // QT_LOCATION_PICKER_H
+1 -1
View File
@@ -100,7 +100,7 @@ void QtMainView::doUpdateRecentProjectMenu()
void QtMainView::doHideStartScreen()
{
m_window->clearWindows();
m_window->hideStartScreen();
}
void QtMainView::doSetTitle(const std::string& title)
+7 -4
View File
@@ -1,7 +1,7 @@
#include "qt/window/QtAboutLicense.h"
#include <QComboBox>
#include <QFormLayout>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QTextBrowser>
@@ -31,9 +31,11 @@ void QtAboutLicense::setup()
hideCancelButton(true);
}
void QtAboutLicense::populateForm(QFormLayout* layout)
void QtAboutLicense::populateWindow(QWidget* widget)
{
for(ThirdPartyLicense license : licenses3rdParties)
QVBoxLayout* layout = new QVBoxLayout(widget);
for (ThirdPartyLicense license : licenses3rdParties)
{
if( !(isTrial() && license.isNotInTrial) )
{
@@ -56,8 +58,9 @@ void QtAboutLicense::populateForm(QFormLayout* layout)
licenseText->setText(QString::fromLatin1(license.license));
layout->addWidget(licenseText);
}
}
widget->setLayout(layout);
}
void QtAboutLicense::handleCancelButtonPress()
+1 -1
View File
@@ -18,7 +18,7 @@ public:
virtual void setup() override;
protected:
virtual void populateForm(QFormLayout* layout) override;
virtual void populateWindow(QWidget* widget) override;
private slots:
void handleCancelButtonPress();
@@ -12,8 +12,15 @@
QtApplicationSettingsScreen::QtApplicationSettingsScreen(QWidget *parent)
: QtSettingsWindow(parent)
, m_headerPaths(nullptr)
, m_frameworkPaths(nullptr)
{
m_headerPaths = new QtProjectWizzardContentPathsHeaderSearchGlobal(nullptr, nullptr);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_frameworkPaths = new QtProjectWizzardContentPathsFrameworkSearchGlobal(nullptr, nullptr);
}
}
QSize QtApplicationSettingsScreen::sizeHint() const
@@ -31,35 +38,28 @@ void QtApplicationSettingsScreen::setup()
void QtApplicationSettingsScreen::load()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_includePaths->setList(appSettings->getHeaderSearchPaths());
m_headerPaths->load();
if (m_frameworkPaths)
{
m_frameworkPaths->setList(appSettings->getFrameworkSearchPaths());
m_frameworkPaths->load();
}
}
void QtApplicationSettingsScreen::populateForm(QFormLayout* layout)
void QtApplicationSettingsScreen::populateWindow(QWidget* widget)
{
int minimumWidthForSecondCol = 360;
QPushButton* helpButton;
QFormLayout* layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
QWidget* includePathsWidget = createLabelWithHelpButton("Header\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleIncludePathHelpPress()));
m_includePaths = new QtDirectoryListBox(this);
m_includePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(includePathsWidget, m_includePaths);
m_headerPaths->populateForm(layout);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
if (m_frameworkPaths)
{
QWidget* frameworkPathsWidget = createLabelWithHelpButton("Framework\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleFrameworkPathHelpPress()));
m_frameworkPaths = new QtDirectoryListBox(this);
m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(frameworkPathsWidget, m_frameworkPaths);
m_frameworkPaths->populateForm(layout);
}
widget->setLayout(layout);
}
void QtApplicationSettingsScreen::handleCancelButtonPress()
@@ -69,35 +69,16 @@ void QtApplicationSettingsScreen::handleCancelButtonPress()
void QtApplicationSettingsScreen::handleUpdateButtonPress()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->setHeaderSearchPaths(m_includePaths->getList());
m_headerPaths->save();
if (m_frameworkPaths)
{
appSettings->setFrameworkSearchPaths(m_frameworkPaths->getList());
m_frameworkPaths->save();
}
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->save();
MessageRefresh().dispatch();
emit finished();
}
void QtApplicationSettingsScreen::handleIncludePathHelpPress()
{
showHelpMessage(
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.\n\n"
"Header Search Paths defined here will be used for all projects."
);
}
void QtApplicationSettingsScreen::handleFrameworkPathHelpPress()
{
showHelpMessage(
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.\n\n"
"Framework Search Paths defined here will be used for all projects."
);
}
@@ -7,6 +7,7 @@
#include "utility/file/FilePath.h"
#include "qt/element/QtDirectoryListBox.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/QtSettingsWindow.h"
class QtApplicationSettingsScreen
@@ -23,21 +24,18 @@ public:
void load();
protected:
virtual void populateForm(QFormLayout* layout) override;
virtual void populateWindow(QWidget* widget) override;
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
void handleIncludePathHelpPress();
void handleFrameworkPathHelpPress();
private:
QPushButton* m_cancelButton;
QPushButton* m_updateButton;
QtDirectoryListBox* m_includePaths;
QtDirectoryListBox* m_frameworkPaths;
QtProjectWizzardContentPathsHeaderSearchGlobal* m_headerPaths;
QtProjectWizzardContentPathsFrameworkSearchGlobal* m_frameworkPaths;
};
#endif //QT_APPLICATION_SETTINGS_SCREEN_H
+103 -109
View File
@@ -12,7 +12,14 @@
#include "component/view/CompositeView.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "qt/window/project_wizzard/QtProjectWizzard.h"
#include "qt/window/QtApplicationSettingsScreen.h"
#include "qt/window/QtStartScreen.h"
#include "qt/window/QtAboutLicense.h"
#include "qt/window/QtAbout.h"
#include "qt/window/QtLicense.h"
#include "settings/ApplicationSettings.h"
#include "settings/ProjectSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageFind.h"
@@ -106,6 +113,7 @@ bool MouseWheelFilter::eventFilter(QObject* obj, QEvent* event)
QtMainWindow::QtMainWindow()
: m_showDockWidgetTitleBars(true)
, m_windowStack(this)
, m_createNewProjectFunctor(std::bind(&QtMainWindow::doCreateNewProject, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4))
{
setObjectName("QtMainWindow");
@@ -245,12 +253,13 @@ void QtMainWindow::saveLayout()
void QtMainWindow::forceEnterLicense()
{
enterLicense();
m_enterLicenseWindow->clear();
m_enterLicenseWindow->setCancelAble(false);
QtLicense* enterLicenseWindow = dynamic_cast<QtLicense*>(enterLicense());
enterLicenseWindow->clear();
enterLicenseWindow->setCancelAble(false);
this->setEnabled(false);
m_enterLicenseWindow->setEnabled(true);
enterLicenseWindow->setEnabled(true);
}
void QtMainWindow::handleMessage(MessageNewProject* message)
@@ -276,137 +285,90 @@ void QtMainWindow::keyPressEvent(QKeyEvent* event)
}
}
void QtMainWindow::pushWindow(QWidget* window)
{
if (m_windowStack.size())
{
m_windowStack.back()->hide();
}
window->show();
m_windowStack.push_back(window);
}
void QtMainWindow::popWindow()
{
if (m_windowStack.size())
{
m_windowStack.back()->hide();
m_windowStack.pop_back();
}
if (m_windowStack.size())
{
m_windowStack.back()->show();
}
}
void QtMainWindow::clearWindows()
{
for (QWidget* window : m_windowStack)
{
window->hide();
}
m_windowStack.clear();
}
void QtMainWindow::activateWindow()
{
this->setEnabled(true);
popWindow();
m_windowStack.popWindow();
}
void QtMainWindow::about()
QtSettingsWindow* QtMainWindow::about()
{
if (!m_aboutWindow)
{
m_aboutWindow = std::make_shared<QtAbout>(this);
m_aboutWindow->setup();
QtAbout* aboutWindow = new QtAbout(this);
aboutWindow->setup();
connect(m_aboutWindow.get(), SIGNAL(finished()), this, SLOT(popWindow()));
connect(m_aboutWindow.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
}
connect(aboutWindow, SIGNAL(finished()), &m_windowStack, SLOT(popWindow()));
connect(aboutWindow, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
pushWindow(m_aboutWindow.get());
m_windowStack.pushWindow(aboutWindow);
return aboutWindow;
}
void QtMainWindow::openSettings()
QtSettingsWindow* QtMainWindow::openSettings()
{
if (!m_applicationSettingsScreen)
{
m_applicationSettingsScreen = std::make_shared<QtApplicationSettingsScreen>(this);
m_applicationSettingsScreen->setup();
QtApplicationSettingsScreen* applicationSettingsScreen = new QtApplicationSettingsScreen(this);
applicationSettingsScreen->setup();
connect(m_applicationSettingsScreen.get(), SIGNAL(finished()), this, SLOT(popWindow()));
connect(m_applicationSettingsScreen.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
}
connect(applicationSettingsScreen, SIGNAL(finished()), &m_windowStack, SLOT(popWindow()));
connect(applicationSettingsScreen, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
m_applicationSettingsScreen->load();
pushWindow(m_applicationSettingsScreen.get());
applicationSettingsScreen->load();
m_windowStack.pushWindow(applicationSettingsScreen);
return applicationSettingsScreen;
}
void QtMainWindow::showLicenses()
QtSettingsWindow* QtMainWindow::showLicenses()
{
if (!m_licenseWindow)
{
m_licenseWindow = std::make_shared<QtAboutLicense>(this);
m_licenseWindow->setup();
QtAboutLicense* licenseWindow = new QtAboutLicense(this);
licenseWindow->setup();
connect(m_licenseWindow.get(), SIGNAL(finished()), this, SLOT(popWindow()));
connect(m_licenseWindow.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
}
connect(licenseWindow, SIGNAL(finished()), &m_windowStack, SLOT(popWindow()));
connect(licenseWindow, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
pushWindow(m_licenseWindow.get());
m_windowStack.pushWindow(licenseWindow);
return licenseWindow;
}
void QtMainWindow::enterLicense()
QtSettingsWindow* QtMainWindow::enterLicense()
{
if (!m_enterLicenseWindow)
{
m_enterLicenseWindow = std::make_shared<QtLicense>(this);
m_enterLicenseWindow->setup();
QtLicense* enterLicenseWindow = new QtLicense(this);
enterLicenseWindow->setup();
connect(m_enterLicenseWindow.get(), SIGNAL(finished()), this, SLOT(activateWindow()));
connect(m_enterLicenseWindow.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
}
connect(enterLicenseWindow, SIGNAL(finished()), this, SLOT(activateWindow()));
connect(enterLicenseWindow, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
m_enterLicenseWindow->load();
pushWindow(m_enterLicenseWindow.get());
enterLicenseWindow->load();
m_windowStack.pushWindow(enterLicenseWindow);
return enterLicenseWindow;
}
void QtMainWindow::showStartScreen()
QtSettingsWindow* QtMainWindow::showStartScreen()
{
if (!m_startScreen)
{
m_startScreen = std::make_shared<QtStartScreen>(this);
m_startScreen->setup();
QtStartScreen* startScreen = new QtStartScreen(this);
startScreen->setup();
connect(m_startScreen.get(), SIGNAL(finished()), this, SLOT(popWindow()));
connect(m_startScreen.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
connect(startScreen, SIGNAL(finished()), &m_windowStack, SLOT(popWindow()));
connect(startScreen, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
connect(m_startScreen.get(), SIGNAL(openOpenProjectDialog()), this, SLOT(openProject()));
connect(m_startScreen.get(), SIGNAL(openNewProjectDialog()), this, SLOT(newProject()));
}
connect(startScreen, SIGNAL(openOpenProjectDialog()), this, SLOT(openProject()));
connect(startScreen, SIGNAL(openNewProjectDialog()), this, SLOT(newProject()));
pushWindow(m_startScreen.get());
m_windowStack.pushWindow(startScreen);
return startScreen;
}
void QtMainWindow::hideStartScreen()
{
m_windowStack.clearWindows();
}
void QtMainWindow::newProject()
{
if (!m_newProjectDialog)
{
m_newProjectDialog = std::make_shared<QtProjectSetupScreen>(this);
m_newProjectDialog->setup();
connect(m_newProjectDialog.get(), SIGNAL(finished()), this, SLOT(clearWindows()));
connect(m_newProjectDialog.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
connect(m_newProjectDialog.get(), SIGNAL(showPreferences()), this, SLOT(openSettings()));
}
m_newProjectDialog->loadEmpty();
pushWindow(m_newProjectDialog.get());
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
wizzard->newProject();
}
void QtMainWindow::openProject(const QString &path)
@@ -421,14 +383,14 @@ void QtMainWindow::openProject(const QString &path)
if (!fileName.isEmpty())
{
MessageLoadProject(fileName.toStdString(), false).dispatch();
clearWindows();
m_windowStack.clearWindows();
}
}
void QtMainWindow::editProject()
{
newProject();
m_newProjectDialog->loadProjectSettings();
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
wizzard->editProject(*ProjectSettings::getInstance().get());
}
void QtMainWindow::find()
@@ -465,7 +427,7 @@ void QtMainWindow::saveProject()
void QtMainWindow::saveAsProject()
{
QString filename = "";
filename = QFileDialog::getSaveFileName(this, "Save File as", "", "Coati Project Files(*.coatiproject)");
filename = QFileDialog::getSaveFileName(this, "Save File as", "", "Coati Project Files (*.coatiproject)");
if(!filename.isEmpty())
{
@@ -524,7 +486,7 @@ void QtMainWindow::toggleView(View* view, bool fromMenu)
void QtMainWindow::handleEscapeShortcut()
{
popWindow();
m_windowStack.popWindow();
MessageInterruptTasks().dispatch();
}
@@ -608,8 +570,27 @@ void QtMainWindow::toggleShowDockWidgetTitleBars()
void QtMainWindow::doCreateNewProject(const std::string& name, const std::string& location,
const std::vector<std::string>& sourceFiles, const std::vector<std::string>& includePaths)
{
newProject();
m_newProjectDialog->setPresets(name, location, sourceFiles, includePaths);
ProjectSettings settings;
settings.setProjectName(name);
settings.setProjectFileLocation(location);
std::vector<FilePath> sourcePaths;
for (const std::string& p : sourceFiles)
{
sourcePaths.push_back(FilePath(p));
}
std::vector<FilePath> headerPaths;
for (const std::string& p : includePaths)
{
headerPaths.push_back(FilePath(p));
}
settings.setSourcePaths(sourcePaths);
settings.setHeaderSearchPaths(headerPaths);
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
wizzard->editProject(settings);
}
void QtMainWindow::setupEditMenu()
@@ -733,3 +714,16 @@ void QtMainWindow::setShowDockWidgetTitleBars(bool showTitleBars)
}
}
}
template<typename T>
T* QtMainWindow::createWindow()
{
T* window = new T(this);
connect(window, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
connect(window, SIGNAL(finished()), &m_windowStack, SLOT(clearWindows()));
m_windowStack.pushWindow(window);
return window;
}
+13 -23
View File
@@ -12,14 +12,10 @@
#include "utility/messaging/type/MessageNewProject.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "qt/window/QtApplicationSettingsScreen.h"
#include "qt/window/QtStartScreen.h"
#include "qt/window/QtProjectSetupScreen.h"
#include "qt/window/QtAboutLicense.h"
#include "qt/window/QtAbout.h"
#include "qt/window/QtLicense.h"
#include "qt/window/QtWindowStack.h"
class QDockWidget;
class QtSettingsWindow;
class View;
class QtViewToggle
@@ -98,18 +94,16 @@ protected:
void keyPressEvent(QKeyEvent* event);
public slots:
void pushWindow(QWidget* window);
void popWindow();
void clearWindows();
void activateWindow();
void about();
void openSettings();
void showLicenses();
void enterLicense();
QtSettingsWindow* about();
QtSettingsWindow* openSettings();
QtSettingsWindow* showLicenses();
QtSettingsWindow* enterLicense();
QtSettingsWindow* showStartScreen();
void hideStartScreen();
void showStartScreen();
void newProject();
void openProject(const QString &path = QString());
void editProject();
@@ -164,6 +158,9 @@ private:
void setShowDockWidgetTitleBars(bool showTitleBars);
template<typename T>
T* createWindow();
std::vector<DockWidget> m_dockWidgets;
QMenu* m_viewMenu;
QAction* m_viewSeparator;
@@ -171,14 +168,7 @@ private:
QAction* m_showTitleBarsAction;
bool m_showDockWidgetTitleBars;
std::shared_ptr<QtApplicationSettingsScreen> m_applicationSettingsScreen;
std::shared_ptr<QtStartScreen> m_startScreen;
std::shared_ptr<QtProjectSetupScreen> m_newProjectDialog;
std::shared_ptr<QtAboutLicense> m_licenseWindow;
std::shared_ptr<QtAbout> m_aboutWindow;
std::shared_ptr<QtLicense> m_enterLicenseWindow;
std::vector<QWidget*> m_windowStack;
QtWindowStack m_windowStack;
QShortcut* m_escapeShortcut;
@@ -1,368 +0,0 @@
#include "qt/window/QtProjectSetupScreen.h"
#include <QFileDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QMessageBox>
#include <QSysInfo>
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/utility.h"
#include "settings/ProjectSettings.h"
QtTextLine::QtTextLine(QWidget *parent)
: QWidget(parent)
{
QBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setContentsMargins(1, 1, 1, 1);
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
m_data = new QtLineEdit(this);
m_data->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_data->setObjectName("locationField");
m_button = new QPushButton("...");
m_button->setObjectName("moreButton");
layout->addWidget(m_data);
layout->addWidget(m_button);
connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress()));
}
QString QtTextLine::getText()
{
return m_data->text();
}
void QtTextLine::setText(QString text)
{
m_data->setText(text);
}
void QtTextLine::clearText()
{
m_data->clear();
}
void QtTextLine::handleButtonPress()
{
QString file = QFileDialog::getExistingDirectory(this, tr("Select Directory"), "");
if (!file.isEmpty())
{
m_data->setText(file);
}
}
QtProjectSetupScreen::QtProjectSetupScreen(QWidget *parent)
: QtSettingsWindow(parent)
, m_frameworkPaths(nullptr)
{
}
QSize QtProjectSetupScreen::sizeHint() const
{
return QSize(600,600);
}
void QtProjectSetupScreen::clear()
{
m_projectName->clear();
m_projectFileLocation->clearText();
m_language->setCurrentIndex(0);
m_cppStandard->setCurrentIndex(0);
m_cStandard->setCurrentIndex(0);
m_sourcePaths->clear();
m_includePaths->clear();
if (m_frameworkPaths)
{
m_frameworkPaths->clear();
}
}
void QtProjectSetupScreen::setup()
{
setupForm();
QPushButton* preferencesButton = new QPushButton("Preferences");
preferencesButton->setObjectName("windowButton");
connect(preferencesButton, SIGNAL(clicked()), this, SLOT(handlePreferencesButtonPress()));
m_buttonsLayout->insertWidget(2, preferencesButton);
m_buttonsLayout->insertStretch(3);
}
void QtProjectSetupScreen::loadEmpty()
{
updateTitle("NEW PROJECT");
updateDoneButton("Create");
clear();
}
void QtProjectSetupScreen::loadProjectSettings()
{
updateTitle("EDIT PROJECT");
updateDoneButton("Save");
ProjectSettings* projSettings = ProjectSettings::getInstance().get();
m_projectName->setText(QString::fromStdString(projSettings->getFilePath().withoutExtension().fileName()));
m_projectFileLocation->setText(QString::fromStdString(projSettings->getFilePath().parentDirectory().str()));
if (projSettings->getLanguage().length() > 0)
{
m_language->setCurrentText(QString::fromStdString(projSettings->getLanguage()));
}
if (projSettings->getStandard().length() > 0)
{
if (m_language->currentIndex() == 0) // c++
{
m_cppStandard->setCurrentText(QString::fromStdString(projSettings->getStandard()));
}
else if (m_language->currentIndex() == 1) // c
{
m_cStandard->setCurrentText(QString::fromStdString(projSettings->getStandard()));
}
}
m_sourcePaths->setList(projSettings->getSourcePaths());
m_includePaths->setList(projSettings->getHeaderSearchPaths());
if (m_frameworkPaths)
{
m_frameworkPaths->setList(projSettings->getFrameworkSearchPaths());
}
}
void QtProjectSetupScreen::setPresets(const std::string& name, const std::string& location,
const std::vector<std::string>& sourceFiles, const std::vector<std::string>& includePaths)
{
m_projectName->setText(QString::fromStdString(name));
m_projectFileLocation->setText(QString::fromStdString(location));
std::vector<FilePath> sourceFilePaths;
for (unsigned int i = 0; i < sourceFiles.size(); i++)
{
sourceFilePaths.push_back(FilePath(sourceFiles[i]));
}
std::vector<FilePath> includePathsPaths;
for (unsigned int i = 0; i < includePaths.size(); i++)
{
includePathsPaths.push_back(FilePath(sourceFiles[i]));
}
m_sourcePaths->setList(sourceFilePaths);
m_includePaths->setList(includePathsPaths);
}
void QtProjectSetupScreen::populateForm(QFormLayout* layout)
{
int minimumWidthForSecondCol = 360;
QLabel* nameLabel = new QLabel("Name");
m_projectName = new QLineEdit();
m_projectName->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
m_projectName->setMinimumWidth(minimumWidthForSecondCol);
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addRow(nameLabel, m_projectName);
QLabel* locationLabel = new QLabel("Location");
m_projectFileLocation = new QtTextLine(this);
m_projectFileLocation->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(locationLabel, m_projectFileLocation);
QLabel* languageLabel = new QLabel("Language");
m_language = new QComboBox();
m_language->insertItem(0, "C++");
m_language->insertItem(1, "C");
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
layout->addRow(languageLabel, m_language);
m_cppStandardLabel = new QLabel("Standard");
m_cppStandard = new QComboBox();
m_cppStandard->insertItem(0, "1z");
m_cppStandard->insertItem(1, "14");
m_cppStandard->insertItem(2, "1y");
m_cppStandard->insertItem(3, "11");
m_cppStandard->insertItem(4, "0x");
m_cppStandard->insertItem(5, "03");
m_cppStandard->insertItem(6, "98");
layout->addRow(m_cppStandardLabel, m_cppStandard);
m_cStandardLabel = new QLabel("Standard");
m_cStandard = new QComboBox();
m_cStandard->insertItem(0, "1x");
m_cStandard->insertItem(1, "11");
m_cStandard->insertItem(2, "9x");
m_cStandard->insertItem(3, "99");
m_cStandard->insertItem(4, "90");
m_cStandard->insertItem(5, "89");
layout->addRow(m_cStandardLabel, m_cStandard);
m_cStandardLabel->hide();
m_cStandard->hide();
QPushButton* helpButton;
QWidget* sourcePathsWidget = createLabelWithHelpButton("Analyzed Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleSourcePathHelpPress()));
m_sourcePaths = new QtDirectoryListBox(this);
m_sourcePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(sourcePathsWidget, m_sourcePaths);
QWidget* includePathsWidget = createLabelWithHelpButton("Header\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleIncludePathHelpPress()));
m_includePaths = new QtDirectoryListBox(this);
m_includePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(includePathsWidget, m_includePaths);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
QWidget* frameworkPathsWidget = createLabelWithHelpButton("Framework\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleFrameworkPathHelpPress()));
m_frameworkPaths = new QtDirectoryListBox(this);
m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(frameworkPathsWidget, m_frameworkPaths);
}
}
void QtProjectSetupScreen::handleCancelButtonPress()
{
emit canceled();
}
void QtProjectSetupScreen::handleUpdateButtonPress()
{
if (m_projectName->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please enter a project name.");
msgBox.exec();
return;
}
if (m_projectFileLocation->getText().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please define the location of the project file.");
msgBox.exec();
return;
}
if (!m_sourcePaths->getList().size())
{
QMessageBox msgBox;
msgBox.setText("Please add at least one source path to your project.");
msgBox.exec();
return;
}
std::shared_ptr<ProjectSettings> projectSettings = ProjectSettings::getInstance();
std::string newLanguage = m_language->currentText().toStdString();
std::string newStandard = "";
if (m_cppStandard->isVisible())
{
newStandard = m_cppStandard->currentText().toStdString();
}
else if (m_cStandard->isVisible())
{
newStandard = m_cStandard->currentText().toStdString();
}
std::vector<FilePath> newSourcePaths = m_sourcePaths->getList();
std::vector<FilePath> newHeaderSearchPaths = m_includePaths->getList();
std::vector<FilePath> newFrameworkPaths = m_frameworkPaths ? m_frameworkPaths->getList() : std::vector<FilePath>();
bool somethingChanged = !(
newLanguage == projectSettings->getLanguage() &&
newStandard == projectSettings->getStandard() &&
utility::isPermutation<FilePath>(newSourcePaths, projectSettings->getSourcePaths()) &&
utility::isPermutation<FilePath>(newHeaderSearchPaths, projectSettings->getHeaderSearchPaths()) &&
utility::isPermutation<FilePath>(newFrameworkPaths, projectSettings->getFrameworkSearchPaths())
);
projectSettings->clear();
projectSettings->setLanguage(newLanguage);
projectSettings->setStandard(newStandard);
projectSettings->setSourcePaths(newSourcePaths);
projectSettings->setHeaderSearchPaths(newHeaderSearchPaths);
projectSettings->setFrameworkSearchPaths(newFrameworkPaths);
std::string projectFilePath =
m_projectFileLocation->getText().toStdString() + "/" + m_projectName->text().toStdString() + ".coatiproject";
projectSettings->save(projectFilePath);
if (m_title->text() == "NEW PROJECT")
{
MessageLoadProject(projectFilePath, false).dispatch();
}
else if (somethingChanged)
{
MessageLoadProject(projectFilePath, true).dispatch();
}
emit finished();
}
void QtProjectSetupScreen::handleSourcePathHelpPress()
{
showHelpMessage(
"Analyzed Paths define the source files and directories that will be analysed by Coati. Usually these are the source "
"and header files of your project or a subset of them."
);
}
void QtProjectSetupScreen::handleIncludePathHelpPress()
{
showHelpMessage(
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.\n\n"
"Please note that you can define Header Search Paths for all your projects in Coati's preferences."
);
}
void QtProjectSetupScreen::handleFrameworkPathHelpPress()
{
showHelpMessage(
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.\n\n"
"Please note that you can define Framework Search Paths for all your projects in Coati's preferences."
);
}
void QtProjectSetupScreen::handlePreferencesButtonPress()
{
emit showPreferences();
}
void QtProjectSetupScreen::handleSelectionChanged(int index)
{
if (index != 0)
{
m_cStandardLabel->show();
m_cStandard->show();
m_cppStandardLabel->hide();
m_cppStandard->hide();
}
else
{
m_cppStandardLabel->show();
m_cppStandard->show();
m_cStandardLabel->hide();
m_cStandard->hide();
}
}
@@ -1,91 +0,0 @@
#ifndef QT_PROJECT_SETUP_SCREEN_H
#define QT_PROJECT_SETUP_SCREEN_H
#include <QComboBox>
#include <QPushButton>
#include <QWidget>
#include "utility/file/FilePath.h"
#include "qt/element/QtDirectoryListBox.h"
#include "qt/element/QtLineEdit.h"
#include "qt/window/QtSettingsWindow.h"
class QtTextLine
: public QWidget
{
Q_OBJECT
public:
QtTextLine(QWidget *parent);
QString getText();
void setText(QString text);
void clearText();
private slots:
void handleButtonPress();
private:
QPushButton* m_button;
QtLineEdit* m_data;
};
class QtProjectSetupScreen
: public QtSettingsWindow
{
Q_OBJECT
public:
QtProjectSetupScreen(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
void clear();
virtual void setup() override;
void loadEmpty();
void loadProjectSettings();
void projectSetupScreen();
// fill screen without having to set project setting beforehand (e.g. when creating a new project)
void setPresets(const std::string& name, const std::string& location,
const std::vector<std::string>& sourceFiles, const std::vector<std::string>& includePaths);
signals:
void showPreferences();
protected:
virtual void populateForm(QFormLayout* layout) override;
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
void handleSelectionChanged(int index);
void handleSourcePathHelpPress();
void handleIncludePathHelpPress();
void handleFrameworkPathHelpPress();
void handlePreferencesButtonPress();
private:
QLineEdit* m_projectName;
QtTextLine* m_projectFileLocation;
QtDirectoryListBox* m_includePaths;
QtDirectoryListBox* m_sourcePaths;
QtDirectoryListBox* m_frameworkPaths;
QPushButton* m_preferencesButton;
QComboBox* m_language;
QComboBox* m_cppStandard;
QComboBox* m_cStandard;
QLabel* m_cppStandardLabel;
QLabel* m_cStandardLabel;
};
#endif //QT_PROJECT_SETUP_SCREEN_H
+2 -45
View File
@@ -145,13 +145,7 @@ void QtSettingsWindow::setupForm()
form->setObjectName("form");
scrollArea->setWidget(form);
QFormLayout* layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
populateForm(layout);
form->setLayout(layout);
populateWindow(form);
windowLayout->addWidget(scrollArea);
windowLayout->addSpacing(20);
@@ -164,7 +158,7 @@ void QtSettingsWindow::setupForm()
scrollArea->raise();
}
void QtSettingsWindow::populateForm(QFormLayout* layout)
void QtSettingsWindow::populateWindow(QWidget* widget)
{
}
@@ -221,40 +215,3 @@ void QtSettingsWindow::hideCancelButton(bool hidden)
m_cancelButton->setVisible(!hidden);
}
}
QWidget* QtSettingsWindow::createLabelWithHelpButton(QString name, QPushButton** helpButton)
{
QWidget* widget = new QWidget();
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 5, 0, 5);
layout->setSpacing(5);
QLabel* label = new QLabel(name);
label->setAlignment(Qt::AlignRight);
layout->addWidget(label);
QPushButton* button = new QPushButton("?");
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
button->setObjectName("help");
layout->addWidget(button, 0, Qt::AlignRight);
layout->addStretch();
widget->setLayout(layout);
*helpButton = button;
return widget;
}
void QtSettingsWindow::showHelpMessage(const QString& msg)
{
QMessageBox msgBox;
msgBox.setText("Help");
msgBox.setInformativeText(msg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
+4 -7
View File
@@ -24,6 +24,9 @@ public:
void setCancelAble(bool cancelAble);
void updateTitle(QString title);
void updateDoneButton(QString text);
signals:
void finished();
void canceled();
@@ -36,19 +39,13 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void setupForm();
virtual void populateForm(QFormLayout* layout);
virtual void populateWindow(QWidget* widget);
void addLogo();
void showButtons(QVBoxLayout* layout);
void updateTitle(QString title);
void updateDoneButton(QString text);
void hideCancelButton(bool hidden);
QWidget* createLabelWithHelpButton(QString name, QPushButton** helpButton);
void showHelpMessage(const QString& msg);
QWidget* m_window;
QLabel* m_title;
+64
View File
@@ -0,0 +1,64 @@
#include "qt/window/QtWindowStack.h"
QtWindowStack::QtWindowStack(QObject* parent)
: QObject(parent)
{
}
QWidget* QtWindowStack::getTopWindow()
{
if (m_stack.size())
{
return m_stack.back();
}
return nullptr;
}
void QtWindowStack::pushWindow(QWidget* window)
{
if (m_stack.size())
{
m_stack.back()->hide();
}
window->show();
m_stack.push_back(window);
emit push();
}
void QtWindowStack::popWindow()
{
if (m_stack.size())
{
m_stack.back()->hide();
delete m_stack.back();
m_stack.pop_back();
emit pop();
}
if (m_stack.size())
{
m_stack.back()->show();
}
else
{
emit empty();
}
}
void QtWindowStack::clearWindows()
{
for (QWidget* window : m_stack)
{
window->hide();
delete window;
}
m_stack.clear();
emit empty();
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef QT_WINDOW_STACK
#define QT_WINDOW_STACK
#include <vector>
#include <QWidget>
class QtWindowStack
: public QObject
{
Q_OBJECT
signals:
void empty();
void pop();
void push();
public:
QtWindowStack(QObject* parent = nullptr);
QWidget* getTopWindow();
public slots:
void pushWindow(QWidget* window);
void popWindow();
void clearWindows();
private:
std::vector<QWidget*> m_stack;
};
#endif // QT_WINDOW_STACK
@@ -0,0 +1,153 @@
#include "qt/window/project_wizzard/QtProjectWizzard.h"
#include <QMessageBox>
#include <QSysInfo>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "utility/messaging/type/MessageLoadProject.h"
QtProjectWizzard::QtProjectWizzard(QWidget* parent)
: QWidget(parent)
, m_windowStack(this)
{
connect(&m_windowStack, SIGNAL(push()), this, SLOT(windowStackChanged()));
connect(&m_windowStack, SIGNAL(pop()), this, SLOT(windowStackChanged()));
}
void QtProjectWizzard::newProject()
{
m_settings = ProjectSettings();
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSelect>();
connect(dynamic_cast<QtProjectWizzardContentSelect*>(window->content()),
SIGNAL(selected(QtProjectWizzardContentSelect::ProjectType)),
this, SLOT(selectedProjectType(QtProjectWizzardContentSelect::ProjectType)));
window->disableNext();
window->disablePrevious();
}
void QtProjectWizzard::editProject(const ProjectSettings& settings)
{
m_settings = settings;
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSummary>();
window->updateTitle("EDIT PROJECT");
window->updateDoneButton("Save");
window->hidePrevious();
connect(window, SIGNAL(next()), this, SLOT(createProject()));
}
template<typename T>
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent()
{
QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget());
window->setContent(new T(&m_settings, window));
window->setup();
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
m_windowStack.pushWindow(window);
return window;
}
void QtProjectWizzard::cancelWizzard()
{
m_windowStack.clearWindows();
emit canceled();
}
void QtProjectWizzard::windowStackChanged()
{
QWidget* window = m_windowStack.getTopWindow();
if (window)
{
dynamic_cast<QtProjectWizzardWindow*>(window)->content()->load();
}
}
void QtProjectWizzard::selectedProjectType(QtProjectWizzardContentSelect::ProjectType type)
{
switch (type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
emptyProject();
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
case QtProjectWizzardContentSelect::PROJECT_VS:
QMessageBox msgBox;
msgBox.setText("Project type not implemented yet!");
msgBox.exec();
break;
}
}
void QtProjectWizzard::emptyProject()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentData>();
// connect(window, SIGNAL(next()), this, SLOT(simpleSetup()));
connect(window, SIGNAL(next()), this, SLOT(sourcePaths()));
}
void QtProjectWizzard::simpleSetup()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSimple>();
connect(window, SIGNAL(next()), this, SLOT(sourcePaths()));
}
void QtProjectWizzard::sourcePaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsSource>();
connect(window, SIGNAL(next()), this, SLOT(headerSearchPaths()));
}
void QtProjectWizzard::headerSearchPaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsHeaderSearch>();
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
connect(window, SIGNAL(next()), this, SLOT(frameworkSearchPaths()));
}
else
{
connect(window, SIGNAL(next()), this, SLOT(showSummary()));
}
}
void QtProjectWizzard::frameworkSearchPaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsFrameworkSearch>();
connect(window, SIGNAL(next()), this, SLOT(showSummary()));
}
void QtProjectWizzard::showSummary()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSummary>();
connect(window, SIGNAL(next()), this, SLOT(createProject()));
}
void QtProjectWizzard::createProject()
{
std::string path = m_settings.getProjectFileLocation() + "/" + m_settings.getProjectName() + ".coatiproject";
m_settings.save(path);
MessageLoadProject(path, true).dispatch();
m_windowStack.clearWindows();
emit finished();
}
@@ -0,0 +1,52 @@
#ifndef QT_PROJECT_WIZZARD_H
#define QT_PROJECT_WIZZARD_H
#include <QWidget>
#include "qt/window/project_wizzard/QtProjectWizzardContentSelect.h"
#include "qt/window/QtWindowStack.h"
class ProjectSettings;
class QtProjectWizzardWindow;
class QtProjectWizzard
: public QWidget
{
Q_OBJECT
signals:
void finished();
void canceled();
public:
QtProjectWizzard(QWidget* parent = nullptr);
public slots:
void newProject();
void editProject(const ProjectSettings& settings);
private:
template<typename T>
QtProjectWizzardWindow* createWindowWithContent();
QtWindowStack m_windowStack;
ProjectSettings m_settings;
private slots:
void cancelWizzard();
void windowStackChanged();
void selectedProjectType(QtProjectWizzardContentSelect::ProjectType type);
void emptyProject();
void simpleSetup();
void sourcePaths();
void headerSearchPaths();
void frameworkSearchPaths();
void showSummary();
void createProject();
};
#endif // QT_PROJECT_WIZZARD_H
@@ -0,0 +1,33 @@
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
QtProjectWizzardContent::QtProjectWizzardContent(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QWidget(window)
, m_settings(settings)
, m_window(window)
{
}
void QtProjectWizzardContent::populateWindow(QWidget* widget)
{
}
void QtProjectWizzardContent::populateForm(QFormLayout* layout)
{
}
void QtProjectWizzardContent::windowReady()
{
}
void QtProjectWizzardContent::load()
{
}
void QtProjectWizzardContent::save()
{
}
bool QtProjectWizzardContent::check()
{
return true;
}
@@ -0,0 +1,32 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_H
#define QT_PROJECT_WIZZARD_CONTENT_H
#include <QWidget>
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "settings/ProjectSettings.h"
class QFormLayout;
class QtProjectWizzardContent
: public QWidget
{
Q_OBJECT
public:
QtProjectWizzardContent(ProjectSettings* settings, QtProjectWizzardWindow* window);
virtual void populateWindow(QWidget* widget);
virtual void populateForm(QFormLayout* layout);
virtual void windowReady();
virtual void load();
virtual void save();
virtual bool check();
protected:
ProjectSettings* m_settings;
QtProjectWizzardWindow* m_window;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_H
@@ -0,0 +1,153 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include <QFormLayout>
#include <QMessageBox>
QtProjectWizzardContentData::QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
{
}
void QtProjectWizzardContentData::populateWindow(QWidget* widget)
{
QFormLayout* layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
populateForm(layout);
widget->setLayout(layout);
}
void QtProjectWizzardContentData::populateForm(QFormLayout* layout)
{
int minimumWidthForSecondCol = 360;
QLabel* nameLabel = new QLabel("Name");
nameLabel->setObjectName("label");
m_projectName = new QLineEdit();
m_projectName->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
m_projectName->setMinimumWidth(minimumWidthForSecondCol);
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addRow(nameLabel, m_projectName);
QLabel* locationLabel = new QLabel("Location");
locationLabel->setObjectName("label");
m_projectFileLocation = new QtLocationPicker(this);
m_projectFileLocation->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(locationLabel, m_projectFileLocation);
QLabel* languageLabel = new QLabel("Language");
languageLabel->setObjectName("label");
m_language = new QComboBox();
m_language->insertItem(0, "C++");
m_language->insertItem(1, "C");
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
layout->addRow(languageLabel, m_language);
m_cppStandardLabel = new QLabel("Standard");
m_cppStandardLabel->setObjectName("label");
m_cppStandard = new QComboBox();
m_cppStandard->insertItem(0, "1z");
m_cppStandard->insertItem(1, "14");
m_cppStandard->insertItem(2, "1y");
m_cppStandard->insertItem(3, "11");
m_cppStandard->insertItem(4, "0x");
m_cppStandard->insertItem(5, "03");
m_cppStandard->insertItem(6, "98");
layout->addRow(m_cppStandardLabel, m_cppStandard);
m_cStandardLabel = new QLabel("Standard");
m_cStandardLabel->setObjectName("label");
m_cStandard = new QComboBox();
m_cStandard->insertItem(0, "1x");
m_cStandard->insertItem(1, "11");
m_cStandard->insertItem(2, "9x");
m_cStandard->insertItem(3, "99");
m_cStandard->insertItem(4, "90");
m_cStandard->insertItem(5, "89");
layout->addRow(m_cStandardLabel, m_cStandard);
m_cStandardLabel->hide();
m_cStandard->hide();
}
void QtProjectWizzardContentData::load()
{
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation()));
if (m_settings->getLanguage().length() > 0)
{
m_language->setCurrentText(QString::fromStdString(m_settings->getLanguage()));
}
if (m_settings->getStandard().length() > 0)
{
if (m_language->currentIndex() == 0) // c++
{
m_cppStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
}
else if (m_language->currentIndex() == 1) // c
{
m_cStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
}
}
}
void QtProjectWizzardContentData::save()
{
m_settings->setProjectName(m_projectName->text().toStdString());
m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
m_settings->setLanguage(m_language->currentText().toStdString());
if (m_cppStandard->isVisible())
{
m_settings->setStandard(m_cppStandard->currentText().toStdString());
}
else if (m_cStandard->isVisible())
{
m_settings->setStandard(m_cStandard->currentText().toStdString());
}
}
bool QtProjectWizzardContentData::check()
{
if (m_projectName->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please enter a project name.");
msgBox.exec();
return false;
}
if (m_projectFileLocation->getText().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please define the location of the project file.");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentData::handleSelectionChanged(int index)
{
if (index != 0)
{
m_cStandardLabel->show();
m_cStandard->show();
m_cppStandardLabel->hide();
m_cppStandard->hide();
}
else
{
m_cppStandardLabel->show();
m_cppStandard->show();
m_cStandardLabel->hide();
m_cStandard->hide();
}
}
@@ -0,0 +1,40 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_DATA_H
#define QT_PROJECT_WIZZARD_CONTENT_DATA_H
#include <QComboBox>
#include <QLabel>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/element/QtLocationPicker.h"
class QtProjectWizzardContentData
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populateWindow(QWidget* widget) override;
virtual void populateForm(QFormLayout* layout) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
private:
QLineEdit* m_projectName;
QtLocationPicker* m_projectFileLocation;
QComboBox* m_language;
QComboBox* m_cppStandard;
QComboBox* m_cStandard;
QLabel* m_cppStandardLabel;
QLabel* m_cStandardLabel;
private slots:
void handleSelectionChanged(int index);
};
#endif // QT_PROJECT_WIZZARD_CONTENT_DATA_H
@@ -0,0 +1,291 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include <QFormLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QMessageBox>
#include "qt/element/QtDirectoryListBox.h"
#include "settings/ApplicationSettings.h"
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
: QPushButton("?", parent)
, m_helpText(helpText)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setObjectName("help");
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
}
void QtHelpButton::handleHelpPress()
{
QMessageBox msgBox;
msgBox.setText("Help");
msgBox.setInformativeText(m_helpText);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_subPaths(nullptr)
{
}
void QtProjectWizzardContentPaths::populateWindow(QWidget* widget)
{
QVBoxLayout* layout = new QVBoxLayout(widget);
populateLayout(layout);
if (m_subPaths)
{
layout->addSpacing(30);
m_subPaths->populateLayout(layout);
}
layout->addStretch();
}
void QtProjectWizzardContentPaths::populateLayout(QVBoxLayout* layout)
{
QLabel* label = new QLabel(m_titleString);
label->setObjectName("label");
layout->addWidget(label);
QLabel* text = new QLabel(m_descriptionString);
text->setWordWrap(true);
layout->addWidget(text);
m_list = new QtDirectoryListBox(this);
layout->addWidget(m_list);
}
void QtProjectWizzardContentPaths::populateForm(QFormLayout* layout)
{
QWidget* widget = new QWidget();
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 5, 0, 5);
vlayout->setSpacing(5);
QLabel* label = new QLabel(m_titleString);
label->setAlignment(Qt::AlignRight);
label->setObjectName("label");
label->setWordWrap(true);
vlayout->addWidget(label);
QtHelpButton* button = new QtHelpButton(m_helpString);
vlayout->addWidget(button, 0, Qt::AlignRight);
vlayout->addStretch();
widget->setLayout(vlayout);
int minimumWidthForSecondCol = 360;
m_list = new QtDirectoryListBox(this);
m_list->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(widget, m_list);
if (m_subPaths)
{
m_subPaths->populateForm(layout);
}
}
void QtProjectWizzardContentPaths::load()
{
loadPaths();
if (m_subPaths)
{
return m_subPaths->loadPaths();
}
}
void QtProjectWizzardContentPaths::save()
{
savePaths();
if (m_subPaths)
{
return m_subPaths->savePaths();
}
}
bool QtProjectWizzardContentPaths::check()
{
if (m_subPaths)
{
return checkPaths() && m_subPaths->checkPaths();
}
return checkPaths();
}
void QtProjectWizzardContentPaths::loadPaths()
{
}
void QtProjectWizzardContentPaths::savePaths()
{
}
bool QtProjectWizzardContentPaths::checkPaths()
{
return true;
}
void QtProjectWizzardContentPaths::setInfo(const QString& title, const QString& description, const QString& help)
{
m_titleString = title;
m_descriptionString = description;
m_helpString = help;
}
QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
setInfo(
"Analyzed Paths",
"Analyzed Paths define the source files and directories that will be analysed by Coati. Usually these are the "
"source and header files of your project or a subset of them.",
"Analyzed Paths define the source files and directories that will be analysed by Coati. Usually these are the "
"source and header files of your project or a subset of them."
);
}
void QtProjectWizzardContentPathsSource::loadPaths()
{
m_list->setList(m_settings->getSourcePaths());
}
void QtProjectWizzardContentPathsSource::savePaths()
{
m_settings->setSourcePaths(m_list->getList());
}
bool QtProjectWizzardContentPathsSource::checkPaths()
{
if (m_list->getList().size() == 0)
{
QMessageBox msgBox;
msgBox.setText("Please set at least one source path for Coati to analyse.");
msgBox.exec();
return false;
}
return true;
}
QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
setInfo(
"Header Search Paths",
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.",
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.\n\n"
"Header Search Paths defined here will be used for all projects."
);
m_subPaths = new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window);
}
void QtProjectWizzardContentPathsHeaderSearch::loadPaths()
{
m_list->setList(m_settings->getHeaderSearchPaths());
}
void QtProjectWizzardContentPathsHeaderSearch::savePaths()
{
m_settings->setHeaderSearchPaths(m_list->getList());
}
QtProjectWizzardContentPathsHeaderSearchGlobal::QtProjectWizzardContentPathsHeaderSearchGlobal(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
setInfo(
"Global Header Search Paths",
"Header Search Paths for all projects.",
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.\n\n"
"Header Search Paths defined here will be used for all projects."
);
}
void QtProjectWizzardContentPathsHeaderSearchGlobal::loadPaths()
{
m_list->setList(ApplicationSettings::getInstance()->getHeaderSearchPaths());
}
void QtProjectWizzardContentPathsHeaderSearchGlobal::savePaths()
{
ApplicationSettings::getInstance()->setHeaderSearchPaths(m_list->getList());
}
QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFrameworkSearch(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
setInfo(
"Framework Search Paths",
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.",
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.\n\n"
"Framework Search Paths defined here will be used for all projects."
);
m_subPaths = new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window);
}
void QtProjectWizzardContentPathsFrameworkSearch::loadPaths()
{
m_list->setList(m_settings->getFrameworkSearchPaths());
}
void QtProjectWizzardContentPathsFrameworkSearch::savePaths()
{
m_settings->setFrameworkSearchPaths(m_list->getList());
}
QtProjectWizzardContentPathsFrameworkSearchGlobal::QtProjectWizzardContentPathsFrameworkSearchGlobal(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
setInfo(
"Global Framework Search Paths",
"Framework Search Paths for all projects",
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.\n\n"
"Framework Search Paths defined here will be used for all projects."
);
}
void QtProjectWizzardContentPathsFrameworkSearchGlobal::loadPaths()
{
m_list->setList(ApplicationSettings::getInstance()->getFrameworkSearchPaths());
}
void QtProjectWizzardContentPathsFrameworkSearchGlobal::savePaths()
{
ApplicationSettings::getInstance()->setFrameworkSearchPaths(m_list->getList());
}
@@ -0,0 +1,116 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PATHS_H
#define QT_PROJECT_WIZZARD_CONTENT_PATHS_H
#include <QPushButton>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QtDirectoryListBox;
class QtHelpButton
: public QPushButton
{
Q_OBJECT
public:
QtHelpButton(const QString& helpText, QWidget* parent = nullptr);
private slots:
void handleHelpPress();
private:
QString m_helpText;
};
class QtProjectWizzardContentPaths
: public QtProjectWizzardContent
{
public:
QtProjectWizzardContentPaths(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
virtual void populateWindow(QWidget* widget) override;
void populateLayout(QVBoxLayout* layout);
virtual void populateForm(QFormLayout* layout) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
virtual void loadPaths();
virtual void savePaths();
virtual bool checkPaths();
protected:
void setInfo(const QString& title, const QString& description, const QString& help);
QtDirectoryListBox* m_list;
QtProjectWizzardContentPaths* m_subPaths;
private:
QString m_titleString;
QString m_descriptionString;
QString m_helpString;
};
class QtProjectWizzardContentPathsSource
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsSource(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual bool checkPaths() override;
};
class QtProjectWizzardContentPathsHeaderSearch
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsHeaderSearch(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
};
class QtProjectWizzardContentPathsHeaderSearchGlobal
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsHeaderSearchGlobal(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
};
class QtProjectWizzardContentPathsFrameworkSearch
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsFrameworkSearch(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
};
class QtProjectWizzardContentPathsFrameworkSearchGlobal
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsFrameworkSearchGlobal(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PATHS_H
@@ -0,0 +1,75 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentSelect.h"
#include <QButtonGroup>
#include <QFormLayout>
#include <QMessageBox>
#include <QLabel>
#include <QRadioButton>
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
{
}
void QtProjectWizzardContentSelect::populateWindow(QWidget* widget)
{
QVBoxLayout* layout = new QVBoxLayout(widget);
QLabel* title = new QLabel("project type");
title->setObjectName("label");
layout->addWidget(title);
QRadioButton* a = new QRadioButton("empty");
QRadioButton* b = new QRadioButton("from Visual Studio Solution");
QRadioButton* c = new QRadioButton("from Compilation Database");
m_buttons = new QButtonGroup(this);
m_buttons->addButton(a);
m_buttons->addButton(b);
m_buttons->addButton(c);
m_buttons->setId(a, PROJECT_EMPTY);
m_buttons->setId(b, PROJECT_CDB);
m_buttons->setId(c, PROJECT_VS);
connect(m_buttons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
{
m_window->enableNext();
}
);
layout->addWidget(a);
layout->addWidget(b);
layout->addWidget(c);
layout->addStretch();
widget->setLayout(layout);
}
bool QtProjectWizzardContentSelect::check()
{
if (m_buttons->checkedId() == -1)
{
QMessageBox msgBox;
msgBox.setText("Please choose how you want to create your project.");
msgBox.exec();
return false;
}
ProjectType type;
switch (m_buttons->checkedId())
{
case 0: type = PROJECT_EMPTY; break;
case 1: type = PROJECT_CDB; break;
case 2: type = PROJECT_VS; break;
}
emit selected(type);
return true;
}
@@ -0,0 +1,35 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_SELECT_H
#define QT_PROJECT_WIZZARD_CONTENT_SELECT_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QButtonGroup;
class QtProjectWizzardContentSelect
: public QtProjectWizzardContent
{
Q_OBJECT
public:
enum ProjectType : int
{
PROJECT_EMPTY = 0,
PROJECT_CDB = 1,
PROJECT_VS = 2
};
QtProjectWizzardContentSelect(ProjectSettings* settings, QtProjectWizzardWindow* window);
signals:
void selected(QtProjectWizzardContentSelect::ProjectType);
protected:
// QtProjectWizzardContent implementation
virtual void populateWindow(QWidget* widget) override;
virtual bool check() override;
private:
QButtonGroup* m_buttons;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_SELECT_H
@@ -0,0 +1,69 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
#include <QButtonGroup>
#include <QVBoxLayout>
#include <QLabel>
#include <QRadioButton>
QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
{
}
void QtProjectWizzardContentSimple::populateWindow(QWidget* widget)
{
QVBoxLayout* layout = new QVBoxLayout(widget);
QLabel* title = new QLabel("simple setup");
title->setObjectName("label");
layout->addWidget(title);
QLabel* text = new QLabel(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
"enim ad minim veniam, quis nostrud exercitation ullamco laboris "
"nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
"reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla "
"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in "
"culpa qui officia deserunt mollit anim id est laborum."
);
text->setWordWrap(true);
layout->addWidget(text);
QRadioButton* a = new QRadioButton("simple setup");
QRadioButton* b = new QRadioButton("advanced setup");
m_buttons = new QButtonGroup(this);
m_buttons->addButton(a);
m_buttons->addButton(b);
m_buttons->setId(a, 0);
m_buttons->setId(b, 1);
connect(m_buttons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
{
m_window->enableNext();
}
);
layout->addWidget(a);
layout->addWidget(b);
layout->addStretch();
widget->setLayout(layout);
}
void QtProjectWizzardContentSimple::load()
{
}
void QtProjectWizzardContentSimple::save()
{
}
bool QtProjectWizzardContentSimple::check()
{
return true;
}
@@ -0,0 +1,27 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H
#define QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QButtonGroup;
class QtProjectWizzardContentSimple
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentSimple(ProjectSettings* settings, QtProjectWizzardWindow* window);
protected:
// QtProjectWizzardContent implementation
virtual void populateWindow(QWidget* widget) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
private:
QButtonGroup* m_buttons;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H
@@ -0,0 +1,78 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
#include <QFormLayout>
#include <QSysInfo>
QtProjectWizzardContentSummary::QtProjectWizzardContentSummary(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_data(nullptr)
, m_source(nullptr)
, m_headerSearch(nullptr)
, m_frameworkSearch(nullptr)
{
m_data = new QtProjectWizzardContentData(settings, window);
m_source = new QtProjectWizzardContentPathsSource(settings, window);
m_headerSearch = new QtProjectWizzardContentPathsHeaderSearch(settings, window);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_frameworkSearch = new QtProjectWizzardContentPathsFrameworkSearch(settings, window);
}
}
void QtProjectWizzardContentSummary::populateWindow(QWidget* widget)
{
QFormLayout* layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
m_data->populateForm(layout);
m_source->populateForm(layout);
m_headerSearch->populateForm(layout);
if (m_frameworkSearch)
{
m_frameworkSearch->populateForm(layout);
}
widget->setLayout(layout);
}
void QtProjectWizzardContentSummary::windowReady()
{
m_window->updateTitle("NEW PROJECT WIZZARD - SUMMARY");
m_window->updateDoneButton("Create");
}
void QtProjectWizzardContentSummary::load()
{
m_data->load();
m_source->load();
m_headerSearch->load();
if (m_frameworkSearch)
{
m_frameworkSearch->load();
}
}
void QtProjectWizzardContentSummary::save()
{
m_data->save();
m_source->save();
m_headerSearch->save();
if (m_frameworkSearch)
{
m_frameworkSearch->save();
}
}
bool QtProjectWizzardContentSummary::check()
{
return
m_data->check() &&
m_source->check() &&
m_headerSearch->check() &&
(!m_frameworkSearch || m_frameworkSearch->check());
}
@@ -0,0 +1,29 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_SUMMARY_H
#define QT_PROJECT_WIZZARD_CONTENT_SUMMARY_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
class QtProjectWizzardContentSummary
: public QtProjectWizzardContent
{
public:
QtProjectWizzardContentSummary(ProjectSettings* settings, QtProjectWizzardWindow* window);
protected:
// QtProjectContentWindow implementation
virtual void populateWindow(QWidget* widget);
virtual void windowReady();
virtual void load();
virtual void save();
virtual bool check();
private:
QtProjectWizzardContentData* m_data;
QtProjectWizzardContentPathsSource* m_source;
QtProjectWizzardContentPathsHeaderSearch* m_headerSearch;
QtProjectWizzardContentPathsFrameworkSearch* m_frameworkSearch;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_SUMMARY_H
@@ -0,0 +1,97 @@
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include <QPushButton>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
QtProjectWizzardWindow::QtProjectWizzardWindow(QWidget *parent)
: QtSettingsWindow(parent)
, m_content(nullptr)
, m_previousButton(nullptr)
{
}
QtProjectWizzardContent* QtProjectWizzardWindow::content() const
{
return m_content;
}
void QtProjectWizzardWindow::setContent(QtProjectWizzardContent* content)
{
m_content = content;
}
void QtProjectWizzardWindow::setup()
{
setupForm();
updateTitle("NEW PROJECT WIZZARD");
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);
m_content->windowReady();
}
void QtProjectWizzardWindow::populateWindow(QWidget* widget)
{
m_content->populateWindow(widget);
}
void QtProjectWizzardWindow::enableNext()
{
if (m_doneButton)
{
m_doneButton->setEnabled(true);
}
}
void QtProjectWizzardWindow::disableNext()
{
if (m_doneButton)
{
m_doneButton->setEnabled(false);
}
}
void QtProjectWizzardWindow::disablePrevious()
{
if (m_previousButton)
{
m_previousButton->setEnabled(false);
}
}
void QtProjectWizzardWindow::hidePrevious()
{
if (m_previousButton)
{
m_previousButton->hide();
}
}
void QtProjectWizzardWindow::handleCancelButtonPress()
{
emit canceled();
}
void QtProjectWizzardWindow::handleUpdateButtonPress()
{
if (m_content->check())
{
m_content->save();
emit next();
}
}
void QtProjectWizzardWindow::handlePreviousButtonPress()
{
m_content->save();
emit previous();
}
@@ -0,0 +1,44 @@
#ifndef QT_PROJECT_WIZZARD_WINDOW_H
#define QT_PROJECT_WIZZARD_WINDOW_H
#include "qt/window/QtSettingsWindow.h"
#include "settings/ProjectSettings.h"
class QPushButton;
class QtProjectWizzardContent;
class QtProjectWizzardWindow
: public QtSettingsWindow
{
Q_OBJECT
signals:
void next();
void previous();
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 disablePrevious();
void hidePrevious();
private:
QtProjectWizzardContent* m_content;
QPushButton* m_previousButton;
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
void handlePreviousButtonPress();
};
#endif // QT_PROJECT_WIZZARD_WINDOW_H