From 9c40d26002eede1a162e8394ae7557a4f5fb1236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eberhard=20Gr=C3=A4ther?= Date: Mon, 10 Feb 2020 21:27:18 +0100 Subject: [PATCH] ui: Mark required contents with * in Source Group setup (issue #723) (#914) * And show '*required' label at bottom of each page --- src/lib_gui/CMakeLists.txt | 1 + .../qt/project_wizard/QtProjectWizard.cpp | 9 ++++-- .../content/QtProjectWizardContent.cpp | 32 +++++++++++++++---- .../content/QtProjectWizardContent.h | 8 ++++- .../QtProjectWizardContentProjectData.cpp | 1 + .../QtProjectWizardContentRequiredLabel.h | 22 +++++++++++++ .../QtProjectWizardContentSourceGroupData.cpp | 3 +- .../content/QtProjectWizardContentVS.cpp | 4 +-- .../path/QtProjectWizardContentPath.cpp | 17 +++------- .../content/path/QtProjectWizardContentPath.h | 2 -- .../path/QtProjectWizardContentPathCDB.cpp | 3 +- ...jectWizardContentPathCodeblocksProject.cpp | 3 +- .../path/QtProjectWizardContentPathCxxPch.cpp | 1 - ...jectWizardContentPathPythonEnvironment.cpp | 1 - ...tProjectWizardContentPathSettingsMaven.cpp | 1 - ...QtProjectWizardContentPathSourceGradle.cpp | 1 + .../QtProjectWizardContentPathSourceMaven.cpp | 1 + .../QtProjectWizardContentPathsSource.cpp | 1 + 18 files changed, 80 insertions(+), 31 deletions(-) create mode 100644 src/lib_gui/qt/project_wizard/content/QtProjectWizardContentRequiredLabel.h diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index d5c4cb03..e9a545f5 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -166,6 +166,7 @@ add_files( qt/project_wizard/content/QtProjectWizardContentPreferences.h qt/project_wizard/content/QtProjectWizardContentProjectData.cpp qt/project_wizard/content/QtProjectWizardContentProjectData.h + qt/project_wizard/content/QtProjectWizardContentRequiredLabel.h qt/project_wizard/content/QtProjectWizardContentSelect.cpp qt/project_wizard/content/QtProjectWizardContentSelect.h qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp diff --git a/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp b/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp index c3ae4f32..7d105d92 100644 --- a/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp +++ b/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp @@ -15,11 +15,10 @@ #include "QtProjectWizardContentCustomCommand.h" #include "QtProjectWizardContentExtensions.h" #include "QtProjectWizardContentGroup.h" -#include "QtProjectWizardContentPath.h" -#include "QtProjectWizardContentPaths.h" #include "QtProjectWizardContentPathsExclude.h" #include "QtProjectWizardContentPathsSource.h" #include "QtProjectWizardContentProjectData.h" +#include "QtProjectWizardContentRequiredLabel.h" #include "QtProjectWizardContentSelect.h" #include "QtProjectWizardContentSourceGroupData.h" #include "QtProjectWizardContentSourceGroupInfoText.h" @@ -624,6 +623,9 @@ void QtProjectWizard::generalButtonClicked() contentGroup->addContent( new QtProjectWizardContentProjectData(m_projectSettings, this, m_editing)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizardContentRequiredLabel(this)); + if (m_allSourceGroupSettings.empty()) { contentGroup->addSpace(); @@ -752,6 +754,9 @@ void QtProjectWizard::selectedSourceGroupChanged(int index) } #endif // BUILD_PYTHON_LANGUAGE_PACKAGE + summary->addSpace(); + summary->addContent(new QtProjectWizardContentRequiredLabel(this)); + setContent(summary); qDeleteAll(m_contentWidget->children()); diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp index 0311cb77..6039155d 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp @@ -42,13 +42,14 @@ QString QtProjectWizardContent::getFileNamesDescription() const return QStringLiteral("files"); } -QLabel* QtProjectWizardContent::createFormLabel(QString name) const +bool QtProjectWizardContent::isRequired() const { - QLabel* label = new QLabel(name); - label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - label->setObjectName(QStringLiteral("label")); - label->setWordWrap(true); - return label; + return m_isRequired; +} + +void QtProjectWizardContent::setIsRequired(bool isRequired) +{ + m_isRequired = isRequired; } QLabel* QtProjectWizardContent::createFormTitle(QString name) const @@ -59,6 +60,25 @@ QLabel* QtProjectWizardContent::createFormTitle(QString name) const return label; } +QLabel* QtProjectWizardContent::createFormLabel(QString name) const +{ + if (m_isRequired) + { + name += QStringLiteral("*"); + } + + return createFormSubLabel(name); +} + +QLabel* QtProjectWizardContent::createFormSubLabel(QString name) const +{ + QLabel* label = new QLabel(name); + label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); + label->setObjectName(QStringLiteral("label")); + label->setWordWrap(true); + return label; +} + QToolButton* QtProjectWizardContent::createSourceGroupButton(QString name, QString iconPath) const { QToolButton* button = new QToolButton(); diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h index c2fcd4b0..d5d8b429 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h @@ -31,9 +31,13 @@ public: virtual QString getFileNamesTitle() const; virtual QString getFileNamesDescription() const; + bool isRequired() const; + void setIsRequired(bool isRequired); + protected: - QLabel* createFormLabel(QString name) const; QLabel* createFormTitle(QString name) const; + QLabel* createFormLabel(QString name) const; + QLabel* createFormSubLabel(QString name) const; QToolButton* createSourceGroupButton(QString name, QString iconPath) const; QtHelpButton* addHelpButton( @@ -53,6 +57,8 @@ private: void showFilesDialog(const std::vector& filePaths); QtThreadedFunctor&> m_showFilesFunctor; + + bool m_isRequired = false; }; #endif // QT_PROJECT_WIZARD_CONTENT_H diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp index c2fa8368..98bc3810 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp @@ -17,6 +17,7 @@ QtProjectWizardContentProjectData::QtProjectWizardContentProjectData( , m_projectName(nullptr) , m_projectFileLocation(nullptr) { + setIsRequired(true); } void QtProjectWizardContentProjectData::populate(QGridLayout* layout, int& row) diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentRequiredLabel.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentRequiredLabel.h new file mode 100644 index 00000000..170f2016 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentRequiredLabel.h @@ -0,0 +1,22 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_REQUIRED_LABEL_H +#define QT_PROJECT_WIZARD_CONTENT_REQUIRED_LABEL_H + +#include "QtProjectWizardContent.h" + +class QtProjectWizardContentRequiredLabel: public QtProjectWizardContent +{ +public: + QtProjectWizardContentRequiredLabel(QtProjectWizardWindow* window) + : QtProjectWizardContent(window) + {} + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override + { + QLabel* label = createFormLabel(QStringLiteral("* required")); + layout->addWidget(label, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + row++; + } +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_REQUIRED_LABEL_H diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp index 1f57660e..f335af47 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp @@ -10,6 +10,7 @@ QtProjectWizardContentSourceGroupData::QtProjectWizardContentSourceGroupData( std::shared_ptr settings, QtProjectWizardWindow* window) : QtProjectWizardContent(window), m_settings(settings), m_name(nullptr), m_status(nullptr) { + setIsRequired(true); } void QtProjectWizardContentSourceGroupData::populate(QGridLayout* layout, int& row) @@ -28,7 +29,7 @@ void QtProjectWizardContentSourceGroupData::populate(QGridLayout* layout, int& r connect( m_status, &QCheckBox::toggled, this, &QtProjectWizardContentSourceGroupData::changedStatus); layout->addWidget( - createFormLabel(QStringLiteral("Status")), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + createFormSubLabel(QStringLiteral("Status")), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); layout->addWidget(m_status, row, QtProjectWizardWindow::BACK_COL); addHelpButton( diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp index 34fbde64..5f619eae 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp @@ -21,7 +21,7 @@ Note: Sourcetrail's Visual Studio plugin has to be installed. Visual Studio has layout, row); - QLabel* descriptionLabel = createFormLabel( + QLabel* descriptionLabel = createFormSubLabel( "Call Visual Studio to create a Compilation Database from the loaded Solution."); descriptionLabel->setObjectName("description"); descriptionLabel->setAlignment(Qt::AlignmentFlag::AlignLeft); @@ -33,7 +33,7 @@ Note: Sourcetrail's Visual Studio plugin has to be installed. Visual Studio has layout->addWidget(button, row, QtProjectWizardWindow::BACK_COL); row++; - QLabel* skipLabel = createFormLabel( + QLabel* skipLabel = createFormSubLabel( "*Skip this step if you already have a Compilation Database for your Solution."); skipLabel->setObjectName("description"); skipLabel->setAlignment(Qt::AlignmentFlag::AlignLeft); diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp index 43f5bc7c..d47e77f5 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp @@ -6,7 +6,7 @@ #include "utilityFile.h" QtProjectWizardContentPath::QtProjectWizardContentPath(QtProjectWizardWindow* window) - : QtProjectWizardContent(window), m_allowEmpty(false) + : QtProjectWizardContent(window) { } @@ -38,15 +38,13 @@ bool QtProjectWizardContentPath::check() { if (m_picker->getText().isEmpty()) { - if (m_allowEmpty) + if (!isRequired()) { break; } - else - { - error = "Please define a path at \"" + m_titleString + "\"."; - break; - } + + error = "Please define a path at \"" + m_titleString + "\"."; + break; } FilePath path = utility::getExpandedAndAbsolutePath( @@ -103,8 +101,3 @@ void QtProjectWizardContentPath::setFileEndings(const std::set& fi { m_fileEndings = fileEndings; } - -void QtProjectWizardContentPath::setAllowEmpty(bool allowEmpty) -{ - m_allowEmpty = allowEmpty; -} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h index 6b842d52..0fc024d4 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h @@ -26,7 +26,6 @@ protected: void setPlaceholderString(const QString& placeholder); void setFileEndings(const std::set& fileEndings); - void setAllowEmpty(bool allowEmpty); QtLocationPicker* m_picker; @@ -37,7 +36,6 @@ private: QString m_helpString; QString m_placeholderString; std::set m_fileEndings; - bool m_allowEmpty; }; #endif // QT_PROJECT_WIZARD_CONTENT_PATH_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp index 105c415f..fa6e4d09 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp @@ -25,6 +25,7 @@ QtProjectWizardContentPathCDB::QtProjectWizardContentPathCDB( "
" "You can make use of environment variables with ${ENV_VAR}."); setFileEndings({L".json"}); + setIsRequired(true); } void QtProjectWizardContentPathCDB::populate(QGridLayout* layout, int& row) @@ -50,7 +51,7 @@ void QtProjectWizardContentPathCDB::populate(QGridLayout* layout, int& row) layout->addWidget(description, row, QtProjectWizardWindow::BACK_COL); row++; - QLabel* title = createFormLabel("Source Files to Index"); + QLabel* title = createFormSubLabel("Source Files to Index"); layout->addWidget(title, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); layout->setRowStretch(row, 0); diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp index 61961835..f5444cab 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp @@ -24,6 +24,7 @@ QtProjectWizardContentPathCodeblocksProject::QtProjectWizardContentPathCodeblock "
" "You can make use of environment variables with ${ENV_VAR}."); setFileEndings({L".cbp"}); + setIsRequired(true); } void QtProjectWizardContentPathCodeblocksProject::populate(QGridLayout* layout, int& row) @@ -46,7 +47,7 @@ void QtProjectWizardContentPathCodeblocksProject::populate(QGridLayout* layout, layout->addWidget(description, row, QtProjectWizardWindow::BACK_COL); row++; - QLabel* title = createFormLabel("Source Files to Index"); + QLabel* title = createFormSubLabel("Source Files to Index"); layout->addWidget(title, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); layout->setRowStretch(row, 0); diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.cpp index dcb07845..b9f9a381 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.cpp @@ -27,7 +27,6 @@ QtProjectWizardContentPathCxxPch::QtProjectWizardContentPathCxxPch( "
" "Leave blank to disable the use of precompiled headers. You can make use of environment " "variables with ${ENV_VAR}."); - setAllowEmpty(true); setPlaceholderString("Not Using Precompiled Header"); } diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp index 08413079..faa5f2db 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp @@ -25,7 +25,6 @@ QtProjectWizardContentPathPythonEnvironment::QtProjectWizardContentPathPythonEnv "Leave blank to use the default Python environment. You can make use of environment " "variables with ${ENV_VAR}."); setPlaceholderString("Use Default"); - setAllowEmpty(true); } void QtProjectWizardContentPathPythonEnvironment::populate(QGridLayout* layout, int& row) diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSettingsMaven.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSettingsMaven.cpp index 15d00431..3295061a 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSettingsMaven.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSettingsMaven.cpp @@ -15,7 +15,6 @@ QtProjectWizardContentPathSettingsMaven::QtProjectWizardContentPathSettingsMaven "
" "You can make use of environment variables with ${ENV_VAR}."); setPlaceholderString("Use Default"); - setAllowEmpty(true); setFileEndings({L".xml"}); } diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp index 5dece92b..599310ac 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp @@ -19,6 +19,7 @@ QtProjectWizardContentPathSourceGradle::QtProjectWizardContentPathSourceGradle( "
" "You can make use of environment variables with ${ENV_VAR}."); setFileEndings({L".gradle"}); + setIsRequired(true); } void QtProjectWizardContentPathSourceGradle::populate(QGridLayout* layout, int& row) diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp index cfd2383a..d27ee9b2 100644 --- a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp @@ -24,6 +24,7 @@ QtProjectWizardContentPathSourceMaven::QtProjectWizardContentPathSourceMaven( "
" "You can make use of environment variables with ${ENV_VAR}."); setFileEndings({L".xml"}); + setIsRequired(true); } void QtProjectWizardContentPathSourceMaven::populate(QGridLayout* layout, int& row) diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp index 6302245a..ebaaf8f7 100644 --- a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp @@ -43,6 +43,7 @@ QtProjectWizardContentPathsSource::QtProjectWizardContentPathsSource( "you will also need to add that directory.
" "
" "You can make use of environment variables with ${ENV_VAR}.")); + setIsRequired(true); } void QtProjectWizardContentPathsSource::load()