Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

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

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/lib_gui/qt/project_wizard/QtProjectWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down
30 changes: 25 additions & 5 deletions src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,39 @@ QString QtProjectWizardContent::getFileNamesDescription() const
return QStringLiteral("files");
}

QLabel* QtProjectWizardContent::createFormLabel(QString name) const
bool QtProjectWizardContent::isRequired() const
{
return m_isRequired;
}

void QtProjectWizardContent::setIsRequired(bool isRequired)
{
m_isRequired = isRequired;
}

QLabel* QtProjectWizardContent::createFormTitle(QString name) const
{
QLabel* label = new QLabel(name);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
label->setObjectName(QStringLiteral("label"));
label->setObjectName(QStringLiteral("titleLabel"));
label->setWordWrap(true);
return label;
}

QLabel* QtProjectWizardContent::createFormTitle(QString name) const
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->setObjectName(QStringLiteral("titleLabel"));
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
label->setObjectName(QStringLiteral("label"));
label->setWordWrap(true);
return label;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ class QtProjectWizardContent: public QWidget
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(
Expand All @@ -53,6 +57,8 @@ protected slots:
void showFilesDialog(const std::vector<FilePath>& filePaths);

QtThreadedFunctor<const std::vector<FilePath>&> m_showFilesFunctor;

bool m_isRequired = false;
};

#endif // QT_PROJECT_WIZARD_CONTENT_H
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ QtProjectWizardContentProjectData::QtProjectWizardContentProjectData(
, m_projectName(nullptr)
, m_projectFileLocation(nullptr)
{
setIsRequired(true);
}

void QtProjectWizardContentProjectData::populate(QGridLayout* layout, int& row)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "utilityFile.h"

QtProjectWizardContentPath::QtProjectWizardContentPath(QtProjectWizardWindow* window)
: QtProjectWizardContent(window), m_allowEmpty(false)
: QtProjectWizardContent(window)
{
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -103,8 +101,3 @@ void QtProjectWizardContentPath::setFileEndings(const std::set<std::wstring>& fi
{
m_fileEndings = fileEndings;
}

void QtProjectWizardContentPath::setAllowEmpty(bool allowEmpty)
{
m_allowEmpty = allowEmpty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class QtProjectWizardContentPath: public QtProjectWizardContent
void setPlaceholderString(const QString& placeholder);

void setFileEndings(const std::set<std::wstring>& fileEndings);
void setAllowEmpty(bool allowEmpty);

QtLocationPicker* m_picker;

Expand All @@ -37,7 +36,6 @@ class QtProjectWizardContentPath: public QtProjectWizardContent
QString m_helpString;
QString m_placeholderString;
std::set<std::wstring> m_fileEndings;
bool m_allowEmpty;
};

#endif // QT_PROJECT_WIZARD_CONTENT_PATH_H
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down