Wizards: Show warning creating subproject outside parent

Provide some feedback regarding creation of subprojects outside
of their parent projects to give the user a last chance to
correct the choices done so far.

Change-Id: I4e02dfca7332ea53b61485673e07248e10e2113e
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Christian Stenger
2024-06-17 12:14:40 +02:00
parent 265f76b9cd
commit e30dd3c5ee
3 changed files with 29 additions and 0 deletions

View File

@@ -295,6 +295,17 @@ void JsonSummaryPage::updateProjectData(FolderNode *node)
m_wizard->setValue(QLatin1String(KEY_QT_KEYWORDS_ENABLED), qtKeyWordsEnabled); m_wizard->setValue(QLatin1String(KEY_QT_KEYWORDS_ENABLED), qtKeyWordsEnabled);
updateFileList(); updateFileList();
setStatusVisible(false);
if (node && !m_fileList.isEmpty()) {
const FilePath parentFolder = node->directory();
const FilePath subProjectFolder = m_fileList.first().file.filePath().parentDir();
if (!subProjectFolder.isChildOf(parentFolder)) {
setStatus(Tr::tr("Subproject \"%1\" outside of \"%2\".")
.arg(subProjectFolder.toUserOutput()).arg(parentFolder.toUserOutput()),
InfoLabel::Warning);
setStatusVisible(true);
}
}
} }
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -275,6 +275,8 @@ ProjectWizardPage::ProjectWizardPage(QWidget *parent)
m_projectLabel->setObjectName("projectLabel"); m_projectLabel->setObjectName("projectLabel");
m_projectComboBox = new Utils::TreeViewComboBox; m_projectComboBox = new Utils::TreeViewComboBox;
m_projectComboBox->setObjectName("projectComboBox"); m_projectComboBox->setObjectName("projectComboBox");
m_infoLabel = new Utils::InfoLabel;
m_infoLabel->setVisible(false);
m_additionalInfo = new QLabel; m_additionalInfo = new QLabel;
m_addToVersionControlLabel = new QLabel(Tr::tr("Add to &version control:")); m_addToVersionControlLabel = new QLabel(Tr::tr("Add to &version control:"));
m_addToVersionControlComboBox = new QComboBox; m_addToVersionControlComboBox = new QComboBox;
@@ -295,6 +297,7 @@ ProjectWizardPage::ProjectWizardPage(QWidget *parent)
Column { Column {
Form { Form {
m_projectLabel, m_projectComboBox, br, m_projectLabel, m_projectComboBox, br,
m_infoLabel, br,
empty, m_additionalInfo, br, empty, m_additionalInfo, br,
m_addToVersionControlLabel, m_addToVersionControlComboBox, m_vcsManageButton, br, m_addToVersionControlLabel, m_addToVersionControlComboBox, m_vcsManageButton, br,
}, },
@@ -610,4 +613,15 @@ void ProjectWizardPage::setProjectUiVisible(bool visible)
m_projectComboBox->setVisible(visible); m_projectComboBox->setVisible(visible);
} }
void ProjectWizardPage::setStatus(const QString &text, InfoLabel::InfoType type)
{
m_infoLabel->setText(text);
m_infoLabel->setType(type);
}
void ProjectWizardPage::setStatusVisible(bool visible)
{
m_infoLabel->setVisible(visible);
}
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -9,6 +9,7 @@
#include <coreplugin/generatedfile.h> #include <coreplugin/generatedfile.h>
#include <coreplugin/iwizardfactory.h> #include <coreplugin/iwizardfactory.h>
#include <utils/infolabel.h>
#include <utils/wizardpage.h> #include <utils/wizardpage.h>
#include <utils/treemodel.h> #include <utils/treemodel.h>
@@ -57,6 +58,8 @@ public:
void initializeVersionControls(); void initializeVersionControls();
void setProjectUiVisible(bool visible); void setProjectUiVisible(bool visible);
void setStatus(const QString &text, Utils::InfoLabel::InfoType type);
void setStatusVisible(bool visible);
signals: signals:
void projectNodeChanged(); void projectNodeChanged();
@@ -85,6 +88,7 @@ private:
QLabel *m_projectLabel; QLabel *m_projectLabel;
Utils::TreeViewComboBox *m_projectComboBox; Utils::TreeViewComboBox *m_projectComboBox;
Utils::InfoLabel *m_infoLabel;
QLabel *m_additionalInfo; QLabel *m_additionalInfo;
QLabel *m_addToVersionControlLabel; QLabel *m_addToVersionControlLabel;
QComboBox *m_addToVersionControlComboBox; QComboBox *m_addToVersionControlComboBox;