Polish targetsetuppage

Task-number: QTCREATORBUG-7740
Task-number: QTCREATORBUG-7739

Change-Id: I587b22fcd5a21b1aa740d2e301da969519de0e45
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Tobias Hunger
2012-09-04 17:00:50 +02:00
committed by Eike Ziller
parent 371e6f59bc
commit cc275c062d
4 changed files with 67 additions and 60 deletions

View File

@@ -126,8 +126,6 @@ TargetSetupPageWrapper::TargetSetupPageWrapper(ProjectExplorer::Project *project
connect(m_configureButton, SIGNAL(clicked()), connect(m_configureButton, SIGNAL(clicked()),
this, SLOT(done())); this, SLOT(done()));
connect(m_targetSetupPage, SIGNAL(noteTextLinkActivated()),
this, SLOT(noteTextLinkActivated()));
connect(m_targetSetupPage, SIGNAL(completeChanged()), connect(m_targetSetupPage, SIGNAL(completeChanged()),
this, SLOT(completeChanged())); this, SLOT(completeChanged()));
connect(ProjectExplorer::KitManager::instance(), SIGNAL(defaultkitChanged()), connect(ProjectExplorer::KitManager::instance(), SIGNAL(defaultkitChanged()),
@@ -146,31 +144,30 @@ void TargetSetupPageWrapper::updateNoteText()
{ {
ProjectExplorer::Kit *k = ProjectExplorer::KitManager::instance()->defaultKit(); ProjectExplorer::Kit *k = ProjectExplorer::KitManager::instance()->defaultKit();
QString text; QString text;
if (!k) bool showHint = false;
text = tr("<p>The project <b>%1</b> is not yet configured.</p>" if (!k) {
"<p>Qt Creator cannot parse the project, because no target " text = tr("The project <b>%1</b> is not yet configured.<br/>"
"has been set up. You can set up targets " "Qt Creator cannot parse the project, because no kit "
"in the <b><a href=\"edit\">options.</a></b></p>") "has been set up.")
.arg(m_project->displayName()); .arg(m_project->displayName());
else if (k->isValid()) showHint = true;
text = tr("<p>The project <b>%1</b> is not yet configured.</p>" } else if (k->isValid()) {
"<p>Qt Creator uses the target <b>%2</b> " text = tr("The project <b>%1</b> is not yet configured.<br/>"
"to parse the project. You can edit " "Qt Creator uses the kit <b>%2</b> to parse the project.")
"targets in the <b><a href=\"edit\">options.</a></b></p>")
.arg(m_project->displayName()) .arg(m_project->displayName())
.arg(k->displayName()); .arg(k->displayName());
else showHint = false;
text = tr("<p>The project <b>%1</b> is not yet configured.</p>" } else {
"<p>Qt Creator uses the <b>invalid</b> target <b>%2</b> " text = tr("The project <b>%1</b> is not yet configured.<br/>"
"to parse the project. You can edit " "Qt Creator uses the <b>invalid</b> kit <b>%2</b> to parse the project.")
"targets in the <b><a href=\"edit\">options</a></b></p>")
.arg(m_project->displayName()) .arg(m_project->displayName())
.arg(k->displayName()); .arg(k->displayName());
showHint = true;
}
m_targetSetupPage->setNoteText(text); m_targetSetupPage->setNoteText(text);
m_targetSetupPage->showOptionsHint(showHint);
} }
void TargetSetupPageWrapper::keyPressEvent(QKeyEvent *event) void TargetSetupPageWrapper::keyPressEvent(QKeyEvent *event)
@@ -195,12 +192,6 @@ void TargetSetupPageWrapper::done()
Core::ICore::instance()->modeManager()->activateMode(Core::Constants::MODE_EDIT); Core::ICore::instance()->modeManager()->activateMode(Core::Constants::MODE_EDIT);
} }
void TargetSetupPageWrapper::noteTextLinkActivated()
{
Core::ICore::instance()->showOptionsDialog(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY),
QLatin1String(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID));
}
void TargetSetupPageWrapper::completeChanged() void TargetSetupPageWrapper::completeChanged()
{ {
m_configureButton->setEnabled(m_targetSetupPage->isComplete()); m_configureButton->setEnabled(m_targetSetupPage->isComplete());

View File

@@ -67,7 +67,6 @@ protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
private slots: private slots:
void done(); void done();
void noteTextLinkActivated();
void kitUpdated(ProjectExplorer::Kit *k); void kitUpdated(ProjectExplorer::Kit *k);
void updateNoteText(); void updateNoteText();
void completeChanged(); void completeChanged();

View File

@@ -71,37 +71,34 @@ public:
QWidget *centralWidget; QWidget *centralWidget;
QWidget *scrollAreaWidget; QWidget *scrollAreaWidget;
QScrollArea *scrollArea; QScrollArea *scrollArea;
QLabel *headerLabel;
QLabel *descriptionLabel; QLabel *descriptionLabel;
QLabel *noValidKitLabel;
QLabel *optionHintLabel;
void setupUi(QWidget *q) void setupUi(QWidget *q)
{ {
QWidget *setupTargetPage = new QWidget(q); QWidget *setupTargetPage = new QWidget(q);
headerLabel = new QLabel(setupTargetPage);
headerLabel->setWordWrap(true);
headerLabel->setVisible(false);
noValidKitLabel = new QLabel(setupTargetPage);
noValidKitLabel->setWordWrap(true);
noValidKitLabel->setText(TargetSetupPage::tr("<span style=\" font-weight:600;\">No valid kits found.</span>"));
descriptionLabel = new QLabel(setupTargetPage); descriptionLabel = new QLabel(setupTargetPage);
descriptionLabel->setWordWrap(true); descriptionLabel->setWordWrap(true);
descriptionLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); descriptionLabel->setVisible(false);
descriptionLabel->setText(TargetSetupPage::tr("Qt Creator can use the following kits:"));
#ifdef Q_OS_MAC optionHintLabel = new QLabel(setupTargetPage);
QString hint = TargetSetupPage::tr( optionHintLabel->setWordWrap(true);
"<html><head/><body><p><span style=\" font-weight:600;\">" optionHintLabel->setText(TargetSetupPage::tr(
"No valid kits found.</span></p>" "Please add a kit in the <a href=\"buildandrun\">options</a> "
"<p>Please add a kit in <a href=\"buildandrun\"><span style=\" text-decoration: underline; color:#0000ff;\">" "or via the maintenance tool of the SDK."));
"Qt Creator &gt; Preferences &gt; Build &amp; Run</span></a>" optionHintLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
" or via the maintenance tool of the SDK.</p></body></html>"); optionHintLabel->setVisible(false);
#else
QString hint = TargetSetupPage::tr(
"<html><head/><body><p><span style=\" font-weight:600;\">"
"No valid kits found.</span></p>"
"<p>Please add a kit in <a href=\"buildandrun\"><span style=\" text-decoration: underline; color:#0000ff;\">"
"Tools &gt; Options &gt; Build &amp; Run</span></a>"
" or via the maintenance tool of the SDK.</p></body></html>");
#endif
QLabel *noValidKitLabel = new QLabel(setupTargetPage);
noValidKitLabel->setWordWrap(true);
noValidKitLabel->setText(hint);
noValidKitLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
centralWidget = new QWidget(setupTargetPage); centralWidget = new QWidget(setupTargetPage);
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed); QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -125,8 +122,10 @@ public:
verticalLayout->addWidget(scrollArea); verticalLayout->addWidget(scrollArea);
QVBoxLayout *verticalLayout_2 = new QVBoxLayout(setupTargetPage); QVBoxLayout *verticalLayout_2 = new QVBoxLayout(setupTargetPage);
verticalLayout_2->addWidget(descriptionLabel); verticalLayout_2->addWidget(headerLabel);
verticalLayout_2->addWidget(noValidKitLabel); verticalLayout_2->addWidget(noValidKitLabel);
verticalLayout_2->addWidget(descriptionLabel);
verticalLayout_2->addWidget(optionHintLabel);
verticalLayout_2->addWidget(centralWidget); verticalLayout_2->addWidget(centralWidget);
verticalLayout_2->addWidget(scrollAreaWidget); verticalLayout_2->addWidget(scrollAreaWidget);
@@ -134,10 +133,8 @@ 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(noValidKitLabel, SIGNAL(linkActivated(QString)), QObject::connect(optionHintLabel, SIGNAL(linkActivated(QString)),
q, SIGNAL(noteTextLinkActivated())); q, SLOT(openOptions()));
QObject::connect(descriptionLabel, SIGNAL(linkActivated(QString)),
q, SIGNAL(noteTextLinkActivated()));
} }
}; };
@@ -155,7 +152,8 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) :
m_firstWidget(0), m_firstWidget(0),
m_ui(new TargetSetupPageUi), m_ui(new TargetSetupPageUi),
m_importWidget(new Internal::ImportWidget(this)), m_importWidget(new Internal::ImportWidget(this)),
m_spacer(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding)) m_spacer(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding)),
m_forceOptionHint(false)
{ {
setObjectName(QLatin1String("TargetSetupPage")); setObjectName(QLatin1String("TargetSetupPage"));
setWindowTitle(tr("Select Kits for Your Project")); setWindowTitle(tr("Select Kits for Your Project"));
@@ -358,10 +356,10 @@ void TargetSetupPage::removeProject(ProjectExplorer::Kit *k, const QString &path
void TargetSetupPage::setProFilePath(const QString &path) void TargetSetupPage::setProFilePath(const QString &path)
{ {
m_proFilePath = path; m_proFilePath = path;
if (!m_proFilePath.isEmpty()) { if (!m_proFilePath.isEmpty())
m_ui->descriptionLabel->setText(tr("Qt Creator can use the following kits for project <b>%1</b>:", m_ui->headerLabel->setText(tr("Qt Creator can use the following kits for project <b>%1</b>:",
"%1: Project name").arg(QFileInfo(m_proFilePath).baseName())); "%1: Project name").arg(QFileInfo(m_proFilePath).baseName()));
} m_ui->headerLabel->setVisible(!m_proFilePath.isEmpty());
if (m_widgets.isEmpty()) if (m_widgets.isEmpty())
return; return;
@@ -373,6 +371,13 @@ void TargetSetupPage::setProFilePath(const QString &path)
void TargetSetupPage::setNoteText(const QString &text) void TargetSetupPage::setNoteText(const QString &text)
{ {
m_ui->descriptionLabel->setText(text); m_ui->descriptionLabel->setText(text);
m_ui->descriptionLabel->setVisible(!text.isEmpty());
}
void TargetSetupPage::showOptionsHint(bool show)
{
m_forceOptionHint = show;
updateVisibility();
} }
void TargetSetupPage::import(const Utils::FileName &path) void TargetSetupPage::import(const Utils::FileName &path)
@@ -584,9 +589,19 @@ 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.isEmpty();
m_ui->noValidKitLabel->setVisible(!hasKits);
m_ui->optionHintLabel->setVisible(m_forceOptionHint || !hasKits);
emit completeChanged(); emit completeChanged();
} }
void TargetSetupPage::openOptions()
{
Core::ICore::instance()->showOptionsDialog(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY),
QLatin1String(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID));
}
void TargetSetupPage::removeWidget(ProjectExplorer::Kit *k) void TargetSetupPage::removeWidget(ProjectExplorer::Kit *k)
{ {
Qt4TargetSetupWidget *widget = m_widgets.value(k->id()); Qt4TargetSetupWidget *widget = m_widgets.value(k->id());

View File

@@ -81,8 +81,7 @@ public:
/// Overrides the summary text of the targetsetuppage /// Overrides the summary text of the targetsetuppage
void setNoteText(const QString &text); void setNoteText(const QString &text);
signals: void showOptionsHint(bool show);
void noteTextLinkActivated();
private slots: private slots:
void import(const Utils::FileName &path); void import(const Utils::FileName &path);
@@ -91,6 +90,7 @@ private slots:
void handleKitRemoval(ProjectExplorer::Kit *k); void handleKitRemoval(ProjectExplorer::Kit *k);
void handleKitUpdate(ProjectExplorer::Kit *k); void handleKitUpdate(ProjectExplorer::Kit *k);
void updateVisibility(); void updateVisibility();
void openOptions();
private: private:
void selectAtLeastOneKit(); void selectAtLeastOneKit();
@@ -123,6 +123,8 @@ private:
Internal::ImportWidget *m_importWidget; Internal::ImportWidget *m_importWidget;
QSpacerItem *m_spacer; QSpacerItem *m_spacer;
bool m_forceOptionHint;
}; };
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager