TargetSetupPage: More improvements

- Do not claim we are parsing unconfigured projects.
- Use our concept of a "usable" kit in some places that still used just
the kit's "valid" attribute.
- Merge two labels that belong together.
- Get rid of unneeded state and indirections.

Fixes: QTCREATORBUG-22963
Change-Id: I2481439435e92e98b7e0ba5053a1e8843a961aec
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2019-10-04 15:55:52 +02:00
parent b6790e82a4
commit 7a87dc0484
3 changed files with 12 additions and 86 deletions

View File

@@ -117,18 +117,11 @@ private:
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT); Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
} }
void kitUpdated(ProjectExplorer::Kit *k)
{
if (k == KitManager::defaultKit())
updateNoteText();
}
void completeChanged() void completeChanged()
{ {
m_configureButton->setEnabled(m_targetSetupPage && m_targetSetupPage->isComplete()); m_configureButton->setEnabled(m_targetSetupPage && m_targetSetupPage->isComplete());
} }
void updateNoteText();
void addTargetSetupPage(); void addTargetSetupPage();
Project * const m_project; Project * const m_project;
@@ -161,41 +154,6 @@ TargetSetupPageWrapper::TargetSetupPageWrapper(Project *project)
this, &TargetSetupPageWrapper::done); this, &TargetSetupPageWrapper::done);
} }
void TargetSetupPageWrapper::updateNoteText()
{
if (!m_targetSetupPage)
return;
Kit *k = KitManager::defaultKit();
QString text;
bool showHint = false;
if (!k) {
text = tr("The project <b>%1</b> is not yet configured.<br/>"
"%2 cannot parse the project, because no kit "
"has been set up.")
.arg(m_project->displayName(), Core::Constants::IDE_DISPLAY_NAME);
showHint = true;
} else if (k->isValid()) {
text = tr("The project <b>%1</b> is not yet configured.<br/>"
"%2 uses the kit <b>%3</b> to parse the project.")
.arg(m_project->displayName())
.arg(Core::Constants::IDE_DISPLAY_NAME)
.arg(k->displayName());
showHint = false;
} else {
text = tr("The project <b>%1</b> is not yet configured.<br/>"
"%2 uses the <b>invalid</b> kit <b>%3</b> to parse the project.")
.arg(m_project->displayName())
.arg(Core::Constants::IDE_DISPLAY_NAME)
.arg(k->displayName());
showHint = true;
}
m_targetSetupPage->setNoteText(text);
m_targetSetupPage->showOptionsHint(showHint);
}
void TargetSetupPageWrapper::addTargetSetupPage() void TargetSetupPageWrapper::addTargetSetupPage()
{ {
m_targetSetupPage = new TargetSetupPage(this); m_targetSetupPage = new TargetSetupPage(this);
@@ -207,16 +165,11 @@ void TargetSetupPageWrapper::addTargetSetupPage()
m_targetSetupPage->initializePage(); m_targetSetupPage->initializePage();
m_targetSetupPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); m_targetSetupPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_setupPageContainer->addWidget(m_targetSetupPage); m_setupPageContainer->addWidget(m_targetSetupPage);
updateNoteText();
completeChanged(); completeChanged();
connect(m_targetSetupPage, &QWizardPage::completeChanged, connect(m_targetSetupPage, &QWizardPage::completeChanged,
this, &TargetSetupPageWrapper::completeChanged); this, &TargetSetupPageWrapper::completeChanged);
connect(KitManager::instance(), &KitManager::defaultkitChanged,
this, &TargetSetupPageWrapper::updateNoteText);
connect(KitManager::instance(), &KitManager::kitUpdated,
this, &TargetSetupPageWrapper::kitUpdated);
} }
// //

View File

