summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-05-11 15:54:30 +0200
committerEike Ziller <eike.ziller@qt.io>2020-05-14 09:21:26 +0000
commit53cf4aa3c5573d34b399d783cdb6dc0c12b041af (patch)
tree3c7843d9cac08a1616b70d9e04e303caa79c70f1 /src
parent567b61eee5488dc8a727bfe73d62ab6115a8ec54 (diff)
downloadqt-creator-53cf4aa3c5573d34b399d783cdb6dc0c12b041af.tar.gz
Fix availability of "Link with Qt" info bar
The info bar should never appear if the button is disabled, for example because the Qt Creator directory is not accessible. Fixes: QTCREATORBUG-23900 Change-Id: I819c87f5ca51f69f34bd462fca8e877be3544100 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qtsupport/qtoptionspage.cpp37
-rw-r--r--src/plugins/qtsupport/qtoptionspage.h2
-rw-r--r--src/plugins/qtsupport/qtsupportplugin.cpp2
3 files changed, 33 insertions, 8 deletions
diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp
index 95c3b84d50..3f851979fe 100644
--- a/src/plugins/qtsupport/qtoptionspage.cpp
+++ b/src/plugins/qtsupport/qtoptionspage.cpp
@@ -823,28 +823,41 @@ static QString linkingPurposeText()
"Linking with a Qt installation automatically registers Qt versions and kits.");
}
-void QtOptionsPageWidget::setupLinkWithQtButton()
+static bool canLinkWithQt(QString *toolTip)
{
+ bool canLink = true;
bool installSettingsExist;
const Utils::optional<QString> installSettingsValue = currentlyLinkedQtDir(
&installSettingsExist);
QStringList tip;
tip << linkingPurposeText();
if (!FilePath::fromString(Core::ICore::resourcePath()).isWritablePath()) {
- m_ui.linkWithQtButton->setEnabled(false);
- tip << tr("%1's resource directory is not writable.").arg(Core::Constants::IDE_DISPLAY_NAME);
+ canLink = false;
+ tip << QtOptionsPageWidget::tr("%1's resource directory is not writable.")
+ .arg(Core::Constants::IDE_DISPLAY_NAME);
}
// guard against redirecting Qt Creator that is part of a Qt installations
// TODO this fails for pre-releases in the online installer
// TODO this will fail when make Qt Creator non-required in the Qt installers
if (installSettingsExist && !installSettingsValue) {
- m_ui.linkWithQtButton->setEnabled(false);
- tip << tr("%1 is part of a Qt installation.").arg(Core::Constants::IDE_DISPLAY_NAME);
+ canLink = false;
+ tip << QtOptionsPageWidget::tr("%1 is part of a Qt installation.")
+ .arg(Core::Constants::IDE_DISPLAY_NAME);
}
const QString link = installSettingsValue ? *installSettingsValue : QString();
if (!link.isEmpty())
- tip << tr("%1 is currently linked to \"%2\".").arg(Core::Constants::IDE_DISPLAY_NAME, link);
- m_ui.linkWithQtButton->setToolTip(tip.join("\n\n"));
+ tip << QtOptionsPageWidget::tr("%1 is currently linked to \"%2\".")
+ .arg(Core::Constants::IDE_DISPLAY_NAME, link);
+ if (toolTip)
+ *toolTip = tip.join("\n\n");
+ return canLink;
+}
+
+void QtOptionsPageWidget::setupLinkWithQtButton()
+{
+ QString tip;
+ canLinkWithQt(&tip);
+ m_ui.linkWithQtButton->setToolTip(tip);
connect(m_ui.linkWithQtButton, &QPushButton::clicked, this, &QtOptionsPage::linkWithQt);
}
@@ -1018,6 +1031,16 @@ QtOptionsPage::QtOptionsPage()
setWidgetCreator([] { return new QtOptionsPageWidget; });
}
+bool QtOptionsPage::canLinkWithQt()
+{
+ return Internal::canLinkWithQt(nullptr);
+}
+
+bool QtOptionsPage::isLinkedWithQt()
+{
+ return currentlyLinkedQtDir(nullptr).has_value();
+}
+
void QtOptionsPage::linkWithQt()
{
QtOptionsPageWidget::linkWithQt();
diff --git a/src/plugins/qtsupport/qtoptionspage.h b/src/plugins/qtsupport/qtoptionspage.h
index e2bfc9cbef..6f5599f51a 100644
--- a/src/plugins/qtsupport/qtoptionspage.h
+++ b/src/plugins/qtsupport/qtoptionspage.h
@@ -35,6 +35,8 @@ class QtOptionsPage final : public Core::IOptionsPage
public:
QtOptionsPage();
+ static bool canLinkWithQt();
+ static bool isLinkedWithQt();
static void linkWithQt();
};
diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp
index 40f00c1e2c..7a8466f81f 100644
--- a/src/plugins/qtsupport/qtsupportplugin.cpp
+++ b/src/plugins/qtsupport/qtsupportplugin.cpp
@@ -122,7 +122,7 @@ static void askAboutQtInstallation()
{
// if the install settings exist, the Qt Creator installation is (probably) already linked to
// a Qt installation, so don't ask
- if (QFile::exists(ICore::settings(QSettings::SystemScope)->fileName())
+ if (!QtOptionsPage::canLinkWithQt() || QtOptionsPage::isLinkedWithQt()
|| !ICore::infoBar()->canInfoBeAdded(kLinkWithQtInstallationSetting))
return;