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);
}
void kitUpdated(ProjectExplorer::Kit *k)
{
if (k == KitManager::defaultKit())
updateNoteText();
}
void completeChanged()
{
m_configureButton->setEnabled(m_targetSetupPage && m_targetSetupPage->isComplete());
}
void updateNoteText();
void addTargetSetupPage();
Project * const m_project;
@@ -161,41 +154,6 @@ TargetSetupPageWrapper::TargetSetupPageWrapper(Project *project)
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()
{
m_targetSetupPage = new TargetSetupPage(this);
@@ -207,16 +165,11 @@ void TargetSetupPageWrapper::addTargetSetupPage()
m_targetSetupPage->initializePage();
m_targetSetupPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_setupPageContainer->addWidget(m_targetSetupPage);
updateNoteText();
completeChanged();
connect(m_targetSetupPage, &QWizardPage::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;
QScrollArea *scrollArea;
QLabel *headerLabel;
QLabel *descriptionLabel;
QLabel *noValidKitLabel;
QLabel *optionHintLabel;
QCheckBox *allKitsCheckBox;
FancyLineEdit *kitFilterLineEdit;
void setupUi(TargetSetupPage *q)
{
auto setupTargetPage = new QWidget(q);
descriptionLabel = new QLabel(setupTargetPage);
descriptionLabel->setWordWrap(true);
descriptionLabel->setVisible(false);
headerLabel = new QLabel(setupTargetPage);
headerLabel->setWordWrap(true);
@@ -105,16 +100,11 @@ public:
noValidKitLabel = new QLabel(setupTargetPage);
noValidKitLabel->setWordWrap(true);
noValidKitLabel->setText(TargetSetupPage::tr("<span style=\" font-weight:600;\">No valid kits found.</span>"));
optionHintLabel = new QLabel(setupTargetPage);
optionHintLabel->setWordWrap(true);
optionHintLabel->setText(TargetSetupPage::tr(
"Please add a kit in the <a href=\"buildandrun\">options</a> "
"or via the maintenance tool of the SDK."));
optionHintLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
optionHintLabel->setVisible(false);
noValidKitLabel->setText(TargetSetupPage::tr("<span style=\" font-weight:600;\">No suitable kits found.</span><br/>"
"Please add a kit in the <a href=\"buildandrun\">options</a> "
"or via the maintenance tool of the SDK."));
noValidKitLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
noValidKitLabel->setVisible(false);
allKitsCheckBox = new QCheckBox(setupTargetPage);
allKitsCheckBox->setTristate(true);
@@ -146,10 +136,8 @@ public:
auto verticalLayout_2 = new QVBoxLayout(setupTargetPage);
verticalLayout_2->addWidget(headerLabel);
verticalLayout_2->addWidget(descriptionLabel);
verticalLayout_2->addWidget(kitFilterLineEdit);
verticalLayout_2->addWidget(noValidKitLabel);
verticalLayout_2->addWidget(optionHintLabel);
verticalLayout_2->addWidget(allKitsCheckBox);
verticalLayout_2->addWidget(centralWidget);
verticalLayout_2->addWidget(scrollAreaWidget);
@@ -158,7 +146,7 @@ public:
verticalLayout_3->setContentsMargins(0, 0, 0, -1);
verticalLayout_3->addWidget(setupTargetPage);
QObject::connect(optionHintLabel, &QLabel::linkActivated,
QObject::connect(noValidKitLabel, &QLabel::linkActivated,
q, &TargetSetupPage::openOptions);
QObject::connect(allKitsCheckBox, &QAbstractButton::clicked,
@@ -213,6 +201,8 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) :
connect(km, &KitManager::kitUpdated, this, &TargetSetupPage::handleKitUpdate);
connect(m_importWidget, &ImportWidget::importFrom,
this, [this](const FilePath &dir) { import(dir); });
connect(KitManager::instance(), &KitManager::kitsChanged,
this, &TargetSetupPage::updateVisibility);
setProperty(SHORT_TITLE_PROPERTY, tr("Kits"));
}
@@ -224,6 +214,7 @@ void TargetSetupPage::initializePage()
setupWidgets();
setupImports();
selectAtLeastOneKit();
updateVisibility();
}
void TargetSetupPage::setRequiredKitPredicate(const Kit::Predicate &predicate)
@@ -348,18 +339,6 @@ bool TargetSetupPage::importLineEditHasFocus() const
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()
{
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->centralWidget->setVisible(m_baseLayout == m_ui->centralWidget->layout());
bool hasKits = m_widgets.size() > 0;
m_ui->noValidKitLabel->setVisible(!hasKits);
m_ui->optionHintLabel->setVisible(m_forceOptionHint || !hasKits);
m_ui->allKitsCheckBox->setVisible(hasKits);
const bool hasUsableKits = KitManager::kit([this](const Kit *k) { return isUsable(k); });
m_ui->noValidKitLabel->setVisible(!hasUsableKits);
m_ui->allKitsCheckBox->setVisible(hasUsableKits);
emit completeChanged();
}

View File

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