From 8cdbb31aafacb95f78af279e59ebe754b5f6ebb0 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 27 Sep 2021 13:07:56 +0200 Subject: [PATCH] QtSupport: Use FilePath for Link with Qt feature Change-Id: Ic153523494e9b253850e74136db5027d4db55c53 Reviewed-by: Christian Stenger Reviewed-by: Artem Sokolovskii --- src/plugins/qtsupport/qtoptionspage.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index e09ead163bc..b026363b34a 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -799,7 +799,7 @@ static QString qtVersionsFile(const QString &baseDir) + Core::Constants::IDE_ID + '/' + "qtversion.xml"; } -static Utils::optional currentlyLinkedQtDir(bool *hasInstallSettings) +static Utils::optional currentlyLinkedQtDir(bool *hasInstallSettings) { const QString installSettingsFilePath = settingsFile(Core::ICore::resourcePath().toString()); const bool installSettingsExist = QFile::exists(installSettingsFilePath); @@ -809,7 +809,7 @@ static Utils::optional currentlyLinkedQtDir(bool *hasInstallSettings) const QVariant value = QSettings(installSettingsFilePath, QSettings::IniFormat) .value(kInstallSettingsKey); if (value.isValid()) - return value.toString(); + return FilePath::fromVariant(value); } return {}; } @@ -826,7 +826,7 @@ static bool canLinkWithQt(QString *toolTip) { bool canLink = true; bool installSettingsExist; - const Utils::optional installSettingsValue = currentlyLinkedQtDir( + const Utils::optional installSettingsValue = currentlyLinkedQtDir( &installSettingsExist); QStringList tip; tip << linkingPurposeText(); @@ -843,10 +843,10 @@ static bool canLinkWithQt(QString *toolTip) tip << QtOptionsPageWidget::tr("%1 is part of a Qt installation.") .arg(Core::Constants::IDE_DISPLAY_NAME); } - const QString link = installSettingsValue ? *installSettingsValue : QString(); + const FilePath link = installSettingsValue ? *installSettingsValue : FilePath(); if (!link.isEmpty()) tip << QtOptionsPageWidget::tr("%1 is currently linked to \"%2\".") - .arg(QString(Core::Constants::IDE_DISPLAY_NAME), QDir::toNativeSeparators(link)); + .arg(QString(Core::Constants::IDE_DISPLAY_NAME), link.toUserOutput()); if (toolTip) *toolTip = tip.join("\n\n"); return canLink; @@ -943,11 +943,11 @@ static bool validateQtInstallDir(FancyLineEdit *input, QString *errorString) return true; } -static QString defaultQtInstallationPath() +static FilePath defaultQtInstallationPath() { if (HostOsInfo::isWindowsHost()) - return {"C:/Qt"}; - return QDir::homePath() + "/Qt"; + return FilePath::fromString({"C:/Qt"}); + return FileUtils::homePath() / "Qt"; } void QtOptionsPageWidget::linkWithQt() @@ -980,8 +980,8 @@ void QtOptionsPageWidget::linkWithQt() return false; return validateQtInstallDir(input, errorString); }); - const Utils::optional currentLink = currentlyLinkedQtDir(nullptr); - pathInput->setPath(currentLink ? *currentLink : defaultQtInstallationPath()); + const Utils::optional currentLink = currentlyLinkedQtDir(nullptr); + pathInput->setFilePath(currentLink ? *currentLink : defaultQtInstallationPath()); auto buttons = new QDialogButtonBox; layout->addStretch(10); layout->addWidget(buttons);