From 346a6f706dcd4fda0c0e1b195c708177b8163ccd Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 2 Mar 2016 11:59:55 +0100 Subject: [PATCH] ui: Added ui for compiler flags to project setup summary bug id = 37 --- src/lib/settings/ProjectSettings.cpp | 8 ++- src/lib/settings/ProjectSettings.h | 1 + src/lib_gui/CMakeLists.txt | 2 + src/lib_gui/qt/element/QtDirectoryListBox.cpp | 49 +++++++++++++++++-- src/lib_gui/qt/element/QtDirectoryListBox.h | 9 +++- .../QtProjectWizzardContentFlags.cpp | 33 +++++++++++++ .../QtProjectWizzardContentFlags.h | 26 ++++++++++ .../QtProjectWizzardContentPaths.h | 1 - .../QtProjectWizzardContentSummary.cpp | 28 ++++++++++- .../QtProjectWizzardContentSummary.h | 2 + web/documentation/index.html | 31 +++++++----- 11 files changed, 170 insertions(+), 20 deletions(-) create mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp create mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index a057b9e1..473f64b4 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -51,7 +51,8 @@ bool ProjectSettings::operator==(const ProjectSettings& other) const getUseSourcePathsForHeaderSearch() == other.getUseSourcePathsForHeaderSearch() && utility::isPermutation(getSourcePaths(), other.getSourcePaths()) && utility::isPermutation(getHeaderSearchPaths(), other.getHeaderSearchPaths()) && - utility::isPermutation(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()); + utility::isPermutation(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()) && + utility::isPermutation(getCompilerFlags(), other.getCompilerFlags()); } void ProjectSettings::save(const FilePath& filePath) @@ -122,6 +123,11 @@ std::vector ProjectSettings::getCompilerFlags() const return getValues("source/compiler_flags/compiler_flag", defaultValues); } +bool ProjectSettings::setCompilerFlags(const std::vector& compilerFlags) +{ + return setValues("source/compiler_flags/compiler_flag", compilerFlags); +} + std::vector ProjectSettings::getHeaderExtensions() const { return getValues("source/extensions/header_extensions", getDefaultHeaderExtensions()); diff --git a/src/lib/settings/ProjectSettings.h b/src/lib/settings/ProjectSettings.h index 99b2da20..6f04df50 100644 --- a/src/lib/settings/ProjectSettings.h +++ b/src/lib/settings/ProjectSettings.h @@ -39,6 +39,7 @@ public: bool setFrameworkSearchPaths(const std::vector& frameworkSearchPaths); std::vector getCompilerFlags() const; + bool setCompilerFlags(const std::vector& compilerFlags); std::vector getHeaderExtensions() const; std::vector getSourceExtensions() const; diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index a41c2512..99bd5fff 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -112,6 +112,8 @@ add_files( qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h qt/window/project_wizzard/QtProjectWizzardContentData.cpp qt/window/project_wizzard/QtProjectWizzardContentData.h + qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp + qt/window/project_wizzard/QtProjectWizzardContentFlags.h qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp qt/window/project_wizzard/QtProjectWizzardContentPaths.h qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index 38d27194..41531115 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -33,6 +33,11 @@ QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* it layout->addWidget(m_data); layout->addWidget(m_button); + if (list->isForStrings()) + { + m_button->hide(); + } + setLayout(layout); connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress())); @@ -96,8 +101,9 @@ void QtListItemWidget::handleFocus() } -QtDirectoryListBox::QtDirectoryListBox(QWidget *parent) - :QFrame(parent) +QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, bool forStrings) + : QFrame(parent) + , m_forStrings(forStrings) { QBoxLayout* layout = new QVBoxLayout(); layout->setSpacing(0); @@ -132,12 +138,19 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent) m_removeButton->setObjectName("minusButton"); innerLayout->addWidget(m_removeButton); + innerLayout->addStretch(); + QLabel* dropInfoText = new QLabel("Drop Files & Folders"); dropInfoText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); dropInfoText->setObjectName("dropInfo"); dropInfoText->setAlignment(Qt::AlignRight); innerLayout->addWidget(dropInfoText); + if (isForStrings()) + { + dropInfoText->hide(); + } + layout->addStretch(); buttonContainer->setLayout(innerLayout); @@ -198,7 +211,28 @@ void QtDirectoryListBox::dropEvent(QDropEvent *event) std::vector QtDirectoryListBox::getList() { + std::vector strList = getStringList(); std::vector list; + for (const std::string& str : strList) + { + list.push_back(str); + } + return list; +} + +void QtDirectoryListBox::setList(const std::vector& list) +{ + std::vector strList; + for (const FilePath& path : list) + { + strList.push_back(path.str()); + } + setStringList(strList); +} + +std::vector QtDirectoryListBox::getStringList() +{ + std::vector list; for (int i = 0; i < m_list->count(); ++i) { QtListItemWidget* widget = dynamic_cast(m_list->itemWidget(m_list->item(i))); @@ -207,14 +241,14 @@ std::vector QtDirectoryListBox::getList() return list; } -void QtDirectoryListBox::setList(const std::vector& list) +void QtDirectoryListBox::setStringList(const std::vector& list) { m_list->clear(); - for (const FilePath& path : list) + for (const std::string& str : list) { QtListItemWidget* widget = addListBoxItem(); - widget->setText(QString::fromStdString(path.str())); + widget->setText(QString::fromStdString(str)); } } @@ -228,6 +262,11 @@ void QtDirectoryListBox::selectItem(QListWidgetItem* item) item->setSelected(true); } +bool QtDirectoryListBox::isForStrings() const +{ + return m_forStrings; +} + void QtDirectoryListBox::resize() { int height = m_list->height() - m_list->viewport()->height(); diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.h b/src/lib_gui/qt/element/QtDirectoryListBox.h index 64e777ed..dab259f2 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.h +++ b/src/lib_gui/qt/element/QtDirectoryListBox.h @@ -46,7 +46,7 @@ class QtDirectoryListBox Q_OBJECT public: - QtDirectoryListBox(QWidget *parent); + QtDirectoryListBox(QWidget *parent, bool forStrings = false); virtual QSize sizeHint() const override; @@ -55,8 +55,13 @@ public: std::vector getList(); void setList(const std::vector& list); + std::vector getStringList(); + void setStringList(const std::vector& list); + void selectItem(QListWidgetItem* item); + bool isForStrings() const; + protected: bool event(QEvent* event) override; @@ -70,6 +75,8 @@ private: QPushButton* m_removeButton; QListWidget* m_list; + bool m_forStrings; + private slots: QtListItemWidget* addListBoxItem(); void removeListBoxItem(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp new file mode 100644 index 00000000..4559b099 --- /dev/null +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp @@ -0,0 +1,33 @@ +#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h" + +#include + +#include "qt/element/QtDirectoryListBox.h" + +QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(ProjectSettings* settings, QtProjectWizzardWindow* window) + : QtProjectWizzardContent(settings, window) +{ +} + +void QtProjectWizzardContentFlags::populateForm(QGridLayout* layout, int& row) +{ + QLabel* label = createFormLabel("Compiler Flags"); + label->setObjectName("label"); + layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); + + addHelpButton("Define compiler flags used during analysis including the dash e.g. -v", layout, row); + + m_list = new QtDirectoryListBox(this, true); + layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL); + row++; +} + +void QtProjectWizzardContentFlags::load() +{ + m_list->setStringList(m_settings->getCompilerFlags()); +} + +void QtProjectWizzardContentFlags::save() +{ + m_settings->setCompilerFlags(m_list->getStringList()); +} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h new file mode 100644 index 00000000..79a7df09 --- /dev/null +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h @@ -0,0 +1,26 @@ +#ifndef QT_PROJECT_WIZZARD_CONTENT_FLAGS_H +#define QT_PROJECT_WIZZARD_CONTENT_FLAGS_H + +#include "qt/window/project_wizzard/QtProjectWizzardContent.h" + +class QtDirectoryListBox; + +class QtProjectWizzardContentFlags + : public QtProjectWizzardContent +{ + Q_OBJECT + +public: + QtProjectWizzardContentFlags(ProjectSettings* settings, QtProjectWizzardWindow* window); + + // QtProjectWizzardContent implementation + virtual void populateForm(QGridLayout* layout, int& row) override; + + virtual void load() override; + virtual void save() override; + +private: + QtDirectoryListBox* m_list; +}; + +#endif // QT_PROJECT_WIZZARD_CONTENT_FLAGS_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index f0127878..71b9892f 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -7,7 +7,6 @@ class QtDirectoryListBox; - class QtProjectWizzardContentPaths : public QtProjectWizzardContent { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp index 63754dcf..fd944fc5 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp @@ -21,6 +21,8 @@ QtProjectWizzardContentSummary::QtProjectWizzardContentSummary(ProjectSettings* { m_frameworkSearch = new QtProjectWizzardContentPathsFrameworkSearch(settings, window); } + + m_compilerFlags = new QtProjectWizzardContentFlags(settings, window); } QtProjectWizzardContentBuildFile* QtProjectWizzardContentSummary::contentBuildFile() @@ -66,6 +68,25 @@ void QtProjectWizzardContentSummary::populateWindow(QGridLayout* layout) m_frameworkSearch->populateForm(layout, row); } + layout->setRowMinimumHeight(row, 15); + row++; + + QFrame* separator = new QFrame(); + separator->setFrameShape(QFrame::HLine); + + QPalette palette = separator->palette(); + palette.setColor(QPalette::WindowText, Qt::lightGray); + separator->setPalette(palette); + + layout->addWidget(separator, row, 0, 1, -1); + row++; + + QLabel* advancedLabel = createFormLabel("ADVANCED"); + layout->addWidget(advancedLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); + row++; + + m_compilerFlags->populateForm(layout, row); + layout->setRowMinimumHeight(row, 10); } @@ -87,6 +108,8 @@ void QtProjectWizzardContentSummary::load() { m_frameworkSearch->load(); } + + m_compilerFlags->load(); } void QtProjectWizzardContentSummary::save() @@ -101,6 +124,8 @@ void QtProjectWizzardContentSummary::save() { m_frameworkSearch->save(); } + + m_compilerFlags->save(); } bool QtProjectWizzardContentSummary::check() @@ -111,7 +136,8 @@ bool QtProjectWizzardContentSummary::check() m_source->check() && m_simple->check() && m_headerSearch->check() && - (!m_frameworkSearch || m_frameworkSearch->check()); + (!m_frameworkSearch || m_frameworkSearch->check()) && + m_compilerFlags->check(); } bool QtProjectWizzardContentSummary::isScrollAble() const diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h index 452facdc..8c09acb6 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h @@ -4,6 +4,7 @@ #include "qt/window/project_wizzard/QtProjectWizzardContent.h" #include "qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h" #include "qt/window/project_wizzard/QtProjectWizzardContentData.h" +#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h" #include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h" @@ -34,6 +35,7 @@ private: QtProjectWizzardContentSimple* m_simple; QtProjectWizzardContentPathsHeaderSearch* m_headerSearch; QtProjectWizzardContentPathsFrameworkSearch* m_frameworkSearch; + QtProjectWizzardContentFlags* m_compilerFlags; }; #endif // QT_PROJECT_WIZZARD_CONTENT_SUMMARY_H diff --git a/web/documentation/index.html b/web/documentation/index.html index fb28f325..80bdf9e5 100644 --- a/web/documentation/index.html +++ b/web/documentation/index.html @@ -610,19 +610,28 @@ Setting Description - Name The name of the project. This will also be the name of the *.coatiproject file generated by Coati. - Location Choose the location of the project file from the dialog. - Language Select the language of your project. This setting is preselected according to your choice in the previous screen. (See Language Support) - Standard Select the language standard that should be used for analyzing your project. Usually the most recent language standard is preselected here. (See Language Support) + Name The name of the project. This will also be the name of the *.coatiproject file generated by Coati. + Location Choose the location of the project file from the dialog. + Language Select the language of your project. This setting is preselected according to your choice in the previous screen. (See Language Support) + Standard Select the language standard that should be used for analyzing your project. Usually the most recent language standard is preselected here. (See Language Support) - Visual Studio Solution Only when using Setup from Visual Studio Solution. Provide the path to your Visual Studio Solution. Clicking the refresh arrow inside the text box will refresh the Project Paths and the Header Search Paths below. + Visual Studio Solution Only when using Setup from Visual Studio Solution. Provide the path to your Visual Studio Solution. Clicking the refresh arrow inside the text box will refresh the Project Paths and the Header Search Paths below. - Project Paths Provide the paths that contain your project's files. Coati will analyze all the source and header files in the specified paths, including subdirectories. - Simple Setup If this checkbox is checked Coati also looks into the analyzed paths (including subdirectories) when resolving #include directives. - Header Search Paths Specify where Coati should be looking for included headers. - Global Header Search Paths Same as Header Search Paths but these are used application wide for all of your Coati projects. - Framework Search Paths Mac only. Define the search paths for .framework files for your project. (For instructions on how to add paths see Path List Box.) - Global Framework Search Paths Same as Framework Search Paths but these are used application wide for all of your Coati projects. + Project Paths Provide the paths that contain your project's files. Coati will analyze all the source and header files in the specified paths, including subdirectories. + Simple Setup If this checkbox is checked Coati also looks into the analyzed paths (including subdirectories) when resolving #include directives. + Header Search Paths Specify where Coati should be looking for included headers. + Global Header Search Paths Same as Header Search Paths but these are used application wide for all of your Coati projects. + Framework Search Paths Mac only. Define the search paths for .framework files for your project. (For instructions on how to add paths see Path List Box.) + Global Framework Search Paths Mac only. Same as Framework Search Paths but these are used application wide for all of your Coati projects. + + + + + + + + +
Advanced Setting Description
Compiler Flags Define compiler flags used during analysis e.g. -v
Interactions: