ui: Mark required contents with * in Source Group setup (issue #723) (#914)

* And show '*required' label at bottom of each page
This commit is contained in:
Eberhard Gräther
2020-02-10 21:27:18 +01:00
committed by GitHub
parent 260f1227bc
commit 9c40d26002
18 changed files with 80 additions and 31 deletions
+1
View File
@@ -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
@@ -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());
@@ -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();
@@ -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<FilePath>& filePaths);
QtThreadedFunctor<const std::vector<FilePath>&> m_showFilesFunctor;
bool m_isRequired = false;
};
#endif // QT_PROJECT_WIZARD_CONTENT_H
@@ -17,6 +17,7 @@ QtProjectWizardContentProjectData::QtProjectWizardContentProjectData(
, m_projectName(nullptr)
, m_projectFileLocation(nullptr)
{
setIsRequired(true);
}
void QtProjectWizardContentProjectData::populate(QGridLayout* layout, int& row)
@@ -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
@@ -10,6 +10,7 @@ QtProjectWizardContentSourceGroupData::QtProjectWizardContentSourceGroupData(
std::shared_ptr<SourceGroupSettings> 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(
@@ -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);
@@ -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<std::wstring>& fi
{
m_fileEndings = fileEndings;
}
void QtProjectWizardContentPath::setAllowEmpty(bool allowEmpty)
{
m_allowEmpty = allowEmpty;
}
@@ -26,7 +26,6 @@ protected:
void setPlaceholderString(const QString& placeholder);
void setFileEndings(const std::set<std::wstring>& fileEndings);
void setAllowEmpty(bool allowEmpty);
QtLocationPicker* m_picker;
@@ -37,7 +36,6 @@ private:
QString m_helpString;
QString m_placeholderString;
std::set<std::wstring> m_fileEndings;
bool m_allowEmpty;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_H
@@ -25,6 +25,7 @@ QtProjectWizardContentPathCDB::QtProjectWizardContentPathCDB(
"<br />"
"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);
@@ -24,6 +24,7 @@ QtProjectWizardContentPathCodeblocksProject::QtProjectWizardContentPathCodeblock
"<br />"
"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);
@@ -27,7 +27,6 @@ QtProjectWizardContentPathCxxPch::QtProjectWizardContentPathCxxPch(
"<br />"
"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");
}
@@ -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)
@@ -15,7 +15,6 @@ QtProjectWizardContentPathSettingsMaven::QtProjectWizardContentPathSettingsMaven
"<br />"
"You can make use of environment variables with ${ENV_VAR}.");
setPlaceholderString("Use Default");
setAllowEmpty(true);
setFileEndings({L".xml"});
}
@@ -19,6 +19,7 @@ QtProjectWizardContentPathSourceGradle::QtProjectWizardContentPathSourceGradle(
"<br />"
"You can make use of environment variables with ${ENV_VAR}.");
setFileEndings({L".gradle"});
setIsRequired(true);
}
void QtProjectWizardContentPathSourceGradle::populate(QGridLayout* layout, int& row)
@@ -24,6 +24,7 @@ QtProjectWizardContentPathSourceMaven::QtProjectWizardContentPathSourceMaven(
"<br />"
"You can make use of environment variables with ${ENV_VAR}.");
setFileEndings({L".xml"});
setIsRequired(true);
}
void QtProjectWizardContentPathSourceMaven::populate(QGridLayout* layout, int& row)
@@ -43,6 +43,7 @@ QtProjectWizardContentPathsSource::QtProjectWizardContentPathsSource(
"you will also need to add that directory.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."));
setIsRequired(true);
}
void QtProjectWizardContentPathsSource::load()