@@ -86,18 +86,13 @@ public:
QWidget *scrollAreaWidget; QWidget *scrollAreaWidget;
QScrollArea *scrollArea; QScrollArea *scrollArea;
QLabel *headerLabel; QLabel *headerLabel;
QLabel *descriptionLabel;
QLabel *noValidKitLabel; QLabel *noValidKitLabel;
QLabel *optionHintLabel;
QCheckBox *allKitsCheckBox; QCheckBox *allKitsCheckBox;
FancyLineEdit *kitFilterLineEdit; FancyLineEdit *kitFilterLineEdit;
void setupUi(TargetSetupPage *q) void setupUi(TargetSetupPage *q)
{ {
auto setupTargetPage = new QWidget(q); auto setupTargetPage = new QWidget(q);
descriptionLabel = new QLabel(setupTargetPage);
descriptionLabel->setWordWrap(true);
descriptionLabel->setVisible(false);
headerLabel = new QLabel(setupTargetPage); headerLabel = new QLabel(setupTargetPage);
headerLabel->setWordWrap(true); headerLabel->setWordWrap(true);
@@ -105,16 +100,11 @@ public:
noValidKitLabel = new QLabel(setupTargetPage); noValidKitLabel = new QLabel(setupTargetPage);
noValidKitLabel->setWordWrap(true); noValidKitLabel->setWordWrap(true);
noValidKitLabel->setText(TargetSetupPage::tr("<span style=\" font-weight:600;\">No valid kits found.</span>")); noValidKitLabel->setText(TargetSetupPage::tr("<span style=\" font-weight:600;\">No suitable kits found.</span><br/>"
optionHintLabel = new QLabel(setupTargetPage);
optionHintLabel->setWordWrap(true);
optionHintLabel->setText(TargetSetupPage::tr(
"Please add a kit in the <a href=\"buildandrun\">options</a> " "Please add a kit in the <a href=\"buildandrun\">options</a> "
"or via the maintenance tool of the SDK.")); "or via the maintenance tool of the SDK."));
optionHintLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); noValidKitLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
optionHintLabel->setVisible(false); noValidKitLabel->setVisible(false);
allKitsCheckBox = new QCheckBox(setupTargetPage); allKitsCheckBox = new QCheckBox(setupTargetPage);
allKitsCheckBox->setTristate(true); allKitsCheckBox->setTristate(true);
@@ -146,10 +136,8 @@ public:
auto verticalLayout_2 = new QVBoxLayout(setupTargetPage); auto verticalLayout_2 = new QVBoxLayout(setupTargetPage);
verticalLayout_2->addWidget(headerLabel); verticalLayout_2->addWidget(headerLabel);
verticalLayout_2->addWidget(descriptionLabel);
verticalLayout_2->addWidget(kitFilterLineEdit); verticalLayout_2->addWidget(kitFilterLineEdit);
verticalLayout_2->addWidget(noValidKitLabel); verticalLayout_2->addWidget(noValidKitLabel);
verticalLayout_2->addWidget(optionHintLabel);
verticalLayout_2->addWidget(allKitsCheckBox); verticalLayout_2->addWidget(allKitsCheckBox);
verticalLayout_2->addWidget(centralWidget); verticalLayout_2->addWidget(centralWidget);
verticalLayout_2->addWidget(scrollAreaWidget); verticalLayout_2->addWidget(scrollAreaWidget);
@@ -158,7 +146,7 @@ public:
verticalLayout_3->setContentsMargins(0, 0, 0, -1); verticalLayout_3->setContentsMargins(0, 0, 0, -1);
verticalLayout_3->addWidget(setupTargetPage); verticalLayout_3->addWidget(setupTargetPage);
QObject::connect(optionHintLabel, &QLabel::linkActivated, QObject::connect(noValidKitLabel, &QLabel::linkActivated,
q, &TargetSetupPage::openOptions); q, &TargetSetupPage::openOptions);
QObject::connect(allKitsCheckBox, &QAbstractButton::clicked, QObject::connect(allKitsCheckBox, &QAbstractButton::clicked,
@@ -213,6 +201,8 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) :
connect(km, &KitManager::kitUpdated, this, &TargetSetupPage::handleKitUpdate); connect(km, &KitManager::kitUpdated, this, &TargetSetupPage::handleKitUpdate);
connect(m_importWidget, &ImportWidget::importFrom, connect(m_importWidget, &ImportWidget::importFrom,
this, [this](const FilePath &dir) { import(dir); }); this, [this](const FilePath &dir) { import(dir); });
connect(KitManager::instance(), &KitManager::kitsChanged,
this, &TargetSetupPage::updateVisibility);
setProperty(SHORT_TITLE_PROPERTY, tr("Kits")); setProperty(SHORT_TITLE_PROPERTY, tr("Kits"));
} }
@@ -224,6 +214,7 @@ void TargetSetupPage::initializePage()
setupWidgets(); setupWidgets();
setupImports(); setupImports();
selectAtLeastOneKit(); selectAtLeastOneKit();
updateVisibility();
} }
void TargetSetupPage::setRequiredKitPredicate(const Kit::Predicate &predicate) void TargetSetupPage::setRequiredKitPredicate(const Kit::Predicate &predicate)
@@ -348,18 +339,6 @@ bool TargetSetupPage::importLineEditHasFocus() const
return m_importWidget->ownsReturnKey(); return m_importWidget->ownsReturnKey();
} }
void TargetSetupPage::setNoteText(const QString &text)
{
m_ui->descriptionLabel->setText(text);
m_ui->descriptionLabel->setVisible(!text.isEmpty());
}
void TargetSetupPage::showOptionsHint(bool show)
{
m_forceOptionHint = show;
updateVisibility();
}
void TargetSetupPage::setupImports() void TargetSetupPage::setupImports()
{ {
if (!m_importer || m_projectPath.isEmpty()) if (!m_importer || m_projectPath.isEmpty())
@@ -446,10 +425,9 @@ void TargetSetupPage::updateVisibility()
m_ui->scrollAreaWidget->setVisible(m_baseLayout == m_ui->scrollArea->widget()->layout()); m_ui->scrollAreaWidget->setVisible(m_baseLayout == m_ui->scrollArea->widget()->layout());
m_ui->centralWidget->setVisible(m_baseLayout == m_ui->centralWidget->layout()); m_ui->centralWidget->setVisible(m_baseLayout == m_ui->centralWidget->layout());
bool hasKits = m_widgets.size() > 0; const bool hasUsableKits = KitManager::kit([this](const Kit *k) { return isUsable(k); });
m_ui->noValidKitLabel->setVisible(!hasKits); m_ui->noValidKitLabel->setVisible(!hasUsableKits);
m_ui->optionHintLabel->setVisible(m_forceOptionHint || !hasKits); m_ui->allKitsCheckBox->setVisible(hasUsableKits);
m_ui->allKitsCheckBox->setVisible(hasKits);
emit completeChanged(); emit completeChanged();
} }

View File

@@ -81,10 +81,6 @@ public:
bool setupProject(Project *project); bool setupProject(Project *project);
QList<Core::Id> selectedKits() const; QList<Core::Id> selectedKits() const;
/// Overrides the summary text of the targetsetuppage
void setNoteText(const QString &text);
void showOptionsHint(bool show);
void openOptions(); void openOptions();
void changeAllKitsSelections(); void changeAllKitsSelections();
@@ -139,7 +135,6 @@ private:
QSpacerItem *m_spacer; QSpacerItem *m_spacer;
QList<QWidget *> m_potentialWidgets; QList<QWidget *> m_potentialWidgets;
bool m_forceOptionHint = false;
bool m_widgetsWereSetUp = false; bool m_widgetsWereSetUp = false;
}; };