diff options
Diffstat (limited to 'src/plugins')
269 files changed, 3560 insertions, 3117 deletions
diff --git a/src/plugins/android/android.pro b/src/plugins/android/android.pro index e48edd2fee..11f36185fe 100644 --- a/src/plugins/android/android.pro +++ b/src/plugins/android/android.pro @@ -19,7 +19,6 @@ HEADERS += \ androidrunner.h \ androidrunnerworker.h \ androiddebugsupport.h \ - androidqtversionfactory.h \ androidqtversion.h \ androidcreatekeystorecertificate.h \ javaparser.h \ @@ -67,7 +66,6 @@ SOURCES += \ androidrunner.cpp \ androidrunnerworker.cpp \ androiddebugsupport.cpp \ - androidqtversionfactory.cpp \ androidqtversion.cpp \ androidcreatekeystorecertificate.cpp \ javaparser.cpp \ diff --git a/src/plugins/android/android.qbs b/src/plugins/android/android.qbs index 912bca631e..0b8b925504 100644 --- a/src/plugins/android/android.qbs +++ b/src/plugins/android/android.qbs @@ -75,8 +75,6 @@ Project { "androidqmltoolingsupport.h", "androidqtversion.cpp", "androidqtversion.h", - "androidqtversionfactory.cpp", - "androidqtversionfactory.h", "androidrunconfiguration.cpp", "androidrunconfiguration.h", "androidrunenvironmentaspect.h", diff --git a/src/plugins/android/androidavdmanager.cpp b/src/plugins/android/androidavdmanager.cpp index 1d9f639588..128cd8a281 100644 --- a/src/plugins/android/androidavdmanager.cpp +++ b/src/plugins/android/androidavdmanager.cpp @@ -294,7 +294,7 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const return false; } auto avdProcess = new QProcess(); - avdProcess->setReadChannelMode(QProcess::MergedChannels); + avdProcess->setProcessChannelMode(QProcess::MergedChannels); QObject::connect(avdProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished), avdProcess, diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index d4320b039a..85a8a02503 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -160,7 +160,7 @@ bool AndroidBuildApkStep::init() OutputFormat::ErrorMessage); } - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit()); if (!version) return false; diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index d26ca3c191..88c3e92a42 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -976,13 +976,13 @@ static bool matchToolChain(const ToolChain *atc, const ToolChain *btc) static bool matchKits(const Kit *a, const Kit *b) { - if (QtSupport::QtKitInformation::qtVersion(a) != QtSupport::QtKitInformation::qtVersion(b)) + if (QtSupport::QtKitAspect::qtVersion(a) != QtSupport::QtKitAspect::qtVersion(b)) return false; - return matchToolChain(ToolChainKitInformation::toolChain(a, ProjectExplorer::Constants::CXX_LANGUAGE_ID), - ToolChainKitInformation::toolChain(b, ProjectExplorer::Constants::CXX_LANGUAGE_ID)) - && matchToolChain(ToolChainKitInformation::toolChain(a, ProjectExplorer::Constants::C_LANGUAGE_ID), - ToolChainKitInformation::toolChain(b, ProjectExplorer::Constants::C_LANGUAGE_ID)); + return matchToolChain(ToolChainKitAspect::toolChain(a, ProjectExplorer::Constants::CXX_LANGUAGE_ID), + ToolChainKitAspect::toolChain(b, ProjectExplorer::Constants::CXX_LANGUAGE_ID)) + && matchToolChain(ToolChainKitAspect::toolChain(a, ProjectExplorer::Constants::C_LANGUAGE_ID), + ToolChainKitAspect::toolChain(b, ProjectExplorer::Constants::C_LANGUAGE_ID)); } void AndroidConfigurations::registerNewToolChains() @@ -1027,10 +1027,10 @@ static QVariant findOrRegisterDebugger(ToolChain *tc) void AndroidConfigurations::updateAutomaticKitList() { const QList<Kit *> existingKits = Utils::filtered(KitManager::kits(), [](Kit *k) { - Core::Id deviceTypeId = DeviceTypeKitInformation::deviceTypeId(k); + Core::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(k); if (k->isAutoDetected() && !k->isSdkProvided() && deviceTypeId == Core::Id(Constants::ANDROID_DEVICE_TYPE)) { - if (!QtSupport::QtKitInformation::qtVersion(k)) + if (!QtSupport::QtKitAspect::qtVersion(k)) KitManager::deregisterKit(k); // Remove autoDetected kits without Qt. else return true; @@ -1076,11 +1076,11 @@ void AndroidConfigurations::updateAutomaticKitList() auto initBasicKitData = [allLanguages, device](Kit *k, const QtSupport::BaseQtVersion *qt) { k->setAutoDetected(true); k->setAutoDetectionSource("AndroidConfiguration"); - DeviceTypeKitInformation::setDeviceTypeId(k, Core::Id(Constants::ANDROID_DEVICE_TYPE)); + DeviceTypeKitAspect::setDeviceTypeId(k, Core::Id(Constants::ANDROID_DEVICE_TYPE)); for (ToolChain *tc : allLanguages) - ToolChainKitInformation::setToolChain(k, tc); - QtSupport::QtKitInformation::setQtVersion(k, qt); - DeviceKitInformation::setDevice(k, device); + ToolChainKitAspect::setToolChain(k, tc); + QtSupport::QtKitAspect::setQtVersion(k, qt); + DeviceKitAspect::setDevice(k, device); }; for (const QtSupport::BaseQtVersion *qt : qtVersionsForArch.value(tc->targetAbi())) { @@ -1098,9 +1098,9 @@ void AndroidConfigurations::updateAutomaticKitList() toSetup = existingKit; } - Debugger::DebuggerKitInformation::setDebugger(toSetup, findOrRegisterDebugger(tc)); + Debugger::DebuggerKitAspect::setDebugger(toSetup, findOrRegisterDebugger(tc)); - AndroidGdbServerKitInformation::setGdbSever(toSetup, currentConfig().gdbServer(tc->targetAbi())); + AndroidGdbServerKitAspect::setGdbSever(toSetup, currentConfig().gdbServer(tc->targetAbi())); toSetup->makeSticky(); toSetup->setUnexpandedDisplayName(tr("Android for %1 (Clang %2)") diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index 2af97bdffd..045e9d3e83 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -29,6 +29,7 @@ #include "androidglobal.h" #include "androidrunner.h" #include "androidmanager.h" +#include "androidqtversion.h" #include <debugger/debuggerkitinformation.h> #include <debugger/debuggerrunconfigurationaspect.h> @@ -167,7 +168,7 @@ void AndroidDebugSupport::start() setUseTargetAsync(true); } - QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit); + QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit); if (isCppDebugging()) { qCDebug(androidDebugSupportLog) << "C++ debugging enabled"; @@ -186,8 +187,11 @@ void AndroidDebugSupport::start() gdbServer.setPort(m_runner->gdbServerPort().number()); setRemoteChannel(gdbServer); - int sdkVersion = qMax(AndroidManager::minimumSDK(target->kit()), - AndroidManager::minimumNDK(target->kit())); + auto qt = static_cast<AndroidQtVersion *>(qtVersion); + QTC_CHECK(qt); + const int minimumNdk = qt ? qt->minimumNDK() : 0; + + int sdkVersion = qMax(AndroidManager::minimumSDK(target->kit()), minimumNdk); Utils::FileName sysRoot = AndroidConfigurations::currentConfig().ndkLocation() .appendPath("platforms") .appendPath(QString("android-%1").arg(sdkVersion)) diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index 1a0d508a56..97b8e5de5b 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -149,7 +149,7 @@ AndroidDeployQtStep::AndroidDeployQtStep(ProjectExplorer::BuildStepList *parent) : ProjectExplorer::BuildStep(parent, stepId()) { setImmutable(true); - m_uninstallPreviousPackage = QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0); + m_uninstallPreviousPackage = QtSupport::QtKitAspect::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0); //: AndroidDeployQtStep default display name setDefaultDisplayName(tr("Deploy to Android device")); @@ -224,7 +224,7 @@ bool AndroidDeployQtStep::init() emit addOutput(tr("Deploying to %1").arg(m_serialNumber), OutputFormat::Stdout); - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit()); if (!version) return false; @@ -527,7 +527,7 @@ void AndroidDeployQtStep::gatherFilesToPull() if (m_deviceInfo.cpuAbi.contains(QLatin1String("arm64-v8a")) || m_deviceInfo.cpuAbi.contains(QLatin1String("x86_64"))) { const Core::Id cxxLanguageId = ProjectExplorer::Constants::CXX_LANGUAGE_ID; - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), cxxLanguageId); + ToolChain *tc = ToolChainKitAspect::toolChain(target()->kit(), cxxLanguageId); if (tc && tc->targetAbi().wordWidth() == 64) { m_filesToPull["/system/bin/app_process64"] = buildDir + "app_process"; libDirName = "lib64"; @@ -634,7 +634,7 @@ void AndroidDeployQtStep::setUninstallPreviousPackage(bool uninstall) AndroidDeployQtStep::UninstallType AndroidDeployQtStep::uninstallPreviousPackage() { - if (QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) + if (QtSupport::QtKitAspect::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) return ForceUnintall; return m_uninstallPreviousPackage ? Uninstall : Keep; } diff --git a/src/plugins/android/androiddevicedialog.cpp b/src/plugins/android/androiddevicedialog.cpp index db70967727..436997aa1f 100644 --- a/src/plugins/android/androiddevicedialog.cpp +++ b/src/plugins/android/androiddevicedialog.cpp @@ -173,7 +173,7 @@ public: // topRight auto drawTopRight = [&](const QString text, const QFontMetrics &fm) { - painter->drawText(opt.rect.right() - fm.width(text) - 6 , 2 + opt.rect.top() + fm.ascent(), text); + painter->drawText(opt.rect.right() - fm.horizontalAdvance(text) - 6 , 2 + opt.rect.top() + fm.ascent(), text); }; if (device.type == AndroidDeviceInfo::Hardware) { diff --git a/src/plugins/android/androidgdbserverkitinformation.cpp b/src/plugins/android/androidgdbserverkitinformation.cpp index d4a7e17d85..a3040343ba 100644 --- a/src/plugins/android/androidgdbserverkitinformation.cpp +++ b/src/plugins/android/androidgdbserverkitinformation.cpp @@ -50,65 +50,83 @@ using namespace Utils; namespace Android { namespace Internal { -AndroidGdbServerKitInformation::AndroidGdbServerKitInformation() +class AndroidGdbServerKitAspectWidget : public KitAspectWidget { - setId(AndroidGdbServerKitInformation::id()); + Q_DECLARE_TR_FUNCTIONS(Android::Internal::AndroidGdbServerKitAspect) +public: + AndroidGdbServerKitAspectWidget(Kit *kit, const KitAspect *ki); + ~AndroidGdbServerKitAspectWidget() override; + + void makeReadOnly() override; + void refresh() override; + + QWidget *mainWidget() const override; + QWidget *buttonWidget() const override; + +private: + void autoDetectDebugger(); + void showDialog(); + + QLabel *m_label; + QPushButton *m_button; +}; + + +AndroidGdbServerKitAspect::AndroidGdbServerKitAspect() +{ + setId(AndroidGdbServerKitAspect::id()); + setDisplayName(tr("Android GDB server")); + setDescription(tr("The GDB server to use for this kit.")); setPriority(27999); // Just one less than Debugger! } -QVariant AndroidGdbServerKitInformation::defaultValue(const Kit *kit) const +QVariant AndroidGdbServerKitAspect::defaultValue(const Kit *kit) const { return autoDetect(kit).toString(); } -QList<Task> AndroidGdbServerKitInformation::validate(const Kit *) const +QList<Task> AndroidGdbServerKitAspect::validate(const Kit *) const { return QList<Task>(); } -KitInformation::ItemList AndroidGdbServerKitInformation::toUserOutput(const Kit *kit) const +bool AndroidGdbServerKitAspect::isApplicableToKit(const Kit *k) const { - return KitInformation::ItemList() - << qMakePair(tr("GDB server"), AndroidGdbServerKitInformation::gdbServer(kit).toUserOutput()); + return DeviceKitAspect::deviceId(k) == Constants::ANDROID_DEVICE_ID; } -KitConfigWidget *AndroidGdbServerKitInformation::createConfigWidget(Kit *kit) const +KitAspect::ItemList AndroidGdbServerKitAspect::toUserOutput(const Kit *kit) const { - QTC_ASSERT(kit, return nullptr); - return new AndroidGdbServerKitInformationWidget(kit, this); + return KitAspect::ItemList() + << qMakePair(tr("GDB server"), AndroidGdbServerKitAspect::gdbServer(kit).toUserOutput()); } -Core::Id AndroidGdbServerKitInformation::id() +KitAspectWidget *AndroidGdbServerKitAspect::createConfigWidget(Kit *kit) const { - return "Android.GdbServer.Information"; + QTC_ASSERT(kit, return nullptr); + return new AndroidGdbServerKitAspectWidget(kit, this); } -bool AndroidGdbServerKitInformation::isAndroidKit(const Kit *kit) +Core::Id AndroidGdbServerKitAspect::id() { - QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(kit); - ToolChain *tc = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); - if (qt && tc) - return qt->type() == QLatin1String(Constants::ANDROIDQT) - && tc->typeId() == Constants::ANDROID_TOOLCHAIN_ID; - return false; - + return "Android.GdbServer.Information"; } -FileName AndroidGdbServerKitInformation::gdbServer(const Kit *kit) +FileName AndroidGdbServerKitAspect::gdbServer(const Kit *kit) { QTC_ASSERT(kit, return FileName()); - return FileName::fromString(kit->value(AndroidGdbServerKitInformation::id()).toString()); + return FileName::fromString(kit->value(AndroidGdbServerKitAspect::id()).toString()); } -void AndroidGdbServerKitInformation::setGdbSever(Kit *kit, const FileName &gdbServerCommand) +void AndroidGdbServerKitAspect::setGdbSever(Kit *kit, const FileName &gdbServerCommand) { QTC_ASSERT(kit, return); - kit->setValue(AndroidGdbServerKitInformation::id(), gdbServerCommand.toString()); + kit->setValue(AndroidGdbServerKitAspect::id(), gdbServerCommand.toString()); } -FileName AndroidGdbServerKitInformation::autoDetect(const Kit *kit) +FileName AndroidGdbServerKitAspect::autoDetect(const Kit *kit) { - ToolChain *tc = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!tc || tc->typeId() != Constants::ANDROID_TOOLCHAIN_ID) return FileName(); auto atc = static_cast<AndroidToolChain *>(tc); @@ -116,12 +134,12 @@ FileName AndroidGdbServerKitInformation::autoDetect(const Kit *kit) } /////////////// -// AndroidGdbServerKitInformationWidget +// AndroidGdbServerKitAspectWidget /////////////// -AndroidGdbServerKitInformationWidget::AndroidGdbServerKitInformationWidget(Kit *kit, const KitInformation *ki) : - KitConfigWidget(kit, ki), +AndroidGdbServerKitAspectWidget::AndroidGdbServerKitAspectWidget(Kit *kit, const KitAspect *ki) : + KitAspectWidget(kit, ki), m_label(new ElidingLabel), m_button(new QPushButton(tr("Manage..."))) { @@ -129,62 +147,47 @@ AndroidGdbServerKitInformationWidget::AndroidGdbServerKitInformationWidget(Kit * auto buttonMenu = new QMenu(m_button); QAction *autoDetectAction = buttonMenu->addAction(tr("Auto-detect")); connect(autoDetectAction, &QAction::triggered, - this, &AndroidGdbServerKitInformationWidget::autoDetectDebugger); + this, &AndroidGdbServerKitAspectWidget::autoDetectDebugger); QAction *changeAction = buttonMenu->addAction(tr("Edit...")); connect(changeAction, &QAction::triggered, - this, &AndroidGdbServerKitInformationWidget::showDialog); + this, &AndroidGdbServerKitAspectWidget::showDialog); m_button->setMenu(buttonMenu); refresh(); } -AndroidGdbServerKitInformationWidget::~AndroidGdbServerKitInformationWidget() +AndroidGdbServerKitAspectWidget::~AndroidGdbServerKitAspectWidget() { delete m_button; delete m_label; } -QString AndroidGdbServerKitInformationWidget::displayName() const -{ - return tr("Android GDB server"); -} - -QString AndroidGdbServerKitInformationWidget::toolTip() const -{ - return tr("The GDB server to use for this kit."); -} - -void AndroidGdbServerKitInformationWidget::makeReadOnly() +void AndroidGdbServerKitAspectWidget::makeReadOnly() { m_button->setEnabled(false); } -void AndroidGdbServerKitInformationWidget::refresh() -{ - m_label->setText(AndroidGdbServerKitInformation::gdbServer(m_kit).toString()); -} - -bool AndroidGdbServerKitInformationWidget::visibleInKit() +void AndroidGdbServerKitAspectWidget::refresh() { - return DeviceKitInformation::deviceId(m_kit) == Constants::ANDROID_DEVICE_ID; + m_label->setText(AndroidGdbServerKitAspect::gdbServer(m_kit).toString()); } -QWidget *AndroidGdbServerKitInformationWidget::mainWidget() const +QWidget *AndroidGdbServerKitAspectWidget::mainWidget() const { return m_label; } -QWidget *AndroidGdbServerKitInformationWidget::buttonWidget() const +QWidget *AndroidGdbServerKitAspectWidget::buttonWidget() const { return m_button; } -void AndroidGdbServerKitInformationWidget::autoDetectDebugger() +void AndroidGdbServerKitAspectWidget::autoDetectDebugger() { - AndroidGdbServerKitInformation::setGdbSever(m_kit, AndroidGdbServerKitInformation::autoDetect(m_kit)); + AndroidGdbServerKitAspect::setGdbSever(m_kit, AndroidGdbServerKitAspect::autoDetect(m_kit)); } -void AndroidGdbServerKitInformationWidget::showDialog() +void AndroidGdbServerKitAspectWidget::showDialog() { QDialog dialog; auto layout = new QVBoxLayout(&dialog); @@ -194,7 +197,7 @@ void AndroidGdbServerKitInformationWidget::showDialog() auto binaryLabel = new QLabel(tr("&Binary:")); auto chooser = new PathChooser; chooser->setExpectedKind(PathChooser::ExistingCommand); - chooser->setPath(AndroidGdbServerKitInformation::gdbServer(m_kit).toString()); + chooser->setPath(AndroidGdbServerKitAspect::gdbServer(m_kit).toString()); binaryLabel->setBuddy(chooser); formLayout->addRow(binaryLabel, chooser); layout->addLayout(formLayout); @@ -207,7 +210,7 @@ void AndroidGdbServerKitInformationWidget::showDialog() dialog.setWindowTitle(tr("GDB Server for \"%1\"").arg(m_kit->displayName())); if (dialog.exec() == QDialog::Accepted) - AndroidGdbServerKitInformation::setGdbSever(m_kit, chooser->fileName()); + AndroidGdbServerKitAspect::setGdbSever(m_kit, chooser->fileName()); } } // namespace Internal diff --git a/src/plugins/android/androidgdbserverkitinformation.h b/src/plugins/android/androidgdbserverkitinformation.h index 8271926e30..6b9bc676d6 100644 --- a/src/plugins/android/androidgdbserverkitinformation.h +++ b/src/plugins/android/androidgdbserverkitinformation.h @@ -26,57 +26,24 @@ #pragma once #include <projectexplorer/kitinformation.h> -#include <projectexplorer/kitconfigwidget.h> - -QT_BEGIN_NAMESPACE -class QLabel; -class QPushButton; -QT_END_NAMESPACE namespace Android { namespace Internal { -class AndroidGdbServerKitInformationWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT -public: - AndroidGdbServerKitInformationWidget(ProjectExplorer::Kit *kit, - const ProjectExplorer::KitInformation *ki); - ~AndroidGdbServerKitInformationWidget() override; - - QString displayName() const override; - QString toolTip() const override; - void makeReadOnly() override; - void refresh() override; - bool visibleInKit() override; - - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - -private: - void autoDetectDebugger(); - void showDialog(); - - QLabel *m_label; - QPushButton *m_button; -}; - -class AndroidGdbServerKitInformation : public ProjectExplorer::KitInformation +class AndroidGdbServerKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - AndroidGdbServerKitInformation(); + AndroidGdbServerKitAspect(); QVariant defaultValue(const ProjectExplorer::Kit *) const override; - QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *) const override; - + bool isApplicableToKit(const ProjectExplorer::Kit *k) const override; ItemList toUserOutput(const ProjectExplorer::Kit *) const override; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *) const override; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *) const override; static Core::Id id(); - static bool isAndroidKit(const ProjectExplorer::Kit *kit); static Utils::FileName gdbServer(const ProjectExplorer::Kit *kit); static void setGdbSever(ProjectExplorer::Kit *kit, const Utils::FileName &gdbServerCommand); static Utils::FileName autoDetect(const ProjectExplorer::Kit *kit); diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp index c31302f114..eb689fdf0b 100644 --- a/src/plugins/android/androidmanager.cpp +++ b/src/plugins/android/androidmanager.cpp @@ -235,7 +235,7 @@ int AndroidManager::minimumSDK(ProjectExplorer::Target *target) int AndroidManager::minimumSDK(const ProjectExplorer::Kit *kit) { int minSDKVersion = -1; - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit); if (version && version->targetDeviceTypes().contains(Constants::ANDROID_DEVICE_TYPE)) { Utils::FileName stockManifestFilePath = Utils::FileName::fromUserInput(version->qmakeProperty("QT_INSTALL_PREFIX") + @@ -248,12 +248,6 @@ int AndroidManager::minimumSDK(const ProjectExplorer::Kit *kit) return minSDKVersion; } -int AndroidManager::minimumNDK(const Kit *kit) -{ - auto qt = static_cast<AndroidQtVersion *>(QtSupport::QtKitInformation::qtVersion(kit)); - return qt->mininmumNDK(); -} - QString AndroidManager::buildTargetSDK(ProjectExplorer::Target *target) { if (auto androidBuildApkStep = AndroidBuildApkStep::findInBuild(target->activeBuildConfiguration())) @@ -266,7 +260,7 @@ QString AndroidManager::buildTargetSDK(ProjectExplorer::Target *target) QString AndroidManager::targetArch(ProjectExplorer::Target *target) { - auto qt = static_cast<AndroidQtVersion *>(QtSupport::QtKitInformation::qtVersion(target->kit())); + auto qt = static_cast<AndroidQtVersion *>(QtSupport::QtKitAspect::qtVersion(target->kit())); return qt->targetArch(); } @@ -603,7 +597,7 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target) { - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit()); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit()); if (!version) return false; diff --git a/src/plugins/android/androidmanager.h b/src/plugins/android/androidmanager.h index e624f2dd1d..7766625c94 100644 --- a/src/plugins/android/androidmanager.h +++ b/src/plugins/android/androidmanager.h @@ -86,7 +86,6 @@ public: static int minimumSDK(ProjectExplorer::Target *target); static int minimumSDK(const ProjectExplorer::Kit *kit); - static int minimumNDK(const ProjectExplorer::Kit *kit); static QString targetArch(ProjectExplorer::Target *target); diff --git a/src/plugins/android/androidmanifesteditorwidget.cpp b/src/plugins/android/androidmanifesteditorwidget.cpp index e040c0db87..6d60a198c2 100644 --- a/src/plugins/android/androidmanifesteditorwidget.cpp +++ b/src/plugins/android/androidmanifesteditorwidget.cpp @@ -91,7 +91,7 @@ Project *androidProject(const Utils::FileName &fileName) if (!project->activeTarget()) continue; Kit *kit = project->activeTarget()->kit(); - if (DeviceTypeKitInformation::deviceTypeId(kit) == Android::Constants::ANDROID_DEVICE_TYPE + if (DeviceTypeKitAspect::deviceTypeId(kit) == Android::Constants::ANDROID_DEVICE_TYPE && fileName.isChildOf(project->projectDirectory())) return project; } @@ -492,7 +492,7 @@ void AndroidManifestEditorWidget::updateTargetComboBox() QStringList items; if (project) { Kit *kit = project->activeTarget()->kit(); - if (DeviceTypeKitInformation::deviceTypeId(kit) == Constants::ANDROID_DEVICE_TYPE) { + if (DeviceTypeKitAspect::deviceTypeId(kit) == Constants::ANDROID_DEVICE_TYPE) { ProjectNode *root = project->rootProjectNode(); root->forEachProjectNode([&items](const ProjectNode *projectNode) { items << projectNode->targetApplications(); diff --git a/src/plugins/android/androidpackageinstallationstep.cpp b/src/plugins/android/androidpackageinstallationstep.cpp index a5d81c2f87..58fb637240 100644 --- a/src/plugins/android/androidpackageinstallationstep.cpp +++ b/src/plugins/android/androidpackageinstallationstep.cpp @@ -66,7 +66,7 @@ bool AndroidPackageInstallationStep::init() if (bc->environment().searchInPath("sh.exe").isEmpty()) dirPath = QDir::toNativeSeparators(dirPath); - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), + ToolChain *tc = ToolChainKitAspect::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); ProcessParameters *pp = processParameters(); diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp index 2b19da438f..10cb97b12f 100644 --- a/src/plugins/android/androidplugin.cpp +++ b/src/plugins/android/androidplugin.cpp @@ -37,7 +37,7 @@ #include "androidpackageinstallationstep.h" #include "androidpotentialkit.h" #include "androidqmltoolingsupport.h" -#include "androidqtversionfactory.h" +#include "androidqtversion.h" #include "androidrunconfiguration.h" #include "androidruncontrol.h" #include "androidsettingspage.h" @@ -107,7 +107,7 @@ public: void handleNewTarget(Target *target) { - if (DeviceTypeKitInformation::deviceTypeId(target->kit()) != Android::Constants::ANDROID_DEVICE_TYPE) + if (DeviceTypeKitAspect::deviceTypeId(target->kit()) != Android::Constants::ANDROID_DEVICE_TYPE) return; for (BuildConfiguration *bc : target->buildConfigurations()) @@ -155,13 +155,13 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa }, [](RunConfiguration *runConfig) { return runConfig->isEnabled() && runConfig->id().name().startsWith("QmlProjectManager.QmlRunConfiguration") - && DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit()) + && DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit()) == Android::Constants::ANDROID_DEVICE_TYPE; }); d = new AndroidPluginPrivate; - KitManager::registerKitInformation<Internal::AndroidGdbServerKitInformation>(); + KitManager::registerKitAspect<Internal::AndroidGdbServerKitAspect>(); connect(KitManager::instance(), &KitManager::kitsLoaded, this, &AndroidPlugin::kitsRestored); diff --git a/src/plugins/android/androidpotentialkit.cpp b/src/plugins/android/androidpotentialkit.cpp index 8264415a12..f755551b28 100644 --- a/src/plugins/android/androidpotentialkit.cpp +++ b/src/plugins/android/androidpotentialkit.cpp @@ -68,7 +68,7 @@ bool AndroidPotentialKit::isEnabled() const { QList<ProjectExplorer::Kit *> kits = ProjectExplorer::KitManager::kits(); foreach (ProjectExplorer::Kit *kit, kits) { - Core::Id deviceId = ProjectExplorer::DeviceKitInformation::deviceId(kit); + Core::Id deviceId = ProjectExplorer::DeviceKitAspect::deviceId(kit); if (kit->isAutoDetected() && deviceId == Core::Id(Constants::ANDROID_DEVICE_ID) && !kit->isSdkProvided()) { @@ -120,7 +120,7 @@ void AndroidPotentialKitWidget::recheck() { QList<ProjectExplorer::Kit *> kits = ProjectExplorer::KitManager::kits(); foreach (ProjectExplorer::Kit *kit, kits) { - Core::Id deviceId = ProjectExplorer::DeviceKitInformation::deviceId(kit); + Core::Id deviceId = ProjectExplorer::DeviceKitAspect::deviceId(kit); if (kit->isAutoDetected() && deviceId == Core::Id(Constants::ANDROID_DEVICE_ID) && !kit->isSdkProvided()) { diff --git a/src/plugins/android/androidqtversion.cpp b/src/plugins/android/androidqtversion.cpp index 9916fc1deb..ec1291ec27 100644 --- a/src/plugins/android/androidqtversion.cpp +++ b/src/plugins/android/androidqtversion.cpp @@ -42,20 +42,16 @@ #include <proparser/profileevaluator.h> -using namespace Android::Internal; using namespace ProjectExplorer; +namespace Android { +namespace Internal { + AndroidQtVersion::AndroidQtVersion() : QtSupport::BaseQtVersion() { } -AndroidQtVersion::AndroidQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) - : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - AndroidQtVersion *AndroidQtVersion::clone() const { return new AndroidQtVersion(*this); @@ -85,7 +81,7 @@ QString AndroidQtVersion::invalidReason() const QList<Abi> AndroidQtVersion::detectQtAbis() const { - QList<Abi> abis = qtAbisFromLibrary(qtCorePaths()); + QList<Abi> abis = BaseQtVersion::detectQtAbis(); for (int i = 0; i < abis.count(); ++i) { abis[i] = Abi(abis.at(i).architecture(), abis.at(i).os(), @@ -103,7 +99,7 @@ void AndroidQtVersion::addToEnvironment(const Kit *k, Utils::Environment &env) c env.set(QLatin1String("ANDROID_NDK_HOST"), config.toolchainHost()); env.set(QLatin1String("ANDROID_NDK_ROOT"), config.ndkLocation().toUserOutput()); env.set(QLatin1String("ANDROID_NDK_PLATFORM"), - config.bestNdkPlatformMatch(qMax(AndroidManager::minimumNDK(k), AndroidManager::minimumSDK(k)))); + config.bestNdkPlatformMatch(qMax(minimumNDK(), AndroidManager::minimumSDK(k)))); } Utils::Environment AndroidQtVersion::qmakeRunEnvironment() const @@ -125,7 +121,7 @@ QString AndroidQtVersion::targetArch() const return m_targetArch; } -int AndroidQtVersion::mininmumNDK() const +int AndroidQtVersion::minimumNDK() const { ensureMkSpecParsed(); return m_minNdk; @@ -160,3 +156,22 @@ QSet<Core::Id> AndroidQtVersion::targetDeviceTypes() const { return {Constants::ANDROID_DEVICE_TYPE}; } + + +// Factory + +AndroidQtVersionFactory::AndroidQtVersionFactory() +{ + setQtVersionCreator([] { return new AndroidQtVersion; }); + setSupportedType(Constants::ANDROIDQT); + setPriority(90); + + setRestrictionChecker([](const SetupData &setup) { + return !setup.config.contains("android-no-sdk") + && (setup.config.contains("android") + || setup.platforms.contains("android")); + }); +} + +} // Internal +} // Android diff --git a/src/plugins/android/androidqtversion.h b/src/plugins/android/androidqtversion.h index d009c68ceb..5a448cf1cc 100644 --- a/src/plugins/android/androidqtversion.h +++ b/src/plugins/android/androidqtversion.h @@ -26,6 +26,7 @@ #pragma once #include <qtsupport/baseqtversion.h> +#include <qtsupport/qtversionfactory.h> #include <QCoreApplication> @@ -38,7 +39,6 @@ class AndroidQtVersion : public QtSupport::BaseQtVersion public: AndroidQtVersion(); - AndroidQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); AndroidQtVersion *clone() const override; QString type() const override; @@ -55,7 +55,8 @@ public: QString description() const override; QString targetArch() const; - int mininmumNDK() const; + int minimumNDK() const; + protected: void parseMkSpec(ProFileEvaluator *) const override; private: @@ -63,5 +64,11 @@ private: mutable int m_minNdk = -1; }; +class AndroidQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + AndroidQtVersionFactory(); +}; + } // namespace Internal } // namespace Android diff --git a/src/plugins/android/androidqtversionfactory.cpp b/src/plugins/android/androidqtversionfactory.cpp deleted file mode 100644 index 00df010def..0000000000 --- a/src/plugins/android/androidqtversionfactory.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "androidqtversionfactory.h" -#include "androidqtversion.h" -#include "androidconstants.h" -#include <qtsupport/qtsupportconstants.h> -#include <utils/qtcassert.h> -#include <proparser/profileevaluator.h> - -#include <QFileInfo> - -namespace Android { -namespace Internal { - -AndroidQtVersionFactory::AndroidQtVersionFactory(QObject *parent) - : QtSupport::QtVersionFactory(parent) -{ -} - -bool AndroidQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::ANDROIDQT); -} - -QtSupport::BaseQtVersion *AndroidQtVersionFactory::restore(const QString &type, - const QVariantMap &data) -{ - QTC_ASSERT(canRestore(type), return nullptr); - auto v = new AndroidQtVersion; - v->fromMap(data); - return v; -} - -int AndroidQtVersionFactory::priority() const -{ - return 90; -} - -QtSupport::BaseQtVersion *AndroidQtVersionFactory::create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) -{ - QFileInfo fi = qmakePath.toFileInfo(); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return nullptr; - if (!evaluator->values(QLatin1String("CONFIG")).contains(QLatin1String("android")) - && evaluator->value(QLatin1String("QMAKE_PLATFORM")) != QLatin1String("android")) - return nullptr; - if (evaluator->values(QLatin1String("CONFIG")).contains(QLatin1String("android-no-sdk"))) - return nullptr; - return new AndroidQtVersion(qmakePath, isAutoDetected, autoDetectionSource); -} - -} // Internal -} // Android diff --git a/src/plugins/android/androidqtversionfactory.h b/src/plugins/android/androidqtversionfactory.h deleted file mode 100644 index 92d2e44725..0000000000 --- a/src/plugins/android/androidqtversionfactory.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <qtsupport/qtversionfactory.h> - -namespace Android { -namespace Internal { - -class AndroidQtVersionFactory : public QtSupport::QtVersionFactory -{ -public: - explicit AndroidQtVersionFactory(QObject *parent = nullptr); - - bool canRestore(const QString &type) override; - QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data) override; - - int priority() const override; - QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, - bool isAutoDetected = false, const QString &autoDetectionSource = QString()) override; -}; - -} // namespace Internal -} // namespace Android diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index 6497f50d62..29dc0a3309 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -223,8 +223,8 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa << "Extra Start Args:" << m_amStartExtraArgs << "Before Start ADB cmds:" << m_beforeStartAdbCommands << "After finish ADB cmds:" << m_afterFinishAdbCommands; - m_gdbserverPath = AndroidGdbServerKitInformation::gdbServer(target->kit()).toString(); - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit()); + m_gdbserverPath = AndroidGdbServerKitAspect::gdbServer(target->kit()).toString(); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit()); m_useAppParamsForQmlDebugger = version->qtVersion() >= QtSupport::QtVersionNumber(5, 12); } diff --git a/src/plugins/android/createandroidmanifestwizard.cpp b/src/plugins/android/createandroidmanifestwizard.cpp index 079fd5bd64..93959e371d 100644 --- a/src/plugins/android/createandroidmanifestwizard.cpp +++ b/src/plugins/android/createandroidmanifestwizard.cpp @@ -215,7 +215,7 @@ CreateAndroidManifestWizard::CreateAndroidManifestWizard(ProjectExplorer::Target setWindowTitle(tr("Create Android Template Files Wizard")); const BuildTargetInfoList buildTargets = target->applicationTargets(); - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit()); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit()); m_copyGradle = version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0); if (buildTargets.list.isEmpty()) { @@ -319,7 +319,7 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles() return; QStringList addedFiles; - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_target->kit()); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(m_target->kit()); if (!version) return; if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) { diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index 706824566c..2b8624a834 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -64,11 +64,11 @@ void AutoTestUnitTests::initTestCase() const QList<Kit *> allKits = KitManager::kits(); if (allKits.count() != 1) QSKIP("This test requires exactly one kit to be present"); - if (auto qtVersion = QtSupport::QtKitInformation::qtVersion(allKits.first())) + if (auto qtVersion = QtSupport::QtKitAspect::qtVersion(allKits.first())) m_isQt4 = qtVersion->qtVersionString().startsWith('4'); else QSKIP("Could not figure out which Qt version is used for default kit."); - const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(), + const ToolChain * const toolchain = ToolChainKitAspect::toolChain(allKits.first(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!toolchain) QSKIP("This test requires that there is a kit with a toolchain."); diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 1f9b73e77c..6e0efcd65a 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -57,7 +57,7 @@ static bool isLocal(RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; + return DeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } static QString ensureExeEnding(const QString& file) diff --git a/src/plugins/autotest/testresultdelegate.h b/src/plugins/autotest/testresultdelegate.h index 5921ebdc92..a3b2cb7c5f 100644 --- a/src/plugins/autotest/testresultdelegate.h +++ b/src/plugins/autotest/testresultdelegate.h @@ -65,7 +65,7 @@ private: m_maxFileLength = srcModel->maxWidthOfFileName(options.font); m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font); m_realFileLength = m_maxFileLength; - m_typeAreaWidth = QFontMetrics(options.font).width("XXXXXXXX"); + m_typeAreaWidth = QFontMetrics(options.font).horizontalAdvance("XXXXXXXX"); m_indentation = options.widget ? options.widget->style()->pixelMetric( QStyle::PM_TreeViewIndentation, &options) : 0; diff --git a/src/plugins/autotest/testresultmodel.cpp b/src/plugins/autotest/testresultmodel.cpp index 99e1ee15ac..46d74064c6 100644 --- a/src/plugins/autotest/testresultmodel.cpp +++ b/src/plugins/autotest/testresultmodel.cpp @@ -305,7 +305,7 @@ void TestResultModel::recalculateMaxWidthOfFileName(const QFont &font) m_maxWidthOfFileName = 0; for (const QString &fileName : m_fileNames) { int pos = fileName.lastIndexOf('/'); - m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName.mid(pos + 1))); + m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1))); } } @@ -313,7 +313,7 @@ void TestResultModel::addFileName(const QString &fileName) { const QFontMetrics fm(m_measurementFont); int pos = fileName.lastIndexOf('/'); - m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName.mid(pos + 1))); + m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1))); m_fileNames.insert(fileName); } @@ -329,7 +329,7 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font) if (m_widthOfLineNumber == 0 || font != m_measurementFont) { QFontMetrics fm(font); m_measurementFont = font; - m_widthOfLineNumber = fm.width("88888"); + m_widthOfLineNumber = fm.horizontalAdvance("88888"); } return m_widthOfLineNumber; } diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 6792b96cb3..b19e54e4c3 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -579,7 +579,7 @@ void TestRunner::debugTests() bool useOutputProcessor = true; if (ProjectExplorer::Target *targ = config->project()->activeTarget()) { - if (Debugger::DebuggerKitInformation::engineType(targ->kit()) == Debugger::CdbEngineType) { + if (Debugger::DebuggerKitAspect::engineType(targ->kit()) == Debugger::CdbEngineType) { emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageWarn, TestRunner::tr("Unable to display test results when using CDB.")))); useOutputProcessor = false; diff --git a/src/plugins/bineditor/bineditorwidget.cpp b/src/plugins/bineditor/bineditorwidget.cpp index b27fc5de78..468e9bd0b7 100644 --- a/src/plugins/bineditor/bineditorwidget.cpp +++ b/src/plugins/bineditor/bineditorwidget.cpp @@ -185,35 +185,35 @@ void BinEditorWidget::init() m_descent = fm.descent(); m_ascent = fm.ascent(); m_lineHeight = fm.lineSpacing(); - m_charWidth = fm.width(QChar(QLatin1Char('M'))); + m_charWidth = fm.horizontalAdvance(QChar(QLatin1Char('M'))); m_margin = m_charWidth; - m_columnWidth = 2 * m_charWidth + fm.width(QChar(QLatin1Char(' '))); + m_columnWidth = 2 * m_charWidth + fm.horizontalAdvance(QChar(QLatin1Char(' '))); m_numLines = m_size / m_bytesPerLine + 1; m_numVisibleLines = viewport()->height() / m_lineHeight; m_textWidth = m_bytesPerLine * m_charWidth + m_charWidth; - int numberWidth = fm.width(QChar(QLatin1Char('9'))); + int numberWidth = fm.horizontalAdvance(QChar(QLatin1Char('9'))); m_labelWidth = 2*m_addressBytes * numberWidth + (m_addressBytes - 1)/2 * m_charWidth; int expectedCharWidth = m_columnWidth / 3; const char *hex = "0123456789abcdef"; m_isMonospacedFont = true; while (*hex) { - if (fm.width(QLatin1Char(*hex)) != expectedCharWidth) { + if (fm.horizontalAdvance(QLatin1Char(*hex)) != expectedCharWidth) { m_isMonospacedFont = false; break; } ++hex; } - if (m_isMonospacedFont && fm.width(QLatin1String("M M ")) != m_charWidth * 4) { + if (m_isMonospacedFont && fm.horizontalAdvance(QLatin1String("M M ")) != m_charWidth * 4) { // On Qt/Mac, monospace font widths may have a fractional component // This breaks the assumption that width("MMM") == width('M') * 3 m_isMonospacedFont = false; - m_columnWidth = fm.width(QLatin1String("MMM")); + m_columnWidth = fm.horizontalAdvance(QLatin1String("MMM")); m_labelWidth = m_addressBytes == 4 - ? fm.width(QLatin1String("MMMM:MMMM")) - : fm.width(QLatin1String("MMMM:MMMM:MMMM:MMMM")); + ? fm.horizontalAdvance(QLatin1String("MMMM:MMMM")) + : fm.horizontalAdvance(QLatin1String("MMMM:MMMM:MMMM:MMMM")); } horizontalScrollBar()->setRange(0, 2 * m_margin + m_bytesPerLine * m_columnWidth @@ -568,7 +568,7 @@ Utils::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEm QChar qc(QLatin1Char(dataAt(dataPos))); if (!qc.isPrint()) qc = 0xB7; - x -= fontMetrics().width(qc); + x -= fontMetrics().horizontalAdvance(qc); if (x <= 0) break; } @@ -913,18 +913,18 @@ void BinEditorWidget::paintEvent(QPaintEvent *e) if (color.isValid()) { painter.fillRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight, color); int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth - + fm.width(printable.left(c)); + + fm.horizontalAdvance(printable.left(c)); painter.fillRect(printable_item_x, y-m_ascent, - fm.width(printable.at(c)), + fm.horizontalAdvance(printable.at(c)), m_lineHeight, color); } if (!isFullySelected && pos >= selStart && pos <= selEnd) { selectionRect |= QRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight); int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth - + fm.width(printable.left(c)); + + fm.horizontalAdvance(printable.left(c)); printableSelectionRect |= QRect(printable_item_x, y-m_ascent, - fm.width(printable.at(c)), + fm.horizontalAdvance(printable.at(c)), m_lineHeight); } } @@ -958,7 +958,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e) paintCursorBorder(&painter, cursorRect); if (m_hexCursor && m_cursorVisible) { if (m_lowNibble) - cursorRect.adjust(fm.width(itemString.left(1)), 0, 0, 0); + cursorRect.adjust(fm.horizontalAdvance(itemString.left(1)), 0, 0, 0); painter.fillRect(cursorRect, Qt::red); painter.save(); painter.setClipRect(cursorRect); @@ -972,7 +972,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e) if (isFullySelected) { painter.save(); - painter.fillRect(text_x, y-m_ascent, fm.width(printable), m_lineHeight, + painter.fillRect(text_x, y-m_ascent, fm.horizontalAdvance(printable), m_lineHeight, palette().highlight()); painter.setPen(palette().highlightedText().color()); painter.drawText(text_x, y, printable); @@ -990,9 +990,9 @@ void BinEditorWidget::paintEvent(QPaintEvent *e) } if (cursor >= 0 && !printable.isEmpty()) { - QRect cursorRect(text_x + fm.width(printable.left(cursor)), + QRect cursorRect(text_x + fm.horizontalAdvance(printable.left(cursor)), y-m_ascent, - fm.width(printable.at(cursor)), + fm.horizontalAdvance(printable.at(cursor)), m_lineHeight); if (m_hexCursor || !m_cursorVisible) { paintCursorBorder(&painter, cursorRect); diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index c3b061a05b..21ed0e7090 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -119,7 +119,7 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti painter->save(); QFontMetrics fm(opt.font); - static int lwidth = fm.width(QLatin1String("8888")) + 18; + static int lwidth = fm.horizontalAdvance(QLatin1String("8888")) + 18; QColor backgroundColor; QColor textColor; @@ -155,13 +155,14 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti QString topRight = index.data(BookmarkManager::LineNumber).toString(); // Check whether we need to be fancy and paint some background - int fwidth = fm.width(topLeft); + int fwidth = fm.horizontalAdvance(topLeft); if (fwidth + lwidth > opt.rect.width()) { int left = opt.rect.right() - lwidth; painter->drawPixmap(left, opt.rect.top(), selected ? m_selectedPixmap : m_normalPixmap); } // topRight - painter->drawText(opt.rect.right() - fm.width(topRight) - 6 , 2 + opt.rect.top() + fm.ascent(), topRight); + painter->drawText(opt.rect.right() - fm.horizontalAdvance(topRight) - 6, + 2 + opt.rect.top() + fm.ascent(), topRight); // Directory QColor mix; diff --git a/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp b/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp index af8c13e76d..4811e1b543 100644 --- a/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp +++ b/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp @@ -386,14 +386,10 @@ private: static int widthLimit() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) auto screen = QGuiApplication::screenAt(QCursor::pos()); if (!screen) screen = QGuiApplication::primaryScreen(); return screen->availableGeometry().width() / 2; -#else - return QApplication::desktop()->availableGeometry(QCursor::pos()).width() / 2; -#endif } private: diff --git a/src/plugins/clangtools/clangtidyclazytool.cpp b/src/plugins/clangtools/clangtidyclazytool.cpp index 3453975a9c..5b3874b48e 100644 --- a/src/plugins/clangtools/clangtidyclazytool.cpp +++ b/src/plugins/clangtools/clangtidyclazytool.cpp @@ -423,7 +423,7 @@ void ClangTidyClazyTool::updateRunActions() Target *target = project ? project->activeTarget() : nullptr; const Core::Id cxx = ProjectExplorer::Constants::CXX_LANGUAGE_ID; bool canRun = target && project->projectLanguages().contains(cxx) - && ToolChainKitInformation::toolChain(target->kit(), cxx); + && ToolChainKitAspect::toolChain(target->kit(), cxx); if (!canRun) toolTip = tr("This is not a C++ project."); diff --git a/src/plugins/clangtools/clangtoolruncontrol.cpp b/src/plugins/clangtools/clangtoolruncontrol.cpp index 26669dce5a..2f994c3a8f 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.cpp +++ b/src/plugins/clangtools/clangtoolruncontrol.cpp @@ -258,7 +258,7 @@ void ClangToolRunControl::init() QTC_ASSERT(buildConfiguration, return); m_environment = buildConfiguration->environment(); - ToolChain *toolChain = ToolChainKitInformation::toolChain(m_target->kit(), + ToolChain *toolChain = ToolChainKitAspect::toolChain(m_target->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); QTC_ASSERT(toolChain, return); m_targetTriple = toolChain->originalTargetTriple(); diff --git a/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp b/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp index e31522f371..86dc36e186 100644 --- a/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp +++ b/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp @@ -166,7 +166,7 @@ static QList<Target *> validTargets(Project *project) return false; } - const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + const ToolChain * const toolchain = ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); QTC_ASSERT(toolchain, return false); if (Core::ICore::clangExecutable(CLANG_BINDIR).isEmpty()) { diff --git a/src/plugins/clangtools/clangtoolsunittests.cpp b/src/plugins/clangtools/clangtoolsunittests.cpp index 3e5d716116..ff1e7ab77c 100644 --- a/src/plugins/clangtools/clangtoolsunittests.cpp +++ b/src/plugins/clangtools/clangtoolsunittests.cpp @@ -58,7 +58,7 @@ void ClangToolsUnitTests::initTestCase() const QList<Kit *> allKits = KitManager::kits(); if (allKits.count() != 1) QSKIP("This test requires exactly one kit to be present"); - const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(), + const ToolChain * const toolchain = ToolChainKitAspect::toolChain(allKits.first(), Constants::CXX_LANGUAGE_ID); if (!toolchain) QSKIP("This test requires that there is a kit with a toolchain."); @@ -94,8 +94,8 @@ void ClangToolsUnitTests::testProject() QFETCH(int, expectedDiagCount); if (projectFilePath.contains("mingw")) { const ToolChain * const toolchain - = ToolChainKitInformation::toolChain(KitManager::kits().constFirst(), - Constants::CXX_LANGUAGE_ID); + = ToolChainKitAspect::toolChain(KitManager::kits().constFirst(), + Constants::CXX_LANGUAGE_ID); if (toolchain->typeId() != ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) QSKIP("This test is mingw specific, does not run for other toolchains"); } diff --git a/src/plugins/cmakeprojectmanager/builddirparameters.cpp b/src/plugins/cmakeprojectmanager/builddirparameters.cpp index f4377d42ae..144234a9bc 100644 --- a/src/plugins/cmakeprojectmanager/builddirparameters.cpp +++ b/src/plugins/cmakeprojectmanager/builddirparameters.cpp @@ -61,25 +61,25 @@ BuildDirParameters::BuildDirParameters(CMakeBuildConfiguration *bc) if (Utils::HostOsInfo::isAnyUnixHost()) environment.set("ICECC", "no"); - cmakeToolId = CMakeKitInformation::cmakeToolId(k); + cmakeToolId = CMakeKitAspect::cmakeToolId(k); - auto tc = ToolChainKitInformation::toolChain(k, Constants::CXX_LANGUAGE_ID); + auto tc = ToolChainKitAspect::toolChain(k, Constants::CXX_LANGUAGE_ID); if (tc) cxxToolChainId = tc->id(); - tc = ToolChainKitInformation::toolChain(k, Constants::C_LANGUAGE_ID); + tc = ToolChainKitAspect::toolChain(k, Constants::C_LANGUAGE_ID); if (tc) cToolChainId = tc->id(); - sysRoot = SysRootKitInformation::sysRoot(k); + sysRoot = SysRootKitAspect::sysRoot(k); expander = k->macroExpander(); configuration = bc->configurationForCMake(); - generator = CMakeGeneratorKitInformation::generator(k); - extraGenerator = CMakeGeneratorKitInformation::extraGenerator(k); - platform = CMakeGeneratorKitInformation::platform(k); - toolset = CMakeGeneratorKitInformation::toolset(k); - generatorArguments = CMakeGeneratorKitInformation::generatorArguments(k); + generator = CMakeGeneratorKitAspect::generator(k); + extraGenerator = CMakeGeneratorKitAspect::extraGenerator(k); + platform = CMakeGeneratorKitAspect::platform(k); + toolset = CMakeGeneratorKitAspect::toolset(k); + generatorArguments = CMakeGeneratorKitAspect::generatorArguments(k); } bool BuildDirParameters::isValid() const { return buildConfiguration && cmakeTool(); } diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index b518888d50..4d0261e920 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -344,7 +344,7 @@ void CMakeBuildConfiguration::setConfigurationForCMake(const CMakeConfig &config m_configurationForCMake = removeDuplicates(config); const Kit *k = target()->kit(); - CMakeConfig kitConfig = CMakeConfigurationKitInformation::configuration(k); + CMakeConfig kitConfig = CMakeConfigurationKitAspect::configuration(k); bool hasKitOverride = false; foreach (const CMakeConfigItem &i, m_configurationForCMake) { const QString b = CMakeConfigItem::expandedValueOf(k, i.key, kitConfig); @@ -364,7 +364,7 @@ void CMakeBuildConfiguration::setConfigurationForCMake(const CMakeConfig &config CMakeConfig CMakeBuildConfiguration::configurationForCMake() const { - return removeDuplicates(CMakeConfigurationKitInformation::configuration(target()->kit()) + m_configurationForCMake); + return removeDuplicates(CMakeConfigurationKitAspect::configuration(target()->kit()) + m_configurationForCMake); } void CMakeBuildConfiguration::setError(const QString &message) @@ -516,10 +516,10 @@ BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(const Kit *k, if (!buildTypeItem.isNull()) extra.configuration.append(buildTypeItem); - const QString sysRoot = SysRootKitInformation::sysRoot(k).toString(); + const QString sysRoot = SysRootKitAspect::sysRoot(k).toString(); if (!sysRoot.isEmpty()) { extra.configuration.append(CMakeConfigItem("CMAKE_SYSROOT", sysRoot.toUtf8())); - ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain( + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitAspect::toolChain( k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (tc) { const QByteArray targetTriple = tc->originalTargetTriple().toUtf8(); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp index 3ee12eeb3b..0271a02787 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp @@ -391,7 +391,7 @@ void CMakeBuildSettingsWidget::updateAdvancedCheckBox() void CMakeBuildSettingsWidget::updateFromKit() { const ProjectExplorer::Kit *k = m_buildConfiguration->target()->kit(); - const CMakeConfig config = CMakeConfigurationKitInformation::configuration(k); + const CMakeConfig config = CMakeConfigurationKitAspect::configuration(k); QHash<QString, QString> configHash; for (const CMakeConfigItem &i : config) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 40a809f581..7d2ef903c9 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -164,7 +164,7 @@ bool CMakeBuildStep::init() canInit = false; } - CMakeTool *tool = CMakeKitInformation::cmakeTool(target()->kit()); + CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit()); if (!tool || !tool->isValid()) { emit addTask(Task(Task::Error, tr("A CMake tool must be set up for building. " @@ -375,7 +375,7 @@ QString CMakeBuildStep::allArguments(const CMakeRunConfiguration *rc) const QString CMakeBuildStep::cmakeCommand() const { - CMakeTool *tool = CMakeKitInformation::cmakeTool(target()->kit()); + CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit()); return tool ? tool->cmakeExecutable().toString() : QString(); } diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp index 2a5cf769a8..6d3ef82933 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp @@ -64,7 +64,7 @@ IAssistProposal *CMakeFileCompletionAssist::perform(const AssistInterface *inter if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) { Project *p = SessionManager::projectForFile(Utils::FileName::fromString(fileName)); if (p && p->activeTarget()) { - CMakeTool *cmake = CMakeKitInformation::cmakeTool(p->activeTarget()->kit()); + CMakeTool *cmake = CMakeKitAspect::cmakeTool(p->activeTarget()->kit()); if (cmake && cmake->isValid()) kw = cmake->keywords(); } diff --git a/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp index d264f1324f..1d3f4e53cd 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp @@ -54,14 +54,14 @@ namespace CMakeProjectManager { namespace Internal { // -------------------------------------------------------------------- -// CMakeKitConfigWidget: +// CMakeKitAspectWidget: // -------------------------------------------------------------------- -CMakeKitConfigWidget::CMakeKitConfigWidget(Kit *kit, - const KitInformation *ki) : - KitConfigWidget(kit, ki), +CMakeKitAspectWidget::CMakeKitAspectWidget(Kit *kit, + const KitAspect *ki) : + KitAspectWidget(kit, ki), m_comboBox(new QComboBox), - m_manageButton(new QPushButton(KitConfigWidget::msgManage())) + m_manageButton(new QPushButton(KitAspectWidget::msgManage())) { m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); m_comboBox->setEnabled(false); @@ -74,60 +74,60 @@ CMakeKitConfigWidget::CMakeKitConfigWidget(Kit *kit, refresh(); connect(m_comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &CMakeKitConfigWidget::currentCMakeToolChanged); + this, &CMakeKitAspectWidget::currentCMakeToolChanged); m_manageButton->setContentsMargins(0, 0, 0, 0); connect(m_manageButton, &QPushButton::clicked, - this, &CMakeKitConfigWidget::manageCMakeTools); + this, &CMakeKitAspectWidget::manageCMakeTools); CMakeToolManager *cmakeMgr = CMakeToolManager::instance(); connect(cmakeMgr, &CMakeToolManager::cmakeAdded, - this, &CMakeKitConfigWidget::cmakeToolAdded); + this, &CMakeKitAspectWidget::cmakeToolAdded); connect(cmakeMgr, &CMakeToolManager::cmakeRemoved, - this, &CMakeKitConfigWidget::cmakeToolRemoved); + this, &CMakeKitAspectWidget::cmakeToolRemoved); connect(cmakeMgr, &CMakeToolManager::cmakeUpdated, - this, &CMakeKitConfigWidget::cmakeToolUpdated); + this, &CMakeKitAspectWidget::cmakeToolUpdated); } -CMakeKitConfigWidget::~CMakeKitConfigWidget() +CMakeKitAspectWidget::~CMakeKitAspectWidget() { delete m_comboBox; delete m_manageButton; } -QString CMakeKitConfigWidget::displayName() const +QString CMakeKitAspectWidget::displayName() const { return tr("CMake Tool"); } -void CMakeKitConfigWidget::makeReadOnly() +void CMakeKitAspectWidget::makeReadOnly() { m_comboBox->setEnabled(false); } -void CMakeKitConfigWidget::refresh() +void CMakeKitAspectWidget::refresh() { - CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit); m_comboBox->setCurrentIndex(tool ? indexOf(tool->id()) : -1); } -QWidget *CMakeKitConfigWidget::mainWidget() const +QWidget *CMakeKitAspectWidget::mainWidget() const { return m_comboBox; } -QWidget *CMakeKitConfigWidget::buttonWidget() const +QWidget *CMakeKitAspectWidget::buttonWidget() const { return m_manageButton; } -QString CMakeKitConfigWidget::toolTip() const +QString CMakeKitAspectWidget::toolTip() const { return tr("The CMake Tool to use when building a project with CMake.<br>" "This setting is ignored when using other build systems."); } -int CMakeKitConfigWidget::indexOf(const Core::Id &id) +int CMakeKitAspectWidget::indexOf(const Core::Id &id) { for (int i = 0; i < m_comboBox->count(); ++i) { if (id == Core::Id::fromSetting(m_comboBox->itemData(i))) @@ -136,7 +136,7 @@ int CMakeKitConfigWidget::indexOf(const Core::Id &id) return -1; } -void CMakeKitConfigWidget::cmakeToolAdded(const Core::Id &id) +void CMakeKitAspectWidget::cmakeToolAdded(const Core::Id &id) { const CMakeTool *tool = CMakeToolManager::findById(id); QTC_ASSERT(tool, return); @@ -146,7 +146,7 @@ void CMakeKitConfigWidget::cmakeToolAdded(const Core::Id &id) refresh(); } -void CMakeKitConfigWidget::cmakeToolUpdated(const Core::Id &id) +void CMakeKitAspectWidget::cmakeToolUpdated(const Core::Id &id) { const int pos = indexOf(id); QTC_ASSERT(pos >= 0, return); @@ -157,7 +157,7 @@ void CMakeKitConfigWidget::cmakeToolUpdated(const Core::Id &id) m_comboBox->setItemText(pos, tool->displayName()); } -void CMakeKitConfigWidget::cmakeToolRemoved(const Core::Id &id) +void CMakeKitAspectWidget::cmakeToolRemoved(const Core::Id &id) { const int pos = indexOf(id); QTC_ASSERT(pos >= 0, return); @@ -172,7 +172,7 @@ void CMakeKitConfigWidget::cmakeToolRemoved(const Core::Id &id) refresh(); } -void CMakeKitConfigWidget::updateComboBox() +void CMakeKitAspectWidget::updateComboBox() { // remove unavailable cmake tool: int pos = indexOf(Core::Id()); @@ -188,29 +188,29 @@ void CMakeKitConfigWidget::updateComboBox() } } -void CMakeKitConfigWidget::currentCMakeToolChanged(int index) +void CMakeKitAspectWidget::currentCMakeToolChanged(int index) { if (m_removingItem) return; const Core::Id id = Core::Id::fromSetting(m_comboBox->itemData(index)); - CMakeKitInformation::setCMakeTool(m_kit, id); + CMakeKitAspect::setCMakeTool(m_kit, id); } -void CMakeKitConfigWidget::manageCMakeTools() +void CMakeKitAspectWidget::manageCMakeTools() { Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID, buttonWidget()); } // -------------------------------------------------------------------- -// CMakeGeneratorKitConfigWidget: +// CMakeGeneratorKitAspectWidget: // -------------------------------------------------------------------- -CMakeGeneratorKitConfigWidget::CMakeGeneratorKitConfigWidget(Kit *kit, - const KitInformation *ki) : - KitConfigWidget(kit, ki), +CMakeGeneratorKitAspectWidget::CMakeGeneratorKitAspectWidget(Kit *kit, + const KitAspect *ki) : + KitAspectWidget(kit, ki), m_label(new QLabel), m_changeButton(new QPushButton) { @@ -219,39 +219,39 @@ CMakeGeneratorKitConfigWidget::CMakeGeneratorKitConfigWidget(Kit *kit, refresh(); connect(m_changeButton, &QPushButton::clicked, - this, &CMakeGeneratorKitConfigWidget::changeGenerator); + this, &CMakeGeneratorKitAspectWidget::changeGenerator); } -CMakeGeneratorKitConfigWidget::~CMakeGeneratorKitConfigWidget() +CMakeGeneratorKitAspectWidget::~CMakeGeneratorKitAspectWidget() { delete m_label; delete m_changeButton; } -QString CMakeGeneratorKitConfigWidget::displayName() const +QString CMakeGeneratorKitAspectWidget::displayName() const { return tr("CMake generator"); } -void CMakeGeneratorKitConfigWidget::makeReadOnly() +void CMakeGeneratorKitAspectWidget::makeReadOnly() { m_changeButton->setEnabled(false); } -void CMakeGeneratorKitConfigWidget::refresh() +void CMakeGeneratorKitAspectWidget::refresh() { if (m_ignoreChange) return; - CMakeTool *const tool = CMakeKitInformation::cmakeTool(m_kit); + CMakeTool *const tool = CMakeKitAspect::cmakeTool(m_kit); if (tool != m_currentTool) m_currentTool = tool; m_changeButton->setEnabled(m_currentTool); - const QString generator = CMakeGeneratorKitInformation::generator(kit()); - const QString extraGenerator = CMakeGeneratorKitInformation::extraGenerator(kit()); - const QString platform = CMakeGeneratorKitInformation::platform(kit()); - const QString toolset = CMakeGeneratorKitInformation::toolset(kit()); + const QString generator = CMakeGeneratorKitAspect::generator(kit()); + const QString extraGenerator = CMakeGeneratorKitAspect::extraGenerator(kit()); + const QString platform = CMakeGeneratorKitAspect::platform(kit()); + const QString toolset = CMakeGeneratorKitAspect::toolset(kit()); const QString message = tr("%1 - %2, Platform: %3, Toolset: %4") .arg(extraGenerator.isEmpty() ? tr("<none>") : extraGenerator) @@ -261,23 +261,23 @@ void CMakeGeneratorKitConfigWidget::refresh() m_label->setText(message); } -QWidget *CMakeGeneratorKitConfigWidget::mainWidget() const +QWidget *CMakeGeneratorKitAspectWidget::mainWidget() const { return m_label; } -QWidget *CMakeGeneratorKitConfigWidget::buttonWidget() const +QWidget *CMakeGeneratorKitAspectWidget::buttonWidget() const { return m_changeButton; } -QString CMakeGeneratorKitConfigWidget::toolTip() const +QString CMakeGeneratorKitAspectWidget::toolTip() const { return tr("CMake generator defines how a project is built when using CMake.<br>" "This setting is ignored when using other build systems."); } -void CMakeGeneratorKitConfigWidget::changeGenerator() +void CMakeGeneratorKitAspectWidget::changeGenerator() { QPointer<QDialog> changeDialog = new QDialog(m_changeButton); @@ -352,12 +352,12 @@ void CMakeGeneratorKitConfigWidget::changeGenerator() toolsetEdit->setEnabled(it->supportsToolset); }; - updateDialog(CMakeGeneratorKitInformation::generator(kit())); + updateDialog(CMakeGeneratorKitAspect::generator(kit())); - generatorCombo->setCurrentText(CMakeGeneratorKitInformation::generator(kit())); - extraGeneratorCombo->setCurrentText(CMakeGeneratorKitInformation::extraGenerator(kit())); - platformEdit->setText(platformEdit->isEnabled() ? CMakeGeneratorKitInformation::platform(kit()) : QLatin1String("<unsupported>")); - toolsetEdit->setText(toolsetEdit->isEnabled() ? CMakeGeneratorKitInformation::toolset(kit()) : QLatin1String("<unsupported>")); + generatorCombo->setCurrentText(CMakeGeneratorKitAspect::generator(kit())); + extraGeneratorCombo->setCurrentText(CMakeGeneratorKitAspect::extraGenerator(kit())); + platformEdit->setText(platformEdit->isEnabled() ? CMakeGeneratorKitAspect::platform(kit()) : QLatin1String("<unsupported>")); + toolsetEdit->setText(toolsetEdit->isEnabled() ? CMakeGeneratorKitAspect::toolset(kit()) : QLatin1String("<unsupported>")); connect(generatorCombo, &QComboBox::currentTextChanged, updateDialog); @@ -365,7 +365,7 @@ void CMakeGeneratorKitConfigWidget::changeGenerator() if (!changeDialog) return; - CMakeGeneratorKitInformation::set(kit(), generatorCombo->currentText(), + CMakeGeneratorKitAspect::set(kit(), generatorCombo->currentText(), extraGeneratorCombo->currentData().toString(), platformEdit->isEnabled() ? platformEdit->text() : QString(), toolsetEdit->isEnabled() ? toolsetEdit->text() : QString()); @@ -373,58 +373,58 @@ void CMakeGeneratorKitConfigWidget::changeGenerator() } // -------------------------------------------------------------------- -// CMakeConfigurationKitConfigWidget: +// CMakeConfigurationKitAspectWidget: // -------------------------------------------------------------------- -CMakeConfigurationKitConfigWidget::CMakeConfigurationKitConfigWidget(Kit *kit, - const KitInformation *ki) : - KitConfigWidget(kit, ki), +CMakeConfigurationKitAspectWidget::CMakeConfigurationKitAspectWidget(Kit *kit, + const KitAspect *ki) : + KitAspectWidget(kit, ki), m_summaryLabel(new Utils::ElidingLabel), m_manageButton(new QPushButton) { refresh(); m_manageButton->setText(tr("Change...")); connect(m_manageButton, &QAbstractButton::clicked, - this, &CMakeConfigurationKitConfigWidget::editConfigurationChanges); + this, &CMakeConfigurationKitAspectWidget::editConfigurationChanges); } -QString CMakeConfigurationKitConfigWidget::displayName() const +QString CMakeConfigurationKitAspectWidget::displayName() const { return tr("CMake Configuration"); } -void CMakeConfigurationKitConfigWidget::makeReadOnly() +void CMakeConfigurationKitAspectWidget::makeReadOnly() { m_manageButton->setEnabled(false); if (m_dialog) m_dialog->reject(); } -void CMakeConfigurationKitConfigWidget::refresh() +void CMakeConfigurationKitAspectWidget::refresh() { - const QStringList current = CMakeConfigurationKitInformation::toStringList(kit()); + const QStringList current = CMakeConfigurationKitAspect::toStringList(kit()); m_summaryLabel->setText(current.join("; ")); if (m_editor) m_editor->setPlainText(current.join('\n')); } -QWidget *CMakeConfigurationKitConfigWidget::mainWidget() const +QWidget *CMakeConfigurationKitAspectWidget::mainWidget() const { return m_summaryLabel; } -QWidget *CMakeConfigurationKitConfigWidget::buttonWidget() const +QWidget *CMakeConfigurationKitAspectWidget::buttonWidget() const { return m_manageButton; } -QString CMakeConfigurationKitConfigWidget::toolTip() const +QString CMakeConfigurationKitAspectWidget::toolTip() const { return tr("Default configuration passed to CMake when setting up a project."); } -void CMakeConfigurationKitConfigWidget::editConfigurationChanges() +void CMakeConfigurationKitAspectWidget::editConfigurationChanges() { if (m_dialog) { m_dialog->activateWindow(); @@ -458,32 +458,32 @@ void CMakeConfigurationKitConfigWidget::editConfigurationChanges() connect(buttons, &QDialogButtonBox::clicked, m_dialog, [buttons, this](QAbstractButton *button) { if (button != buttons->button(QDialogButtonBox::Reset)) return; - CMakeConfigurationKitInformation::setConfiguration(kit(), - CMakeConfigurationKitInformation::defaultConfiguration(kit())); + CMakeConfigurationKitAspect::setConfiguration(kit(), + CMakeConfigurationKitAspect::defaultConfiguration(kit())); }); - connect(m_dialog, &QDialog::accepted, this, &CMakeConfigurationKitConfigWidget::acceptChangesDialog); - connect(m_dialog, &QDialog::rejected, this, &CMakeConfigurationKitConfigWidget::closeChangesDialog); + connect(m_dialog, &QDialog::accepted, this, &CMakeConfigurationKitAspectWidget::acceptChangesDialog); + connect(m_dialog, &QDialog::rejected, this, &CMakeConfigurationKitAspectWidget::closeChangesDialog); connect(buttons->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, - this, &CMakeConfigurationKitConfigWidget::applyChanges); + this, &CMakeConfigurationKitAspectWidget::applyChanges); refresh(); m_dialog->show(); } -void CMakeConfigurationKitConfigWidget::applyChanges() +void CMakeConfigurationKitAspectWidget::applyChanges() { QTC_ASSERT(m_editor, return); - CMakeConfigurationKitInformation::fromStringList(kit(), m_editor->toPlainText().split(QLatin1Char('\n'))); + CMakeConfigurationKitAspect::fromStringList(kit(), m_editor->toPlainText().split(QLatin1Char('\n'))); } -void CMakeConfigurationKitConfigWidget::closeChangesDialog() +void CMakeConfigurationKitAspectWidget::closeChangesDialog() { m_dialog->deleteLater(); m_dialog = nullptr; m_editor = nullptr; } -void CMakeConfigurationKitConfigWidget::acceptChangesDialog() +void CMakeConfigurationKitAspectWidget::acceptChangesDialog() { applyChanges(); closeChangesDialog(); diff --git a/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h deleted file mode 100644 index 3839750f66..0000000000 --- a/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <projectexplorer/kitconfigwidget.h> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QDialog; -class QLabel; -class QPlainTextEdit; -class QPushButton; -QT_END_NAMESPACE - -namespace ProjectExplorer { - class Kit; - class KitInformation; -} // namespace ProjectExplorer - -namespace CMakeProjectManager { - -class CMakeTool; - -namespace Internal { - -// -------------------------------------------------------------------- -// CMakeKitConfigWidget: -// -------------------------------------------------------------------- - -class CMakeKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT -public: - CMakeKitConfigWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitInformation *ki); - ~CMakeKitConfigWidget() override; - - // KitConfigWidget interface - QString displayName() const override; - void makeReadOnly() override; - void refresh() override; - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString toolTip() const override; - -private: - int indexOf(const Core::Id &id); - void updateComboBox(); - void cmakeToolAdded(const Core::Id &id); - void cmakeToolUpdated(const Core::Id &id); - void cmakeToolRemoved(const Core::Id &id); - void currentCMakeToolChanged(int index); - void manageCMakeTools(); - - bool m_removingItem = false; - QComboBox *m_comboBox; - QPushButton *m_manageButton; -}; - -// -------------------------------------------------------------------- -// CMakeGeneratorKitConfigWidget: -// -------------------------------------------------------------------- - -class CMakeGeneratorKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT -public: - CMakeGeneratorKitConfigWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitInformation *ki); - ~CMakeGeneratorKitConfigWidget() override; - - // KitConfigWidget interface - QString displayName() const override; - void makeReadOnly() override; - void refresh() override; - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString toolTip() const override; - -private: - void changeGenerator(); - - bool m_ignoreChange = false; - QLabel *m_label; - QPushButton *m_changeButton; - CMakeTool *m_currentTool = nullptr; -}; - -// -------------------------------------------------------------------- -// CMakeConfigurationKitConfigWidget: -// -------------------------------------------------------------------- - -class CMakeConfigurationKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT -public: - CMakeConfigurationKitConfigWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitInformation *ki); - - // KitConfigWidget interface - QString displayName() const override; - void makeReadOnly() override; - void refresh() override; - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString toolTip() const override; - -private: - void editConfigurationChanges(); - - void applyChanges(); - void closeChangesDialog(); - void acceptChangesDialog(); - - QLabel *m_summaryLabel; - QPushButton *m_manageButton; - QDialog *m_dialog = nullptr; - QPlainTextEdit *m_editor = nullptr; -}; - -} // namespace Internal -} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp index 4dc49ce630..e56cf7c4bf 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp @@ -24,12 +24,13 @@ ****************************************************************************/ #include "cmakekitinformation.h" -#include "cmakekitconfigwidget.h" #include "cmakeprojectconstants.h" #include "cmaketoolmanager.h" #include "cmaketool.h" #include <app/app_version.h> +#include <coreplugin/icore.h> +#include <coreplugin/variablechooser.h> #include <projectexplorer/task.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/kit.h> @@ -37,18 +38,28 @@ #include <qtsupport/baseqtversion.h> #include <qtsupport/qtkitinformation.h> #include <projectexplorer/projectexplorerconstants.h> - #include <utils/algorithm.h> +#include <utils/elidinglabel.h> #include <utils/environment.h> #include <utils/qtcassert.h> +#include <QComboBox> +#include <QDialog> +#include <QDialogButtonBox> +#include <QGridLayout> +#include <QLabel> +#include <QLineEdit> +#include <QPlainTextEdit> +#include <QPointer> +#include <QPushButton> #include <QVariant> using namespace ProjectExplorer; namespace CMakeProjectManager { +namespace Internal { // -------------------------------------------------------------------- -// CMakeKitInformation: +// CMakeKitAspect: // -------------------------------------------------------------------- static Core::Id defaultCMakeToolId() @@ -59,14 +70,145 @@ static Core::Id defaultCMakeToolId() static const char TOOL_ID[] = "CMakeProjectManager.CMakeKitInformation"; -// -------------------------------------------------------------------- -// CMakeKitInformation: -// -------------------------------------------------------------------- +class CMakeKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeKitAspect) +public: + CMakeKitAspectWidget(Kit *kit, const KitAspect *ki) : KitAspectWidget(kit, ki), + m_comboBox(new QComboBox), + m_manageButton(new QPushButton(KitAspectWidget::msgManage())) + { + m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); + m_comboBox->setEnabled(false); + m_comboBox->setToolTip(ki->description()); + + foreach (CMakeTool *tool, CMakeToolManager::cmakeTools()) + cmakeToolAdded(tool->id()); + + updateComboBox(); + refresh(); + connect(m_comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &CMakeKitAspectWidget::currentCMakeToolChanged); + + m_manageButton->setContentsMargins(0, 0, 0, 0); + connect(m_manageButton, &QPushButton::clicked, + this, &CMakeKitAspectWidget::manageCMakeTools); + + CMakeToolManager *cmakeMgr = CMakeToolManager::instance(); + connect(cmakeMgr, &CMakeToolManager::cmakeAdded, + this, &CMakeKitAspectWidget::cmakeToolAdded); + connect(cmakeMgr, &CMakeToolManager::cmakeRemoved, + this, &CMakeKitAspectWidget::cmakeToolRemoved); + connect(cmakeMgr, &CMakeToolManager::cmakeUpdated, + this, &CMakeKitAspectWidget::cmakeToolUpdated); + } + + ~CMakeKitAspectWidget() override + { + delete m_comboBox; + delete m_manageButton; + } + +private: + // KitAspectWidget interface + void makeReadOnly() override { m_comboBox->setEnabled(false); } + QWidget *mainWidget() const override { return m_comboBox; } + QWidget *buttonWidget() const override { return m_manageButton; } + + void refresh() override + { + CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit); + m_comboBox->setCurrentIndex(tool ? indexOf(tool->id()) : -1); + } + + int indexOf(const Core::Id &id) + { + for (int i = 0; i < m_comboBox->count(); ++i) { + if (id == Core::Id::fromSetting(m_comboBox->itemData(i))) + return i; + } + return -1; + } + + void updateComboBox() + { + // remove unavailable cmake tool: + int pos = indexOf(Core::Id()); + if (pos >= 0) + m_comboBox->removeItem(pos); + + if (m_comboBox->count() == 0) { + m_comboBox->addItem(tr("<No CMake Tool available>"), + Core::Id().toSetting()); + m_comboBox->setEnabled(false); + } else { + m_comboBox->setEnabled(true); + } + } + + void cmakeToolAdded(const Core::Id &id) + { + const CMakeTool *tool = CMakeToolManager::findById(id); + QTC_ASSERT(tool, return); + + m_comboBox->addItem(tool->displayName(), tool->id().toSetting()); + updateComboBox(); + refresh(); + } + + void cmakeToolUpdated(const Core::Id &id) + { + const int pos = indexOf(id); + QTC_ASSERT(pos >= 0, return); + + const CMakeTool *tool = CMakeToolManager::findById(id); + QTC_ASSERT(tool, return); + + m_comboBox->setItemText(pos, tool->displayName()); + } + + void cmakeToolRemoved(const Core::Id &id) + { + const int pos = indexOf(id); + QTC_ASSERT(pos >= 0, return); + + // do not handle the current index changed signal + m_removingItem = true; + m_comboBox->removeItem(pos); + m_removingItem = false; + + // update the checkbox and set the current index + updateComboBox(); + refresh(); + } + + void currentCMakeToolChanged(int index) + { + if (m_removingItem) + return; + + const Core::Id id = Core::Id::fromSetting(m_comboBox->itemData(index)); + CMakeKitAspect::setCMakeTool(m_kit, id); + } + + void manageCMakeTools() + { + Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID, + buttonWidget()); + } + + bool m_removingItem = false; + QComboBox *m_comboBox; + QPushButton *m_manageButton; +}; -CMakeKitInformation::CMakeKitInformation() +CMakeKitAspect::CMakeKitAspect() { - setObjectName(QLatin1String("CMakeKitInformation")); + setObjectName(QLatin1String("CMakeKitAspect")); setId(TOOL_ID); + setDisplayName(tr("CMake Tool")); + setDescription(tr("The CMake Tool to use when building a project with CMake.<br>" + "This setting is ignored when using other build systems.")); setPriority(20000); //make sure the default value is set if a selected CMake is removed @@ -78,24 +220,24 @@ CMakeKitInformation::CMakeKitInformation() [this]() { foreach (Kit *k, KitManager::kits()) fix(k); }); } -Core::Id CMakeKitInformation::id() +Core::Id CMakeKitAspect::id() { return TOOL_ID; } -Core::Id CMakeKitInformation::cmakeToolId(const Kit *k) +Core::Id CMakeKitAspect::cmakeToolId(const Kit *k) { if (!k) return {}; return Core::Id::fromSetting(k->value(TOOL_ID)); } -CMakeTool *CMakeKitInformation::cmakeTool(const Kit *k) +CMakeTool *CMakeKitAspect::cmakeTool(const Kit *k) { return CMakeToolManager::findById(cmakeToolId(k)); } -void CMakeKitInformation::setCMakeTool(Kit *k, const Core::Id id) +void CMakeKitAspect::setCMakeTool(Kit *k, const Core::Id id) { const Core::Id toSet = id.isValid() ? id : defaultCMakeToolId(); QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(toSet), return); @@ -103,16 +245,16 @@ void CMakeKitInformation::setCMakeTool(Kit *k, const Core::Id id) k->setValue(TOOL_ID, toSet.toSetting()); } -QVariant CMakeKitInformation::defaultValue(const Kit *k) const +QVariant CMakeKitAspect::defaultValue(const Kit *k) const { const Core::Id id = k ? defaultCMakeToolId() : Core::Id(); return id.toSetting(); } -QList<Task> CMakeKitInformation::validate(const Kit *k) const +QList<Task> CMakeKitAspect::validate(const Kit *k) const { QList<Task> result; - CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + CMakeTool *tool = CMakeKitAspect::cmakeTool(k); if (tool) { CMakeTool::Version version = tool->version(); if (version.major < 3) { @@ -124,42 +266,42 @@ QList<Task> CMakeKitInformation::validate(const Kit *k) const return result; } -void CMakeKitInformation::setup(Kit *k) +void CMakeKitAspect::setup(Kit *k) { - CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + CMakeTool *tool = CMakeKitAspect::cmakeTool(k); if (!tool) setCMakeTool(k, defaultCMakeToolId()); } -void CMakeKitInformation::fix(Kit *k) +void CMakeKitAspect::fix(Kit *k) { - if (!CMakeKitInformation::cmakeTool(k)) + if (!CMakeKitAspect::cmakeTool(k)) setup(k); } -KitInformation::ItemList CMakeKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList CMakeKitAspect::toUserOutput(const Kit *k) const { const CMakeTool *const tool = cmakeTool(k); return ItemList() << qMakePair(tr("CMake"), tool ? tool->displayName() : tr("Unconfigured")); } -KitConfigWidget *CMakeKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *CMakeKitAspect::createConfigWidget(Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::CMakeKitConfigWidget(k, this); + return new CMakeKitAspectWidget(k, this); } -void CMakeKitInformation::addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const +void CMakeKitAspect::addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const { QTC_ASSERT(k, return); expander->registerFileVariables("CMake:Executable", tr("Path to the cmake executable"), [k]() -> QString { - CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + CMakeTool *tool = CMakeKitAspect::cmakeTool(k); return tool ? tool->cmakeExecutable().toString() : QString(); }); } -QSet<Core::Id> CMakeKitInformation::availableFeatures(const Kit *k) const +QSet<Core::Id> CMakeKitAspect::availableFeatures(const Kit *k) const { if (cmakeTool(k)) return { CMakeProjectManager::Constants::CMAKE_FEATURE_ID }; @@ -167,7 +309,7 @@ QSet<Core::Id> CMakeKitInformation::availableFeatures(const Kit *k) const } // -------------------------------------------------------------------- -// CMakeGeneratorKitInformation: +// CMakeGeneratorKitAspect: // -------------------------------------------------------------------- static const char GENERATOR_ID[] = "CMake.GeneratorKitInformation"; @@ -177,6 +319,158 @@ static const char EXTRA_GENERATOR_KEY[] = "ExtraGenerator"; static const char PLATFORM_KEY[] = "Platform"; static const char TOOLSET_KEY[] = "Toolset"; +class CMakeGeneratorKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeGeneratorKitAspect) +public: + CMakeGeneratorKitAspectWidget(Kit *kit, const ::KitAspect *ki) + : KitAspectWidget(kit, ki), + m_label(new QLabel), + m_changeButton(new QPushButton) + { + m_label->setToolTip(ki->description()); + m_changeButton->setText(tr("Change...")); + refresh(); + connect(m_changeButton, &QPushButton::clicked, + this, &CMakeGeneratorKitAspectWidget::changeGenerator); + } + + ~CMakeGeneratorKitAspectWidget() override + { + delete m_label; + delete m_changeButton; + } + +private: + // KitAspectWidget interface + void makeReadOnly() override { m_changeButton->setEnabled(false); } + QWidget *mainWidget() const override { return m_label; } + QWidget *buttonWidget() const override { return m_changeButton; } + + void refresh() override + { + if (m_ignoreChange) + return; + + CMakeTool *const tool = CMakeKitAspect::cmakeTool(m_kit); + if (tool != m_currentTool) + m_currentTool = tool; + + m_changeButton->setEnabled(m_currentTool); + const QString generator = CMakeGeneratorKitAspect::generator(kit()); + const QString extraGenerator = CMakeGeneratorKitAspect::extraGenerator(kit()); + const QString platform = CMakeGeneratorKitAspect::platform(kit()); + const QString toolset = CMakeGeneratorKitAspect::toolset(kit()); + + const QString message = tr("%1 - %2, Platform: %3, Toolset: %4") + .arg(extraGenerator.isEmpty() ? tr("<none>") : extraGenerator) + .arg(generator.isEmpty() ? tr("<none>") : generator) + .arg(platform.isEmpty() ? tr("<none>") : platform) + .arg(toolset.isEmpty() ? tr("<none>") : toolset); + m_label->setText(message); + } + + void changeGenerator() + { + QPointer<QDialog> changeDialog = new QDialog(m_changeButton); + + // Disable help button in titlebar on windows: + Qt::WindowFlags flags = changeDialog->windowFlags(); + flags &= ~Qt::WindowContextHelpButtonHint; + flags |= Qt::MSWindowsFixedSizeDialogHint; + changeDialog->setWindowFlags(flags); + + changeDialog->setWindowTitle(tr("CMake Generator")); + + auto *layout = new QGridLayout(changeDialog); + layout->setSizeConstraint(QLayout::SetFixedSize); + + auto *cmakeLabel = new QLabel; + cmakeLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + auto *generatorCombo = new QComboBox; + auto *extraGeneratorCombo = new QComboBox; + auto *platformEdit = new QLineEdit; + auto *toolsetEdit = new QLineEdit; + + int row = 0; + layout->addWidget(new QLabel(QLatin1String("Executable:"))); + layout->addWidget(cmakeLabel, row, 1); + + ++row; + layout->addWidget(new QLabel(tr("Generator:")), row, 0); + layout->addWidget(generatorCombo, row, 1); + + ++row; + layout->addWidget(new QLabel(tr("Extra generator:")), row, 0); + layout->addWidget(extraGeneratorCombo, row, 1); + + ++row; + layout->addWidget(new QLabel(tr("Platform:")), row, 0); + layout->addWidget(platformEdit, row, 1); + + ++row; + layout->addWidget(new QLabel(tr("Toolset:")), row, 0); + layout->addWidget(toolsetEdit, row, 1); + + ++row; + auto *bb = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); + layout->addWidget(bb, row, 0, 1, 2); + + connect(bb, &QDialogButtonBox::accepted, changeDialog.data(), &QDialog::accept); + connect(bb, &QDialogButtonBox::rejected, changeDialog.data(), &QDialog::reject); + + cmakeLabel->setText(m_currentTool->cmakeExecutable().toUserOutput()); + + QList<CMakeTool::Generator> generatorList = m_currentTool->supportedGenerators(); + Utils::sort(generatorList, &CMakeTool::Generator::name); + + for (auto it = generatorList.constBegin(); it != generatorList.constEnd(); ++it) + generatorCombo->addItem(it->name); + + auto updateDialog = [&generatorList, generatorCombo, extraGeneratorCombo, + platformEdit, toolsetEdit](const QString &name) { + auto it = std::find_if(generatorList.constBegin(), generatorList.constEnd(), + [name](const CMakeTool::Generator &g) { return g.name == name; }); + QTC_ASSERT(it != generatorList.constEnd(), return); + generatorCombo->setCurrentText(name); + + extraGeneratorCombo->clear(); + extraGeneratorCombo->addItem(tr("<none>"), QString()); + foreach (const QString &eg, it->extraGenerators) + extraGeneratorCombo->addItem(eg, eg); + extraGeneratorCombo->setEnabled(extraGeneratorCombo->count() > 1); + + platformEdit->setEnabled(it->supportsPlatform); + toolsetEdit->setEnabled(it->supportsToolset); + }; + + updateDialog(CMakeGeneratorKitAspect::generator(kit())); + + generatorCombo->setCurrentText(CMakeGeneratorKitAspect::generator(kit())); + extraGeneratorCombo->setCurrentText(CMakeGeneratorKitAspect::extraGenerator(kit())); + platformEdit->setText(platformEdit->isEnabled() ? CMakeGeneratorKitAspect::platform(kit()) : QLatin1String("<unsupported>")); + toolsetEdit->setText(toolsetEdit->isEnabled() ? CMakeGeneratorKitAspect::toolset(kit()) : QLatin1String("<unsupported>")); + + connect(generatorCombo, &QComboBox::currentTextChanged, updateDialog); + + if (changeDialog->exec() == QDialog::Accepted) { + if (!changeDialog) + return; + + CMakeGeneratorKitAspect::set(kit(), generatorCombo->currentText(), + extraGeneratorCombo->currentData().toString(), + platformEdit->isEnabled() ? platformEdit->text() : QString(), + toolsetEdit->isEnabled() ? toolsetEdit->text() : QString()); + } + } + + bool m_ignoreChange = false; + QLabel *m_label; + QPushButton *m_changeButton; + CMakeTool *m_currentTool = nullptr; +}; + namespace { struct GeneratorInfo { @@ -222,62 +516,65 @@ static void setGeneratorInfo(Kit *k, const GeneratorInfo &info) k->setValue(GENERATOR_ID, info.toVariant()); } -CMakeGeneratorKitInformation::CMakeGeneratorKitInformation() +CMakeGeneratorKitAspect::CMakeGeneratorKitAspect() { - setObjectName(QLatin1String("CMakeGeneratorKitInformation")); + setObjectName(QLatin1String("CMakeGeneratorKitAspect")); setId(GENERATOR_ID); + setDisplayName(tr("CMake generator")); + setDescription(tr("CMake generator defines how a project is built when using CMake.<br>" + "This setting is ignored when using other build systems.")); setPriority(19000); } -QString CMakeGeneratorKitInformation::generator(const Kit *k) +QString CMakeGeneratorKitAspect::generator(const Kit *k) { return generatorInfo(k).generator; } -QString CMakeGeneratorKitInformation::extraGenerator(const Kit *k) +QString CMakeGeneratorKitAspect::extraGenerator(const Kit *k) { return generatorInfo(k).extraGenerator; } -QString CMakeGeneratorKitInformation::platform(const Kit *k) +QString CMakeGeneratorKitAspect::platform(const Kit *k) { return generatorInfo(k).platform; } -QString CMakeGeneratorKitInformation::toolset(const Kit *k) +QString CMakeGeneratorKitAspect::toolset(const Kit *k) { return generatorInfo(k).toolset; } -void CMakeGeneratorKitInformation::setGenerator(Kit *k, const QString &generator) +void CMakeGeneratorKitAspect::setGenerator(Kit *k, const QString &generator) { GeneratorInfo info = generatorInfo(k); info.generator = generator; setGeneratorInfo(k, info); } -void CMakeGeneratorKitInformation::setExtraGenerator(Kit *k, const QString &extraGenerator) +void CMakeGeneratorKitAspect::setExtraGenerator(Kit *k, const QString &extraGenerator) { GeneratorInfo info = generatorInfo(k); info.extraGenerator = extraGenerator; setGeneratorInfo(k, info); } -void CMakeGeneratorKitInformation::setPlatform(Kit *k, const QString &platform) +void CMakeGeneratorKitAspect::setPlatform(Kit *k, const QString &platform) { GeneratorInfo info = generatorInfo(k); info.platform = platform; setGeneratorInfo(k, info); } -void CMakeGeneratorKitInformation::setToolset(Kit *k, const QString &toolset) +void CMakeGeneratorKitAspect::setToolset(Kit *k, const QString &toolset) { GeneratorInfo info = generatorInfo(k); info.toolset = toolset; setGeneratorInfo(k, info); } -void CMakeGeneratorKitInformation::set(Kit *k, +void CMakeGeneratorKitAspect::set(Kit *k, const QString &generator, const QString &extraGenerator, const QString &platform, const QString &toolset) { @@ -285,7 +582,7 @@ void CMakeGeneratorKitInformation::set(Kit *k, setGeneratorInfo(k, info); } -QStringList CMakeGeneratorKitInformation::generatorArguments(const Kit *k) +QStringList CMakeGeneratorKitAspect::generatorArguments(const Kit *k) { QStringList result; GeneratorInfo info = generatorInfo(k); @@ -307,11 +604,11 @@ QStringList CMakeGeneratorKitInformation::generatorArguments(const Kit *k) return result; } -QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const +QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const { QTC_ASSERT(k, return QVariant()); - CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + CMakeTool *tool = CMakeKitAspect::cmakeTool(k); if (!tool) return QVariant(); @@ -332,7 +629,7 @@ QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const if (Utils::HostOsInfo::isWindowsHost()) { // *sigh* Windows with its zoo of incompatible stuff again... - ToolChain *tc = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) { it = std::find_if(known.constBegin(), known.constEnd(), [extraGenerator](const CMakeTool::Generator &g) { @@ -360,9 +657,9 @@ QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const return GeneratorInfo({it->name, extraGenerator, QString(), QString()}).toVariant(); } -QList<Task> CMakeGeneratorKitInformation::validate(const Kit *k) const +QList<Task> CMakeGeneratorKitAspect::validate(const Kit *k) const { - CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + CMakeTool *tool = CMakeKitAspect::cmakeTool(k); GeneratorInfo info = generatorInfo(k); QList<Task> result; @@ -400,16 +697,16 @@ QList<Task> CMakeGeneratorKitInformation::validate(const Kit *k) const return result; } -void CMakeGeneratorKitInformation::setup(Kit *k) +void CMakeGeneratorKitAspect::setup(Kit *k) { GeneratorInfo info; info.fromVariant(defaultValue(k)); setGeneratorInfo(k, info); } -void CMakeGeneratorKitInformation::fix(Kit *k) +void CMakeGeneratorKitAspect::fix(Kit *k) { - const CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + const CMakeTool *tool = CMakeKitAspect::cmakeTool(k); const GeneratorInfo info = generatorInfo(k); if (!tool) @@ -431,7 +728,7 @@ void CMakeGeneratorKitInformation::fix(Kit *k) } } -void CMakeGeneratorKitInformation::upgrade(Kit *k) +void CMakeGeneratorKitAspect::upgrade(Kit *k) { QTC_ASSERT(k, return); @@ -450,7 +747,7 @@ void CMakeGeneratorKitInformation::upgrade(Kit *k) } } -KitInformation::ItemList CMakeGeneratorKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList CMakeGeneratorKitAspect::toUserOutput(const Kit *k) const { const GeneratorInfo info = generatorInfo(k); QString message; @@ -466,13 +763,13 @@ KitInformation::ItemList CMakeGeneratorKitInformation::toUserOutput(const Kit *k return ItemList() << qMakePair(tr("CMake Generator"), message); } -KitConfigWidget *CMakeGeneratorKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *CMakeGeneratorKitAspect::createConfigWidget(Kit *k) const { - return new Internal::CMakeGeneratorKitConfigWidget(k, this); + return new CMakeGeneratorKitAspectWidget(k, this); } // -------------------------------------------------------------------- -// CMakeConfigurationKitInformation: +// CMakeConfigurationKitAspect: // -------------------------------------------------------------------- static const char CONFIGURATION_ID[] = "CMake.ConfigurationKitInformation"; @@ -482,14 +779,122 @@ static const char CMAKE_CXX_TOOLCHAIN_KEY[] = "CMAKE_CXX_COMPILER"; static const char CMAKE_QMAKE_KEY[] = "QT_QMAKE_EXECUTABLE"; static const char CMAKE_PREFIX_PATH_KEY[] = "CMAKE_PREFIX_PATH"; -CMakeConfigurationKitInformation::CMakeConfigurationKitInformation() +class CMakeConfigurationKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeConfigurationKitAspect) +public: + CMakeConfigurationKitAspectWidget(Kit *kit, const KitAspect *ki) + : KitAspectWidget(kit, ki), + m_summaryLabel(new Utils::ElidingLabel), + m_manageButton(new QPushButton) + { + refresh(); + m_manageButton->setText(tr("Change...")); + connect(m_manageButton, &QAbstractButton::clicked, + this, &CMakeConfigurationKitAspectWidget::editConfigurationChanges); + } + +private: + // KitAspectWidget interface + QWidget *mainWidget() const override { return m_summaryLabel; } + QWidget *buttonWidget() const override { return m_manageButton; } + + void makeReadOnly() override + { + m_manageButton->setEnabled(false); + if (m_dialog) + m_dialog->reject(); + } + + void refresh() override + { + const QStringList current = CMakeConfigurationKitAspect::toStringList(kit()); + + m_summaryLabel->setText(current.join("; ")); + if (m_editor) + m_editor->setPlainText(current.join('\n')); + } + + void editConfigurationChanges() + { + if (m_dialog) { + m_dialog->activateWindow(); + m_dialog->raise(); + return; + } + + QTC_ASSERT(!m_editor, return); + + m_dialog = new QDialog(m_summaryLabel->window()); + m_dialog->setWindowTitle(tr("Edit CMake Configuration")); + auto layout = new QVBoxLayout(m_dialog); + m_editor = new QPlainTextEdit; + m_editor->setToolTip(tr("Enter one variable per line with the variable name " + "separated from the variable value by \"=\".<br>" + "You may provide a type hint by adding \":TYPE\" before the \"=\".")); + m_editor->setMinimumSize(800, 200); + + auto chooser = new Core::VariableChooser(m_dialog); + chooser->addSupportedWidget(m_editor); + chooser->addMacroExpanderProvider([this]() { return kit()->macroExpander(); }); + + auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Apply + |QDialogButtonBox::Reset|QDialogButtonBox::Cancel); + + layout->addWidget(m_editor); + layout->addWidget(buttons); + + connect(buttons, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, m_dialog, &QDialog::reject); + connect(buttons, &QDialogButtonBox::clicked, m_dialog, [buttons, this](QAbstractButton *button) { + if (button != buttons->button(QDialogButtonBox::Reset)) + return; + CMakeConfigurationKitAspect::setConfiguration(kit(), + CMakeConfigurationKitAspect::defaultConfiguration(kit())); + }); + connect(m_dialog, &QDialog::accepted, this, &CMakeConfigurationKitAspectWidget::acceptChangesDialog); + connect(m_dialog, &QDialog::rejected, this, &CMakeConfigurationKitAspectWidget::closeChangesDialog); + connect(buttons->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, + this, &CMakeConfigurationKitAspectWidget::applyChanges); + + refresh(); + m_dialog->show(); + } + + void applyChanges() + { + QTC_ASSERT(m_editor, return); + CMakeConfigurationKitAspect::fromStringList(kit(), m_editor->toPlainText().split(QLatin1Char('\n'))); + } + void closeChangesDialog() + { + m_dialog->deleteLater(); + m_dialog = nullptr; + m_editor = nullptr; + } + void acceptChangesDialog() + { + applyChanges(); + closeChangesDialog(); + } + + QLabel *m_summaryLabel; + QPushButton *m_manageButton; + QDialog *m_dialog = nullptr; + QPlainTextEdit *m_editor = nullptr; +}; + + +CMakeConfigurationKitAspect::CMakeConfigurationKitAspect() { - setObjectName(QLatin1String("CMakeConfigurationKitInformation")); + setObjectName(QLatin1String("CMakeConfigurationKitAspect")); setId(CONFIGURATION_ID); + setDisplayName(tr("CMake Configuration")); + setDescription(tr("Default configuration passed to CMake when setting up a project.")); setPriority(18000); } -CMakeConfig CMakeConfigurationKitInformation::configuration(const Kit *k) +CMakeConfig CMakeConfigurationKitAspect::configuration(const Kit *k) { if (!k) return CMakeConfig(); @@ -497,7 +902,7 @@ CMakeConfig CMakeConfigurationKitInformation::configuration(const Kit *k) return Utils::transform(tmp, &CMakeConfigItem::fromString); } -void CMakeConfigurationKitInformation::setConfiguration(Kit *k, const CMakeConfig &config) +void CMakeConfigurationKitAspect::setConfiguration(Kit *k, const CMakeConfig &config) { if (!k) return; @@ -505,17 +910,17 @@ void CMakeConfigurationKitInformation::setConfiguration(Kit *k, const CMakeConfi k->setValue(CONFIGURATION_ID, tmp); } -QStringList CMakeConfigurationKitInformation::toStringList(const Kit *k) +QStringList CMakeConfigurationKitAspect::toStringList(const Kit *k) { QStringList current - = Utils::transform(CMakeConfigurationKitInformation::configuration(k), + = Utils::transform(CMakeConfigurationKitAspect::configuration(k), [](const CMakeConfigItem &i) { return i.toString(); }); current = Utils::filtered(current, [](const QString &s) { return !s.isEmpty(); }); Utils::sort(current); return current; } -void CMakeConfigurationKitInformation::fromStringList(Kit *k, const QStringList &in) +void CMakeConfigurationKitAspect::fromStringList(Kit *k, const QStringList &in) { CMakeConfig result; foreach (const QString &s, in) { @@ -526,7 +931,7 @@ void CMakeConfigurationKitInformation::fromStringList(Kit *k, const QStringList setConfiguration(k, result); } -CMakeConfig CMakeConfigurationKitInformation::defaultConfiguration(const Kit *k) +CMakeConfig CMakeConfigurationKitAspect::defaultConfiguration(const Kit *k) { Q_UNUSED(k); CMakeConfig config; @@ -541,7 +946,7 @@ CMakeConfig CMakeConfigurationKitInformation::defaultConfiguration(const Kit *k) return config; } -QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const +QVariant CMakeConfigurationKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k); @@ -552,13 +957,13 @@ QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const return tmp; } -QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const +QList<Task> CMakeConfigurationKitAspect::validate(const Kit *k) const { QTC_ASSERT(k, return QList<Task>()); - const QtSupport::BaseQtVersion *const version = QtSupport::QtKitInformation::qtVersion(k); - const ToolChain *const tcC = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID); - const ToolChain *const tcCxx = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + const QtSupport::BaseQtVersion *const version = QtSupport::QtKitAspect::qtVersion(k); + const ToolChain *const tcC = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID); + const ToolChain *const tcCxx = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); const CMakeConfig config = configuration(k); const bool isQt4 = version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0); @@ -650,28 +1055,29 @@ QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const return result; } -void CMakeConfigurationKitInformation::setup(Kit *k) +void CMakeConfigurationKitAspect::setup(Kit *k) { if (k && !k->hasValue(CONFIGURATION_ID)) k->setValue(CONFIGURATION_ID, defaultValue(k)); } -void CMakeConfigurationKitInformation::fix(Kit *k) +void CMakeConfigurationKitAspect::fix(Kit *k) { Q_UNUSED(k); } -KitInformation::ItemList CMakeConfigurationKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList CMakeConfigurationKitAspect::toUserOutput(const Kit *k) const { const QStringList current = toStringList(k); return ItemList() << qMakePair(tr("CMake Configuration"), current.join(QLatin1String("<br>"))); } -KitConfigWidget *CMakeConfigurationKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *CMakeConfigurationKitAspect::createConfigWidget(Kit *k) const { if (!k) return nullptr; - return new Internal::CMakeConfigurationKitConfigWidget(k, this); + return new CMakeConfigurationKitAspectWidget(k, this); } +} // namespace Internal } // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.h b/src/plugins/cmakeprojectmanager/cmakekitinformation.h index 3da3f7d7b2..b7e6f4c5bf 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.h +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.h @@ -25,21 +25,20 @@ #pragma once -#include "cmake_global.h" - #include "cmakeconfigitem.h" #include <projectexplorer/kitmanager.h> namespace CMakeProjectManager { - class CMakeTool; -class CMAKE_EXPORT CMakeKitInformation : public ProjectExplorer::KitInformation +namespace Internal { + +class CMakeKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - CMakeKitInformation(); + CMakeKitAspect(); static Core::Id id(); @@ -47,24 +46,24 @@ public: static CMakeTool *cmakeTool(const ProjectExplorer::Kit *k); static void setCMakeTool(ProjectExplorer::Kit *k, const Core::Id id); - // KitInformation interface + // KitAspect interface QVariant defaultValue(const ProjectExplorer::Kit *k) const final; QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const final; void setup(ProjectExplorer::Kit *k) final; void fix(ProjectExplorer::Kit *k) final; ItemList toUserOutput(const ProjectExplorer::Kit *k) const final; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final; QSet<Core::Id> availableFeatures(const ProjectExplorer::Kit *k) const final; }; -class CMAKE_EXPORT CMakeGeneratorKitInformation : public ProjectExplorer::KitInformation +class CMakeGeneratorKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - CMakeGeneratorKitInformation(); + CMakeGeneratorKitAspect(); static QString generator(const ProjectExplorer::Kit *k); static QString extraGenerator(const ProjectExplorer::Kit *k); @@ -78,21 +77,21 @@ public: const QString &extraGenerator, const QString &platform, const QString &toolset); static QStringList generatorArguments(const ProjectExplorer::Kit *k); - // KitInformation interface + // KitAspect interface QVariant defaultValue(const ProjectExplorer::Kit *k) const final; QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const final; void setup(ProjectExplorer::Kit *k) final; void fix(ProjectExplorer::Kit *k) final; void upgrade(ProjectExplorer::Kit *k) final; ItemList toUserOutput(const ProjectExplorer::Kit *k) const final; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; }; -class CMAKE_EXPORT CMakeConfigurationKitInformation : public ProjectExplorer::KitInformation +class CMakeConfigurationKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - CMakeConfigurationKitInformation(); + CMakeConfigurationKitAspect(); static CMakeConfig configuration(const ProjectExplorer::Kit *k); static void setConfiguration(ProjectExplorer::Kit *k, const CMakeConfig &config); @@ -102,13 +101,14 @@ public: static CMakeConfig defaultConfiguration(const ProjectExplorer::Kit *k); - // KitInformation interface + // KitAspect interface QVariant defaultValue(const ProjectExplorer::Kit *k) const final; QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const final; void setup(ProjectExplorer::Kit *k) final; void fix(ProjectExplorer::Kit *k) final; ItemList toUserOutput(const ProjectExplorer::Kit *k) const final; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; }; +} // namespace Internal } // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index ec8e0d076d..989cc7b446 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -360,9 +360,9 @@ QList<Task> CMakeProject::projectIssues(const Kit *k) const { QList<Task> result = Project::projectIssues(k); - if (!CMakeKitInformation::cmakeTool(k)) + if (!CMakeKitAspect::cmakeTool(k)) result.append(createProjectTask(Task::TaskType::Error, tr("No cmake tool set."))); - if (ToolChainKitInformation::toolChains(k).isEmpty()) + if (ToolChainKitAspect::toolChains(k).isEmpty()) result.append(createProjectTask(Task::TaskType::Warning, tr("No compilers set in kit."))); return result; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index 170e52e933..77ae1887bd 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -107,7 +107,7 @@ namespace Internal { CMakeProjectImporter::CMakeProjectImporter(const Utils::FileName &path) : QtProjectImporter(path) { - useTemporaryKitInformation(CMakeKitInformation::id(), + useTemporaryKitAspect(CMakeKitAspect::id(), [this](Kit *k, const QVariantList &vl) { cleanupTemporaryCMake(k, vl); }, [this](Kit *k, const QVariantList &vl) { persistTemporaryCMake(k, vl); }); @@ -286,24 +286,24 @@ bool CMakeProjectImporter::matchKit(void *directoryData, const Kit *k) const { const DirectoryData *data = static_cast<DirectoryData *>(directoryData); - CMakeTool *cm = CMakeKitInformation::cmakeTool(k); + CMakeTool *cm = CMakeKitAspect::cmakeTool(k); if (!cm || cm->cmakeExecutable() != data->cmakeBinary) return false; - if (CMakeGeneratorKitInformation::generator(k) != QString::fromUtf8(data->generator) - || CMakeGeneratorKitInformation::extraGenerator(k) != QString::fromUtf8(data->extraGenerator) - || CMakeGeneratorKitInformation::platform(k) != QString::fromUtf8(data->platform) - || CMakeGeneratorKitInformation::toolset(k) != QString::fromUtf8(data->toolset)) + if (CMakeGeneratorKitAspect::generator(k) != QString::fromUtf8(data->generator) + || CMakeGeneratorKitAspect::extraGenerator(k) != QString::fromUtf8(data->extraGenerator) + || CMakeGeneratorKitAspect::platform(k) != QString::fromUtf8(data->platform) + || CMakeGeneratorKitAspect::toolset(k) != QString::fromUtf8(data->toolset)) return false; - if (SysRootKitInformation::sysRoot(k) != Utils::FileName::fromUtf8(data->sysroot)) + if (SysRootKitAspect::sysRoot(k) != Utils::FileName::fromUtf8(data->sysroot)) return false; - if (data->qt.qt && QtSupport::QtKitInformation::qtVersionId(k) != data->qt.qt->uniqueId()) + if (data->qt.qt && QtSupport::QtKitAspect::qtVersionId(k) != data->qt.qt->uniqueId()) return false; for (const CMakeToolChainData &tcd : data->toolChains) { - ToolChain *tc = ToolChainKitInformation::toolChain(k, tcd.mapLanguageIdToQtC()); + ToolChain *tc = ToolChainKitAspect::toolChain(k, tcd.mapLanguageIdToQtC()); if (!tc || tc->compilerCommand() != tcd.compilerPath) return false; } @@ -321,14 +321,14 @@ Kit *CMakeProjectImporter::createKit(void *directoryData) const const CMakeToolData cmtd = findOrCreateCMakeTool(data->cmakeBinary); QTC_ASSERT(cmtd.cmakeTool, return); if (cmtd.isTemporary) - addTemporaryData(CMakeKitInformation::id(), cmtd.cmakeTool->id().toSetting(), k); + addTemporaryData(CMakeKitAspect::id(), cmtd.cmakeTool->id().toSetting(), k); - CMakeGeneratorKitInformation::setGenerator(k, QString::fromUtf8(data->generator)); - CMakeGeneratorKitInformation::setExtraGenerator(k, QString::fromUtf8(data->extraGenerator)); - CMakeGeneratorKitInformation::setPlatform(k, QString::fromUtf8(data->platform)); - CMakeGeneratorKitInformation::setToolset(k, QString::fromUtf8(data->toolset)); + CMakeGeneratorKitAspect::setGenerator(k, QString::fromUtf8(data->generator)); + CMakeGeneratorKitAspect::setExtraGenerator(k, QString::fromUtf8(data->extraGenerator)); + CMakeGeneratorKitAspect::setPlatform(k, QString::fromUtf8(data->platform)); + CMakeGeneratorKitAspect::setToolset(k, QString::fromUtf8(data->toolset)); - SysRootKitInformation::setSysRoot(k, Utils::FileName::fromUtf8(data->sysroot)); + SysRootKitAspect::setSysRoot(k, Utils::FileName::fromUtf8(data->sysroot)); for (const CMakeToolChainData &cmtcd : data->toolChains) { const ToolChainData tcd @@ -337,10 +337,10 @@ Kit *CMakeProjectImporter::createKit(void *directoryData) const if (tcd.areTemporary) { for (ToolChain *tc : tcd.tcs) - addTemporaryData(ToolChainKitInformation::id(), tc->id(), k); + addTemporaryData(ToolChainKitAspect::id(), tc->id(), k); } - ToolChainKitInformation::setToolChain(k, tcd.tcs.at(0)); + ToolChainKitAspect::setToolChain(k, tcd.tcs.at(0)); } qCInfo(cmInputLog()) << "Temporary Kit created."; @@ -388,7 +388,7 @@ void CMakeProjectImporter::cleanupTemporaryCMake(Kit *k, const QVariantList &vl) if (vl.isEmpty()) return; // No temporary CMake QTC_ASSERT(vl.count() == 1, return); - CMakeKitInformation::setCMakeTool(k, Core::Id()); // Always mark Kit as not using this Qt + CMakeKitAspect::setCMakeTool(k, Core::Id()); // Always mark Kit as not using this Qt CMakeToolManager::deregisterCMakeTool(Core::Id::fromSetting(vl.at(0))); qCDebug(cmInputLog()) << "Temporary CMake tool cleaned up."; } @@ -400,7 +400,7 @@ void CMakeProjectImporter::persistTemporaryCMake(Kit *k, const QVariantList &vl) QTC_ASSERT(vl.count() == 1, return); const QVariant data = vl.at(0); CMakeTool *tmpCmake = CMakeToolManager::findById(Core::Id::fromSetting(data)); - CMakeTool *actualCmake = CMakeKitInformation::cmakeTool(k); + CMakeTool *actualCmake = CMakeKitAspect::cmakeTool(k); // User changed Kit away from temporary CMake that was set up: if (tmpCmake && actualCmake != tmpCmake) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 641c53bb25..c81dd01df9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -25,7 +25,6 @@ HEADERS = builddirmanager.h \ cmaketoolmanager.h \ cmake_global.h \ cmakekitinformation.h \ - cmakekitconfigwidget.h \ cmakecbpparser.h \ cmakebuildsettingswidget.h \ cmakeindenter.h \ @@ -61,7 +60,6 @@ SOURCES = builddirmanager.cpp \ cmakesettingspage.cpp \ cmaketoolmanager.cpp \ cmakekitinformation.cpp \ - cmakekitconfigwidget.cpp \ cmakecbpparser.cpp \ cmakebuildsettingswidget.cpp \ cmakeindenter.cpp \ diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs index cfa9b36e30..c71a0fd821 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs @@ -42,8 +42,6 @@ QtcPlugin { "cmakeeditor.h", "cmakefilecompletionassist.cpp", "cmakefilecompletionassist.h", - "cmakekitconfigwidget.h", - "cmakekitconfigwidget.cpp", "cmakekitinformation.h", "cmakekitinformation.cpp", "cmakelocatorfilter.cpp", @@ -92,6 +90,6 @@ QtcPlugin { "tealeafreader.cpp", "tealeafreader.h", "treescanner.cpp", - "treescanner.h" + "treescanner.h", ] } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index ebd5d44d42..c5085199f9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -106,9 +106,9 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * new CMakeToolManager(this); - KitManager::registerKitInformation<CMakeKitInformation>(); - KitManager::registerKitInformation<CMakeGeneratorKitInformation>(); - KitManager::registerKitInformation<CMakeConfigurationKitInformation>(); + KitManager::registerKitAspect<CMakeKitAspect>(); + KitManager::registerKitAspect<CMakeGeneratorKitAspect>(); + KitManager::registerKitAspect<CMakeConfigurationKitAspect>(); //menus ActionContainer *msubproject = diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 3872fe90f4..073a147dd7 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -49,7 +49,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id) return; const Kit *k = target->kit(); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(k); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k); if (qt) env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS")); }; @@ -63,7 +63,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id) connect(target->project(), &Project::parsingFinished, this, &CMakeRunConfiguration::updateTargetInformation); - if (QtSupport::QtKitInformation::qtVersion(target->kit())) + if (QtSupport::QtKitAspect::qtVersion(target->kit())) setOutputFormatter<QtSupport::QtOutputFormatter>(); } diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp index f4865d7edf..f29749a210 100644 --- a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp @@ -134,7 +134,7 @@ QString compilerPath(QString pathFlag) ToolChain *toolchainFromFlags(const Kit *kit, const QStringList &flags, const Core::Id &language) { if (flags.empty()) - return ToolChainKitInformation::toolChain(kit, language); + return ToolChainKitAspect::toolChain(kit, language); // Try exact compiler match. const Utils::FileName compiler = Utils::FileName::fromString(compilerPath(flags.front())); @@ -157,7 +157,7 @@ ToolChain *toolchainFromFlags(const Kit *kit, const QStringList &flags, const Co return toolchain; } - toolchain = ToolChainKitInformation::toolChain(kit, language); + toolchain = ToolChainKitAspect::toolChain(kit, language); qWarning() << "No matching toolchain found, use the default."; return toolchain; } @@ -216,7 +216,7 @@ CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile, if (!cToolchain) { cToolchain = toolchainFromFlags(kit, originalFlags, ProjectExplorer::Constants::C_LANGUAGE_ID); - ToolChainKitInformation::setToolChain(kit, cToolchain); + ToolChainKitAspect::setToolChain(kit, cToolchain); } addDriverModeFlagIfNeeded(cToolchain, flags); rpp.setFlagsForC({cToolchain, flags}); @@ -224,7 +224,7 @@ CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile, if (!cxxToolchain) { cxxToolchain = toolchainFromFlags(kit, originalFlags, ProjectExplorer::Constants::CXX_LANGUAGE_ID); - ToolChainKitInformation::setToolChain(kit, cxxToolchain); + ToolChainKitAspect::setToolChain(kit, cxxToolchain); } addDriverModeFlagIfNeeded(cxxToolchain, flags); rpp.setFlagsForCxx({cxxToolchain, flags}); diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp index 33d2123238..e4ed48648b 100644 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp +++ b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp @@ -78,11 +78,7 @@ void FilePropertiesDialog::refresh() m_ui->owner->setText(fileInfo.owner()); m_ui->group->setText(fileInfo.group()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) m_ui->size->setText(locale.formattedDataSize(fileInfo.size())); -#else - m_ui->size->setText(tr("%1 Bytes").arg(locale.toString(fileInfo.size()))); -#endif m_ui->readable->setChecked(fileInfo.isReadable()); m_ui->writable->setChecked(fileInfo.isWritable()); m_ui->executable->setChecked(fileInfo.isExecutable()); diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 8d496ea3d2..d332817f62 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -102,19 +102,19 @@ static QVector<QString> splitInTwoLines(const QString &text, nextSplitPos = rx.lastIndexIn(text, nextSplitPos - text.length() - 1); if (nextSplitPos != -1) { int splitCandidate = nextSplitPos + rx.matchedLength(); - if (fontMetrics.width(text.mid(splitCandidate)) <= availableWidth) + if (fontMetrics.horizontalAdvance(text.mid(splitCandidate)) <= availableWidth) splitPos = splitCandidate; else break; } - } while (nextSplitPos > 0 && fontMetrics.width(text.left(nextSplitPos)) > availableWidth); + } while (nextSplitPos > 0 && fontMetrics.horizontalAdvance(text.left(nextSplitPos)) > availableWidth); // check if we could split at white space at all if (splitPos < 0) { splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, int(availableWidth)); QString common = Utils::commonPrefix(QStringList({splitLines[0], text})); splitLines[1] = text.mid(common.length()); // elide the second line even if it fits, since it is cut off in mid-word - while (fontMetrics.width(QChar(0x2026) /*'...'*/ + splitLines[1]) > availableWidth + while (fontMetrics.horizontalAdvance(QChar(0x2026) /*'...'*/ + splitLines[1]) > availableWidth && splitLines[1].length() > 3 /*keep at least three original characters (should not happen)*/) { splitLines[1].remove(0, 1); @@ -222,7 +222,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event) painter.setFont(boldFont); QVector<QString> splitBuildConfiguration(2); const QString buildConfiguration = defaultAction()->property("subtitle").toString(); - if (boldFm.width(buildConfiguration) <= availableWidth) + if (boldFm.horizontalAdvance(buildConfiguration) <= availableWidth) // text fits in one line splitBuildConfiguration[0] = buildConfiguration; else diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index eba8f0c203..8ce0cfb199 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -98,7 +98,7 @@ QSize FancyTabBar::tabSizeHint(bool minimum) const const int width = 60 + spacing + 2; int maxLabelwidth = 0; for (auto tab : qAsConst(m_tabs)) { - const int width = fm.width(tab->text); + const int width = fm.horizontalAdvance(tab->text); if (width > maxLabelwidth) maxLabelwidth = width; } diff --git a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp index 81ec2541c6..5e1c8ed349 100644 --- a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp +++ b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp @@ -114,7 +114,7 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle const bool isSelected = option.state & QStyle::State_Selected; QString lineText = QString::number(lineNumber); int minimumLineNumberDigits = qMax((int)m_minimumLineNumberDigits, lineText.count()); - int fontWidth = painter->fontMetrics().width(QString(minimumLineNumberDigits, QLatin1Char('0'))); + int fontWidth = painter->fontMetrics().horizontalAdvance(QString(minimumLineNumberDigits, QLatin1Char('0'))); int lineNumberAreaWidth = lineNumberAreaHorizontalPadding + fontWidth + lineNumberAreaHorizontalPadding; QRect lineNumberAreaRect(rect); lineNumberAreaRect.setWidth(lineNumberAreaWidth); @@ -168,8 +168,8 @@ void SearchResultTreeItemDelegate::drawText(QPainter *painter, const QString textBefore = text.left(searchTermStart).replace(QLatin1Char('\t'), m_tabString); const QString textHighlight = text.mid(searchTermStart, searchTermLength).replace(QLatin1Char('\t'), m_tabString); const QString textAfter = text.mid(searchTermStart + searchTermLength).replace(QLatin1Char('\t'), m_tabString); - int searchTermStartPixels = painter->fontMetrics().width(textBefore); - int searchTermLengthPixels = painter->fontMetrics().width(textHighlight); + int searchTermStartPixels = painter->fontMetrics().horizontalAdvance(textBefore); + int searchTermLengthPixels = painter->fontMetrics().horizontalAdvance(textHighlight); // rects QRect beforeHighlightRect(rect); diff --git a/src/plugins/coreplugin/find/searchresultwidget.cpp b/src/plugins/coreplugin/find/searchresultwidget.cpp index 9428a31a1d..5827885802 100644 --- a/src/plugins/coreplugin/find/searchresultwidget.cpp +++ b/src/plugins/coreplugin/find/searchresultwidget.cpp @@ -72,8 +72,8 @@ public: QSize sizeHint() const override { QSize sh = QLineEdit::minimumSizeHint(); - sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')), - fontMetrics().width(text())); + sh.rwidth() += qMax(25 * fontMetrics().horizontalAdvance(QLatin1Char('x')), + fontMetrics().horizontalAdvance(text())); return sh; } }; diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 78e819a9c3..a2f435a966 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -721,11 +721,11 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool() && cb->currentText.endsWith(asterisk) - && option->fontMetrics.width(cb->currentText) > elideWidth; + && option->fontMetrics.horizontalAdvance(cb->currentText) > elideWidth; QString text; if (notElideAsterisk) { - elideWidth -= option->fontMetrics.width(asterisk); + elideWidth -= option->fontMetrics.horizontalAdvance(asterisk); text = asterisk; } text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth)); @@ -979,7 +979,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9); if (!alignarrow) { - int labelwidth = option->fontMetrics.width(cb->currentText); + int labelwidth = option->fontMetrics.horizontalAdvance(cb->currentText); if (reverse) arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4)); else diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index bda60b5812..463c34e64a 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -324,7 +324,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : m_opToolBarWidgets->addWidget(toolButtonsContainer); - minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName())); + minTitleWidth = qMax(minTitleWidth, titleFm.horizontalAdvance(outPane->displayName())); QString suffix = outPane->displayName().simplified(); suffix.remove(QLatin1Char(' ')); @@ -667,7 +667,7 @@ void OutputPaneToggleButton::paintEvent(QPaintEvent*) { const QFontMetrics fm = fontMetrics(); const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent(); - const int numberWidth = fm.width(m_number); + const int numberWidth = fm.horizontalAdvance(m_number); QPainter p(this); diff --git a/src/plugins/coreplugin/progressmanager/progressbar.cpp b/src/plugins/coreplugin/progressmanager/progressbar.cpp index 2dd28712e9..5a97a282d7 100644 --- a/src/plugins/coreplugin/progressmanager/progressbar.cpp +++ b/src/plugins/coreplugin/progressmanager/progressbar.cpp @@ -177,7 +177,7 @@ QSize ProgressBar::sizeHint() const int height = PROGRESSBAR_HEIGHT + 5; if (m_titleVisible) { QFontMetrics fm(titleFont()); - width = qMax(width, fm.width(m_title) + 16); + width = qMax(width, fm.horizontalAdvance(m_title) + 16); height += fm.height() + 5; } if (m_separatorVisible) diff --git a/src/plugins/cpaster/columnindicatortextedit.cpp b/src/plugins/cpaster/columnindicatortextedit.cpp index a219170bef..cfbe8b2489 100644 --- a/src/plugins/cpaster/columnindicatortextedit.cpp +++ b/src/plugins/cpaster/columnindicatortextedit.cpp @@ -43,7 +43,7 @@ ColumnIndicatorTextEdit::ColumnIndicatorTextEdit(QWidget *parent) : setSizePolicy(sizePolicy); int cmx = 0, cmy = 0, cmw = 0, cmh = 0; getContentsMargins(&cmx, &cmy, &cmw, &cmh); - m_columnIndicator = QFontMetrics(font).width(QLatin1Char('W')) * 100 + cmx + 1; + m_columnIndicator = QFontMetrics(font).horizontalAdvance(QLatin1Char('W')) * 100 + cmx + 1; m_columnIndicatorFont.setFamily(QLatin1String("Times")); m_columnIndicatorFont.setPointSizeF(7.0); } diff --git a/src/plugins/cpptools/cppkitinfo.cpp b/src/plugins/cpptools/cppkitinfo.cpp index 6cdf7d52df..e57a4dbd73 100644 --- a/src/plugins/cpptools/cppkitinfo.cpp +++ b/src/plugins/cpptools/cppkitinfo.cpp @@ -48,12 +48,12 @@ KitInfo::KitInfo(Project *project) // Toolchains if (kit) { - cToolChain = ToolChainKitInformation::toolChain(kit, Constants::C_LANGUAGE_ID); - cxxToolChain = ToolChainKitInformation::toolChain(kit, Constants::CXX_LANGUAGE_ID); + cToolChain = ToolChainKitAspect::toolChain(kit, Constants::C_LANGUAGE_ID); + cxxToolChain = ToolChainKitAspect::toolChain(kit, Constants::CXX_LANGUAGE_ID); } // Sysroot - sysRootPath = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString(); + sysRootPath = ProjectExplorer::SysRootKitAspect::sysRoot(kit).toString(); } bool KitInfo::isValid() const diff --git a/src/plugins/cpptools/cpptoolsreuse.cpp b/src/plugins/cpptools/cpptoolsreuse.cpp index 9bcf806b7d..da1c79b4c0 100644 --- a/src/plugins/cpptools/cpptoolsreuse.cpp +++ b/src/plugins/cpptools/cpptoolsreuse.cpp @@ -323,18 +323,9 @@ bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb) "C++ Indexer: Skipping file \"%1\" because it is too big.") .arg(absoluteFilePath); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QMetaObject::invokeMethod(Core::MessageManager::instance(), [msg]() { Core::MessageManager::write(msg, Core::MessageManager::Silent); }); -#else - QMetaObject::invokeMethod(Core::MessageManager::instance(), - "write", - Qt::QueuedConnection, - Q_ARG(QString, msg), - Q_ARG(Core::MessageManager::PrintToOutputPaneFlags, - Core::MessageManager::Silent)); -#endif qWarning().noquote() << msg; return true; diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 0702536262..3d0b9d253d 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -63,7 +63,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent) d->kitChooser = new KitChooser(this); d->kitChooser->setKitPredicate([](const Kit *kit) { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return kit->isValid() && device && !device->sshParameters().host().isEmpty(); }); d->executable = new QLineEdit(this); @@ -132,7 +132,7 @@ Runnable StartRemoteDialog::runnable() const { Kit *kit = d->kitChooser->currentKit(); Runnable r; - r.device = DeviceKitInformation::device(kit); + r.device = DeviceKitAspect::device(kit); r.executable = d->executable->text(); r.commandLineArguments = d->arguments->text(); r.workingDirectory = d->workingDirectory->text(); diff --git a/src/plugins/debugger/console/consoleitemdelegate.cpp b/src/plugins/debugger/console/consoleitemdelegate.cpp index 265ee6ce17..2196d7a260 100644 --- a/src/plugins/debugger/console/consoleitemdelegate.cpp +++ b/src/plugins/debugger/console/consoleitemdelegate.cpp @@ -186,7 +186,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o const int pos = file.lastIndexOf('/'); if (pos != -1) file = file.mid(pos +1); - const int realFileWidth = fm.width(file); + const int realFileWidth = fm.horizontalAdvance(file); painter->setClipRect(positions.fileArea()); painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(), file); @@ -203,7 +203,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o // Paint LineArea QString lineText = index.data(ConsoleItem::LineRole).toString(); painter->setClipRect(positions.lineArea()); - const int realLineWidth = fm.width(lineText); + const int realLineWidth = fm.horizontalAdvance(lineText); painter->drawText(positions.lineAreaRight() - realLineWidth, positions.adjustedTop() + fm.ascent(), lineText); } diff --git a/src/plugins/debugger/console/consoleitemmodel.cpp b/src/plugins/debugger/console/consoleitemmodel.cpp index 525aca0dc0..aa31132956 100644 --- a/src/plugins/debugger/console/consoleitemmodel.cpp +++ b/src/plugins/debugger/console/consoleitemmodel.cpp @@ -92,7 +92,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font) filename = filename.mid(pos + 1); QFontMetrics fm(font); - m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename)); + m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.horizontalAdvance(filename)); return m_maxSizeOfFileName; } @@ -100,7 +100,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font) int ConsoleItemModel::sizeOfLineNumber(const QFont &font) { QFontMetrics fm(font); - return fm.width("88888"); + return fm.horizontalAdvance("88888"); } } // Internal diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index acbf5136b9..0f91ac1a92 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -29,7 +29,6 @@ HEADERS += \ debuggerprotocol.h \ debuggerrunconfigurationaspect.h \ debuggerruncontrol.h \ - debuggerkitconfigwidget.h \ debuggerkitinformation.h \ disassembleragent.h \ disassemblerlines.h \ @@ -76,7 +75,6 @@ SOURCES += \ debuggerprotocol.cpp \ debuggerrunconfigurationaspect.cpp \ debuggerruncontrol.cpp \ - debuggerkitconfigwidget.cpp \ debuggerkitinformation.cpp \ disassembleragent.cpp \ disassemblerlines.cpp \ diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index 50dd65fe76..6add8dd906 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -51,7 +51,6 @@ Project { "debuggerinternalconstants.h", "debuggeritem.cpp", "debuggeritem.h", "debuggeritemmanager.cpp", "debuggeritemmanager.h", - "debuggerkitconfigwidget.cpp", "debuggerkitconfigwidget.h", "debuggerkitinformation.cpp", "debuggerkitinformation.h", "debuggermainwindow.cpp", "debuggermainwindow.h", "debuggerplugin.cpp", "debuggerplugin.h", diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index db5731a5aa..00f34e6952 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -109,21 +109,21 @@ DebuggerKitChooser::DebuggerKitChooser(Mode mode, QWidget *parent) { setKitPredicate([this](const Kit *k) { // Match valid debuggers and restrict local debugging to compatible toolchains. - auto errors = DebuggerKitInformation::configurationErrors(k); + auto errors = DebuggerKitAspect::configurationErrors(k); // we do not care for mismatched ABI if we want *any* debugging - if (m_mode == AnyDebugging && errors == DebuggerKitInformation::DebuggerDoesNotMatch) - errors = DebuggerKitInformation::NoConfigurationError; + if (m_mode == AnyDebugging && errors == DebuggerKitAspect::DebuggerDoesNotMatch) + errors = DebuggerKitAspect::NoConfigurationError; if (errors) return false; if (m_mode == LocalDebugging) - return ToolChainKitInformation::targetAbi(k).os() == m_hostAbi.os(); + return ToolChainKitAspect::targetAbi(k).os() == m_hostAbi.os(); return true; }); } QString DebuggerKitChooser::kitToolTip(Kit *k) const { - return DebuggerKitInformation::displayString(k); + return DebuggerKitAspect::displayString(k); } /////////////////////////////////////////////////////////////////////// @@ -229,7 +229,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) d->kitChooser = new KitChooser(this); d->kitChooser->setKitPredicate([](const Kit *k) { - return !DebuggerKitInformation::configurationErrors(k); + return !DebuggerKitAspect::configurationErrors(k); }); d->kitChooser->populate(); @@ -403,7 +403,7 @@ void StartApplicationDialog::run(bool attachRemote) return; Kit *k = dialog.d->kitChooser->currentKit(); - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, k); diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 2c889a016b..0acf32b688 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -26,7 +26,6 @@ #include "debuggeritem.h" #include "debuggeritemmanager.h" #include "debuggerkitinformation.h" -#include "debuggerkitconfigwidget.h" #include "debuggerprotocol.h" #include <projectexplorer/abi.h> @@ -303,14 +302,14 @@ QString DebuggerItem::displayName() const return m_unexpandedDisplayName; MacroExpander expander; - expander.registerVariable("Debugger:Type", DebuggerKitInformation::tr("Type of Debugger Backend"), + expander.registerVariable("Debugger:Type", DebuggerKitAspect::tr("Type of Debugger Backend"), [this] { return engineTypeName(); }); - expander.registerVariable("Debugger:Version", DebuggerKitInformation::tr("Debugger"), + expander.registerVariable("Debugger:Version", DebuggerKitAspect::tr("Debugger"), [this] { return !m_version.isEmpty() ? m_version : - DebuggerKitInformation::tr("Unknown debugger version"); }); - expander.registerVariable("Debugger:Abi", DebuggerKitInformation::tr("Debugger"), + DebuggerKitAspect::tr("Unknown debugger version"); }); + expander.registerVariable("Debugger:Abi", DebuggerKitAspect::tr("Debugger"), [this] { return !m_abis.isEmpty() ? abiNames().join(' ') : - DebuggerKitInformation::tr("Unknown debugger ABI"); }); + DebuggerKitAspect::tr("Unknown debugger ABI"); }); return expander.expand(m_unexpandedDisplayName); } diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 1cd8b3ec09..d0eebeebd2 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -790,7 +790,7 @@ void DebuggerItemManagerPrivate::readLegacyDebuggers(const FileName &file) QVariantMap data1 = v.toMap(); QString kitName = data1.value("PE.Profile.Name").toString(); QVariantMap data2 = data1.value("PE.Profile.Data").toMap(); - QVariant v3 = data2.value(DebuggerKitInformation::id().toString()); + QVariant v3 = data2.value(DebuggerKitAspect::id().toString()); QString fn; if (v3.type() == QVariant::String) fn = v3.toString(); diff --git a/src/plugins/debugger/debuggerkitconfigwidget.cpp b/src/plugins/debugger/debuggerkitconfigwidget.cpp index d95a2861ac..6d21b1915b 100644 --- a/src/plugins/debugger/debuggerkitconfigwidget.cpp +++ b/src/plugins/debugger/debuggerkitconfigwidget.cpp @@ -60,11 +60,11 @@ namespace Debugger { namespace Internal { // ----------------------------------------------------------------------- -// DebuggerKitConfigWidget +// DebuggerKitAspectWidget // ----------------------------------------------------------------------- -DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInformation *ki) - : KitConfigWidget(workingCopy, ki) +DebuggerKitAspectWidget::DebuggerKitAspectWidget(Kit *workingCopy, const KitAspect *ki) + : KitAspectWidget(workingCopy, ki) { m_comboBox = new QComboBox; m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); @@ -72,37 +72,37 @@ DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInfo refresh(); connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &DebuggerKitConfigWidget::currentDebuggerChanged); + this, &DebuggerKitAspectWidget::currentDebuggerChanged); - m_manageButton = new QPushButton(KitConfigWidget::msgManage()); + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); m_manageButton->setContentsMargins(0, 0, 0, 0); connect(m_manageButton, &QAbstractButton::clicked, - this, &DebuggerKitConfigWidget::manageDebuggers); + this, &DebuggerKitAspectWidget::manageDebuggers); } -DebuggerKitConfigWidget::~DebuggerKitConfigWidget() +DebuggerKitAspectWidget::~DebuggerKitAspectWidget() { delete m_comboBox; delete m_manageButton; } -QString DebuggerKitConfigWidget::toolTip() const +QString DebuggerKitAspectWidget::toolTip() const { return tr("The debugger to use for this kit."); } -QString DebuggerKitConfigWidget::displayName() const +QString DebuggerKitAspectWidget::displayName() const { return tr("Debugger"); } -void DebuggerKitConfigWidget::makeReadOnly() +void DebuggerKitAspectWidget::makeReadOnly() { m_manageButton->setEnabled(false); m_comboBox->setEnabled(false); } -void DebuggerKitConfigWidget::refresh() +void DebuggerKitAspectWidget::refresh() { m_ignoreChanges = true; m_comboBox->clear(); @@ -111,43 +111,43 @@ void DebuggerKitConfigWidget::refresh() for (const DebuggerItem &item : DebuggerItemManager::debuggers()) m_comboBox->addItem(item.displayName(), item.id()); - const DebuggerItem *item = DebuggerKitInformation::debugger(m_kit); + const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit); updateComboBox(item ? item->id() : QVariant()); m_ignoreChanges = false; } -QWidget *DebuggerKitConfigWidget::buttonWidget() const +QWidget *DebuggerKitAspectWidget::buttonWidget() const { return m_manageButton; } -QWidget *DebuggerKitConfigWidget::mainWidget() const +QWidget *DebuggerKitAspectWidget::mainWidget() const { return m_comboBox; } -void DebuggerKitConfigWidget::manageDebuggers() +void DebuggerKitAspectWidget::manageDebuggers() { Core::ICore::showOptionsDialog(ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID, buttonWidget()); } -void DebuggerKitConfigWidget::currentDebuggerChanged(int) +void DebuggerKitAspectWidget::currentDebuggerChanged(int) { if (m_ignoreChanges) return; int currentIndex = m_comboBox->currentIndex(); QVariant id = m_comboBox->itemData(currentIndex); - m_kit->setValue(DebuggerKitInformation::id(), id); + m_kit->setValue(DebuggerKitAspect::id(), id); } -QVariant DebuggerKitConfigWidget::currentId() const +QVariant DebuggerKitAspectWidget::currentId() const { return m_comboBox->itemData(m_comboBox->currentIndex()); } -void DebuggerKitConfigWidget::updateComboBox(const QVariant &id) +void DebuggerKitAspectWidget::updateComboBox(const QVariant &id) { for (int i = 0; i < m_comboBox->count(); ++i) { if (id == m_comboBox->itemData(i)) { diff --git a/src/plugins/debugger/debuggerkitconfigwidget.h b/src/plugins/debugger/debuggerkitconfigwidget.h deleted file mode 100644 index e424481bef..0000000000 --- a/src/plugins/debugger/debuggerkitconfigwidget.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <coreplugin/dialogs/ioptionspage.h> -#include <projectexplorer/kitconfigwidget.h> -#include <projectexplorer/abi.h> -#include <utils/detailswidget.h> -#include <utils/fileutils.h> -#include <utils/pathchooser.h> - -#include <QDialog> -#include <QStandardItemModel> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QLabel; -class QPushButton; -QT_END_NAMESPACE - -namespace Debugger { -namespace Internal { - -// ----------------------------------------------------------------------- -// DebuggerKitConfigWidget -// ----------------------------------------------------------------------- - -class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT - -public: - DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy, - const ProjectExplorer::KitInformation *ki); - ~DebuggerKitConfigWidget() override; - - QString displayName() const override; - QString toolTip() const override; - void makeReadOnly() override; - void refresh() override; - QWidget *buttonWidget() const override; - QWidget *mainWidget() const override; - -private: - void manageDebuggers(); - void currentDebuggerChanged(int idx); - - QVariant currentId() const; - void updateComboBox(const QVariant &id); - - bool m_isReadOnly; - bool m_ignoreChanges = false; - QComboBox *m_comboBox; - QPushButton *m_manageButton; -}; - -} // namespace Internal -} // namespace Debugger diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index 426df5dfa7..9b38456c98 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -27,7 +27,8 @@ #include "debuggeritemmanager.h" #include "debuggeritem.h" -#include "debuggerkitconfigwidget.h" + +#include <coreplugin/icore.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorerconstants.h> @@ -37,7 +38,9 @@ #include <utils/macroexpander.h> #include <utils/qtcassert.h> +#include <QComboBox> #include <QFileInfo> +#include <QPushButton> #include <utility> using namespace ProjectExplorer; @@ -46,19 +49,111 @@ using namespace Utils; namespace Debugger { // -------------------------------------------------------------------------- -// DebuggerKitInformation +// DebuggerKitAspect // -------------------------------------------------------------------------- -DebuggerKitInformation::DebuggerKitInformation() +namespace Internal { + +class DebuggerKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(Debugger::DebuggerKitAspect) + +public: + DebuggerKitAspectWidget(Kit *workingCopy, const KitAspect *ki) + : KitAspectWidget(workingCopy, ki) + { + m_comboBox = new QComboBox; + m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); + m_comboBox->setEnabled(true); + + refresh(); + m_comboBox->setToolTip(ki->description()); + connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &DebuggerKitAspectWidget::currentDebuggerChanged); + + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); + m_manageButton->setContentsMargins(0, 0, 0, 0); + connect(m_manageButton, &QAbstractButton::clicked, + this, &DebuggerKitAspectWidget::manageDebuggers); + } + + ~DebuggerKitAspectWidget() override + { + delete m_comboBox; + delete m_manageButton; + } + +private: + QWidget *buttonWidget() const override { return m_manageButton; } + QWidget *mainWidget() const override { return m_comboBox; } + + void makeReadOnly() override + { + m_manageButton->setEnabled(false); + m_comboBox->setEnabled(false); + } + + void refresh() override + { + m_ignoreChanges = true; + m_comboBox->clear(); + m_comboBox->addItem(tr("None"), QString()); + for (const DebuggerItem &item : DebuggerItemManager::debuggers()) + m_comboBox->addItem(item.displayName(), item.id()); + + const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit); + updateComboBox(item ? item->id() : QVariant()); + m_ignoreChanges = false; + } + + void manageDebuggers() + { + Core::ICore::showOptionsDialog(ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID, + buttonWidget()); + } + + void currentDebuggerChanged(int idx) + { + Q_UNUSED(idx); + if (m_ignoreChanges) + return; + + int currentIndex = m_comboBox->currentIndex(); + QVariant id = m_comboBox->itemData(currentIndex); + m_kit->setValue(DebuggerKitAspect::id(), id); + } + + QVariant currentId() const { return m_comboBox->itemData(m_comboBox->currentIndex()); } + + void updateComboBox(const QVariant &id) + { + for (int i = 0; i < m_comboBox->count(); ++i) { + if (id == m_comboBox->itemData(i)) { + m_comboBox->setCurrentIndex(i); + return; + } + } + m_comboBox->setCurrentIndex(0); + } + + bool m_ignoreChanges = false; + QComboBox *m_comboBox; + QPushButton *m_manageButton; +}; +} // namespace Internal + +DebuggerKitAspect::DebuggerKitAspect() { - setObjectName("DebuggerKitInformation"); - setId(DebuggerKitInformation::id()); + setObjectName("DebuggerKitAspect"); + setId(DebuggerKitAspect::id()); + setDisplayName(tr("Debugger")); + setDescription(tr("The debugger to use for this kit.")); setPriority(28000); } -QVariant DebuggerKitInformation::defaultValue(const Kit *k) const +QVariant DebuggerKitAspect::defaultValue(const Kit *k) const { - const Abi toolChainAbi = ToolChainKitInformation::targetAbi(k); + const Abi toolChainAbi = ToolChainKitAspect::targetAbi(k); const Utils::FileNameList paths = Environment::systemEnvironment().path(); QVariant nextBestFit; for (const DebuggerItem &item : DebuggerItemManager::debuggers()) { @@ -75,7 +170,7 @@ QVariant DebuggerKitInformation::defaultValue(const Kit *k) const return nextBestFit; } -void DebuggerKitInformation::setup(Kit *k) +void DebuggerKitAspect::setup(Kit *k) { QTC_ASSERT(k, return); @@ -92,9 +187,9 @@ void DebuggerKitInformation::setup(Kit *k) // <value type="QString" key="Binary">auto</value> // <value type="int" key="EngineType">4</value> // </valuemap> - const QVariant rawId = k->value(DebuggerKitInformation::id()); + const QVariant rawId = k->value(DebuggerKitAspect::id()); - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); // Get the best of the available debugger matching the kit's toolchain. // The general idea is to find an item that exactly matches what @@ -160,17 +255,17 @@ void DebuggerKitInformation::setup(Kit *k) } // Use the best id we found, or an invalid one. - k->setValue(DebuggerKitInformation::id(), bestLevel != DebuggerItem::DoesNotMatch ? bestItem.id() : QVariant()); + k->setValue(DebuggerKitAspect::id(), bestLevel != DebuggerItem::DoesNotMatch ? bestItem.id() : QVariant()); } // This handles the upgrade path from 2.8 to 3.0 -void DebuggerKitInformation::fix(Kit *k) +void DebuggerKitAspect::fix(Kit *k) { QTC_ASSERT(k, return); // This can be Id, binary path, but not "auto" anymore. - const QVariant rawId = k->value(DebuggerKitInformation::id()); + const QVariant rawId = k->value(DebuggerKitAspect::id()); if (rawId.isNull()) // No debugger set, that is fine. return; @@ -179,7 +274,7 @@ void DebuggerKitInformation::fix(Kit *k) if (!DebuggerItemManager::findById(rawId)) { qWarning("Unknown debugger id %s in kit %s", qPrintable(rawId.toString()), qPrintable(k->displayName())); - k->setValue(DebuggerKitInformation::id(), QVariant()); + k->setValue(DebuggerKitAspect::id(), QVariant()); } return; // All fine (now). } @@ -189,7 +284,7 @@ void DebuggerKitInformation::fix(Kit *k) if (binary == "auto") { // This should not happen as "auto" is handled by setup() already. QTC_CHECK(false); - k->setValue(DebuggerKitInformation::id(), QVariant()); + k->setValue(DebuggerKitAspect::id(), QVariant()); return; } @@ -198,21 +293,21 @@ void DebuggerKitInformation::fix(Kit *k) if (!item) { qWarning("Debugger command %s invalid in kit %s", qPrintable(binary), qPrintable(k->displayName())); - k->setValue(DebuggerKitInformation::id(), QVariant()); + k->setValue(DebuggerKitAspect::id(), QVariant()); return; } - k->setValue(DebuggerKitInformation::id(), item->id()); + k->setValue(DebuggerKitAspect::id(), item->id()); } // Check the configuration errors and return a flag mask. Provide a quick check and // a verbose one with a list of errors. -DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configurationErrors(const Kit *k) +DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(const Kit *k) { QTC_ASSERT(k, return NoDebugger); - const DebuggerItem *item = DebuggerKitInformation::debugger(k); + const DebuggerItem *item = DebuggerKitAspect::debugger(k); if (!item) return NoDebugger; @@ -226,10 +321,10 @@ DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configuratio else if (!fi.isExecutable()) result |= DebuggerNotExecutable; - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); if (item->matchTarget(tcAbi) == DebuggerItem::DoesNotMatch) { // currently restricting the check to desktop devices, may be extended to all device types - const IDevice::ConstPtr device = DeviceKitInformation::device(k); + const IDevice::ConstPtr device = DeviceKitAspect::device(k); if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) result |= DebuggerDoesNotMatch; } @@ -247,14 +342,14 @@ DebuggerKitInformation::ConfigurationErrors DebuggerKitInformation::configuratio return result; } -const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit) +const DebuggerItem *DebuggerKitAspect::debugger(const Kit *kit) { QTC_ASSERT(kit, return nullptr); - const QVariant id = kit->value(DebuggerKitInformation::id()); + const QVariant id = kit->value(DebuggerKitAspect::id()); return DebuggerItemManager::findById(id); } -Runnable DebuggerKitInformation::runnable(const Kit *kit) +Runnable DebuggerKitAspect::runnable(const Kit *kit) { Runnable runnable; if (const DebuggerItem *item = debugger(kit)) { @@ -266,7 +361,7 @@ Runnable DebuggerKitInformation::runnable(const Kit *kit) return runnable; } -QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k) +QList<Task> DebuggerKitAspect::validateDebugger(const Kit *k) { QList<Task> result; @@ -303,12 +398,12 @@ QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k) return result; } -KitConfigWidget *DebuggerKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *DebuggerKitAspect::createConfigWidget(Kit *k) const { - return new Internal::DebuggerKitConfigWidget(k, this); + return new Internal::DebuggerKitAspectWidget(k, this); } -void DebuggerKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const +void DebuggerKitAspect::addToMacroExpander(Kit *kit, MacroExpander *expander) const { QTC_ASSERT(kit, return); expander->registerVariable("Debugger:Name", tr("Name of Debugger"), @@ -339,19 +434,19 @@ void DebuggerKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expande }); } -KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList DebuggerKitAspect::toUserOutput(const Kit *k) const { return ItemList() << qMakePair(tr("Debugger"), displayString(k)); } -DebuggerEngineType DebuggerKitInformation::engineType(const Kit *k) +DebuggerEngineType DebuggerKitAspect::engineType(const Kit *k) { const DebuggerItem *item = debugger(k); QTC_ASSERT(item, return NoEngineType); return item->engineType(); } -QString DebuggerKitInformation::displayString(const Kit *k) +QString DebuggerKitAspect::displayString(const Kit *k) { const DebuggerItem *item = debugger(k); if (!item) @@ -361,15 +456,15 @@ QString DebuggerKitInformation::displayString(const Kit *k) return binary.isEmpty() ? tr("%1 <None>").arg(name) : tr("%1 using \"%2\"").arg(name, binary); } -void DebuggerKitInformation::setDebugger(Kit *k, const QVariant &id) +void DebuggerKitAspect::setDebugger(Kit *k, const QVariant &id) { // Only register reasonably complete debuggers. QTC_ASSERT(DebuggerItemManager::findById(id), return); QTC_ASSERT(k, return); - k->setValue(DebuggerKitInformation::id(), id); + k->setValue(DebuggerKitAspect::id(), id); } -Core::Id DebuggerKitInformation::id() +Core::Id DebuggerKitAspect::id() { return "Debugger.Information"; } diff --git a/src/plugins/debugger/debuggerkitinformation.h b/src/plugins/debugger/debuggerkitinformation.h index 035f00dedf..9d12917660 100644 --- a/src/plugins/debugger/debuggerkitinformation.h +++ b/src/plugins/debugger/debuggerkitinformation.h @@ -34,17 +34,16 @@ namespace Debugger { class DebuggerItem; -class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation +class DEBUGGER_EXPORT DebuggerKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - DebuggerKitInformation(); + DebuggerKitAspect(); QVariant defaultValue(const ProjectExplorer::Kit *k) const override; - QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override - { return DebuggerKitInformation::validateDebugger(k); } + { return DebuggerKitAspect::validateDebugger(k); } void setup(ProjectExplorer::Kit *k) override; void fix(ProjectExplorer::Kit *k) override; @@ -66,7 +65,7 @@ public: static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k); static ConfigurationErrors configurationErrors(const ProjectExplorer::Kit *k); - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const override; ItemList toUserOutput(const ProjectExplorer::Kit *k) const override; diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 12371975f8..a84b8e2781 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -137,7 +137,7 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) m_centralWidgetStack = new QStackedWidget; m_statusLabel = new Utils::StatusLabel; m_statusLabel->setProperty("panelwidget", true); - m_statusLabel->setIndent(2 * QFontMetrics(q->font()).width(QChar('x'))); + m_statusLabel->setIndent(2 * QFontMetrics(q->font()).horizontalAdvance(QChar('x'))); m_editorPlaceHolder = new EditorManagerPlaceHolder; m_perspectiveChooser = new QComboBox; @@ -423,7 +423,8 @@ void DebuggerMainWindowPrivate::selectPerspective(Perspective *perspective) if (index != -1) { m_perspectiveChooser->setCurrentIndex(index); - const int contentWidth = m_perspectiveChooser->fontMetrics().width(perspective->d->m_name); + const int contentWidth = + m_perspectiveChooser->fontMetrics().horizontalAdvance(perspective->d->m_name); QStyleOptionComboBox option; option.initFrom(m_perspectiveChooser); const QSize sz(contentWidth, 1); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index cdb1e87ad2..771eac9be1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -28,7 +28,6 @@ #include "debuggeractions.h" #include "debuggerinternalconstants.h" #include "debuggercore.h" -#include "debuggerkitconfigwidget.h" #include "debuggerdialogs.h" #include "debuggerengine.h" #include "debuggericons.h" @@ -549,12 +548,12 @@ QWidget *addSearch(BaseTreeView *treeView) static Kit::Predicate cdbPredicate(char wordWidth = 0) { return [wordWidth](const Kit *k) -> bool { - if (DebuggerKitInformation::engineType(k) != CdbEngineType - || DebuggerKitInformation::configurationErrors(k)) { + if (DebuggerKitAspect::engineType(k) != CdbEngineType + || DebuggerKitAspect::configurationErrors(k)) { return false; } if (wordWidth) - return ToolChainKitInformation::targetAbi(k).wordWidth() == wordWidth; + return ToolChainKitAspect::targetAbi(k).wordWidth() == wordWidth; return true; }; } @@ -810,14 +809,14 @@ static Kit *guessKitFromAbis(const QList<Abi> &abis) if (!abis.isEmpty()) { // Try exact abis. kit = KitManager::kit([abis](const Kit *k) { - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); - return abis.contains(tcAbi) && !DebuggerKitInformation::configurationErrors(k); + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); + return abis.contains(tcAbi) && !DebuggerKitAspect::configurationErrors(k); }); if (!kit) { // Or something compatible. kit = KitManager::kit([abis](const Kit *k) { - const Abi tcAbi = ToolChainKitInformation::targetAbi(k); - return !DebuggerKitInformation::configurationErrors(k) + const Abi tcAbi = ToolChainKitAspect::targetAbi(k); + return !DebuggerKitAspect::configurationErrors(k) && Utils::contains(abis, [tcAbi](const Abi &a) { return a.isCompatibleWith(tcAbi); }); }); } @@ -882,7 +881,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, if (!kit) kit = guessKitFromAbis(Abi::abisOfBinary(FileName::fromString(executable))); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, kit); debugger->setInferiorExecutable(executable); @@ -1578,7 +1577,7 @@ void DebuggerPluginPrivate::attachCore() setConfigValue("LastExternalStartScript", dlg.overrideStartScript()); setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile()); - IDevice::ConstPtr device = DeviceKitInformation::device(dlg.kit()); + IDevice::ConstPtr device = DeviceKitAspect::device(dlg.kit()); auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, dlg.kit()); debugger->setInferiorExecutable(dlg.symbolFile()); @@ -1606,7 +1605,7 @@ void DebuggerPluginPrivate::startRemoteCdbSession() return; setConfigValue(connectionKey, dlg.connection()); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, kit); debugger->setStartMode(AttachToRemoteServer); @@ -1621,7 +1620,7 @@ public: RemoteAttachRunner(RunControl *runControl, Kit *kit, int pid) : DebuggerRunTool(runControl, kit) { - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); setId("AttachToRunningProcess"); setUsePortsGatherer(true, false); portsGatherer()->setDevice(device); @@ -1657,7 +1656,7 @@ void DebuggerPluginPrivate::attachToRunningApplication() dlg->setAttribute(Qt::WA_DeleteOnClose); Kit *kit = kitChooser->currentKit(); QTC_ASSERT(kit, return); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return); DeviceProcessItem process = dlg->currentProcess(); @@ -1694,14 +1693,14 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, DeviceProcessItem process, bool contAfterAttach) { QTC_ASSERT(kit, return nullptr); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return nullptr); if (process.pid == 0) { AsynchronousMessageBox::warning(tr("Warning"), tr("Cannot attach to process with PID 0")); return nullptr; } - const Abi tcAbi = ToolChainKitInformation::targetAbi(kit); + const Abi tcAbi = ToolChainKitAspect::targetAbi(kit); const bool isWindows = (tcAbi.os() == Abi::WindowsOS); if (isWindows && isWinProcessBeingDebugged(process.pid)) { AsynchronousMessageBox::warning( @@ -1796,7 +1795,7 @@ void DebuggerPluginPrivate::attachToQmlPort() setConfigValue("LastQmlServerPort", dlg.port()); setConfigValue("LastProfile", kit->id().toSetting()); - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return); auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); @@ -2074,7 +2073,7 @@ void DebuggerPluginPrivate::extensionsInitialized() if (runnable.device && runnable.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) return true; - if (DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit()) + if (DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) return true; @@ -2252,7 +2251,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess mstart->addSeparator(Constants::G_GENERAL); mstart->addSeparator(Constants::G_SPECIAL); - KitManager::registerKitInformation<DebuggerKitInformation>(); + KitManager::registerKitAspect<DebuggerKitAspect>(); // Task integration. //: Category under which Analyzer tasks are listed in Issues view @@ -2461,7 +2460,7 @@ void DebuggerUnitTests::initTestCase() // const QList<Kit *> allKits = KitManager::kits(); // if (allKits.count() != 1) // QSKIP("This test requires exactly one kit to be present"); -// const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first()); +// const ToolChain * const toolchain = ToolChainKitAspect::toolChain(allKits.first()); // if (!toolchain) // QSKIP("This test requires that there is a kit with a toolchain."); // bool hasClangExecutable; diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp index bd4b09060f..6e59ee00b2 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp @@ -278,7 +278,7 @@ void DebuggerRunConfigurationAspect::setUseMultiProcess(bool value) bool DebuggerRunConfigurationAspect::isQmlDebuggingSpinboxSuppressed() const { Kit *k = m_target->kit(); - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); if (dev.isNull()) return false; return dev->canAutoDetectPorts(); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index a664d30c40..6379b9a526 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -912,12 +912,12 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer kit = runConfig->target()->kit(); QTC_ASSERT(kit, return); - m_runParameters.sysRoot = SysRootKitInformation::sysRoot(kit); + m_runParameters.sysRoot = SysRootKitAspect::sysRoot(kit); m_runParameters.macroExpander = kit->macroExpander(); - m_runParameters.debugger = DebuggerKitInformation::runnable(kit); - m_runParameters.cppEngineType = DebuggerKitInformation::engineType(kit); + m_runParameters.debugger = DebuggerKitAspect::runnable(kit); + m_runParameters.cppEngineType = DebuggerKitAspect::engineType(kit); - if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit)) + if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit)) m_runParameters.qtPackageSourceLocation = qtVersion->qtPackageSourcePath().toString(); if (auto aspect = runConfig ? runConfig->aspect<DebuggerRunConfigurationAspect>() : nullptr) { @@ -943,7 +943,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer m_runParameters.projectSourceFiles = project->files(Project::SourceFiles); } - m_runParameters.toolChainAbi = ToolChainKitInformation::targetAbi(kit); + m_runParameters.toolChainAbi = ToolChainKitAspect::targetAbi(kit); bool ok = false; int nativeMixedOverride = qgetenv("QTC_DEBUGGER_NATIVE_MIXED").toInt(&ok); @@ -952,7 +952,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // This will only be shown in some cases, but we don't want to access // the kit at that time anymore. - const QList<Task> tasks = DebuggerKitInformation::validateDebugger(kit); + const QList<Task> tasks = DebuggerKitAspect::validateDebugger(kit); for (const Task &t : tasks) { if (t.type != Task::Warning) m_runParameters.validationErrors.append(t.description); diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 6f23a9df62..5821f43a11 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -624,15 +624,10 @@ void DebuggerToolTipWidget::computeSize() // Add a bit of space to account for tooltip border, and not // touch the border of the screen. QPoint pos(x(), y()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) auto screen = QGuiApplication::screenAt(pos); if (!screen) screen = QGuiApplication::primaryScreen(); QRect desktopRect = screen->availableGeometry(); -#else - QTC_ASSERT(QApplication::desktop(), return); - QRect desktopRect = QApplication::desktop()->availableGeometry(); -#endif const int maxWidth = desktopRect.right() - pos.x() - 5 - 5; const int maxHeight = desktopRect.bottom() - pos.y() - 5 - 5; diff --git a/src/plugins/debugger/enginemanager.cpp b/src/plugins/debugger/enginemanager.cpp index 883668e498..3d659b589f 100644 --- a/src/plugins/debugger/enginemanager.cpp +++ b/src/plugins/debugger/enginemanager.cpp @@ -362,7 +362,8 @@ void EngineManagerPrivate::selectUiForCurrentEngine() row = m_engineModel.rootItem()->indexOf(m_currentItem); m_engineChooser->setCurrentIndex(row); - const int contentWidth = m_engineChooser->fontMetrics().width(m_engineChooser->currentText() + "xx"); + const int contentWidth = + m_engineChooser->fontMetrics().horizontalAdvance(m_engineChooser->currentText() + "xx"); QStyleOptionComboBox option; option.initFrom(m_engineChooser); const QSize sz(contentWidth, 1); diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index 8bd68aa791..82d26e4ae7 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -137,7 +137,7 @@ void SelectRemoteFileDialog::attachToDevice(Kit *k) { m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); QTC_ASSERT(k, return); - IDevice::ConstPtr device = DeviceKitInformation::device(k); + IDevice::ConstPtr device = DeviceKitAspect::device(k); QTC_ASSERT(device, return); SshConnectionParameters sshParams = device->sshParameters(); m_fileSystemModel.setSshConnection(sshParams); @@ -352,7 +352,7 @@ bool AttachCoreDialog::isLocalKit() const { Kit *k = d->kitChooser->currentKit(); QTC_ASSERT(k, return false); - IDevice::ConstPtr device = DeviceKitInformation::device(k); + IDevice::ConstPtr device = DeviceKitAspect::device(k); QTC_ASSERT(device, return false); return device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } @@ -367,7 +367,7 @@ void AttachCoreDialog::coreFileChanged(const QString &core) if (!HostOsInfo::isWindowsHost() && QFile::exists(core)) { Kit *k = d->kitChooser->currentKit(); QTC_ASSERT(k, return); - Runnable debugger = DebuggerKitInformation::runnable(k); + Runnable debugger = DebuggerKitAspect::runnable(k); CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(debugger, core); if (!cinfo.foundExecutableName.isEmpty()) d->symbolFileName->setFileName(FileName::fromString(cinfo.foundExecutableName)); diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index 281ae32965..65477ac83f 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -119,7 +119,7 @@ public: painter->setPen(lightColor); // FIXME: performance? this changes only on real font changes. QFontMetrics fm(option.font); - int charWidth = qMax(fm.width('x'), fm.width('0')); + int charWidth = qMax(fm.horizontalAdvance('x'), fm.horizontalAdvance('0')); QString str = index.data(Qt::DisplayRole).toString(); int x = option.rect.x(); bool light = !paintRed; diff --git a/src/plugins/debugger/unstartedappwatcherdialog.cpp b/src/plugins/debugger/unstartedappwatcherdialog.cpp index 8a52c57e1d..25cfe10d7b 100644 --- a/src/plugins/debugger/unstartedappwatcherdialog.cpp +++ b/src/plugins/debugger/unstartedappwatcherdialog.cpp @@ -59,7 +59,7 @@ static bool isLocal(RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; + return DeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } /*! @@ -275,7 +275,7 @@ void UnstartedAppWatcherDialog::stopAndCheckExecutable() void UnstartedAppWatcherDialog::kitChanged() { - const DebuggerItem *debugger = DebuggerKitInformation::debugger(m_kitChooser->currentKit()); + const DebuggerItem *debugger = DebuggerKitAspect::debugger(m_kitChooser->currentKit()); if (!debugger) return; if (debugger->engineType() == Debugger::CdbEngineType) { diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index 0975273ee2..c63d969519 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -401,7 +401,7 @@ void SideDiffEditorWidget::paintSeparator(QPainter &painter, painter.setPen(foreground); const QString replacementText = " {" + foldReplacementText(block) + "}; "; - const int replacementTextWidth = fontMetrics().width(replacementText) + 24; + const int replacementTextWidth = fontMetrics().horizontalAdvance(replacementText) + 24; int x = replacementTextWidth + int(offset.x()); if (x < document()->documentMargin() || !TextDocumentLayout::isFolded(block)) { diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 70db12a6b4..72e12aeb53 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -2686,7 +2686,7 @@ void FakeVimHandler::Private::ensureCursorVisible() void FakeVimHandler::Private::updateEditor() { - const int charWidth = QFontMetrics(EDITOR(font())).width(' '); + const int charWidth = QFontMetrics(EDITOR(font())).horizontalAdvance(' '); EDITOR(setTabStopWidth(charWidth * config(ConfigTabStop).toInt())); setupCharClass(); } @@ -2695,7 +2695,7 @@ void FakeVimHandler::Private::restoreWidget(int tabSize) { //EDITOR(removeEventFilter(q)); //EDITOR(setReadOnly(m_wasReadOnly)); - const int charWidth = QFontMetrics(EDITOR(font())).width(' '); + const int charWidth = QFontMetrics(EDITOR(font())).horizontalAdvance(' '); EDITOR(setTabStopWidth(charWidth * tabSize)); g.visualMode = NoVisualMode; // Force "ordinary" cursor. diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp index 28dfdc86bb..40c7ea28d4 100644 --- a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp @@ -122,7 +122,7 @@ BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const void GenericBuildConfiguration::addToEnvironment(Utils::Environment &env) const { prependCompilerPathToEnvironment(env); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit()); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target()->kit()); if (qt) env.prependOrSetPath(qt->binPath().toString()); } diff --git a/src/plugins/ios/ios.pro b/src/plugins/ios/ios.pro index d4e4d9e05d..a6bf22abf8 100644 --- a/src/plugins/ios/ios.pro +++ b/src/plugins/ios/ios.pro @@ -15,7 +15,6 @@ HEADERS += \ iossettingswidget.h \ iosrunner.h \ iosdsymbuildstep.h \ - iosqtversionfactory.h \ iosqtversion.h \ iosplugin.h \ iosdevicefactory.h \ @@ -42,7 +41,6 @@ SOURCES += \ iossettingswidget.cpp \ iosrunner.cpp \ iosdsymbuildstep.cpp \ - iosqtversionfactory.cpp \ iosqtversion.cpp \ iosplugin.cpp \ iosdevicefactory.cpp \ diff --git a/src/plugins/ios/ios.qbs b/src/plugins/ios/ios.qbs index c5553f9e45..223b7705ad 100644 --- a/src/plugins/ios/ios.qbs +++ b/src/plugins/ios/ios.qbs @@ -47,8 +47,6 @@ QtcPlugin { "iosprobe.h", "iosqtversion.cpp", "iosqtversion.h", - "iosqtversionfactory.cpp", - "iosqtversionfactory.h", "iosrunconfiguration.cpp", "iosrunconfiguration.h", "iosrunner.cpp", diff --git a/src/plugins/ios/iosbuildconfiguration.cpp b/src/plugins/ios/iosbuildconfiguration.cpp index 3f6de58d38..2d5b6022ca 100644 --- a/src/plugins/ios/iosbuildconfiguration.cpp +++ b/src/plugins/ios/iosbuildconfiguration.cpp @@ -58,7 +58,7 @@ QList<ProjectExplorer::NamedWidget *> IosBuildConfiguration::createSubConfigWidg { auto subConfigWidgets = QmakeBuildConfiguration::createSubConfigWidgets(); - Core::Id devType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id devType = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId(target()->kit()); // Ownership of this widget is with BuildSettingsWidget auto buildSettingsWidget = new IosBuildSettingsWidget(devType, m_signingIdentifier, m_autoManagedSigning); @@ -113,7 +113,7 @@ void IosBuildConfiguration::updateQmakeCommand() if (!m_signingIdentifier.isEmpty() ) extraArgs << forceOverrideArg; - Core::Id devType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id devType = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId(target()->kit()); if (devType == Constants::IOS_DEVICE_TYPE && !m_signingIdentifier.isEmpty()) { if (m_autoManagedSigning) { extraArgs << qmakeIosTeamSettings + m_signingIdentifier; diff --git a/src/plugins/ios/iosbuildstep.cpp b/src/plugins/ios/iosbuildstep.cpp index 8d78446c51..5b99ac6529 100644 --- a/src/plugins/ios/iosbuildstep.cpp +++ b/src/plugins/ios/iosbuildstep.cpp @@ -76,7 +76,7 @@ bool IosBuildStep::init() if (!bc) emit addTask(Task::buildConfigurationMissingTask()); - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!tc) emit addTask(Task::compilerMissingTask()); @@ -138,7 +138,7 @@ QStringList IosBuildStep::defaultArguments() const { QStringList res; Kit *kit = target()->kit(); - ToolChain *tc = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); switch (buildConfiguration()->buildType()) { case BuildConfiguration::Debug : res << "-configuration" << "Debug"; @@ -158,8 +158,8 @@ QStringList IosBuildStep::defaultArguments() const auto gtc = static_cast<GccToolChain *>(tc); res << gtc->platformCodeGenFlags(); } - if (!SysRootKitInformation::sysRoot(kit).isEmpty()) - res << "-sdk" << SysRootKitInformation::sysRoot(kit).toString(); + if (!SysRootKitAspect::sysRoot(kit).isEmpty()) + res << "-sdk" << SysRootKitAspect::sysRoot(kit).toString(); res << "SYMROOT=" + buildConfiguration()->buildDirectory().toString(); return res; } diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp index 3ceec86714..0cdb719852 100644 --- a/src/plugins/ios/iosconfigurations.cpp +++ b/src/plugins/ios/iosconfigurations.cpp @@ -168,7 +168,7 @@ static QHash<XcodePlatform::ToolchainTarget, ToolChainPair> findToolChains(const static QSet<Kit *> existingAutoDetectedIosKits() { return Utils::filtered(KitManager::kits(), [](Kit *kit) -> bool { - Core::Id deviceKind = DeviceTypeKitInformation::deviceTypeId(kit); + Core::Id deviceKind = DeviceTypeKitAspect::deviceTypeId(kit); return kit->isAutoDetected() && (deviceKind == Constants::IOS_DEVICE_TYPE || deviceKind == Constants::IOS_SIMULATOR_TYPE); }).toSet(); @@ -183,33 +183,33 @@ static void printKits(const QSet<Kit *> &kits) static void setupKit(Kit *kit, Core::Id pDeviceType, const ToolChainPair& toolChains, const QVariant &debuggerId, const Utils::FileName &sdkPath, BaseQtVersion *qtVersion) { - DeviceTypeKitInformation::setDeviceTypeId(kit, pDeviceType); + DeviceTypeKitAspect::setDeviceTypeId(kit, pDeviceType); if (toolChains.first) - ToolChainKitInformation::setToolChain(kit, toolChains.first); + ToolChainKitAspect::setToolChain(kit, toolChains.first); else - ToolChainKitInformation::clearToolChain(kit, ProjectExplorer::Constants::C_LANGUAGE_ID); + ToolChainKitAspect::clearToolChain(kit, ProjectExplorer::Constants::C_LANGUAGE_ID); if (toolChains.second) - ToolChainKitInformation::setToolChain(kit, toolChains.second); + ToolChainKitAspect::setToolChain(kit, toolChains.second); else - ToolChainKitInformation::clearToolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChainKitAspect::clearToolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); - QtKitInformation::setQtVersion(kit, qtVersion); + QtKitAspect::setQtVersion(kit, qtVersion); // only replace debugger with the default one if we find an unusable one here // (since the user could have changed it) - if ((!DebuggerKitInformation::debugger(kit) - || !DebuggerKitInformation::debugger(kit)->isValid() - || DebuggerKitInformation::debugger(kit)->engineType() != LldbEngineType) + if ((!DebuggerKitAspect::debugger(kit) + || !DebuggerKitAspect::debugger(kit)->isValid() + || DebuggerKitAspect::debugger(kit)->engineType() != LldbEngineType) && debuggerId.isValid()) - DebuggerKitInformation::setDebugger(kit, debuggerId); + DebuggerKitAspect::setDebugger(kit, debuggerId); - kit->setMutable(DeviceKitInformation::id(), true); - kit->setSticky(QtKitInformation::id(), true); - kit->setSticky(ToolChainKitInformation::id(), true); - kit->setSticky(DeviceTypeKitInformation::id(), true); - kit->setSticky(SysRootKitInformation::id(), true); - kit->setSticky(DebuggerKitInformation::id(), false); + kit->setMutable(DeviceKitAspect::id(), true); + kit->setSticky(QtKitAspect::id(), true); + kit->setSticky(ToolChainKitAspect::id(), true); + kit->setSticky(DeviceTypeKitAspect::id(), true); + kit->setSticky(SysRootKitAspect::id(), true); + kit->setSticky(DebuggerKitAspect::id(), false); - SysRootKitInformation::setSysRoot(kit, sdkPath); + SysRootKitAspect::setSysRoot(kit, sdkPath); } static QVersionNumber findXcodeVersion(const Utils::FileName &developerPath) @@ -287,10 +287,10 @@ void IosConfigurations::updateAutomaticKitList() Kit *kit = Utils::findOrDefault(existingKits, [&pDeviceType, &platformToolchains, &qtVersion](const Kit *kit) { // we do not compare the sdk (thus automatically upgrading it in place if a // new Xcode is used). Change? - return DeviceTypeKitInformation::deviceTypeId(kit) == pDeviceType - && ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID) == platformToolchains.second - && ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::C_LANGUAGE_ID) == platformToolchains.first - && QtKitInformation::qtVersion(kit) == qtVersion; + return DeviceTypeKitAspect::deviceTypeId(kit) == pDeviceType + && ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID) == platformToolchains.second + && ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::C_LANGUAGE_ID) == platformToolchains.first + && QtKitAspect::qtVersion(kit) == qtVersion; }); QTC_ASSERT(!resultingKits.contains(kit), continue); if (kit) { diff --git a/src/plugins/ios/iosdeploystep.cpp b/src/plugins/ios/iosdeploystep.cpp index 65a225e7e6..d0a2b0c1fc 100644 --- a/src/plugins/ios/iosdeploystep.cpp +++ b/src/plugins/ios/iosdeploystep.cpp @@ -73,7 +73,7 @@ Core::Id IosDeployStep::stepId() void IosDeployStep::updateDisplayNames() { IDevice::ConstPtr dev = - DeviceKitInformation::device(target()->kit()); + DeviceKitAspect::device(target()->kit()); const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName(); setDefaultDisplayName(tr("Deploy to %1").arg(devName)); setDisplayName(tr("Deploy to %1").arg(devName)); @@ -82,7 +82,7 @@ void IosDeployStep::updateDisplayNames() bool IosDeployStep::init() { QTC_ASSERT(m_transferStatus == NoTransfer, return false); - m_device = DeviceKitInformation::device(target()->kit()); + m_device = DeviceKitAspect::device(target()->kit()); auto runConfig = qobject_cast<const IosRunConfiguration *>( this->target()->activeRunConfiguration()); QTC_ASSERT(runConfig, return false); diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp index 0f8cd500a0..abb94ffe24 100644 --- a/src/plugins/ios/iosdevice.cpp +++ b/src/plugins/ios/iosdevice.cpp @@ -538,11 +538,11 @@ void IosDeviceManager::updateAvailableDevices(const QStringList &devices) } } -IosDevice::ConstPtr IosKitInformation::device(Kit *kit) +IosDevice::ConstPtr IosKitAspect::device(Kit *kit) { if (!kit) return IosDevice::ConstPtr(); - IDevice::ConstPtr dev = DeviceKitInformation::device(kit); + IDevice::ConstPtr dev = DeviceKitAspect::device(kit); IosDevice::ConstPtr res = dev.dynamicCast<const IosDevice>(); return res; } diff --git a/src/plugins/ios/iosdevice.h b/src/plugins/ios/iosdevice.h index 54f5785e70..990227827f 100644 --- a/src/plugins/ios/iosdevice.h +++ b/src/plugins/ios/iosdevice.h @@ -103,7 +103,7 @@ private: QStringList m_userModeDeviceIds; }; -namespace IosKitInformation { +namespace IosKitAspect { IosDevice::ConstPtr device(ProjectExplorer::Kit *); } diff --git a/src/plugins/ios/iosplugin.cpp b/src/plugins/ios/iosplugin.cpp index 401b2a050c..b7c7172eae 100644 --- a/src/plugins/ios/iosplugin.cpp +++ b/src/plugins/ios/iosplugin.cpp @@ -32,7 +32,7 @@ #include "iosdeploystep.h" #include "iosdevicefactory.h" #include "iosdsymbuildstep.h" -#include "iosqtversionfactory.h" +#include "iosqtversion.h" #include "iosrunner.h" #include "iossettingspage.h" #include "iossimulator.h" diff --git a/src/plugins/ios/iosqtversion.cpp b/src/plugins/ios/iosqtversion.cpp index 7b83b6b5ea..3be0207973 100644 --- a/src/plugins/ios/iosqtversion.cpp +++ b/src/plugins/ios/iosqtversion.cpp @@ -42,13 +42,6 @@ using namespace ProjectExplorer; IosQtVersion::IosQtVersion() = default; -IosQtVersion::IosQtVersion(const Utils::FileName &path, bool isAutodetected, - const QString &autodetectionSource) - : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - IosQtVersion *IosQtVersion::clone() const { return new IosQtVersion(*this); @@ -78,7 +71,7 @@ QString IosQtVersion::invalidReason() const QList<Abi> IosQtVersion::detectQtAbis() const { - QList<Abi> abis = qtAbisFromLibrary(qtCorePaths()); + QList<Abi> abis = BaseQtVersion::detectQtAbis(); for (int i = 0; i < abis.count(); ++i) { abis[i] = Abi(abis.at(i).architecture(), abis.at(i).os(), @@ -115,3 +108,16 @@ QSet<Core::Id> IosQtVersion::targetDeviceTypes() const // iOS Qt version supports ios devices as well as simulator. return {Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE}; } + + +// Factory + +IosQtVersionFactory::IosQtVersionFactory() +{ + setQtVersionCreator([] { return new IosQtVersion; }); + setSupportedType(Constants::IOSQT); + setPriority(90); + setRestrictionChecker([](const SetupData &setup) { + return setup.platforms.contains("ios"); + }); +} diff --git a/src/plugins/ios/iosqtversion.h b/src/plugins/ios/iosqtversion.h index 6d4a093ba5..8ae07c4ce0 100644 --- a/src/plugins/ios/iosqtversion.h +++ b/src/plugins/ios/iosqtversion.h @@ -26,6 +26,7 @@ #pragma once #include <qtsupport/baseqtversion.h> +#include <qtsupport/qtversionfactory.h> #include <QCoreApplication> @@ -38,8 +39,6 @@ class IosQtVersion : public QtSupport::BaseQtVersion public: IosQtVersion(); - IosQtVersion(const Utils::FileName &path, bool isAutodetected = false, - const QString &autodetectionSource = QString()); IosQtVersion *clone() const override; QString type() const override; @@ -56,5 +55,11 @@ public: QString description() const override; }; +class IosQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + IosQtVersionFactory(); +}; + } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosqtversionfactory.cpp b/src/plugins/ios/iosqtversionfactory.cpp deleted file mode 100644 index 4ef21af112..0000000000 --- a/src/plugins/ios/iosqtversionfactory.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "iosqtversionfactory.h" -#include "iosqtversion.h" -#include "iosconstants.h" -#include <qtsupport/qtsupportconstants.h> -#include <utils/qtcassert.h> -#include <proparser/profileevaluator.h> - -#include <QFileInfo> - -namespace Ios { -namespace Internal { - -IosQtVersionFactory::IosQtVersionFactory(QObject *parent) - : QtSupport::QtVersionFactory(parent) -{ -} - -bool IosQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::IOSQT); -} - -QtSupport::BaseQtVersion *IosQtVersionFactory::restore(const QString &type, - const QVariantMap &data) -{ - QTC_ASSERT(canRestore(type), return nullptr); - auto v = new IosQtVersion; - v->fromMap(data); - return v; -} - -int IosQtVersionFactory::priority() const -{ - return 90; -} - -QtSupport::BaseQtVersion *IosQtVersionFactory::create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected, - const QString &autoDetectionSource) -{ - if (!(evaluator->values(QLatin1String("QMAKE_PLATFORM")).contains(QLatin1String("ios")))) - return nullptr; - return new IosQtVersion(qmakePath, isAutoDetected, autoDetectionSource); -} - -} // Internal -} // Ios diff --git a/src/plugins/ios/iosqtversionfactory.h b/src/plugins/ios/iosqtversionfactory.h deleted file mode 100644 index 4810e2ee8e..0000000000 --- a/src/plugins/ios/iosqtversionfactory.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <qtsupport/qtversionfactory.h> - -namespace Ios { -namespace Internal { - -class IosQtVersionFactory : public QtSupport::QtVersionFactory -{ -public: - explicit IosQtVersionFactory(QObject *parent = nullptr); - - bool canRestore(const QString &type) override; - QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data) override; - - int priority() const override; - QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()) override; -}; - -} // namespace Internal -} // namespace Ios diff --git a/src/plugins/ios/iosrunconfiguration.cpp b/src/plugins/ios/iosrunconfiguration.cpp index 0d26ba7e8f..435a67ef29 100644 --- a/src/plugins/ios/iosrunconfiguration.cpp +++ b/src/plugins/ios/iosrunconfiguration.cpp @@ -125,7 +125,7 @@ void IosDeviceTypeAspect::deviceChanges() void IosDeviceTypeAspect::updateDeviceType() { - if (DeviceTypeKitInformation::deviceTypeId(m_runConfiguration->target()->kit()) + if (DeviceTypeKitAspect::deviceTypeId(m_runConfiguration->target()->kit()) == Constants::IOS_DEVICE_TYPE) m_deviceType = IosDeviceType(IosDeviceType::IosDevice); else if (m_deviceType.type == IosDeviceType::IosDevice) @@ -134,7 +134,7 @@ void IosDeviceTypeAspect::updateDeviceType() void IosRunConfiguration::updateDisplayNames() { - IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); + IDevice::ConstPtr dev = DeviceKitAspect::device(target()->kit()); const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName(); setDefaultDisplayName(tr("Run on %1").arg(devName)); setDisplayName(tr("Run %1 on %2").arg(applicationName()).arg(devName)); @@ -144,12 +144,12 @@ void IosRunConfiguration::updateDisplayNames() void IosRunConfiguration::updateEnabledState() { - Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id devType = DeviceTypeKitAspect::deviceTypeId(target()->kit()); if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE) { setEnabled(false); return; } - IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); + IDevice::ConstPtr dev = DeviceKitAspect::device(target()->kit()); if (dev.isNull() || dev->deviceState() != IDevice::DeviceReadyToUse) { setEnabled(false); return; @@ -176,7 +176,7 @@ QString IosRunConfiguration::applicationName() const FileName IosRunConfiguration::bundleDirectory() const { FileName res; - Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id devType = DeviceTypeKitAspect::deviceTypeId(target()->kit()); bool isDevice = (devType == Constants::IOS_DEVICE_TYPE); if (!isDevice && devType != Constants::IOS_SIMULATOR_TYPE) { qCWarning(iosLog) << "unexpected device type in bundleDirForTarget: " << devType.toString(); @@ -238,10 +238,10 @@ void IosDeviceTypeAspect::toMap(QVariantMap &map) const QString IosRunConfiguration::disabledReason() const { - Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id devType = DeviceTypeKitAspect::deviceTypeId(target()->kit()); if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE) return tr("Kit has incorrect device type for running on iOS devices."); - IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); + IDevice::ConstPtr dev = DeviceKitAspect::device(target()->kit()); QString validDevName; bool hasConncetedDev = false; if (devType == Constants::IOS_DEVICE_TYPE) { diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index dc6d222e0f..5b3a21d136 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -81,7 +81,7 @@ static void stopRunningRunControl(RunControl *runControl) RunConfiguration *runConfig = runControl->runConfiguration(); Target *target = runConfig->target(); - Core::Id devId = DeviceKitInformation::deviceId(target->kit()); + Core::Id devId = DeviceKitAspect::deviceId(target->kit()); // The device can only run an application at a time, if an app is running stop it. if (activeRunControls.contains(devId)) { @@ -101,7 +101,7 @@ IosRunner::IosRunner(RunControl *runControl) auto runConfig = qobject_cast<IosRunConfiguration *>(runControl->runConfiguration()); m_bundleDir = runConfig->bundleDirectory().toString(); m_arguments = runConfig->aspect<ArgumentsAspect>()->arguments(runConfig->macroExpander()); - m_device = DeviceKitInformation::device(runConfig->target()->kit()); + m_device = DeviceKitAspect::device(runConfig->target()->kit()); m_deviceType = runConfig->deviceType(); } diff --git a/src/plugins/ios/iossimulator.cpp b/src/plugins/ios/iossimulator.cpp index 6a8ad80735..259c5334f2 100644 --- a/src/plugins/ios/iossimulator.cpp +++ b/src/plugins/ios/iossimulator.cpp @@ -144,7 +144,7 @@ IosSimulator::ConstPtr IosKitInformation::simulator(Kit *kit) { if (!kit) return IosSimulator::ConstPtr(); - IDevice::ConstPtr dev = DeviceKitInformation::device(kit); + IDevice::ConstPtr dev = DeviceKitAspect::device(kit); IosSimulator::ConstPtr res = dev.dynamicCast<const IosSimulator>(); return res; } diff --git a/src/plugins/nim/project/nimcompilerbuildstep.cpp b/src/plugins/nim/project/nimcompilerbuildstep.cpp index a959ddbb1a..e03ddc85cf 100644 --- a/src/plugins/nim/project/nimcompilerbuildstep.cpp +++ b/src/plugins/nim/project/nimcompilerbuildstep.cpp @@ -226,7 +226,7 @@ void NimCompilerBuildStep::updateCommand() QTC_ASSERT(target(), return); QTC_ASSERT(target()->kit(), return); Kit *kit = target()->kit(); - auto tc = dynamic_cast<NimToolChain*>(ToolChainKitInformation::toolChain(kit, Constants::C_NIMLANGUAGE_ID)); + auto tc = dynamic_cast<NimToolChain*>(ToolChainKitAspect::toolChain(kit, Constants::C_NIMLANGUAGE_ID)); QTC_ASSERT(tc, return); processParameters()->setCommand(tc->compilerCommand().toString()); } diff --git a/src/plugins/nim/project/nimproject.cpp b/src/plugins/nim/project/nimproject.cpp index 2af19e4d49..f5e61c611b 100644 --- a/src/plugins/nim/project/nimproject.cpp +++ b/src/plugins/nim/project/nimproject.cpp @@ -153,7 +153,7 @@ void NimProject::updateProject() QList<Task> NimProject::projectIssues(const Kit *k) const { QList<Task> result = Project::projectIssues(k); - auto tc = dynamic_cast<NimToolChain *>(ToolChainKitInformation::toolChain(k, + auto tc = dynamic_cast<NimToolChain *>(ToolChainKitAspect::toolChain(k, Constants::C_NIMLANGUAGE_ID)); if (!tc) { result.append(createProjectTask(Task::TaskType::Error, tr("No Nim compiler set."))); diff --git a/src/plugins/perfprofiler/perfconfigwidget.cpp b/src/plugins/perfprofiler/perfconfigwidget.cpp index 1aaefcd77d..287808244d 100644 --- a/src/plugins/perfprofiler/perfconfigwidget.cpp +++ b/src/plugins/perfprofiler/perfconfigwidget.cpp @@ -147,7 +147,7 @@ void PerfConfigWidget::setTarget(ProjectExplorer::Target *target) ProjectExplorer::IDevice::ConstPtr device; if (target) { if (ProjectExplorer::Kit *kit = target->kit()) - device = ProjectExplorer::DeviceKitInformation::device(kit); + device = ProjectExplorer::DeviceKitAspect::device(kit); } if (device.isNull()) { diff --git a/src/plugins/perfprofiler/perfdatareader.cpp b/src/plugins/perfprofiler/perfdatareader.cpp index 3cfb7c2989..c137e87b8c 100644 --- a/src/plugins/perfprofiler/perfdatareader.cpp +++ b/src/plugins/perfprofiler/perfdatareader.cpp @@ -293,7 +293,7 @@ QStringList PerfDataReader::collectArguments(const QString &executableDirPath, if (!executableDirPath.isEmpty()) arguments << QLatin1String("--app") << executableDirPath; - if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(kit)) { + if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(kit)) { arguments << QLatin1String("--extra") << QString::fromLatin1("%1%5%2%5%3%5%4") .arg(QDir::toNativeSeparators(qt->libraryPath().toString())) .arg(QDir::toNativeSeparators(qt->pluginPath().toString())) @@ -302,7 +302,7 @@ QStringList PerfDataReader::collectArguments(const QString &executableDirPath, .arg(QDir::listSeparator()); } - if (auto toolChain = ProjectExplorer::ToolChainKitInformation::toolChain( + if (auto toolChain = ProjectExplorer::ToolChainKitAspect::toolChain( kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID)) { ProjectExplorer::Abi::Architecture architecture = toolChain->targetAbi().architecture(); if (architecture == ProjectExplorer::Abi::ArmArchitecture && @@ -313,7 +313,7 @@ QStringList PerfDataReader::collectArguments(const QString &executableDirPath, } } - QString sysroot = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString(); + QString sysroot = ProjectExplorer::SysRootKitAspect::sysRoot(kit).toString(); if (!sysroot.isEmpty()) arguments << QLatin1String("--sysroot") << sysroot; diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp index 1736103189..57de5ce14a 100644 --- a/src/plugins/perfprofiler/perfprofilertool.cpp +++ b/src/plugins/perfprofiler/perfprofilertool.cpp @@ -555,7 +555,7 @@ void PerfProfilerTool::gotoSourceLocation(QString filePath, int lineNumber, int static Utils::FileNameList collectQtIncludePaths(const ProjectExplorer::Kit *kit) { - QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(kit); + QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(kit); if (qt == nullptr) return Utils::FileNameList(); Utils::FileNameList paths{qt->headerPath()}; @@ -570,7 +570,7 @@ static Utils::FileNameList collectQtIncludePaths(const ProjectExplorer::Kit *kit static Utils::FileName sysroot(const Kit *kit) { - return SysRootKitInformation::sysRoot(kit); + return SysRootKitAspect::sysRoot(kit); } static Utils::FileNameList sourceFiles(const Project *currentProject = nullptr) diff --git a/src/plugins/perfprofiler/perfprofilertraceview.cpp b/src/plugins/perfprofiler/perfprofilertraceview.cpp index a55bdd4830..69ac873686 100644 --- a/src/plugins/perfprofiler/perfprofilertraceview.cpp +++ b/src/plugins/perfprofiler/perfprofilertraceview.cpp @@ -74,11 +74,7 @@ PerfProfilerTraceView::PerfProfilerTraceView(QWidget *parent, PerfProfilerTool * bool PerfProfilerTraceView::isUsable() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) return quickWindow()->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; -#else - return true; -#endif } void PerfProfilerTraceView::selectByTypeId(int typeId) diff --git a/src/plugins/perfprofiler/perftracepointdialog.cpp b/src/plugins/perfprofiler/perftracepointdialog.cpp index f42ec8a9a7..87e206b138 100644 --- a/src/plugins/perfprofiler/perftracepointdialog.cpp +++ b/src/plugins/perfprofiler/perftracepointdialog.cpp @@ -52,7 +52,7 @@ PerfTracePointDialog::PerfTracePointDialog() : const Kit *kit = target->kit(); QTC_ASSERT(kit, return); - m_device = DeviceKitInformation::device(kit); + m_device = DeviceKitAspect::device(kit); if (!m_device) { m_ui->textEdit->setPlainText(tr("Error: No device available for active target.")); return; diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 7973ed4c05..0d5fb891c1 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -307,7 +307,7 @@ void BuildConfiguration::prependCompilerPathToEnvironment(Utils::Environment &en void BuildConfiguration::prependCompilerPathToEnvironment(Kit *k, Utils::Environment &env) { const ToolChain *tc - = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!tc) return; @@ -363,7 +363,7 @@ bool BuildConfigurationFactory::supportsTargetDeviceType(Core::Id id) const BuildConfigurationFactory *BuildConfigurationFactory::find(const Kit *k, const QString &projectPath) { QTC_ASSERT(k, return nullptr); - const Core::Id deviceType = DeviceTypeKitInformation::deviceTypeId(k); + const Core::Id deviceType = DeviceTypeKitAspect::deviceTypeId(k); for (BuildConfigurationFactory *factory : g_buildConfigurationFactories) { if (Utils::mimeTypeForFile(projectPath).matchesName(factory->m_supportedProjectMimeTypeName) && factory->supportsTargetDeviceType(deviceType)) @@ -405,7 +405,7 @@ bool BuildConfigurationFactory::canHandle(const Target *target) const if (containsType(target->project()->projectIssues(target->kit()), Task::TaskType::Error)) return false; - if (!supportsTargetDeviceType(DeviceTypeKitInformation::deviceTypeId(target->kit()))) + if (!supportsTargetDeviceType(DeviceTypeKitAspect::deviceTypeId(target->kit()))) return false; return true; diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index 544677517a..6018659c7e 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -193,8 +193,6 @@ void BuildManager::cancel() return; d->m_canceling = true; d->m_currentBuildStep->cancel(); - while (d->m_canceling) - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); // TODO: Is this really necessary? } } diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index d293b09290..e5bf324dcc 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -299,7 +299,7 @@ bool BuildStepFactory::canHandle(BuildStepList *bsl) const if (!m_supportedDeviceTypes.isEmpty()) { Target *target = bsl->target(); QTC_ASSERT(target, return false); - Core::Id deviceType = DeviceTypeKitInformation::deviceTypeId(target->kit()); + Core::Id deviceType = DeviceTypeKitAspect::deviceTypeId(target->kit()); if (!m_supportedDeviceTypes.contains(deviceType)) return false; } diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp index 7619a06ca2..4d16599a12 100644 --- a/src/plugins/projectexplorer/deployconfiguration.cpp +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -162,7 +162,7 @@ bool DeployConfigurationFactory::canHandle(Target *target) const if (!m_supportedTargetDeviceTypes.isEmpty()) { if (!m_supportedTargetDeviceTypes.contains( - DeviceTypeKitInformation::deviceTypeId(target->kit()))) + DeviceTypeKitAspect::deviceTypeId(target->kit()))) return false; } diff --git a/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp b/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp index 7935efb5fc..29e95751f6 100644 --- a/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp @@ -44,9 +44,9 @@ DeviceCheckBuildStep::DeviceCheckBuildStep(BuildStepList *bsl) bool DeviceCheckBuildStep::init() { - IDevice::ConstPtr device = DeviceKitInformation::device(target()->kit()); + IDevice::ConstPtr device = DeviceKitAspect::device(target()->kit()); if (!device) { - Core::Id deviceTypeId = DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(target()->kit()); IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId); if (!factory || !factory->canCreate()) { emit addOutput(tr("No device configured."), BuildStep::OutputFormat::ErrorMessage); @@ -71,7 +71,7 @@ bool DeviceCheckBuildStep::init() DeviceManager *dm = DeviceManager::instance(); dm->addDevice(newDevice); - DeviceKitInformation::setDevice(target()->kit(), newDevice); + DeviceKitAspect::setDevice(target()->kit(), newDevice); } return true; diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp b/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp index dd6a851929..8e68d6b21b 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp @@ -267,7 +267,7 @@ void DeviceProcessesDialogPrivate::killProcess() void DeviceProcessesDialogPrivate::updateDevice() { - setDevice(DeviceKitInformation::device(kitChooser->currentKit())); + setDevice(DeviceKitAspect::device(kitChooser->currentKit())); } void DeviceProcessesDialogPrivate::handleProcessKilled() diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 54caab5f99..b681a56809 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -249,7 +249,7 @@ Core::Id IDevice::id() const */ bool IDevice::isCompatibleWith(const Kit *k) const { - return DeviceTypeKitInformation::deviceTypeId(k) == type(); + return DeviceTypeKitAspect::deviceTypeId(k) == type(); } void IDevice::addDeviceAction(const DeviceAction &deviceAction) diff --git a/src/plugins/projectexplorer/environmentwidget.cpp b/src/plugins/projectexplorer/environmentwidget.cpp index ad643e78be..bcc7e4174b 100644 --- a/src/plugins/projectexplorer/environmentwidget.cpp +++ b/src/plugins/projectexplorer/environmentwidget.cpp @@ -208,9 +208,6 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails d->m_terminalButton->setText(tr("Open &Terminal")); d->m_terminalButton->setToolTip(tr("Open a terminal with this environment set up.")); buttonLayout->addWidget(d->m_terminalButton); -#if defined(Q_OS_UNIX) && QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - d->m_terminalButton->setVisible(false); -#endif buttonLayout->addStretch(); horizontalLayout->addLayout(buttonLayout); diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index df7297c33d..30b7fbef01 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -255,7 +255,7 @@ Utils::Environment ExtraCompiler::buildEnvironment() const return bc->environment(); } else { QList<Utils::EnvironmentItem> changes = - EnvironmentKitInformation::environmentChanges(target->kit()); + EnvironmentKitAspect::environmentChanges(target->kit()); Utils::Environment env = Utils::Environment::systemEnvironment(); env.modify(changes); return env; diff --git a/src/plugins/projectexplorer/filterkitaspectsdialog.cpp b/src/plugins/projectexplorer/filterkitaspectsdialog.cpp new file mode 100644 index 0000000000..418ae03564 --- /dev/null +++ b/src/plugins/projectexplorer/filterkitaspectsdialog.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "filterkitaspectsdialog.h" + +#include "kitmanager.h" + +#include <utils/itemviews.h> +#include <utils/qtcassert.h> +#include <utils/treemodel.h> + +#include <QDialogButtonBox> +#include <QHeaderView> +#include <QString> +#include <QVBoxLayout> + +using namespace Utils; + +namespace ProjectExplorer { +namespace Internal { + +class FilterTreeItem : public TreeItem +{ +public: + FilterTreeItem(const KitAspect *aspect, bool enabled) : m_aspect(aspect), m_enabled(enabled) + { } + + QString displayName() const { return m_aspect->displayName(); } + Core::Id id() const { return m_aspect->id(); } + bool enabled() const { return m_enabled; } + +private: + QVariant data(int column, int role) const override + { + QTC_ASSERT(column < 2, return QVariant()); + if (column == 0 && role == Qt::DisplayRole) + return displayName(); + if (column == 1 && role == Qt::CheckStateRole) + return m_enabled ? Qt::Checked : Qt::Unchecked; + return QVariant(); + } + + bool setData(int column, const QVariant &data, int role) override + { + QTC_ASSERT(column == 1 && !m_aspect->isEssential(), return false); + if (role == Qt::CheckStateRole) { + m_enabled = data.toInt() == Qt::Checked; + return true; + } + return false; + } + + Qt::ItemFlags flags(int column) const override + { + QTC_ASSERT(column < 2, return Qt::ItemFlags()); + Qt::ItemFlags flags = Qt::ItemIsSelectable; + if (column == 0 || !m_aspect->isEssential()) + flags |= Qt::ItemIsEnabled; + if (column == 1 && !m_aspect->isEssential()) + flags |= Qt::ItemIsUserCheckable; + return flags; + } + + const KitAspect * const m_aspect; + bool m_enabled; +}; + +class FilterKitAspectsModel : public TreeModel<TreeItem, FilterTreeItem> +{ +public: + FilterKitAspectsModel(const Kit *kit, QObject *parent) : TreeModel(parent) + { + setHeader({tr("Setting"), tr("Visible")}); + for (const KitAspect * const aspect : KitManager::kitAspects()) { + if (kit && !aspect->isApplicableToKit(kit)) + continue; + const QSet<Core::Id> irrelevantAspects = kit ? kit->irrelevantAspects() + : KitManager::irrelevantAspects(); + auto * const item = new FilterTreeItem(aspect, + !irrelevantAspects.contains(aspect->id())); + rootItem()->appendChild(item); + } + static const auto cmp = [](const TreeItem *item1, const TreeItem *item2) { + return static_cast<const FilterTreeItem *>(item1)->displayName() + < static_cast<const FilterTreeItem *>(item2)->displayName(); + }; + rootItem()->sortChildren(cmp); + } + + QSet<Core::Id> disabledItems() const + { + QSet<Core::Id> ids; + for (int i = 0; i < rootItem()->childCount(); ++i) { + const FilterTreeItem * const item + = static_cast<FilterTreeItem *>(rootItem()->childAt(i)); + if (!item->enabled()) + ids << item->id(); + } + return ids; + } +}; + +class FilterTreeView : public TreeView +{ +public: + FilterTreeView(QWidget *parent) : TreeView(parent) + { + setUniformRowHeights(true); + } + +private: + QSize sizeHint() const override + { + const int width = columnWidth(0) + columnWidth(1); + const int height = model()->rowCount() * rowHeight(model()->index(0, 0)) + + header()->sizeHint().height(); + return {width, height}; + } +}; + +FilterKitAspectsDialog::FilterKitAspectsDialog(const Kit *kit, QWidget *parent) + : QDialog(parent), m_model(new FilterKitAspectsModel(kit, this)) +{ + auto * const layout = new QVBoxLayout(this); + auto * const view = new FilterTreeView(this); + view->setModel(m_model); + view->resizeColumnToContents(0); + layout->addWidget(view); + auto * const buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + layout->addWidget(buttonBox); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); +} + +QSet<Core::Id> FilterKitAspectsDialog::irrelevantAspects() const +{ + return static_cast<FilterKitAspectsModel *>(m_model)->disabledItems(); +} + +} // namespace Internal +} // namespace ProjectExplorer diff --git a/src/plugins/winrt/winrtqtversionfactory.h b/src/plugins/projectexplorer/filterkitaspectsdialog.h index 4a88ce40fa..441abd658d 100644 --- a/src/plugins/winrt/winrtqtversionfactory.h +++ b/src/plugins/projectexplorer/filterkitaspectsdialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -25,24 +25,25 @@ #pragma once -#include <qtsupport/qtversionfactory.h> +#include <coreplugin/id.h> -namespace WinRt { +#include <QDialog> + +namespace Utils { class BaseTreeModel; } + +namespace ProjectExplorer { +class Kit; namespace Internal { -class WinRtQtVersionFactory : public QtSupport::QtVersionFactory +class FilterKitAspectsDialog : public QDialog { public: - explicit WinRtQtVersionFactory(QObject *parent = nullptr); - ~WinRtQtVersionFactory(); - - bool canRestore(const QString &type); - QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data); + FilterKitAspectsDialog(const Kit *kit, QWidget *parent); + QSet<Core::Id> irrelevantAspects() const; - int priority() const; - QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, - bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +private: + Utils::BaseTreeModel * const m_model; }; -} // Internal -} // WinRt +} // namespace Internal +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index e0f3939bf3..e92e66c5b2 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -36,6 +36,7 @@ #include <utils/fileutils.h> #include <utils/icon.h> #include <utils/macroexpander.h> +#include <utils/optional.h> #include <utils/qtcassert.h> #include <QApplication> @@ -58,6 +59,7 @@ const char DATA_KEY[] = "PE.Profile.Data"; const char ICON_KEY[] = "PE.Profile.Icon"; const char MUTABLE_INFO_KEY[] = "PE.Profile.MutableInfo"; const char STICKY_INFO_KEY[] = "PE.Profile.StickyInfo"; +const char IRRELEVANT_ASPECTS_KEY[] = "PE.Kit.IrrelevantAspects"; namespace ProjectExplorer { namespace Internal { @@ -86,8 +88,8 @@ public: [kit] { return kit->id().toString(); }); m_macroExpander.registerVariable("Kit:FileSystemName", tr("Kit filesystem-friendly name"), [kit] { return kit->fileSystemFriendlyName(); }); - foreach (KitInformation *ki, KitManager::kitInformation()) - ki->addToMacroExpander(kit, &m_macroExpander); + for (KitAspect *aspect : KitManager::kitAspects()) + aspect->addToMacroExpander(kit, &m_macroExpander); // This provides the same global fall back as the global expander // without relying on the currentKit() discovery process there. @@ -122,6 +124,7 @@ public: QHash<Id, QVariant> m_data; QSet<Id> m_sticky; QSet<Id> m_mutable; + optional<QSet<Id>> m_irrelevantAspects; MacroExpander m_macroExpander; }; @@ -134,8 +137,8 @@ public: Kit::Kit(Id id) : d(std::make_unique<Internal::KitPrivate>(id, this)) { - foreach (KitInformation *sti, KitManager::kitInformation()) - d->m_data.insert(sti->id(), sti->defaultValue(this)); + for (KitAspect *aspect : KitManager::kitAspects()) + d->m_data.insert(aspect->id(), aspect->defaultValue(this)); } Kit::Kit(const QVariantMap &data) : @@ -158,6 +161,9 @@ Kit::Kit(const QVariantMap &data) : d->m_fileSystemFriendlyName = data.value(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY)).toString(); d->m_iconPath = FileName::fromString(data.value(QLatin1String(ICON_KEY), d->m_iconPath.toString()).toString()); + const auto it = data.constFind(IRRELEVANT_ASPECTS_KEY); + if (it != data.constEnd()) + d->m_irrelevantAspects = transform<QSet<Id>>(it.value().toList(), &Id::fromSetting); QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap(); d->m_data.clear(); // remove default values @@ -206,6 +212,7 @@ Kit *Kit::clone(bool keepName) const k->d->m_iconPath = d->m_iconPath; k->d->m_sticky = d->m_sticky; k->d->m_mutable = d->m_mutable; + k->d->m_irrelevantAspects = d->m_irrelevantAspects; return k; } @@ -222,6 +229,7 @@ void Kit::copyFrom(const Kit *k) d->m_mustNotify = true; d->m_sticky = k->d->m_sticky; d->m_mutable = k->d->m_mutable; + d->m_irrelevantAspects = k->d->m_irrelevantAspects; } bool Kit::isValid() const @@ -246,11 +254,9 @@ bool Kit::hasWarning() const QList<Task> Kit::validate() const { QList<Task> result; - QList<KitInformation *> infoList = KitManager::kitInformation(); - for (KitInformation *i : infoList) { - QList<Task> tmp = i->validate(this); - result.append(tmp); - } + for (KitAspect *aspect : KitManager::kitAspects()) + result.append(aspect->validate(this)); + d->m_hasError = containsType(result, Task::TaskType::Error); d->m_hasWarning = containsType(result, Task::TaskType::Warning); @@ -262,27 +268,27 @@ QList<Task> Kit::validate() const void Kit::fix() { KitGuard g(this); - foreach (KitInformation *i, KitManager::kitInformation()) - i->fix(this); + for (KitAspect *aspect : KitManager::kitAspects()) + aspect->fix(this); } void Kit::setup() { KitGuard g(this); - // Process the KitInfos in reverse order: They may only be based on other information lower in - // the stack. - QList<KitInformation *> info = KitManager::kitInformation(); - for (int i = info.count() - 1; i >= 0; --i) - info.at(i)->setup(this); + // Process the KitAspects in reverse order: They may only be based on other information + // lower in the stack. + const QList<KitAspect *> aspects = KitManager::kitAspects(); + for (int i = aspects.count() - 1; i >= 0; --i) + aspects.at(i)->setup(this); } void Kit::upgrade() { KitGuard g(this); - // Process the KitInfos in reverse order: They may only be based on other information lower in - // the stack. - for (KitInformation *ki : KitManager::kitInformation()) - ki->upgrade(this); + // Process the KitAspects in reverse order: They may only be based on other information + // lower in the stack. + for (KitAspect *aspect : KitManager::kitAspects()) + aspect->upgrade(this); } QString Kit::unexpandedDisplayName() const @@ -371,7 +377,7 @@ QIcon Kit::icon() const return d->m_cachedIcon; } - const Core::Id deviceType = DeviceTypeKitInformation::deviceTypeId(this); + const Core::Id deviceType = DeviceTypeKitAspect::deviceTypeId(this); const QIcon deviceTypeIcon = iconForDeviceType(deviceType); if (!deviceTypeIcon.isNull()) { d->m_cachedIcon = deviceTypeIcon; @@ -463,8 +469,8 @@ bool Kit::isEqual(const Kit *other) const && d->m_iconPath == other->d->m_iconPath && d->m_unexpandedDisplayName == other->d->m_unexpandedDisplayName && d->m_fileSystemFriendlyName == other->d->m_fileSystemFriendlyName + && d->m_irrelevantAspects == other->d->m_irrelevantAspects && d->m_mutable == other->d->m_mutable; - } QVariantMap Kit::toMap() const @@ -491,6 +497,11 @@ QVariantMap Kit::toMap() const stickyInfo << id.toString(); data.insert(QLatin1String(STICKY_INFO_KEY), stickyInfo); + if (d->m_irrelevantAspects) { + data.insert(IRRELEVANT_ASPECTS_KEY, transform<QVariantList>(d->m_irrelevantAspects.value(), + &Id::toSetting)); + } + QVariantMap extra; const IdVariantConstIt cend = d->m_data.constEnd(); @@ -503,17 +514,15 @@ QVariantMap Kit::toMap() const void Kit::addToEnvironment(Environment &env) const { - QList<KitInformation *> infoList = KitManager::kitInformation(); - foreach (KitInformation *ki, infoList) - ki->addToEnvironment(this, env); + for (KitAspect *aspect : KitManager::kitAspects()) + aspect->addToEnvironment(this, env); } IOutputParser *Kit::createOutputParser() const { auto first = new OsParser; - QList<KitInformation *> infoList = KitManager::kitInformation(); - foreach (KitInformation *ki, infoList) - first->appendOutputParser(ki->createOutputParser(this)); + for (KitAspect *aspect : KitManager::kitAspects()) + first->appendOutputParser(aspect->createOutputParser(this)); return first; } @@ -528,10 +537,9 @@ QString Kit::toHtml(const QList<Task> &additional) const str << "<p>" << ProjectExplorer::toHtml(additional + validate()) << "</p>"; str << "<table>"; - QList<KitInformation *> infoList = KitManager::kitInformation(); - foreach (KitInformation *ki, infoList) { - KitInformation::ItemList list = ki->toUserOutput(this); - foreach (const KitInformation::Item &j, list) { + for (KitAspect *aspect : KitManager::kitAspects()) { + const KitAspect::ItemList list = aspect->toUserOutput(this); + for (const KitAspect::Item &j : list) { QString contents = j.second; if (contents.count() > 256) { int pos = contents.lastIndexOf("<br>", 256); @@ -573,9 +581,9 @@ void Kit::setSdkProvided(bool sdkProvided) void Kit::makeSticky() { - foreach (KitInformation *ki, KitManager::kitInformation()) { - if (hasValue(ki->id())) - setSticky(ki->id(), true); + for (KitAspect *aspect : KitManager::kitAspects()) { + if (hasValue(aspect->id())) + setSticky(aspect->id(), true); } } @@ -616,11 +624,21 @@ bool Kit::isMutable(Id id) const return d->m_mutable.contains(id); } +void Kit::setIrrelevantAspects(const QSet<Id> &irrelevant) +{ + d->m_irrelevantAspects = irrelevant; +} + +QSet<Id> Kit::irrelevantAspects() const +{ + return d->m_irrelevantAspects.value_or(KitManager::irrelevantAspects()); +} + QSet<Id> Kit::supportedPlatforms() const { QSet<Id> platforms; - foreach (const KitInformation *ki, KitManager::kitInformation()) { - const QSet<Id> ip = ki->supportedPlatforms(this); + for (const KitAspect *aspect : KitManager::kitAspects()) { + const QSet<Id> ip = aspect->supportedPlatforms(this); if (ip.isEmpty()) continue; if (platforms.isEmpty()) @@ -634,8 +652,8 @@ QSet<Id> Kit::supportedPlatforms() const QSet<Id> Kit::availableFeatures() const { QSet<Id> features; - foreach (const KitInformation *ki, KitManager::kitInformation()) - features |= ki->availableFeatures(this); + for (const KitAspect *aspect : KitManager::kitAspects()) + features |= aspect->availableFeatures(this); return features; } diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h index ab9b1681f6..adfef62c0f 100644 --- a/src/plugins/projectexplorer/kit.h +++ b/src/plugins/projectexplorer/kit.h @@ -123,6 +123,9 @@ public: void setMutable(Core::Id id, bool b); bool isMutable(Core::Id id) const; + void setIrrelevantAspects(const QSet<Core::Id> &irrelevant); + QSet<Core::Id> irrelevantAspects() const; + QSet<Core::Id> supportedPlatforms() const; QSet<Core::Id> availableFeatures() const; bool hasFeatures(const QSet<Core::Id> &features) const; @@ -142,7 +145,7 @@ private: const std::unique_ptr<Internal::KitPrivate> d; - friend class KitInformation; + friend class KitAspect; friend class KitManager; friend class Internal::KitManagerPrivate; friend class Internal::KitModel; // needed for setAutoDetected() when cloning kits diff --git a/src/plugins/projectexplorer/kitchooser.cpp b/src/plugins/projectexplorer/kitchooser.cpp index 9e0b4b25f1..55e6e8cda4 100644 --- a/src/plugins/projectexplorer/kitchooser.cpp +++ b/src/plugins/projectexplorer/kitchooser.cpp @@ -25,7 +25,6 @@ #include "kitchooser.h" -#include "kitconfigwidget.h" #include "kitinformation.h" #include "kitmanager.h" #include "project.h" @@ -52,7 +51,7 @@ KitChooser::KitChooser(QWidget *parent) : { m_chooser = new QComboBox(this); m_chooser->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - m_manageButton = new QPushButton(KitConfigWidget::msgManage(), this); + m_manageButton = new QPushButton(KitAspectWidget::msgManage(), this); auto layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); diff --git a/src/plugins/projectexplorer/kitconfigwidget.cpp b/src/plugins/projectexplorer/kitconfigwidget.cpp deleted file mode 100644 index 4b9fbebd60..0000000000 --- a/src/plugins/projectexplorer/kitconfigwidget.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "kitconfigwidget.h" - -#include "kit.h" -#include "kitinformation.h" - -namespace ProjectExplorer { - -KitConfigWidget::KitConfigWidget(Kit *kit, const KitInformation *ki) : m_kit(kit), - m_kitInformation(ki), m_isSticky(kit->isSticky(ki->id())) -{ } - -Core::Id KitConfigWidget::kitInformationId() const -{ - return m_kitInformation->id(); -} - -bool KitConfigWidget::isMutable() const -{ - return m_kit->isMutable(m_kitInformation->id()); -} - -void KitConfigWidget::setMutable(bool b) -{ - m_kit->setMutable(m_kitInformation->id(), b); -} - -QString KitConfigWidget::msgManage() -{ - return tr("Manage..."); -} - -void KitConfigWidget::setPalette(const QPalette &p) -{ - if (mainWidget()) - mainWidget()->setPalette(p); - if (buttonWidget()) - buttonWidget()->setPalette(p); -} - -void KitConfigWidget::setStyle(QStyle *s) -{ - if (mainWidget()) - mainWidget()->setStyle(s); - if (buttonWidget()) - buttonWidget()->setStyle(s); -} - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitconfigwidget.h b/src/plugins/projectexplorer/kitconfigwidget.h deleted file mode 100644 index 05c7ea058b..0000000000 --- a/src/plugins/projectexplorer/kitconfigwidget.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "projectexplorer_export.h" - -#include <coreplugin/id.h> - -#include <QWidget> - -namespace ProjectExplorer { - -class Kit; -class KitInformation; - -// -------------------------------------------------------------------------- -// KitConfigWidget -// -------------------------------------------------------------------------- - -class PROJECTEXPLORER_EXPORT KitConfigWidget : public QObject -{ - Q_OBJECT - -public: - KitConfigWidget(Kit *kit, const KitInformation *ki); - - Core::Id kitInformationId() const; - - virtual QString displayName() const = 0; - virtual QString toolTip() const { return QString(); } - virtual void makeReadOnly() = 0; - virtual void refresh() = 0; - virtual bool visibleInKit() { return true; } - - virtual QWidget *mainWidget() const = 0; - virtual QWidget *buttonWidget() const { return nullptr; } - - bool isSticky() const { return m_isSticky; } - bool isMutable() const; - void setMutable(bool b); - - static QString msgManage(); - - Kit *kit() const { return m_kit; } - - virtual void setPalette(const QPalette &p); - virtual void setStyle(QStyle *s); - -signals: - void dirty(); - -protected: - Kit *m_kit; - const KitInformation *m_kitInformation; - bool m_isSticky; -}; - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index f4da43f095..ce8796e786 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -28,20 +28,32 @@ #include "abi.h" #include "devicesupport/desktopdevice.h" #include "devicesupport/devicemanager.h" +#include "devicesupport/devicemanagermodel.h" +#include "devicesupport/idevicefactory.h" #include "projectexplorerconstants.h" #include "kit.h" -#include "kitinformationconfigwidget.h" #include "toolchain.h" #include "toolchainmanager.h" +#include <coreplugin/icore.h> +#include <coreplugin/variablechooser.h> #include <ssh/sshconnection.h> - #include <utils/algorithm.h> +#include <utils/environment.h> +#include <utils/environmentdialog.h> #include <utils/macroexpander.h> +#include <utils/pathchooser.h> #include <utils/qtcassert.h> +#include <QCheckBox> +#include <QComboBox> #include <QDir> #include <QFileInfo> +#include <QFontMetrics> +#include <QGridLayout> +#include <QLabel> +#include <QPushButton> +#include <QVBoxLayout> namespace ProjectExplorer { @@ -50,26 +62,76 @@ const char KITINFORMATION_ID_V2[] = "PE.Profile.ToolChains"; const char KITINFORMATION_ID_V3[] = "PE.Profile.ToolChainsV3"; // -------------------------------------------------------------------------- -// SysRootKitInformation: +// SysRootKitAspect: // -------------------------------------------------------------------------- -SysRootKitInformation::SysRootKitInformation() +namespace Internal { +class SysRootKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::SysRootKitAspect) + +public: + SysRootKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki) + { + m_chooser = new Utils::PathChooser; + m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); + m_chooser->setHistoryCompleter(QLatin1String("PE.SysRoot.History")); + m_chooser->setFileName(SysRootKitAspect::sysRoot(k)); + connect(m_chooser, &Utils::PathChooser::pathChanged, + this, &SysRootKitAspectWidget::pathWasChanged); + } + + ~SysRootKitAspectWidget() override { delete m_chooser; } + +private: + void makeReadOnly() override { m_chooser->setReadOnly(true); } + QWidget *buttonWidget() const override { return m_chooser->buttonAtIndex(0); } + QWidget *mainWidget() const override { return m_chooser->lineEdit(); } + + void refresh() override + { + if (!m_ignoreChange) + m_chooser->setFileName(SysRootKitAspect::sysRoot(m_kit)); + } + + void setPalette(const QPalette &p) override + { + KitAspectWidget::setPalette(p); + m_chooser->setOkColor(p.color(QPalette::Active, QPalette::Text)); + } + + void pathWasChanged() + { + m_ignoreChange = true; + SysRootKitAspect::setSysRoot(m_kit, m_chooser->fileName()); + m_ignoreChange = false; + } + + Utils::PathChooser *m_chooser; + bool m_ignoreChange = false; +}; +} // namespace Internal + +SysRootKitAspect::SysRootKitAspect() { setObjectName(QLatin1String("SysRootInformation")); - setId(SysRootKitInformation::id()); + setId(SysRootKitAspect::id()); + setDisplayName(tr("Sysroot")); + setDescription(tr("The root directory of the system image to use.<br>" + "Leave empty when building for the desktop.")); setPriority(31000); } -QVariant SysRootKitInformation::defaultValue(const Kit *k) const +QVariant SysRootKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k) return QString(); } -QList<Task> SysRootKitInformation::validate(const Kit *k) const +QList<Task> SysRootKitAspect::validate(const Kit *k) const { QList<Task> result; - const Utils::FileName dir = SysRootKitInformation::sysRoot(k); + const Utils::FileName dir = SysRootKitAspect::sysRoot(k); if (dir.isEmpty()) return result; @@ -91,41 +153,41 @@ QList<Task> SysRootKitInformation::validate(const Kit *k) const return result; } -KitConfigWidget *SysRootKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *SysRootKitAspect::createConfigWidget(Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::SysRootInformationConfigWidget(k, this); + return new Internal::SysRootKitAspectWidget(k, this); } -KitInformation::ItemList SysRootKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList SysRootKitAspect::toUserOutput(const Kit *k) const { return ItemList() << qMakePair(tr("Sys Root"), sysRoot(k).toUserOutput()); } -void SysRootKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const +void SysRootKitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const { QTC_ASSERT(kit, return); expander->registerFileVariables("SysRoot", tr("Sys Root"), [kit]() -> QString { - return SysRootKitInformation::sysRoot(kit).toString(); + return SysRootKitAspect::sysRoot(kit).toString(); }); } -Core::Id SysRootKitInformation::id() +Core::Id SysRootKitAspect::id() { return "PE.Profile.SysRoot"; } -Utils::FileName SysRootKitInformation::sysRoot(const Kit *k) +Utils::FileName SysRootKitAspect::sysRoot(const Kit *k) { if (!k) return Utils::FileName(); - if (!k->value(SysRootKitInformation::id()).toString().isEmpty()) - return Utils::FileName::fromString(k->value(SysRootKitInformation::id()).toString()); + if (!k->value(SysRootKitAspect::id()).toString().isEmpty()) + return Utils::FileName::fromString(k->value(SysRootKitAspect::id()).toString()); - for (ToolChain *tc : ToolChainKitInformation::toolChains(k)) { + for (ToolChain *tc : ToolChainKitAspect::toolChains(k)) { if (!tc->sysRoot().isEmpty()) return Utils::FileName::fromString(tc->sysRoot()); } @@ -133,12 +195,12 @@ Utils::FileName SysRootKitInformation::sysRoot(const Kit *k) return Utils::FileName(); } -void SysRootKitInformation::setSysRoot(Kit *k, const Utils::FileName &v) +void SysRootKitAspect::setSysRoot(Kit *k, const Utils::FileName &v) { if (!k) return; - for (ToolChain *tc : ToolChainKitInformation::toolChains(k)) { + for (ToolChain *tc : ToolChainKitAspect::toolChains(k)) { if (!tc->sysRoot().isEmpty()) { // It's the sysroot from toolchain, don't set it. if (tc->sysRoot() == v.toString()) @@ -148,21 +210,145 @@ void SysRootKitInformation::setSysRoot(Kit *k, const Utils::FileName &v) break; } } - k->setValue(SysRootKitInformation::id(), v.toString()); + k->setValue(SysRootKitAspect::id(), v.toString()); } // -------------------------------------------------------------------------- -// ToolChainKitInformation: +// ToolChainKitAspect: // -------------------------------------------------------------------------- -ToolChainKitInformation::ToolChainKitInformation() +namespace Internal { +class ToolChainKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::ToolChainKitAspect) + +public: + ToolChainKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki) + { + m_mainWidget = new QWidget; + m_mainWidget->setContentsMargins(0, 0, 0, 0); + + auto layout = new QGridLayout(m_mainWidget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setColumnStretch(1, 2); + + QList<Core::Id> languageList = ToolChainManager::allLanguages().toList(); + Utils::sort(languageList, [](Core::Id l1, Core::Id l2) { + return ToolChainManager::displayNameOfLanguageId(l1) + < ToolChainManager::displayNameOfLanguageId(l2); + }); + QTC_ASSERT(!languageList.isEmpty(), return); + int row = 0; + foreach (Core::Id l, languageList) { + layout->addWidget(new QLabel(ToolChainManager::displayNameOfLanguageId(l) + ':'), row, 0); + auto cb = new QComboBox; + cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy()); + cb->setToolTip(ki->description()); + + m_languageComboboxMap.insert(l, cb); + layout->addWidget(cb, row, 1); + ++row; + + connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, [this, l](int idx) { currentToolChainChanged(l, idx); }); + } + + refresh(); + + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); + m_manageButton->setContentsMargins(0, 0, 0, 0); + connect(m_manageButton, &QAbstractButton::clicked, + this, &ToolChainKitAspectWidget::manageToolChains); + } + + ~ToolChainKitAspectWidget() override + { + delete m_mainWidget; + delete m_manageButton; + } + +private: + QWidget *mainWidget() const override { return m_mainWidget; } + QWidget *buttonWidget() const override { return m_manageButton; } + + void refresh() override + { + m_ignoreChanges = true; + foreach (Core::Id l, m_languageComboboxMap.keys()) { + const QList<ToolChain *> ltcList + = ToolChainManager::toolChains(Utils::equal(&ToolChain::language, l)); + + QComboBox *cb = m_languageComboboxMap.value(l); + cb->clear(); + cb->addItem(tr("<No compiler>"), QByteArray()); + + foreach (ToolChain *tc, ltcList) + cb->addItem(tc->displayName(), tc->id()); + + cb->setEnabled(cb->count() > 1 && !m_isReadOnly); + const int index = indexOf(cb, ToolChainKitAspect::toolChain(m_kit, l)); + cb->setCurrentIndex(index); + } + m_ignoreChanges = false; + } + + void makeReadOnly() override + { + m_isReadOnly = true; + foreach (Core::Id l, m_languageComboboxMap.keys()) { + m_languageComboboxMap.value(l)->setEnabled(false); + } + } + + void manageToolChains() + { + Core::ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, buttonWidget()); + } + + void currentToolChainChanged(Core::Id language, int idx) + { + if (m_ignoreChanges || idx < 0) + return; + + const QByteArray id = m_languageComboboxMap.value(language)->itemData(idx).toByteArray(); + ToolChain *tc = ToolChainManager::findToolChain(id); + QTC_ASSERT(!tc || tc->language() == language, return); + if (tc) + ToolChainKitAspect::setToolChain(m_kit, tc); + else + ToolChainKitAspect::clearToolChain(m_kit, language); + } + + int indexOf(QComboBox *cb, const ToolChain *tc) + { + const QByteArray id = tc ? tc->id() : QByteArray(); + for (int i = 0; i < cb->count(); ++i) { + if (id == cb->itemData(i).toByteArray()) + return i; + } + return -1; + } + + QWidget *m_mainWidget = nullptr; + QPushButton *m_manageButton = nullptr; + QHash<Core::Id, QComboBox *> m_languageComboboxMap; + bool m_ignoreChanges = false; + bool m_isReadOnly = false; +}; +} // namespace Internal + +ToolChainKitAspect::ToolChainKitAspect() { setObjectName(QLatin1String("ToolChainInformation")); - setId(ToolChainKitInformation::id()); + setId(ToolChainKitAspect::id()); + setDisplayName(tr("Compiler")); + setDescription(tr("The compiler to use for building.<br>" + "Make sure the compiler will produce binaries compatible " + "with the target device, Qt version and other libraries used.")); setPriority(30000); connect(KitManager::instance(), &KitManager::kitsLoaded, - this, &ToolChainKitInformation::kitsWereLoaded); + this, &ToolChainKitAspect::kitsWereLoaded); } // language id -> tool chain id @@ -189,19 +375,19 @@ static QVariant defaultToolChainValue() return result; } -QVariant ToolChainKitInformation::defaultValue(const Kit *k) const +QVariant ToolChainKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k); return defaultToolChainValue(); } -QList<Task> ToolChainKitInformation::validate(const Kit *k) const +QList<Task> ToolChainKitAspect::validate(const Kit *k) const { QList<Task> result; const QList<ToolChain*> tcList = toolChains(k); if (tcList.isEmpty()) { - result << Task(Task::Warning, ToolChainKitInformation::msgNoToolChainInTarget(), + result << Task(Task::Warning, ToolChainKitAspect::msgNoToolChainInTarget(), Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); } else { QSet<Abi> targetAbis; @@ -218,7 +404,7 @@ QList<Task> ToolChainKitInformation::validate(const Kit *k) const return result; } -void ToolChainKitInformation::upgrade(Kit *k) +void ToolChainKitAspect::upgrade(Kit *k) { QTC_ASSERT(k, return); @@ -238,7 +424,7 @@ void ToolChainKitInformation::upgrade(Kit *k) // Used up to 4.1: newValue.insert(Deprecated::Toolchain::languageId(Deprecated::Toolchain::Cxx), oldValue.toString()); - const Core::Id typeId = DeviceTypeKitInformation::deviceTypeId(k); + const Core::Id typeId = DeviceTypeKitAspect::deviceTypeId(k); if (typeId == Constants::DESKTOP_DEVICE_TYPE) { // insert default C compiler which did not exist before newValue.insert(Deprecated::Toolchain::languageId(Deprecated::Toolchain::C), @@ -253,7 +439,7 @@ void ToolChainKitInformation::upgrade(Kit *k) // upgrade 4.2 to 4.3 (keep old settings around for now) { const QVariant oldValue = k->value(oldIdV2); - const QVariant value = k->value(ToolChainKitInformation::id()); + const QVariant value = k->value(ToolChainKitAspect::id()); if (value.isNull() && !oldValue.isNull()) { QVariantMap newValue = oldValue.toMap(); QVariantMap::iterator it = newValue.find(Deprecated::Toolchain::languageId(Deprecated::Toolchain::C)); @@ -262,14 +448,14 @@ void ToolChainKitInformation::upgrade(Kit *k) it = newValue.find(Deprecated::Toolchain::languageId(Deprecated::Toolchain::Cxx)); if (it != newValue.end()) newValue.insert(Core::Id(Constants::CXX_LANGUAGE_ID).toString(), it.value()); - k->setValue(ToolChainKitInformation::id(), newValue); - k->setSticky(ToolChainKitInformation::id(), k->isSticky(oldIdV2)); + k->setValue(ToolChainKitAspect::id(), newValue); + k->setSticky(ToolChainKitAspect::id(), k->isSticky(oldIdV2)); } } // upgrade 4.3-temporary-master-state to 4.3: { - const QVariantMap valueMap = k->value(ToolChainKitInformation::id()).toMap(); + const QVariantMap valueMap = k->value(ToolChainKitAspect::id()).toMap(); QVariantMap result; for (const QString &key : valueMap.keys()) { const int pos = key.lastIndexOf('.'); @@ -278,11 +464,11 @@ void ToolChainKitInformation::upgrade(Kit *k) else result.insert(key, valueMap.value(key)); } - k->setValue(ToolChainKitInformation::id(), result); + k->setValue(ToolChainKitAspect::id(), result); } } -void ToolChainKitInformation::fix(Kit *k) +void ToolChainKitAspect::fix(Kit *k) { QTC_ASSERT(ToolChainManager::isLoaded(), return); foreach (const Core::Id& l, ToolChainManager::allLanguages()) { @@ -303,12 +489,12 @@ static Core::Id findLanguage(const QString &ls) [lsUpper](Core::Id l) { return lsUpper == l.toString().toUpper(); }); } -void ToolChainKitInformation::setup(Kit *k) +void ToolChainKitAspect::setup(Kit *k) { QTC_ASSERT(ToolChainManager::isLoaded(), return); QTC_ASSERT(k, return); - const QVariantMap value = k->value(ToolChainKitInformation::id()).toMap(); + const QVariantMap value = k->value(ToolChainKitAspect::id()).toMap(); for (auto i = value.constBegin(); i != value.constEnd(); ++i) { Core::Id l = findLanguage(i.key()); @@ -333,32 +519,32 @@ void ToolChainKitInformation::setup(Kit *k) } } -KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *ToolChainKitAspect::createConfigWidget(Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::ToolChainInformationConfigWidget(k, this); + return new Internal::ToolChainKitAspectWidget(k, this); } -QString ToolChainKitInformation::displayNamePostfix(const Kit *k) const +QString ToolChainKitAspect::displayNamePostfix(const Kit *k) const { ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID); return tc ? tc->displayName() : QString(); } -KitInformation::ItemList ToolChainKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList ToolChainKitAspect::toUserOutput(const Kit *k) const { ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID); return ItemList() << qMakePair(tr("Compiler"), tc ? tc->displayName() : tr("None")); } -void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const +void ToolChainKitAspect::addToEnvironment(const Kit *k, Utils::Environment &env) const { ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID); if (tc) tc->addToEnvironment(env); } -void ToolChainKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const +void ToolChainKitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const { QTC_ASSERT(kit, return); @@ -388,7 +574,7 @@ void ToolChainKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander } -IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const +IOutputParser *ToolChainKitAspect::createOutputParser(const Kit *k) const { for (const Core::Id langId : {Constants::CXX_LANGUAGE_ID, Constants::C_LANGUAGE_ID}) { if (const ToolChain * const tc = toolChain(k, langId)) @@ -397,7 +583,7 @@ IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const return nullptr; } -QSet<Core::Id> ToolChainKitInformation::availableFeatures(const Kit *k) const +QSet<Core::Id> ToolChainKitAspect::availableFeatures(const Kit *k) const { QSet<Core::Id> result; for (ToolChain *tc : toolChains(k)) @@ -405,30 +591,30 @@ QSet<Core::Id> ToolChainKitInformation::availableFeatures(const Kit *k) const return result; } -Core::Id ToolChainKitInformation::id() +Core::Id ToolChainKitAspect::id() { return KITINFORMATION_ID_V3; } -QByteArray ToolChainKitInformation::toolChainId(const Kit *k, Core::Id language) +QByteArray ToolChainKitAspect::toolChainId(const Kit *k, Core::Id language) { QTC_ASSERT(ToolChainManager::isLoaded(), return nullptr); if (!k) return QByteArray(); - QVariantMap value = k->value(ToolChainKitInformation::id()).toMap(); + QVariantMap value = k->value(ToolChainKitAspect::id()).toMap(); return value.value(language.toString(), QByteArray()).toByteArray(); } -ToolChain *ToolChainKitInformation::toolChain(const Kit *k, Core::Id language) +ToolChain *ToolChainKitAspect::toolChain(const Kit *k, Core::Id language) { return ToolChainManager::findToolChain(toolChainId(k, language)); } -QList<ToolChain *> ToolChainKitInformation::toolChains(const Kit *k) +QList<ToolChain *> ToolChainKitAspect::toolChains(const Kit *k) { QTC_ASSERT(k, return QList<ToolChain *>()); - const QVariantMap value = k->value(ToolChainKitInformation::id()).toMap(); + const QVariantMap value = k->value(ToolChainKitAspect::id()).toMap(); const QList<ToolChain *> tcList = Utils::transform(ToolChainManager::allLanguages().toList(), [&value](Core::Id l) -> ToolChain * { @@ -437,18 +623,18 @@ QList<ToolChain *> ToolChainKitInformation::toolChains(const Kit *k) return Utils::filtered(tcList, [](ToolChain *tc) { return tc; }); } -void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc) +void ToolChainKitAspect::setToolChain(Kit *k, ToolChain *tc) { QTC_ASSERT(tc, return); QTC_ASSERT(k, return); - QVariantMap result = k->value(ToolChainKitInformation::id()).toMap(); + QVariantMap result = k->value(ToolChainKitAspect::id()).toMap(); result.insert(tc->language().toString(), tc->id()); k->setValue(id(), result); } /** - * @brief ToolChainKitInformation::setAllToolChainsToMatch + * @brief ToolChainKitAspect::setAllToolChainsToMatch * * Set up all toolchains to be similar to the one toolchain provided. Similar ideally means * that all toolchains use the "same" compiler from the same installation, but we will @@ -457,7 +643,7 @@ void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc) * @param k The kit to set up * @param tc The toolchain to match other languages for. */ -void ToolChainKitInformation::setAllToolChainsToMatch(Kit *k, ToolChain *tc) +void ToolChainKitAspect::setAllToolChainsToMatch(Kit *k, ToolChain *tc) { QTC_ASSERT(tc, return); QTC_ASSERT(k, return); @@ -465,7 +651,7 @@ void ToolChainKitInformation::setAllToolChainsToMatch(Kit *k, ToolChain *tc) const QList<ToolChain *> allTcList = ToolChainManager::toolChains(); QTC_ASSERT(allTcList.contains(tc), return); - QVariantMap result = k->value(ToolChainKitInformation::id()).toMap(); + QVariantMap result = k->value(ToolChainKitAspect::id()).toMap(); result.insert(tc->language().toString(), tc->id()); for (Core::Id l : ToolChainManager::allLanguages()) { @@ -496,17 +682,17 @@ void ToolChainKitInformation::setAllToolChainsToMatch(Kit *k, ToolChain *tc) k->setValue(id(), result); } -void ToolChainKitInformation::clearToolChain(Kit *k, Core::Id language) +void ToolChainKitAspect::clearToolChain(Kit *k, Core::Id language) { QTC_ASSERT(language.isValid(), return); QTC_ASSERT(k, return); - QVariantMap result = k->value(ToolChainKitInformation::id()).toMap(); + QVariantMap result = k->value(ToolChainKitAspect::id()).toMap(); result.insert(language.toString(), QByteArray()); k->setValue(id(), result); } -Abi ToolChainKitInformation::targetAbi(const Kit *k) +Abi ToolChainKitAspect::targetAbi(const Kit *k) { QList<ToolChain *> tcList = toolChains(k); // Find the best possible ABI for all the tool chains... @@ -539,29 +725,29 @@ Abi ToolChainKitInformation::targetAbi(const Kit *k) return candidates.at(0); // Use basically a random Abi... } -QString ToolChainKitInformation::msgNoToolChainInTarget() +QString ToolChainKitAspect::msgNoToolChainInTarget() { return tr("No compiler set in kit."); } -void ToolChainKitInformation::kitsWereLoaded() +void ToolChainKitAspect::kitsWereLoaded() { foreach (Kit *k, KitManager::kits()) fix(k); connect(ToolChainManager::instance(), &ToolChainManager::toolChainRemoved, - this, &ToolChainKitInformation::toolChainRemoved); + this, &ToolChainKitAspect::toolChainRemoved); connect(ToolChainManager::instance(), &ToolChainManager::toolChainUpdated, - this, &ToolChainKitInformation::toolChainUpdated); + this, &ToolChainKitAspect::toolChainUpdated); } -void ToolChainKitInformation::toolChainUpdated(ToolChain *tc) +void ToolChainKitAspect::toolChainUpdated(ToolChain *tc) { for (Kit *k : KitManager::kits([tc](const Kit *k) { return toolChain(k, tc->language()) == tc; })) notifyAboutUpdate(k); } -void ToolChainKitInformation::toolChainRemoved(ToolChain *tc) +void ToolChainKitAspect::toolChainRemoved(ToolChain *tc) { Q_UNUSED(tc); foreach (Kit *k, KitManager::kits()) @@ -569,35 +755,83 @@ void ToolChainKitInformation::toolChainRemoved(ToolChain *tc) } // -------------------------------------------------------------------------- -// DeviceTypeKitInformation: +// DeviceTypeKitAspect: // -------------------------------------------------------------------------- +namespace Internal { +class DeviceTypeKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::DeviceTypeKitAspect) + +public: + DeviceTypeKitAspectWidget(Kit *workingCopy, const KitAspect *ki) + : KitAspectWidget(workingCopy, ki), m_comboBox(new QComboBox) + { + for (IDeviceFactory *factory : IDeviceFactory::allDeviceFactories()) + m_comboBox->addItem(factory->displayName(), factory->deviceType().toSetting()); + m_comboBox->setToolTip(ki->description()); + refresh(); + connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &DeviceTypeKitAspectWidget::currentTypeChanged); + } -DeviceTypeKitInformation::DeviceTypeKitInformation() + ~DeviceTypeKitAspectWidget() override { delete m_comboBox; } + +private: + QWidget *mainWidget() const override { return m_comboBox; } + void makeReadOnly() override { m_comboBox->setEnabled(false); } + + void refresh() override + { + Core::Id devType = DeviceTypeKitAspect::deviceTypeId(m_kit); + if (!devType.isValid()) + m_comboBox->setCurrentIndex(-1); + for (int i = 0; i < m_comboBox->count(); ++i) { + if (m_comboBox->itemData(i) == devType.toSetting()) { + m_comboBox->setCurrentIndex(i); + break; + } + } + } + + void currentTypeChanged(int idx) + { + Core::Id type = idx < 0 ? Core::Id() : Core::Id::fromSetting(m_comboBox->itemData(idx)); + DeviceTypeKitAspect::setDeviceTypeId(m_kit, type); + } + + QComboBox *m_comboBox; +}; +} // namespace Internal + +DeviceTypeKitAspect::DeviceTypeKitAspect() { setObjectName(QLatin1String("DeviceTypeInformation")); - setId(DeviceTypeKitInformation::id()); + setId(DeviceTypeKitAspect::id()); + setDisplayName(tr("Device type")); + setDescription(tr("The type of device to run applications on.")); setPriority(33000); + makeEssential(); } -QVariant DeviceTypeKitInformation::defaultValue(const Kit *k) const +QVariant DeviceTypeKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k); return QByteArray(Constants::DESKTOP_DEVICE_TYPE); } -QList<Task> DeviceTypeKitInformation::validate(const Kit *k) const +QList<Task> DeviceTypeKitAspect::validate(const Kit *k) const { Q_UNUSED(k); return QList<Task>(); } -KitConfigWidget *DeviceTypeKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *DeviceTypeKitAspect::createConfigWidget(Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::DeviceTypeInformationConfigWidget(k, this); + return new Internal::DeviceTypeKitAspectWidget(k, this); } -KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList DeviceTypeKitAspect::toUserOutput(const Kit *k) const { QTC_ASSERT(k, return {}); Core::Id type = deviceTypeId(k); @@ -609,57 +843,135 @@ KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) co return ItemList() << qMakePair(tr("Device type"), typeDisplayName); } -const Core::Id DeviceTypeKitInformation::id() +const Core::Id DeviceTypeKitAspect::id() { return "PE.Profile.DeviceType"; } -const Core::Id DeviceTypeKitInformation::deviceTypeId(const Kit *k) +const Core::Id DeviceTypeKitAspect::deviceTypeId(const Kit *k) { - return k ? Core::Id::fromSetting(k->value(DeviceTypeKitInformation::id())) : Core::Id(); + return k ? Core::Id::fromSetting(k->value(DeviceTypeKitAspect::id())) : Core::Id(); } -void DeviceTypeKitInformation::setDeviceTypeId(Kit *k, Core::Id type) +void DeviceTypeKitAspect::setDeviceTypeId(Kit *k, Core::Id type) { QTC_ASSERT(k, return); - k->setValue(DeviceTypeKitInformation::id(), type.toSetting()); + k->setValue(DeviceTypeKitAspect::id(), type.toSetting()); } -Kit::Predicate DeviceTypeKitInformation::deviceTypePredicate(Core::Id type) +Kit::Predicate DeviceTypeKitAspect::deviceTypePredicate(Core::Id type) { return [type](const Kit *kit) { return type.isValid() && deviceTypeId(kit) == type; }; } -QSet<Core::Id> DeviceTypeKitInformation::supportedPlatforms(const Kit *k) const +QSet<Core::Id> DeviceTypeKitAspect::supportedPlatforms(const Kit *k) const { return {deviceTypeId(k)}; } -QSet<Core::Id> DeviceTypeKitInformation::availableFeatures(const Kit *k) const +QSet<Core::Id> DeviceTypeKitAspect::availableFeatures(const Kit *k) const { - Core::Id id = DeviceTypeKitInformation::deviceTypeId(k); + Core::Id id = DeviceTypeKitAspect::deviceTypeId(k); if (id.isValid()) return {id.withPrefix("DeviceType.")}; return QSet<Core::Id>(); } // -------------------------------------------------------------------------- -// DeviceKitInformation: +// DeviceKitAspect: // -------------------------------------------------------------------------- +namespace Internal { +class DeviceKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::DeviceKitAspect) + +public: + DeviceKitAspectWidget(Kit *workingCopy, const KitAspect *ki) + : KitAspectWidget(workingCopy, ki), m_comboBox(new QComboBox), + m_model(new DeviceManagerModel(DeviceManager::instance())) + { + m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); + m_comboBox->setModel(m_model); + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); + refresh(); + m_comboBox->setToolTip(ki->description()); + + connect(m_model, &QAbstractItemModel::modelAboutToBeReset, + this, &DeviceKitAspectWidget::modelAboutToReset); + connect(m_model, &QAbstractItemModel::modelReset, + this, &DeviceKitAspectWidget::modelReset); + connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &DeviceKitAspectWidget::currentDeviceChanged); + connect(m_manageButton, &QAbstractButton::clicked, + this, &DeviceKitAspectWidget::manageDevices); + } + + ~DeviceKitAspectWidget() override + { + delete m_comboBox; + delete m_model; + delete m_manageButton; + } + +private: + QWidget *mainWidget() const override { return m_comboBox; } + QWidget *buttonWidget() const override { return m_manageButton; } + void makeReadOnly() override { m_comboBox->setEnabled(false); } + + void refresh() override + { + m_model->setTypeFilter(DeviceTypeKitAspect::deviceTypeId(m_kit)); + m_comboBox->setCurrentIndex(m_model->indexOf(DeviceKitAspect::device(m_kit))); + } + + void manageDevices() + { + Core::ICore::showOptionsDialog(Constants::DEVICE_SETTINGS_PAGE_ID, buttonWidget()); + } + + void modelAboutToReset() + { + m_selectedId = m_model->deviceId(m_comboBox->currentIndex()); + m_ignoreChange = true; + } + + void modelReset() + { + m_comboBox->setCurrentIndex(m_model->indexForId(m_selectedId)); + m_ignoreChange = false; + } + + void currentDeviceChanged() + { + if (m_ignoreChange) + return; + DeviceKitAspect::setDeviceId(m_kit, m_model->deviceId(m_comboBox->currentIndex())); + } + + bool m_isReadOnly = false; + bool m_ignoreChange = false; + QComboBox *m_comboBox; + QPushButton *m_manageButton; + DeviceManagerModel *m_model; + Core::Id m_selectedId; +}; +} // namespace Internal -DeviceKitInformation::DeviceKitInformation() +DeviceKitAspect::DeviceKitAspect() { setObjectName(QLatin1String("DeviceInformation")); - setId(DeviceKitInformation::id()); + setId(DeviceKitAspect::id()); + setDisplayName(tr("Device")); + setDescription(tr("The device to run the applications on.")); setPriority(32000); connect(KitManager::instance(), &KitManager::kitsLoaded, - this, &DeviceKitInformation::kitsWereLoaded); + this, &DeviceKitAspect::kitsWereLoaded); } -QVariant DeviceKitInformation::defaultValue(const Kit *k) const +QVariant DeviceKitAspect::defaultValue(const Kit *k) const { - Core::Id type = DeviceTypeKitInformation::deviceTypeId(k); + Core::Id type = DeviceTypeKitAspect::deviceTypeId(k); // Use default device if that is compatible: IDevice::ConstPtr dev = DeviceManager::instance()->defaultDevice(type); if (dev && dev->isCompatibleWith(k)) @@ -674,9 +986,9 @@ QVariant DeviceKitInformation::defaultValue(const Kit *k) const return QString(); } -QList<Task> DeviceKitInformation::validate(const Kit *k) const +QList<Task> DeviceKitAspect::validate(const Kit *k) const { - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); QList<Task> result; if (dev.isNull()) result.append(Task(Task::Warning, tr("No device set."), @@ -688,9 +1000,9 @@ QList<Task> DeviceKitInformation::validate(const Kit *k) const return result; } -void DeviceKitInformation::fix(Kit *k) +void DeviceKitAspect::fix(Kit *k) { - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); if (!dev.isNull() && !dev->isCompatibleWith(k)) { qWarning("Device is no longer compatible with kit \"%s\", removing it.", qPrintable(k->displayName())); @@ -698,109 +1010,109 @@ void DeviceKitInformation::fix(Kit *k) } } -void DeviceKitInformation::setup(Kit *k) +void DeviceKitAspect::setup(Kit *k) { QTC_ASSERT(DeviceManager::instance()->isLoaded(), return); - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); if (!dev.isNull() && dev->isCompatibleWith(k)) return; setDeviceId(k, Core::Id::fromSetting(defaultValue(k))); } -KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *DeviceKitAspect::createConfigWidget(Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::DeviceInformationConfigWidget(k, this); + return new Internal::DeviceKitAspectWidget(k, this); } -QString DeviceKitInformation::displayNamePostfix(const Kit *k) const +QString DeviceKitAspect::displayNamePostfix(const Kit *k) const { IDevice::ConstPtr dev = device(k); return dev.isNull() ? QString() : dev->displayName(); } -KitInformation::ItemList DeviceKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList DeviceKitAspect::toUserOutput(const Kit *k) const { IDevice::ConstPtr dev = device(k); return ItemList() << qMakePair(tr("Device"), dev.isNull() ? tr("Unconfigured") : dev->displayName()); } -void DeviceKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const +void DeviceKitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const { QTC_ASSERT(kit, return); expander->registerVariable("Device:HostAddress", tr("Host address"), [kit]() -> QString { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->sshParameters().host() : QString(); }); expander->registerVariable("Device:SshPort", tr("SSH port"), [kit]() -> QString { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? QString::number(device->sshParameters().port()) : QString(); }); expander->registerVariable("Device:UserName", tr("User name"), [kit]() -> QString { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->sshParameters().userName() : QString(); }); expander->registerVariable("Device:KeyFile", tr("Private key file"), [kit]() -> QString { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->sshParameters().privateKeyFile : QString(); }); expander->registerVariable("Device:Name", tr("Device name"), [kit]() -> QString { - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->displayName() : QString(); }); } -Core::Id DeviceKitInformation::id() +Core::Id DeviceKitAspect::id() { return "PE.Profile.Device"; } -IDevice::ConstPtr DeviceKitInformation::device(const Kit *k) +IDevice::ConstPtr DeviceKitAspect::device(const Kit *k) { QTC_ASSERT(DeviceManager::instance()->isLoaded(), return IDevice::ConstPtr()); return DeviceManager::instance()->find(deviceId(k)); } -Core::Id DeviceKitInformation::deviceId(const Kit *k) +Core::Id DeviceKitAspect::deviceId(const Kit *k) { - return k ? Core::Id::fromSetting(k->value(DeviceKitInformation::id())) : Core::Id(); + return k ? Core::Id::fromSetting(k->value(DeviceKitAspect::id())) : Core::Id(); } -void DeviceKitInformation::setDevice(Kit *k, IDevice::ConstPtr dev) +void DeviceKitAspect::setDevice(Kit *k, IDevice::ConstPtr dev) { setDeviceId(k, dev ? dev->id() : Core::Id()); } -void DeviceKitInformation::setDeviceId(Kit *k, Core::Id id) +void DeviceKitAspect::setDeviceId(Kit *k, Core::Id id) { QTC_ASSERT(k, return); - k->setValue(DeviceKitInformation::id(), id.toSetting()); + k->setValue(DeviceKitAspect::id(), id.toSetting()); } -void DeviceKitInformation::kitsWereLoaded() +void DeviceKitAspect::kitsWereLoaded() { foreach (Kit *k, KitManager::kits()) fix(k); DeviceManager *dm = DeviceManager::instance(); - connect(dm, &DeviceManager::deviceListReplaced, this, &DeviceKitInformation::devicesChanged); - connect(dm, &DeviceManager::deviceAdded, this, &DeviceKitInformation::devicesChanged); - connect(dm, &DeviceManager::deviceRemoved, this, &DeviceKitInformation::devicesChanged); - connect(dm, &DeviceManager::deviceUpdated, this, &DeviceKitInformation::deviceUpdated); + connect(dm, &DeviceManager::deviceListReplaced, this, &DeviceKitAspect::devicesChanged); + connect(dm, &DeviceManager::deviceAdded, this, &DeviceKitAspect::devicesChanged); + connect(dm, &DeviceManager::deviceRemoved, this, &DeviceKitAspect::devicesChanged); + connect(dm, &DeviceManager::deviceUpdated, this, &DeviceKitAspect::deviceUpdated); connect(KitManager::instance(), &KitManager::kitUpdated, - this, &DeviceKitInformation::kitUpdated); + this, &DeviceKitAspect::kitUpdated); connect(KitManager::instance(), &KitManager::unmanagedKitUpdated, - this, &DeviceKitInformation::kitUpdated); + this, &DeviceKitAspect::kitUpdated); } -void DeviceKitInformation::deviceUpdated(Core::Id id) +void DeviceKitAspect::deviceUpdated(Core::Id id) { foreach (Kit *k, KitManager::kits()) { if (deviceId(k) == id) @@ -808,40 +1120,147 @@ void DeviceKitInformation::deviceUpdated(Core::Id id) } } -void DeviceKitInformation::kitUpdated(Kit *k) +void DeviceKitAspect::kitUpdated(Kit *k) { setup(k); // Set default device if necessary } -void DeviceKitInformation::devicesChanged() +void DeviceKitAspect::devicesChanged() { foreach (Kit *k, KitManager::kits()) setup(k); // Set default device if necessary } // -------------------------------------------------------------------------- -// EnvironmentKitInformation: +// EnvironmentKitAspect: // -------------------------------------------------------------------------- +namespace Internal { +class EnvironmentKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::EnvironmentKitAspect) + +public: + EnvironmentKitAspectWidget(Kit *workingCopy, const KitAspect *ki) + : KitAspectWidget(workingCopy, ki), + m_summaryLabel(new QLabel), + m_manageButton(new QPushButton), + m_mainWidget(new QWidget) + { + auto *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(m_summaryLabel); + if (Utils::HostOsInfo::isWindowsHost()) + initMSVCOutputSwitch(layout); + m_mainWidget->setLayout(layout); + refresh(); + m_manageButton->setText(tr("Change...")); + connect(m_manageButton, &QAbstractButton::clicked, + this, &EnvironmentKitAspectWidget::editEnvironmentChanges); + } + +private: + QWidget *mainWidget() const override { return m_mainWidget; } + QWidget *buttonWidget() const override { return m_manageButton; } + void makeReadOnly() override { m_manageButton->setEnabled(false); } + + void refresh() override + { + const QList<Utils::EnvironmentItem> changes = currentEnvironment(); + QString shortSummary = Utils::EnvironmentItem::toStringList(changes).join(QLatin1String("; ")); + QFontMetrics fm(m_summaryLabel->font()); + shortSummary = fm.elidedText(shortSummary, Qt::ElideRight, m_summaryLabel->width()); + m_summaryLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.") : shortSummary); + } + + void editEnvironmentChanges() + { + bool ok; + Utils::MacroExpander *expander = m_kit->macroExpander(); + Utils::EnvironmentDialog::Polisher polisher = [expander](QWidget *w) { + Core::VariableChooser::addSupportForChildWidgets(w, expander); + }; + QList<Utils::EnvironmentItem> + changes = Utils::EnvironmentDialog::getEnvironmentItems(&ok, + m_summaryLabel, + currentEnvironment(), + QString(), + polisher); + if (!ok) + return; + + if (Utils::HostOsInfo::isWindowsHost()) { + const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033"); + if (m_vslangCheckbox->isChecked() && changes.indexOf(forceMSVCEnglishItem) < 0) + changes.append(forceMSVCEnglishItem); + } + + EnvironmentKitAspect::setEnvironmentChanges(m_kit, changes); + } + + QList<Utils::EnvironmentItem> currentEnvironment() const + { + QList<Utils::EnvironmentItem> changes = EnvironmentKitAspect::environmentChanges(m_kit); + + if (Utils::HostOsInfo::isWindowsHost()) { + const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033"); + if (changes.indexOf(forceMSVCEnglishItem) >= 0) { + m_vslangCheckbox->setCheckState(Qt::Checked); + changes.removeAll(forceMSVCEnglishItem); + } + } + + Utils::sort(changes, [](const Utils::EnvironmentItem &lhs, const Utils::EnvironmentItem &rhs) + { return QString::localeAwareCompare(lhs.name, rhs.name) < 0; }); + return changes; + } + + void initMSVCOutputSwitch(QVBoxLayout *layout) + { + m_vslangCheckbox = new QCheckBox(tr("Force UTF-8 MSVC compiler output")); + layout->addWidget(m_vslangCheckbox); + m_vslangCheckbox->setToolTip(tr("Either switches MSVC to English or keeps the language and " + "just forces UTF-8 output (may vary depending on the used MSVC " + "compiler).")); + connect(m_vslangCheckbox, &QCheckBox::toggled, this, [this](bool checked) { + QList<Utils::EnvironmentItem> changes + = EnvironmentKitAspect::environmentChanges(m_kit); + const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033"); + if (!checked && changes.indexOf(forceMSVCEnglishItem) >= 0) + changes.removeAll(forceMSVCEnglishItem); + if (checked && changes.indexOf(forceMSVCEnglishItem) < 0) + changes.append(forceMSVCEnglishItem); + EnvironmentKitAspect::setEnvironmentChanges(m_kit, changes); + }); + } + + QLabel *m_summaryLabel; + QPushButton *m_manageButton; + QCheckBox *m_vslangCheckbox; + QWidget *m_mainWidget; +}; +} // namespace Internal -EnvironmentKitInformation::EnvironmentKitInformation() +EnvironmentKitAspect::EnvironmentKitAspect() { - setObjectName(QLatin1String("EnvironmentKitInformation")); - setId(EnvironmentKitInformation::id()); + setObjectName(QLatin1String("EnvironmentKitAspect")); + setId(EnvironmentKitAspect::id()); + setDisplayName(tr("Environment")); + setDescription(tr("Additional build environment settings when using this kit.")); setPriority(29000); } -QVariant EnvironmentKitInformation::defaultValue(const Kit *k) const +QVariant EnvironmentKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k) return QStringList(); } -QList<Task> EnvironmentKitInformation::validate(const Kit *k) const +QList<Task> EnvironmentKitAspect::validate(const Kit *k) const { QList<Task> result; QTC_ASSERT(k, return result); - const QVariant variant = k->value(EnvironmentKitInformation::id()); + const QVariant variant = k->value(EnvironmentKitAspect::id()); if (!variant.isNull() && !variant.canConvert(QVariant::List)) { result.append(Task(Task::Error, tr("The environment setting value is invalid."), Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM))); @@ -849,18 +1268,18 @@ QList<Task> EnvironmentKitInformation::validate(const Kit *k) const return result; } -void EnvironmentKitInformation::fix(Kit *k) +void EnvironmentKitAspect::fix(Kit *k) { QTC_ASSERT(k, return); - const QVariant variant = k->value(EnvironmentKitInformation::id()); + const QVariant variant = k->value(EnvironmentKitAspect::id()); if (!variant.isNull() && !variant.canConvert(QVariant::List)) { qWarning("Kit \"%s\" has a wrong environment value set.", qPrintable(k->displayName())); setEnvironmentChanges(k, QList<Utils::EnvironmentItem>()); } } -void EnvironmentKitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const +void EnvironmentKitAspect::addToEnvironment(const Kit *k, Utils::Environment &env) const { const QStringList values = Utils::transform(Utils::EnvironmentItem::toStringList(environmentChanges(k)), @@ -868,34 +1287,34 @@ void EnvironmentKitInformation::addToEnvironment(const Kit *k, Utils::Environmen env.modify(Utils::EnvironmentItem::fromStringList(values)); } -KitConfigWidget *EnvironmentKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *EnvironmentKitAspect::createConfigWidget(Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::KitEnvironmentConfigWidget(k, this); + return new Internal::EnvironmentKitAspectWidget(k, this); } -KitInformation::ItemList EnvironmentKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList EnvironmentKitAspect::toUserOutput(const Kit *k) const { return { qMakePair(tr("Environment"), Utils::EnvironmentItem::toStringList(environmentChanges(k)).join("<br>")) }; } -Core::Id EnvironmentKitInformation::id() +Core::Id EnvironmentKitAspect::id() { return "PE.Profile.Environment"; } -QList<Utils::EnvironmentItem> EnvironmentKitInformation::environmentChanges(const Kit *k) +QList<Utils::EnvironmentItem> EnvironmentKitAspect::environmentChanges(const Kit *k) { if (k) - return Utils::EnvironmentItem::fromStringList(k->value(EnvironmentKitInformation::id()).toStringList()); + return Utils::EnvironmentItem::fromStringList(k->value(EnvironmentKitAspect::id()).toStringList()); return QList<Utils::EnvironmentItem>(); } -void EnvironmentKitInformation::setEnvironmentChanges(Kit *k, const QList<Utils::EnvironmentItem> &changes) +void EnvironmentKitAspect::setEnvironmentChanges(Kit *k, const QList<Utils::EnvironmentItem> &changes) { if (k) - k->setValue(EnvironmentKitInformation::id(), Utils::EnvironmentItem::toStringList(changes)); + k->setValue(EnvironmentKitAspect::id(), Utils::EnvironmentItem::toStringList(changes)); } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitinformation.h b/src/plugins/projectexplorer/kitinformation.h index c32dbefa27..f3c170e195 100644 --- a/src/plugins/projectexplorer/kitinformation.h +++ b/src/plugins/projectexplorer/kitinformation.h @@ -37,25 +37,22 @@ namespace ProjectExplorer { -class KitConfigWidget; +class KitAspectWidget; // -------------------------------------------------------------------------- // SysRootInformation: // -------------------------------------------------------------------------- -class PROJECTEXPLORER_EXPORT SysRootKitInformation : public KitInformation +class PROJECTEXPLORER_EXPORT SysRootKitAspect : public KitAspect { Q_OBJECT public: - SysRootKitInformation(); + SysRootKitAspect(); QVariant defaultValue(const Kit *k) const override; - QList<Task> validate(const Kit *k) const override; - - KitConfigWidget *createConfigWidget(Kit *k) const override; - + KitAspectWidget *createConfigWidget(Kit *k) const override; ItemList toUserOutput(const Kit *k) const override; void addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const override; @@ -68,21 +65,20 @@ public: // ToolChainInformation: // -------------------------------------------------------------------------- -class PROJECTEXPLORER_EXPORT ToolChainKitInformation : public KitInformation +class PROJECTEXPLORER_EXPORT ToolChainKitAspect : public KitAspect { Q_OBJECT public: - ToolChainKitInformation(); + ToolChainKitAspect(); QVariant defaultValue(const Kit *k) const override; - QList<Task> validate(const Kit *k) const override; void upgrade(Kit *k) override; void fix(Kit *k) override; void setup(Kit *k) override; - KitConfigWidget *createConfigWidget(Kit *k) const override; + KitAspectWidget *createConfigWidget(Kit *k) const override; QString displayNamePostfix(const Kit *k) const override; @@ -114,19 +110,16 @@ private: // DeviceTypeInformation: // -------------------------------------------------------------------------- -class PROJECTEXPLORER_EXPORT DeviceTypeKitInformation : public KitInformation +class PROJECTEXPLORER_EXPORT DeviceTypeKitAspect : public KitAspect { Q_OBJECT public: - DeviceTypeKitInformation(); + DeviceTypeKitAspect(); QVariant defaultValue(const Kit *k) const override; - QList<Task> validate(const Kit *k) const override; - - KitConfigWidget *createConfigWidget(Kit *k) const override; - + KitAspectWidget *createConfigWidget(Kit *k) const override; ItemList toUserOutput(const Kit *k) const override; static const Core::Id id(); @@ -143,20 +136,19 @@ public: // DeviceInformation: // -------------------------------------------------------------------------- -class PROJECTEXPLORER_EXPORT DeviceKitInformation : public KitInformation +class PROJECTEXPLORER_EXPORT DeviceKitAspect : public KitAspect { Q_OBJECT public: - DeviceKitInformation(); + DeviceKitAspect(); QVariant defaultValue(const Kit *k) const override; - QList<Task> validate(const Kit *k) const override; void fix(Kit *k) override; void setup(Kit *k) override; - KitConfigWidget *createConfigWidget(Kit *k) const override; + KitAspectWidget *createConfigWidget(Kit *k) const override; QString displayNamePostfix(const Kit *k) const override; @@ -178,23 +170,22 @@ private: }; // -------------------------------------------------------------------------- -// EnvironmentKitInformation: +// EnvironmentKitAspect: // -------------------------------------------------------------------------- -class PROJECTEXPLORER_EXPORT EnvironmentKitInformation : public KitInformation +class PROJECTEXPLORER_EXPORT EnvironmentKitAspect : public KitAspect { Q_OBJECT public: - EnvironmentKitInformation(); + EnvironmentKitAspect(); QVariant defaultValue(const Kit *k) const override; - QList<Task> validate(const Kit *k) const override; void fix(Kit *k) override; void addToEnvironment(const Kit *k, Utils::Environment &env) const override; - KitConfigWidget *createConfigWidget(Kit *k) const override; + KitAspectWidget *createConfigWidget(Kit *k) const override; ItemList toUserOutput(const Kit *k) const override; diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp index a366d84646..57ebc2f9b8 100644 --- a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp @@ -61,76 +61,76 @@ namespace ProjectExplorer { namespace Internal { // -------------------------------------------------------------------------- -// SysRootInformationConfigWidget: +// SysRootKitAspectWidget: // -------------------------------------------------------------------------- -SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k, const KitInformation *ki) : - KitConfigWidget(k, ki) +SysRootKitAspectWidget::SysRootKitAspectWidget(Kit *k, const KitAspect *ki) : + KitAspectWidget(k, ki) { m_chooser = new Utils::PathChooser; m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); m_chooser->setHistoryCompleter(QLatin1String("PE.SysRoot.History")); - m_chooser->setFileName(SysRootKitInformation::sysRoot(k)); + m_chooser->setFileName(SysRootKitAspect::sysRoot(k)); connect(m_chooser, &Utils::PathChooser::pathChanged, - this, &SysRootInformationConfigWidget::pathWasChanged); + this, &SysRootKitAspectWidget::pathWasChanged); } -SysRootInformationConfigWidget::~SysRootInformationConfigWidget() +SysRootKitAspectWidget::~SysRootKitAspectWidget() { delete m_chooser; } -QString SysRootInformationConfigWidget::displayName() const +QString SysRootKitAspectWidget::displayName() const { return tr("Sysroot"); } -QString SysRootInformationConfigWidget::toolTip() const +QString SysRootKitAspectWidget::toolTip() const { return tr("The root directory of the system image to use.<br>" "Leave empty when building for the desktop."); } -void SysRootInformationConfigWidget::setPalette(const QPalette &p) +void SysRootKitAspectWidget::setPalette(const QPalette &p) { - KitConfigWidget::setPalette(p); + KitAspectWidget::setPalette(p); m_chooser->setOkColor(p.color(QPalette::Active, QPalette::Text)); } -void SysRootInformationConfigWidget::refresh() +void SysRootKitAspectWidget::refresh() { if (!m_ignoreChange) - m_chooser->setFileName(SysRootKitInformation::sysRoot(m_kit)); + m_chooser->setFileName(SysRootKitAspect::sysRoot(m_kit)); } -void SysRootInformationConfigWidget::makeReadOnly() +void SysRootKitAspectWidget::makeReadOnly() { m_chooser->setReadOnly(true); } -QWidget *SysRootInformationConfigWidget::mainWidget() const +QWidget *SysRootKitAspectWidget::mainWidget() const { return m_chooser->lineEdit(); } -QWidget *SysRootInformationConfigWidget::buttonWidget() const +QWidget *SysRootKitAspectWidget::buttonWidget() const { return m_chooser->buttonAtIndex(0); } -void SysRootInformationConfigWidget::pathWasChanged() +void SysRootKitAspectWidget::pathWasChanged() { m_ignoreChange = true; - SysRootKitInformation::setSysRoot(m_kit, m_chooser->fileName()); + SysRootKitAspect::setSysRoot(m_kit, m_chooser->fileName()); m_ignoreChange = false; } // -------------------------------------------------------------------------- -// ToolChainInformationConfigWidget: +// ToolChainKitAspectWidget: // -------------------------------------------------------------------------- -ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, const KitInformation *ki) : - KitConfigWidget(k, ki) +ToolChainKitAspectWidget::ToolChainKitAspectWidget(Kit *k, const KitAspect *ki) : + KitAspectWidget(k, ki) { m_mainWidget = new QWidget; m_mainWidget->setContentsMargins(0, 0, 0, 0); @@ -163,31 +163,31 @@ ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, const refresh(); - m_manageButton = new QPushButton(KitConfigWidget::msgManage()); + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); m_manageButton->setContentsMargins(0, 0, 0, 0); connect(m_manageButton, &QAbstractButton::clicked, - this, &ToolChainInformationConfigWidget::manageToolChains); + this, &ToolChainKitAspectWidget::manageToolChains); } -ToolChainInformationConfigWidget::~ToolChainInformationConfigWidget() +ToolChainKitAspectWidget::~ToolChainKitAspectWidget() { delete m_mainWidget; delete m_manageButton; } -QString ToolChainInformationConfigWidget::displayName() const +QString ToolChainKitAspectWidget::displayName() const { return tr("Compiler"); } -QString ToolChainInformationConfigWidget::toolTip() const +QString ToolChainKitAspectWidget::toolTip() const { return tr("The compiler to use for building.<br>" "Make sure the compiler will produce binaries compatible with the target device, " "Qt version and other libraries used."); } -void ToolChainInformationConfigWidget::refresh() +void ToolChainKitAspectWidget::refresh() { m_ignoreChanges = true; @@ -203,13 +203,13 @@ void ToolChainInformationConfigWidget::refresh() cb->addItem(tc->displayName(), tc->id()); cb->setEnabled(cb->count() > 1 && !m_isReadOnly); - const int index = indexOf(cb, ToolChainKitInformation::toolChain(m_kit, l)); + const int index = indexOf(cb, ToolChainKitAspect::toolChain(m_kit, l)); cb->setCurrentIndex(index); } m_ignoreChanges = false; } -void ToolChainInformationConfigWidget::makeReadOnly() +void ToolChainKitAspectWidget::makeReadOnly() { m_isReadOnly = true; foreach (Core::Id l, m_languageComboboxMap.keys()) { @@ -217,22 +217,22 @@ void ToolChainInformationConfigWidget::makeReadOnly() } } -QWidget *ToolChainInformationConfigWidget::mainWidget() const +QWidget *ToolChainKitAspectWidget::mainWidget() const { return m_mainWidget; } -QWidget *ToolChainInformationConfigWidget::buttonWidget() const +QWidget *ToolChainKitAspectWidget::buttonWidget() const { return m_manageButton; } -void ToolChainInformationConfigWidget::manageToolChains() +void ToolChainKitAspectWidget::manageToolChains() { ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, buttonWidget()); } -void ToolChainInformationConfigWidget::currentToolChainChanged(Id language, int idx) +void ToolChainKitAspectWidget::currentToolChainChanged(Id language, int idx) { if (m_ignoreChanges || idx < 0) return; @@ -241,12 +241,12 @@ void ToolChainInformationConfigWidget::currentToolChainChanged(Id language, int ToolChain *tc = ToolChainManager::findToolChain(id); QTC_ASSERT(!tc || tc->language() == language, return); if (tc) - ToolChainKitInformation::setToolChain(m_kit, tc); + ToolChainKitAspect::setToolChain(m_kit, tc); else - ToolChainKitInformation::clearToolChain(m_kit, language); + ToolChainKitAspect::clearToolChain(m_kit, language); } -int ToolChainInformationConfigWidget::indexOf(QComboBox *cb, const ToolChain *tc) +int ToolChainKitAspectWidget::indexOf(QComboBox *cb, const ToolChain *tc) { const QByteArray id = tc ? tc->id() : QByteArray(); for (int i = 0; i < cb->count(); ++i) { @@ -257,11 +257,11 @@ int ToolChainInformationConfigWidget::indexOf(QComboBox *cb, const ToolChain *tc } // -------------------------------------------------------------------------- -// DeviceTypeInformationConfigWidget: +// DeviceTypeKitAspectWidget: // -------------------------------------------------------------------------- -DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy, const KitInformation *ki) : - KitConfigWidget(workingCopy, ki), m_comboBox(new QComboBox) +DeviceTypeKitAspectWidget::DeviceTypeKitAspectWidget(Kit *workingCopy, const KitAspect *ki) : + KitAspectWidget(workingCopy, ki), m_comboBox(new QComboBox) { for (IDeviceFactory *factory : IDeviceFactory::allDeviceFactories()) m_comboBox->addItem(factory->displayName(), factory->deviceType().toSetting()); @@ -270,32 +270,32 @@ DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workin refresh(); connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &DeviceTypeInformationConfigWidget::currentTypeChanged); + this, &DeviceTypeKitAspectWidget::currentTypeChanged); } -DeviceTypeInformationConfigWidget::~DeviceTypeInformationConfigWidget() +DeviceTypeKitAspectWidget::~DeviceTypeKitAspectWidget() { delete m_comboBox; } -QWidget *DeviceTypeInformationConfigWidget::mainWidget() const +QWidget *DeviceTypeKitAspectWidget::mainWidget() const { return m_comboBox; } -QString DeviceTypeInformationConfigWidget::displayName() const +QString DeviceTypeKitAspectWidget::displayName() const { return tr("Device type"); } -QString DeviceTypeInformationConfigWidget::toolTip() const +QString DeviceTypeKitAspectWidget::toolTip() const { return tr("The type of device to run applications on."); } -void DeviceTypeInformationConfigWidget::refresh() +void DeviceTypeKitAspectWidget::refresh() { - Id devType = DeviceTypeKitInformation::deviceTypeId(m_kit); + Id devType = DeviceTypeKitAspect::deviceTypeId(m_kit); if (!devType.isValid()) m_comboBox->setCurrentIndex(-1); for (int i = 0; i < m_comboBox->count(); ++i) { @@ -306,112 +306,112 @@ void DeviceTypeInformationConfigWidget::refresh() } } -void DeviceTypeInformationConfigWidget::makeReadOnly() +void DeviceTypeKitAspectWidget::makeReadOnly() { m_comboBox->setEnabled(false); } -void DeviceTypeInformationConfigWidget::currentTypeChanged(int idx) +void DeviceTypeKitAspectWidget::currentTypeChanged(int idx) { Id type = idx < 0 ? Id() : Id::fromSetting(m_comboBox->itemData(idx)); - DeviceTypeKitInformation::setDeviceTypeId(m_kit, type); + DeviceTypeKitAspect::setDeviceTypeId(m_kit, type); } // -------------------------------------------------------------------------- -// DeviceInformationConfigWidget: +// DeviceKitAspectWidget: // -------------------------------------------------------------------------- -DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *workingCopy, const KitInformation *ki) : - KitConfigWidget(workingCopy, ki), +DeviceKitAspectWidget::DeviceKitAspectWidget(Kit *workingCopy, const KitAspect *ki) : + KitAspectWidget(workingCopy, ki), m_comboBox(new QComboBox), m_model(new DeviceManagerModel(DeviceManager::instance())) { m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy()); m_comboBox->setModel(m_model); - m_manageButton = new QPushButton(KitConfigWidget::msgManage()); + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); refresh(); m_comboBox->setToolTip(toolTip()); connect(m_model, &QAbstractItemModel::modelAboutToBeReset, - this, &DeviceInformationConfigWidget::modelAboutToReset); + this, &DeviceKitAspectWidget::modelAboutToReset); connect(m_model, &QAbstractItemModel::modelReset, - this, &DeviceInformationConfigWidget::modelReset); + this, &DeviceKitAspectWidget::modelReset); connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &DeviceInformationConfigWidget::currentDeviceChanged); + this, &DeviceKitAspectWidget::currentDeviceChanged); connect(m_manageButton, &QAbstractButton::clicked, - this, &DeviceInformationConfigWidget::manageDevices); + this, &DeviceKitAspectWidget::manageDevices); } -DeviceInformationConfigWidget::~DeviceInformationConfigWidget() +DeviceKitAspectWidget::~DeviceKitAspectWidget() { delete m_comboBox; delete m_model; delete m_manageButton; } -QWidget *DeviceInformationConfigWidget::mainWidget() const +QWidget *DeviceKitAspectWidget::mainWidget() const { return m_comboBox; } -QString DeviceInformationConfigWidget::displayName() const +QString DeviceKitAspectWidget::displayName() const { return tr("Device"); } -QString DeviceInformationConfigWidget::toolTip() const +QString DeviceKitAspectWidget::toolTip() const { return tr("The device to run the applications on."); } -void DeviceInformationConfigWidget::refresh() +void DeviceKitAspectWidget::refresh() { - m_model->setTypeFilter(DeviceTypeKitInformation::deviceTypeId(m_kit)); - m_comboBox->setCurrentIndex(m_model->indexOf(DeviceKitInformation::device(m_kit))); + m_model->setTypeFilter(DeviceTypeKitAspect::deviceTypeId(m_kit)); + m_comboBox->setCurrentIndex(m_model->indexOf(DeviceKitAspect::device(m_kit))); } -void DeviceInformationConfigWidget::makeReadOnly() +void DeviceKitAspectWidget::makeReadOnly() { m_comboBox->setEnabled(false); } -QWidget *DeviceInformationConfigWidget::buttonWidget() const +QWidget *DeviceKitAspectWidget::buttonWidget() const { return m_manageButton; } -void DeviceInformationConfigWidget::manageDevices() +void DeviceKitAspectWidget::manageDevices() { ICore::showOptionsDialog(Constants::DEVICE_SETTINGS_PAGE_ID, buttonWidget()); } -void DeviceInformationConfigWidget::modelAboutToReset() +void DeviceKitAspectWidget::modelAboutToReset() { m_selectedId = m_model->deviceId(m_comboBox->currentIndex()); m_ignoreChange = true; } -void DeviceInformationConfigWidget::modelReset() +void DeviceKitAspectWidget::modelReset() { m_comboBox->setCurrentIndex(m_model->indexForId(m_selectedId)); m_ignoreChange = false; } -void DeviceInformationConfigWidget::currentDeviceChanged() +void DeviceKitAspectWidget::currentDeviceChanged() { if (m_ignoreChange) return; - DeviceKitInformation::setDeviceId(m_kit, m_model->deviceId(m_comboBox->currentIndex())); + DeviceKitAspect::setDeviceId(m_kit, m_model->deviceId(m_comboBox->currentIndex())); } // -------------------------------------------------------------------- -// KitEnvironmentConfigWidget: +// EnvironmentKitAspectWidget: // -------------------------------------------------------------------- -KitEnvironmentConfigWidget::KitEnvironmentConfigWidget(Kit *workingCopy, const KitInformation *ki) : - KitConfigWidget(workingCopy, ki), +EnvironmentKitAspectWidget::EnvironmentKitAspectWidget(Kit *workingCopy, const KitAspect *ki) : + KitAspectWidget(workingCopy, ki), m_summaryLabel(new QLabel), m_manageButton(new QPushButton), m_mainWidget(new QWidget) @@ -427,25 +427,25 @@ KitEnvironmentConfigWidget::KitEnvironmentConfigWidget(Kit *workingCopy, const K refresh(); m_manageButton->setText(tr("Change...")); connect(m_manageButton, &QAbstractButton::clicked, - this, &KitEnvironmentConfigWidget::editEnvironmentChanges); + this, &EnvironmentKitAspectWidget::editEnvironmentChanges); } -QWidget *KitEnvironmentConfigWidget::mainWidget() const +QWidget *EnvironmentKitAspectWidget::mainWidget() const { return m_mainWidget; } -QString KitEnvironmentConfigWidget::displayName() const +QString EnvironmentKitAspectWidget::displayName() const { return tr("Environment"); } -QString KitEnvironmentConfigWidget::toolTip() const +QString EnvironmentKitAspectWidget::toolTip() const { return tr("Additional build environment settings when using this kit."); } -void KitEnvironmentConfigWidget::refresh() +void EnvironmentKitAspectWidget::refresh() { const QList<Utils::EnvironmentItem> changes = currentEnvironment(); QString shortSummary = Utils::EnvironmentItem::toStringList(changes).join(QLatin1String("; ")); @@ -454,14 +454,14 @@ void KitEnvironmentConfigWidget::refresh() m_summaryLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.") : shortSummary); } -void KitEnvironmentConfigWidget::makeReadOnly() +void EnvironmentKitAspectWidget::makeReadOnly() { m_manageButton->setEnabled(false); } -QList<Utils::EnvironmentItem> KitEnvironmentConfigWidget::currentEnvironment() const +QList<Utils::EnvironmentItem> EnvironmentKitAspectWidget::currentEnvironment() const { - QList<Utils::EnvironmentItem> changes = EnvironmentKitInformation::environmentChanges(m_kit); + QList<Utils::EnvironmentItem> changes = EnvironmentKitAspect::environmentChanges(m_kit); if (Utils::HostOsInfo::isWindowsHost()) { const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033"); @@ -476,7 +476,7 @@ QList<Utils::EnvironmentItem> KitEnvironmentConfigWidget::currentEnvironment() c return changes; } -void KitEnvironmentConfigWidget::editEnvironmentChanges() +void EnvironmentKitAspectWidget::editEnvironmentChanges() { bool ok; Utils::MacroExpander *expander = m_kit->macroExpander(); @@ -498,15 +498,15 @@ void KitEnvironmentConfigWidget::editEnvironmentChanges() changes.append(forceMSVCEnglishItem); } - EnvironmentKitInformation::setEnvironmentChanges(m_kit, changes); + EnvironmentKitAspect::setEnvironmentChanges(m_kit, changes); } -QWidget *KitEnvironmentConfigWidget::buttonWidget() const +QWidget *EnvironmentKitAspectWidget::buttonWidget() const { return m_manageButton; } -void KitEnvironmentConfigWidget::initMSVCOutputSwitch(QVBoxLayout *layout) +void EnvironmentKitAspectWidget::initMSVCOutputSwitch(QVBoxLayout *layout) { m_vslangCheckbox = new QCheckBox(tr("Force UTF-8 MSVC compiler output")); layout->addWidget(m_vslangCheckbox); @@ -515,13 +515,13 @@ void KitEnvironmentConfigWidget::initMSVCOutputSwitch(QVBoxLayout *layout) "compiler).")); connect(m_vslangCheckbox, &QCheckBox::toggled, this, [this](bool checked) { QList<Utils::EnvironmentItem> changes - = EnvironmentKitInformation::environmentChanges(m_kit); + = EnvironmentKitAspect::environmentChanges(m_kit); const Utils::EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033"); if (!checked && changes.indexOf(forceMSVCEnglishItem) >= 0) changes.removeAll(forceMSVCEnglishItem); if (checked && changes.indexOf(forceMSVCEnglishItem) < 0) changes.append(forceMSVCEnglishItem); - EnvironmentKitInformation::setEnvironmentChanges(m_kit, changes); + EnvironmentKitAspect::setEnvironmentChanges(m_kit, changes); }); } diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.h b/src/plugins/projectexplorer/kitinformationconfigwidget.h deleted file mode 100644 index 5fb6016d8c..0000000000 --- a/src/plugins/projectexplorer/kitinformationconfigwidget.h +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "kitconfigwidget.h" -#include "toolchain.h" - -#include <coreplugin/id.h> - -#include <utils/environment.h> - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QComboBox; -class QLabel; -class QPlainTextEdit; -class QPushButton; -class QVBoxLayout; -QT_END_NAMESPACE - -namespace Utils { class PathChooser; } - -namespace ProjectExplorer { - -class DeviceManagerModel; - -namespace Internal { - -// -------------------------------------------------------------------------- -// SysRootInformationConfigWidget: -// -------------------------------------------------------------------------- - -class SysRootInformationConfigWidget : public KitConfigWidget -{ - Q_OBJECT - -public: - SysRootInformationConfigWidget(Kit *k, const KitInformation *ki); - ~SysRootInformationConfigWidget() override; - - QString displayName() const override; - void refresh() override; - void makeReadOnly() override; - QWidget *buttonWidget() const override; - QWidget *mainWidget() const override; - QString toolTip() const override; - - void setPalette(const QPalette &p) override; - -private: - void pathWasChanged(); - - Utils::PathChooser *m_chooser; - bool m_ignoreChange = false; -}; - -// -------------------------------------------------------------------------- -// ToolChainInformationConfigWidget: -// -------------------------------------------------------------------------- - -class ToolChainInformationConfigWidget : public KitConfigWidget -{ - Q_OBJECT - -public: - ToolChainInformationConfigWidget(Kit *k, const KitInformation *ki); - ~ToolChainInformationConfigWidget() override; - - QString displayName() const override; - void refresh() override; - void makeReadOnly() override; - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString toolTip() const override; - -private: - void manageToolChains(); - void currentToolChainChanged(Core::Id language, int idx); - - int indexOf(QComboBox *cb, const ToolChain *tc); - - QWidget *m_mainWidget = nullptr; - QPushButton *m_manageButton = nullptr; - QHash<Core::Id, QComboBox *> m_languageComboboxMap; - bool m_ignoreChanges = false; - bool m_isReadOnly = false; -}; - -// -------------------------------------------------------------------------- -// DeviceTypeInformationConfigWidget: -// -------------------------------------------------------------------------- - -class DeviceTypeInformationConfigWidget : public KitConfigWidget -{ - Q_OBJECT - -public: - DeviceTypeInformationConfigWidget(Kit *workingCopy, const KitInformation *ki); - ~DeviceTypeInformationConfigWidget() override; - - QWidget *mainWidget() const override; - QString displayName() const override; - QString toolTip() const override; - void refresh() override; - void makeReadOnly() override; - -private: - void currentTypeChanged(int idx); - - QComboBox *m_comboBox; -}; - -// -------------------------------------------------------------------------- -// DeviceInformationConfigWidget: -// -------------------------------------------------------------------------- - -class DeviceInformationConfigWidget : public KitConfigWidget -{ - Q_OBJECT - -public: - DeviceInformationConfigWidget(Kit *workingCopy, const KitInformation *ki); - ~DeviceInformationConfigWidget() override; - - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString displayName() const override; - QString toolTip() const override; - void refresh() override; - void makeReadOnly() override; - -private: - void manageDevices(); - void modelAboutToReset(); - void modelReset(); - void currentDeviceChanged(); - - bool m_isReadOnly = false; - bool m_ignoreChange = false; - QComboBox *m_comboBox; - QPushButton *m_manageButton; - DeviceManagerModel *m_model; - Core::Id m_selectedId; -}; - -class KitEnvironmentConfigWidget : public KitConfigWidget -{ - Q_OBJECT - -public: - KitEnvironmentConfigWidget(Kit *workingCopy, const KitInformation *ki); - - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString displayName() const override; - QString toolTip() const override; - void refresh() override; - void makeReadOnly() override; - -private: - void editEnvironmentChanges(); - QList<Utils::EnvironmentItem> currentEnvironment() const; - - void initMSVCOutputSwitch(QVBoxLayout *layout); - - QLabel *m_summaryLabel; - QPushButton *m_manageButton; - QCheckBox *m_vslangCheckbox; - QWidget *m_mainWidget; -}; - -} // namespace Internal -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index 499f1f19b4..0b4984fd24 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -41,6 +41,7 @@ #include <utils/stringutils.h> #include <QSettings> +#include <QStyle> using namespace Core; using namespace Utils; @@ -53,6 +54,7 @@ const char KIT_DATA_KEY[] = "Profile."; const char KIT_COUNT_KEY[] = "Profile.Count"; const char KIT_FILE_VERSION_KEY[] = "Version"; const char KIT_DEFAULT_KEY[] = "Profile.Default"; +const char KIT_IRRELEVANT_ASPECTS_KEY[] = "Kit.IrrelevantAspects"; const char KIT_FILENAME[] = "/profiles.xml"; static FileName settingsFileName() @@ -69,9 +71,10 @@ class KitManagerPrivate public: Kit *m_defaultKit = nullptr; bool m_initialized = false; - std::vector<std::unique_ptr<KitInformation>> m_informationList; + std::vector<std::unique_ptr<KitAspect>> m_informationList; std::vector<std::unique_ptr<Kit>> m_kitList; std::unique_ptr<PersistentSettingsWriter> m_writer; + QSet<Id> m_irrelevantAspects; }; } // namespace Internal @@ -151,11 +154,11 @@ void KitManager::restoreKits() Kit *ptr = i->get(); // Overwrite settings that the SDK sets to those values: - foreach (const KitInformation *ki, KitManager::kitInformation()) { + for (const KitAspect *aspect : KitManager::kitAspects()) { // Copy sticky settings over: - if (ptr->isSticky(ki->id())) { - ptr->setValue(ki->id(), toStore->value(ki->id())); - ptr->setSticky(ki->id(), true); + if (ptr->isSticky(aspect->id())) { + ptr->setValue(aspect->id(), toStore->value(aspect->id())); + ptr->setSticky(aspect->id(), true); } } toStore = std::move(*i); @@ -219,6 +222,8 @@ void KitManager::saveKits() data.insert(QLatin1String(KIT_COUNT_KEY), count); data.insert(QLatin1String(KIT_DEFAULT_KEY), d->m_defaultKit ? QString::fromLatin1(d->m_defaultKit->id().name()) : QString()); + data.insert(KIT_IRRELEVANT_ASPECTS_KEY, + transform<QVariantList>(d->m_irrelevantAspects, &Id::toSetting)); d->m_writer->save(data, ICore::mainWindow()); } @@ -227,7 +232,7 @@ bool KitManager::isLoaded() return d->m_initialized; } -void KitManager::registerKitInformation(std::unique_ptr<KitInformation> &&ki) +void KitManager::registerKitAspect(std::unique_ptr<KitAspect> &&ki) { QTC_ASSERT(ki->id().isValid(), return ); QTC_ASSERT(!Utils::contains(d->m_informationList, ki.get()), return ); @@ -235,8 +240,8 @@ void KitManager::registerKitInformation(std::unique_ptr<KitInformation> &&ki) auto it = std::lower_bound(std::begin(d->m_informationList), std::end(d->m_informationList), ki, - [](const std::unique_ptr<KitInformation> &a, - const std::unique_ptr<KitInformation> &b) { + [](const std::unique_ptr<KitAspect> &a, + const std::unique_ptr<KitAspect> &b) { return a->priority() > b->priority(); }); d->m_informationList.insert(it, std::move(ki)); @@ -334,6 +339,9 @@ KitManager::KitList KitManager::restoreKits(const FileName &fileName) if (Utils::contains(result.kits, [id](const std::unique_ptr<Kit> &k) { return k->id() == id; })) result.defaultKit = id; + const auto it = data.constFind(KIT_IRRELEVANT_ASPECTS_KEY); + if (it != data.constEnd()) + d->m_irrelevantAspects = transform<QSet<Id>>(it.value().toList(), &Id::fromSetting); return result; } @@ -364,20 +372,19 @@ Kit *KitManager::defaultKit() return d->m_defaultKit; } -QList<KitInformation *> KitManager::kitInformation() +const QList<KitAspect *> KitManager::kitAspects() { return Utils::toRawPointer<QList>(d->m_informationList); } -KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k) +const QSet<Id> KitManager::irrelevantAspects() { - auto *result = new KitManagerConfigWidget(k); - foreach (KitInformation *ki, kitInformation()) - result->addConfigWidget(ki->createConfigWidget(result->workingCopy())); - - result->updateVisibility(); + return d->m_irrelevantAspects; +} - return result; +void KitManager::setIrrelevantAspects(const QSet<Id> &aspects) +{ + d->m_irrelevantAspects = aspects; } void KitManager::notifyAboutUpdate(Kit *k) @@ -442,7 +449,7 @@ void KitManager::completeKit(Kit *k) { QTC_ASSERT(k, return); KitGuard g(k); - for (const std::unique_ptr<KitInformation> &ki : d->m_informationList) { + for (const std::unique_ptr<KitAspect> &ki : d->m_informationList) { ki->upgrade(k); if (!k->hasValue(ki->id())) k->setValue(ki->id(), ki->defaultValue(k)); @@ -452,51 +459,81 @@ void KitManager::completeKit(Kit *k) } // -------------------------------------------------------------------- -// KitInformation: +// KitAspect: // -------------------------------------------------------------------- -void KitInformation::addToEnvironment(const Kit *k, Environment &env) const +void KitAspect::addToEnvironment(const Kit *k, Environment &env) const { Q_UNUSED(k); Q_UNUSED(env); } -IOutputParser *KitInformation::createOutputParser(const Kit *k) const +IOutputParser *KitAspect::createOutputParser(const Kit *k) const { Q_UNUSED(k); return nullptr; } -QString KitInformation::displayNamePostfix(const Kit *k) const +QString KitAspect::displayNamePostfix(const Kit *k) const { Q_UNUSED(k); return QString(); } -QSet<Id> KitInformation::supportedPlatforms(const Kit *k) const +QSet<Id> KitAspect::supportedPlatforms(const Kit *k) const { Q_UNUSED(k); return QSet<Id>(); } -QSet<Id> KitInformation::availableFeatures(const Kit *k) const +QSet<Id> KitAspect::availableFeatures(const Kit *k) const { Q_UNUSED(k); return QSet<Id>(); } -void KitInformation::addToMacroExpander(Kit *k, MacroExpander *expander) const +void KitAspect::addToMacroExpander(Kit *k, MacroExpander *expander) const { Q_UNUSED(k); Q_UNUSED(expander); } -void KitInformation::notifyAboutUpdate(Kit *k) +void KitAspect::notifyAboutUpdate(Kit *k) { if (k) k->kitUpdated(); } +KitAspectWidget::KitAspectWidget(Kit *kit, const KitAspect *ki) : m_kit(kit), + m_kitInformation(ki), m_isSticky(kit->isSticky(ki->id())) +{ } + +Core::Id KitAspectWidget::kitInformationId() const +{ + return m_kitInformation->id(); +} + +QString KitAspectWidget::msgManage() +{ + return tr("Manage..."); +} + +void KitAspectWidget::setPalette(const QPalette &p) +{ + if (mainWidget()) + mainWidget()->setPalette(p); + if (buttonWidget()) + buttonWidget()->setPalette(p); +} + +void KitAspectWidget::setStyle(QStyle *s) +{ + if (mainWidget()) + mainWidget()->setStyle(s); + if (buttonWidget()) + buttonWidget()->setStyle(s); +} + // -------------------------------------------------------------------- // KitFeatureProvider: // -------------------------------------------------------------------- diff --git a/src/plugins/projectexplorer/kitmanager.h b/src/plugins/projectexplorer/kitmanager.h index 189dc1c216..4b031846a0 100644 --- a/src/plugins/projectexplorer/kitmanager.h +++ b/src/plugins/projectexplorer/kitmanager.h @@ -34,9 +34,14 @@ #include <QObject> #include <QPair> +#include <QSet> #include <functional> +QT_BEGIN_NAMESPACE +class QStyle; +QT_END_NAMESPACE + namespace Utils { class Environment; class FileName; @@ -46,22 +51,21 @@ class MacroExpander; namespace ProjectExplorer { class Task; class IOutputParser; -class KitConfigWidget; +class KitAspectWidget; class KitManager; namespace Internal { -class KitManagerConfigWidget; class KitModel; } // namespace Internal /** - * @brief The KitInformation class + * @brief The KitAspect class * * One piece of information stored in the kit. * * This needs to get registered with the \a KitManager. */ -class PROJECTEXPLORER_EXPORT KitInformation : public QObject +class PROJECTEXPLORER_EXPORT KitAspect : public QObject { Q_OBJECT @@ -71,6 +75,9 @@ public: Core::Id id() const { return m_id; } int priority() const { return m_priority; } + QString displayName() const { return m_displayName; } + QString description() const { return m_description; } + bool isEssential() const { return m_essential; } virtual QVariant defaultValue(const Kit *) const = 0; @@ -85,7 +92,7 @@ public: virtual ItemList toUserOutput(const Kit *) const = 0; - virtual KitConfigWidget *createConfigWidget(Kit *) const = 0; + virtual KitAspectWidget *createConfigWidget(Kit *) const = 0; virtual void addToEnvironment(const Kit *k, Utils::Environment &env) const; virtual IOutputParser *createOutputParser(const Kit *k) const; @@ -97,14 +104,56 @@ public: virtual void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const; + virtual bool isApplicableToKit(const Kit *) const { return true; } + protected: void setId(Core::Id id) { m_id = id; } + void setDisplayName(const QString &name) { m_displayName = name; } + void setDescription(const QString &desc) { m_description = desc; } + void makeEssential() { m_essential = true; } void setPriority(int priority) { m_priority = priority; } void notifyAboutUpdate(Kit *k); private: + QString m_displayName; + QString m_description; Core::Id m_id; int m_priority = 0; // The higher the closer to the top. + bool m_essential = false; +}; + +class PROJECTEXPLORER_EXPORT KitAspectWidget : public QObject +{ + Q_OBJECT + +public: + KitAspectWidget(Kit *kit, const KitAspect *ki); + + Core::Id kitInformationId() const; + + virtual void makeReadOnly() = 0; + virtual void refresh() = 0; + bool visibleInKit() { return m_kitInformation->isApplicableToKit(m_kit); } + + virtual QWidget *mainWidget() const = 0; + virtual QWidget *buttonWidget() const { return nullptr; } + + bool isSticky() const { return m_isSticky; } + + static QString msgManage(); + + Kit *kit() const { return m_kit; } + + virtual void setPalette(const QPalette &p); + virtual void setStyle(QStyle *s); + +signals: + void dirty(); + +protected: + Kit *m_kit; + const KitAspect *m_kitInformation; + bool m_isSticky; }; class PROJECTEXPLORER_EXPORT KitManager : public QObject @@ -120,17 +169,17 @@ public: static Kit *kit(Core::Id id); static Kit *defaultKit(); - static QList<KitInformation *> kitInformation(); - - static Internal::KitManagerConfigWidget *createConfigWidget(Kit *k); + static const QList<KitAspect *> kitAspects(); + static const QSet<Core::Id> irrelevantAspects(); + static void setIrrelevantAspects(const QSet<Core::Id> &aspects); static bool registerKit(std::unique_ptr<Kit> &&k); static void deregisterKit(Kit *k); static void setDefaultKit(Kit *k); template<typename KI, typename... Args> - static void registerKitInformation(Args&&... args) { - registerKitInformation(std::make_unique<KI>(std::forward<Args>(args)...)); + static void registerKitAspect(Args&&... args) { + registerKitAspect(std::make_unique<KI>(std::forward<Args>(args)...)); } static QSet<Core::Id> supportedPlatforms(); @@ -159,10 +208,10 @@ signals: private: explicit KitManager(QObject *parent = nullptr); - static void registerKitInformation(std::unique_ptr<KitInformation> &&ki); + static void registerKitAspect(std::unique_ptr<KitAspect> &&ki); // Make sure the this is only called after all - // KitInformation are registered! + // KitAspects are registered! void restoreKits(); class KitList { @@ -178,7 +227,7 @@ private: friend class ProjectExplorerPlugin; // for constructor friend class Kit; friend class Internal::KitModel; - friend class KitInformation; // for notifyAbutUpdate + friend class KitAspect; // for notifyAbutUpdate }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index 473c8455e2..7624da21d9 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -45,6 +45,7 @@ #include <QLabel> #include <QLineEdit> #include <QPainter> +#include <QPushButton> #include <QToolButton> #include <QScrollArea> #include <QSizePolicy> @@ -121,6 +122,15 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) : auto chooser = new Core::VariableChooser(this); chooser->addSupportedWidget(m_nameEdit); chooser->addMacroExpanderProvider([this]() { return m_modifiedKit->macroExpander(); }); + + for (KitAspect *aspect : KitManager::kitAspects()) + addAspectToWorkingCopy(aspect); + + updateVisibility(); + + if (k && k->isAutoDetected()) + makeStickySubWidgetsReadOnly(); + setVisible(false); } KitManagerConfigWidget::~KitManagerConfigWidget() @@ -211,22 +221,25 @@ QString KitManagerConfigWidget::validityMessage() const return m_modifiedKit->toHtml(tmp); } -void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget) +void KitManagerConfigWidget::addAspectToWorkingCopy(KitAspect *aspect) { + QTC_ASSERT(aspect, return); + KitAspectWidget *widget = aspect->createConfigWidget(workingCopy()); QTC_ASSERT(widget, return); QTC_ASSERT(!m_widgets.contains(widget), return); - const QString name = widget->displayName() + ':'; - QString toolTip = widget->toolTip(); + const QString name = aspect->displayName() + ':'; + QString toolTip = aspect->description(); auto action = new QAction(tr("Mark as Mutable"), nullptr); action->setCheckable(true); - action->setChecked(widget->isMutable()); + action->setChecked(workingCopy()->isMutable(aspect->id())); + action->setEnabled(!widget->isSticky()); widget->mainWidget()->addAction(action); widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(action, &QAction::toggled, this, [this, widget, action] { - widget->setMutable(action->isChecked()); + connect(action, &QAction::toggled, this, [this, aspect, action] { + workingCopy()->setMutable(aspect->id(), action->isChecked()); emit dirty(); }); @@ -249,8 +262,9 @@ void KitManagerConfigWidget::updateVisibility() { int count = m_widgets.count(); for (int i = 0; i < count; ++i) { - KitConfigWidget *widget = m_widgets.at(i); - bool visible = widget->visibleInKit(); + KitAspectWidget *widget = m_widgets.at(i); + const bool visible = widget->visibleInKit() + && !m_modifiedKit->irrelevantAspects().contains(widget->kitInformationId()); widget->mainWidget()->setVisible(visible); if (widget->buttonWidget()) widget->buttonWidget()->setVisible(visible); @@ -265,7 +279,7 @@ void KitManagerConfigWidget::setHasUniqueName(bool unique) void KitManagerConfigWidget::makeStickySubWidgetsReadOnly() { - foreach (KitConfigWidget *w, m_widgets) { + foreach (KitAspectWidget *w, m_widgets) { if (w->isSticky()) w->makeReadOnly(); } @@ -348,7 +362,7 @@ void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k) k->fix(); m_fixingKit = false; - foreach (KitConfigWidget *w, m_widgets) + foreach (KitAspectWidget *w, m_widgets) w->refresh(); m_cachedDisplayName.clear(); @@ -376,7 +390,7 @@ void KitManagerConfigWidget::kitWasUpdated(Kit *k) void KitManagerConfigWidget::showEvent(QShowEvent *event) { Q_UNUSED(event); - foreach (KitConfigWidget *widget, m_widgets) + foreach (KitAspectWidget *widget, m_widgets) widget->refresh(); } diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.h b/src/plugins/projectexplorer/kitmanagerconfigwidget.h index 026a8e25b4..8617a118cf 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.h +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.h @@ -25,7 +25,7 @@ #pragma once -#include "kitconfigwidget.h" +#include "kitmanager.h" #include <QWidget> @@ -60,7 +60,7 @@ public: bool isValid() const; bool hasWarning() const; QString validityMessage() const; - void addConfigWidget(KitConfigWidget *widget); + void addAspectToWorkingCopy(KitAspect *aspect); void makeStickySubWidgetsReadOnly(); Kit *workingCopy() const; @@ -97,7 +97,7 @@ private: QToolButton *m_iconButton; QLineEdit *m_nameEdit; QLineEdit *m_fileSystemFriendlyNameLineEdit; - QList<KitConfigWidget *> m_widgets; + QList<KitAspectWidget *> m_widgets; QList<QLabel *> m_labels; Kit *m_kit; std::unique_ptr<Kit> m_modifiedKit; diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index dbc04d559f..7795f3f02c 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -46,12 +46,7 @@ class KitNode : public TreeItem public: KitNode(Kit *k) { - widget = KitManager::createConfigWidget(k); - if (widget) { - if (k && k->isAutoDetected()) - widget->makeStickySubWidgetsReadOnly(); - widget->setVisible(false); - } + widget = new KitManagerConfigWidget(k); } ~KitNode() override @@ -271,6 +266,13 @@ Kit *KitModel::markForAddition(Kit *baseKit) return k; } +void KitModel::updateVisibility() +{ + forItemsAtLevel<2>([](const TreeItem *ti) { + static_cast<const KitNode *>(ti)->widget->updateVisibility(); + }); +} + KitNode *KitModel::findWorkingCopy(Kit *k) const { return findItemAtLevel<2>([k](KitNode *n) { return n->widget->workingCopy() == k; }); diff --git a/src/plugins/projectexplorer/kitmodel.h b/src/plugins/projectexplorer/kitmodel.h index 8070eefe30..c752215d41 100644 --- a/src/plugins/projectexplorer/kitmodel.h +++ b/src/plugins/projectexplorer/kitmodel.h @@ -69,6 +69,8 @@ public: void markForRemoval(Kit *k); Kit *markForAddition(Kit *baseKit); + void updateVisibility(); + signals: void kitStateChanged(); diff --git a/src/plugins/projectexplorer/kitoptionspage.cpp b/src/plugins/projectexplorer/kitoptionspage.cpp index 262d6c2706..d9ebe3f0e0 100644 --- a/src/plugins/projectexplorer/kitoptionspage.cpp +++ b/src/plugins/projectexplorer/kitoptionspage.cpp @@ -25,6 +25,7 @@ #include "kitoptionspage.h" +#include "filterkitaspectsdialog.h" #include "kitmodel.h" #include "kit.h" #include "projectexplorerconstants.h" @@ -32,6 +33,8 @@ #include "kitmanagerconfigwidget.h" #include "kitmanager.h" +#include <utils/qtcassert.h> + #include <QHBoxLayout> #include <QHeaderView> #include <QItemSelectionModel> @@ -67,10 +70,12 @@ public: QPushButton *m_cloneButton = nullptr; QPushButton *m_delButton = nullptr; QPushButton *m_makeDefaultButton = nullptr; + QPushButton *m_filterButton = nullptr; + QPushButton *m_defaultFilterButton = nullptr; KitModel *m_model = nullptr; QItemSelectionModel *m_selectionModel = nullptr; - QWidget *m_currentWidget = nullptr; + KitManagerConfigWidget *m_currentWidget = nullptr; }; KitOptionsPageWidget::KitOptionsPageWidget() @@ -85,6 +90,12 @@ KitOptionsPageWidget::KitOptionsPageWidget() m_cloneButton = new QPushButton(KitOptionsPage::tr("Clone"), this); m_delButton = new QPushButton(KitOptionsPage::tr("Remove"), this); m_makeDefaultButton = new QPushButton(KitOptionsPage::tr("Make Default"), this); + m_filterButton = new QPushButton(KitOptionsPage::tr("Settings Filter..."), this); + m_filterButton->setToolTip(KitOptionsPage::tr( + "Choose which settings to display for this kit.")); + m_defaultFilterButton = new QPushButton(KitOptionsPage::tr("Default Settings Filter..."), this); + m_defaultFilterButton->setToolTip(KitOptionsPage::tr( + "Choose which kit settings to display by default.")); auto buttonLayout = new QVBoxLayout; buttonLayout->setSpacing(6); @@ -93,6 +104,8 @@ KitOptionsPageWidget::KitOptionsPageWidget() buttonLayout->addWidget(m_cloneButton); buttonLayout->addWidget(m_delButton); buttonLayout->addWidget(m_makeDefaultButton); + buttonLayout->addWidget(m_filterButton); + buttonLayout->addWidget(m_defaultFilterButton); buttonLayout->addStretch(); auto horizontalLayout = new QHBoxLayout; @@ -131,14 +144,28 @@ KitOptionsPageWidget::KitOptionsPageWidget() this, &KitOptionsPageWidget::removeKit); connect(m_makeDefaultButton, &QAbstractButton::clicked, this, &KitOptionsPageWidget::makeDefaultKit); - + connect(m_filterButton, &QAbstractButton::clicked, this, [this] { + QTC_ASSERT(m_currentWidget, return); + FilterKitAspectsDialog dlg(m_currentWidget->workingCopy(), this); + if (dlg.exec() == QDialog::Accepted) { + m_currentWidget->workingCopy()->setIrrelevantAspects(dlg.irrelevantAspects()); + m_currentWidget->updateVisibility(); + } + }); + connect(m_defaultFilterButton, &QAbstractButton::clicked, this, [this] { + FilterKitAspectsDialog dlg(nullptr, this); + if (dlg.exec() == QDialog::Accepted) { + KitManager::setIrrelevantAspects(dlg.irrelevantAspects()); + m_model->updateVisibility(); + } + }); updateState(); } void KitOptionsPageWidget::kitSelectionChanged() { QModelIndex current = currentIndex(); - QWidget *newWidget = m_model->widget(current); + KitManagerConfigWidget * const newWidget = m_model->widget(current); if (newWidget == m_currentWidget) return; @@ -216,6 +243,7 @@ void KitOptionsPageWidget::updateState() m_cloneButton->setEnabled(canCopy); m_delButton->setEnabled(canDelete); m_makeDefaultButton->setEnabled(canMakeDefault); + m_filterButton->setEnabled(canCopy); } QModelIndex KitOptionsPageWidget::currentIndex() const diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index b909962ce9..34db908c61 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -126,7 +126,7 @@ QString MakeStep::defaultDisplayName() static const QList<ToolChain *> preferredToolChains(const Kit *kit) { - QList<ToolChain *> tcs = ToolChainKitInformation::toolChains(kit); + QList<ToolChain *> tcs = ToolChainKitAspect::toolChains(kit); // prefer CXX, then C, then others Utils::sort(tcs, [](ToolChain *tcA, ToolChain *tcB) { if (tcA->language() == tcB->language()) diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index 7d0573b0ac..aa01c0f9b6 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -25,10 +25,8 @@ #include "buildconfiguration.h" #include "deployconfiguration.h" -#include "kitconfigwidget.h" #include "kit.h" #include "kitmanager.h" -#include "kitmanager.h" #include "miniprojecttargetselector.h" #include "projectexplorer.h" #include "projectexplorericons.h" @@ -298,7 +296,7 @@ void ProjectListWidget::addProject(Project *project) setCurrentItem(item); QFontMetrics fn(font()); - int width = fn.width(displayName) + padding(); + int width = fn.horizontalAdvance(displayName) + padding(); if (width > optimalWidth()) setOptimalWidth(width); @@ -333,7 +331,7 @@ void ProjectListWidget::removeProject(Project *project) // recheck optimal width int width = 0; for (int i = 0; i < count(); ++i) - width = qMax(fn.width(item(i)->text()) + padding(), width); + width = qMax(fn.horizontalAdvance(item(i)->text()) + padding(), width); setOptimalWidth(width); m_ignoreIndexChange = false; @@ -377,7 +375,7 @@ void ProjectListWidget::projectDisplayNameChanged(Project *project) QFontMetrics fn(font()); int width = 0; for (int i = 0; i < count(); ++i) - width = qMax(fn.width(item(i)->text()) + padding(), width); + width = qMax(fn.horizontalAdvance(item(i)->text()) + padding(), width); setOptimalWidth(width); m_ignoreIndexChange = false; @@ -424,7 +422,7 @@ void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguratio int width = 0; foreach (ProjectConfiguration *pc, list) { addProjectConfiguration(pc); - width = qMax(width, fn.width(pc->displayName()) + padding()); + width = qMax(width, fn.horizontalAdvance(pc->displayName()) + padding()); } setOptimalWidth(width); setActiveProjectConfiguration(active); @@ -463,7 +461,7 @@ void GenericListWidget::addProjectConfiguration(ProjectConfiguration *pc) connect(pc, &ProjectConfiguration::toolTipChanged, this, &GenericListWidget::toolTipChanged); QFontMetrics fn(font()); - int width = fn.width(pc->displayName()) + padding(); + int width = fn.horizontalAdvance(pc->displayName()) + padding(); if (width > optimalWidth()) setOptimalWidth(width); @@ -481,7 +479,7 @@ void GenericListWidget::removeProjectConfiguration(ProjectConfiguration *pc) int width = 0; for (int i = 0; i < count(); ++i) { auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>(); - width = qMax(width, fn.width(p->displayName()) + padding()); + width = qMax(width, fn.horizontalAdvance(p->displayName()) + padding()); } setOptimalWidth(width); @@ -534,7 +532,7 @@ void GenericListWidget::displayNameChanged() int width = 0; for (int i = 0; i < count(); ++i) { auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>(); - width = qMax(width, fn.width(p->displayName()) + padding()); + width = qMax(width, fn.horizontalAdvance(p->displayName()) + padding()); } setOptimalWidth(width); @@ -579,7 +577,7 @@ KitAreaWidget::~KitAreaWidget() void KitAreaWidget::setKit(Kit *k) { - foreach (KitConfigWidget *w, m_widgets) + foreach (KitAspectWidget *w, m_widgets) delete(w); m_widgets.clear(); @@ -591,11 +589,11 @@ void KitAreaWidget::setKit(Kit *k) m_labels.clear(); int row = 0; - foreach (KitInformation *ki, KitManager::kitInformation()) { - if (k && k->isMutable(ki->id())) { - KitConfigWidget *widget = ki->createConfigWidget(k); + for (KitAspect *aspect : KitManager::kitAspects()) { + if (k && k->isMutable(aspect->id())) { + KitAspectWidget *widget = aspect->createConfigWidget(k); m_widgets << widget; - QLabel *label = new QLabel(widget->displayName()); + QLabel *label = new QLabel(aspect->displayName()); m_labels << label; widget->setStyle(QStyleFactory::create(QLatin1String("fusion"))); @@ -619,10 +617,10 @@ void KitAreaWidget::updateKit(Kit *k) return; bool addedMutables = false; - QList<Core::Id> knownIdList = Utils::transform(m_widgets, &KitConfigWidget::kitInformationId); + QList<Core::Id> knownIdList = Utils::transform(m_widgets, &KitAspectWidget::kitInformationId); - foreach (KitInformation *ki, KitManager::kitInformation()) { - Core::Id currentId = ki->id(); + for (KitAspect *aspect : KitManager::kitAspects()) { + const Core::Id currentId = aspect->id(); if (m_kit->isMutable(currentId) && !knownIdList.removeOne(currentId)) { addedMutables = true; break; @@ -635,7 +633,7 @@ void KitAreaWidget::updateKit(Kit *k) setKit(m_kit); } else { // Refresh all widgets if the number of mutable settings did not change - foreach (KitConfigWidget *w, m_widgets) + foreach (KitAspectWidget *w, m_widgets) w->refresh(); } } diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.h b/src/plugins/projectexplorer/miniprojecttargetselector.h index 0c2e51a4f4..032f69f7eb 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.h +++ b/src/plugins/projectexplorer/miniprojecttargetselector.h @@ -37,7 +37,7 @@ QT_END_NAMESPACE namespace ProjectExplorer { class Kit; -class KitConfigWidget; +class KitAspectWidget; class Project; class Target; class BuildConfiguration; @@ -101,7 +101,7 @@ private: QGridLayout *m_layout; Kit *m_kit = nullptr; - QList<KitConfigWidget *> m_widgets; + QList<KitAspectWidget *> m_widgets; QList<QLabel *> m_labels; }; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index b514b3f2fb..0e78a50abc 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -603,12 +603,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er IWizardFactory::registerFeatureProvider(new KitFeatureProvider); - // Register KitInformation: - KitManager::registerKitInformation<DeviceTypeKitInformation>(); - KitManager::registerKitInformation<DeviceKitInformation>(); - KitManager::registerKitInformation<ToolChainKitInformation>(); - KitManager::registerKitInformation<SysRootKitInformation>(); - KitManager::registerKitInformation<EnvironmentKitInformation>(); + // Register KitAspects: + KitManager::registerKitAspect<DeviceTypeKitAspect>(); + KitManager::registerKitAspect<DeviceKitAspect>(); + KitManager::registerKitAspect<ToolChainKitAspect>(); + KitManager::registerKitAspect<SysRootKitAspect>(); + KitManager::registerKitAspect<EnvironmentKitAspect>(); IWizardFactory::registerFactoryCreator([]() -> QList<IWizardFactory *> { QList<IWizardFactory *> result; @@ -889,7 +889,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_openTerminalHereBuildEnv = new QAction(tr("Build Environment"), this); dd->m_openTerminalHereRunEnv = new QAction(tr("Run Environment"), this); -#if !defined(Q_OS_UNIX) || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) cmd = ActionManager::registerAction(dd->m_openTerminalHereBuildEnv, "ProjectExplorer.OpenTerminalHereBuildEnv", projecTreeContext); @@ -899,7 +898,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er "ProjectExplorer.OpenTerminalHereRunEnv", projecTreeContext); dd->m_openTerminalMenu->addAction(dd->m_openTerminalHereRunEnv); -#endif // Open With menu mfileContextMenu->addMenu(openWith, Constants::G_FILE_OPEN); @@ -1535,7 +1533,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er tr("The host address of the device in the currently active kit."), []() -> QString { Kit *kit = currentKit(); - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->sshParameters().host() : QString(); }); @@ -1543,7 +1541,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er tr("The SSH port of the device in the currently active kit."), []() -> QString { Kit *kit = currentKit(); - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? QString::number(device->sshParameters().port()) : QString(); }); @@ -1551,7 +1549,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er tr("The username with which to log into the device in the currently active kit."), []() -> QString { Kit *kit = currentKit(); - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->sshParameters().userName() : QString(); }); @@ -1561,7 +1559,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er "in the currently active kit."), []() -> QString { Kit *kit = currentKit(); - const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); return device ? device->sshParameters().privateKeyFile : QString(); }); @@ -2543,7 +2541,7 @@ int ProjectExplorerPluginPrivate::queue(QList<Project *> projects, QList<Id> ste return false; IDevice::ConstPtr device = rc->runnable().device; if (device.isNull()) - device = DeviceKitInformation::device(t->kit()); + device = DeviceKitAspect::device(t->kit()); return !device.isNull() && device->type() == Core::Id(Constants::DESKTOP_DEVICE_TYPE); }); } diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 8ef32ae9ba..14033e5c47 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -17,6 +17,7 @@ HEADERS += projectexplorer.h \ environmentaspect.h \ environmentaspectwidget.h \ extraabi.h \ + filterkitaspectsdialog.h \ gcctoolchain.h \ importwidget.h \ userfileaccessor.h \ @@ -31,9 +32,7 @@ HEADERS += projectexplorer.h \ targetsetupwidget.h \ kit.h \ kitchooser.h \ - kitconfigwidget.h \ kitinformation.h \ - kitinformationconfigwidget.h \ kitfeatureprovider.h \ kitmanager.h \ kitmanagerconfigwidget.h \ @@ -170,6 +169,7 @@ SOURCES += projectexplorer.cpp \ environmentaspect.cpp \ environmentaspectwidget.cpp \ extraabi.cpp \ + filterkitaspectsdialog.cpp \ gcctoolchain.cpp \ importwidget.cpp \ projectconfigurationmodel.cpp \ @@ -184,9 +184,7 @@ SOURCES += projectexplorer.cpp \ targetsetupwidget.cpp \ kit.cpp \ kitchooser.cpp \ - kitconfigwidget.cpp \ kitinformation.cpp \ - kitinformationconfigwidget.cpp \ kitmanager.cpp \ kitmanagerconfigwidget.cpp \ kitmodel.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 5836c06c45..5294cbd7a5 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -69,6 +69,7 @@ Project { "expanddata.cpp", "expanddata.h", "extraabi.cpp", "extraabi.h", "extracompiler.cpp", "extracompiler.h", + "filterkitaspectsdialog.cpp", "filterkitaspectsdialog.h", "foldernavigationwidget.cpp", "foldernavigationwidget.h", "gccparser.cpp", "gccparser.h", "gcctoolchain.cpp", "gcctoolchain.h", @@ -81,10 +82,8 @@ Project { "itaskhandler.h", "kit.cpp", "kit.h", "kitchooser.cpp", "kitchooser.h", - "kitconfigwidget.cpp", "kitconfigwidget.h", "kitfeatureprovider.h", "kitinformation.cpp", "kitinformation.h", - "kitinformationconfigwidget.cpp", "kitinformationconfigwidget.h", "kitmanager.cpp", "kitmanager.h", "kitmanagerconfigwidget.cpp", "kitmanagerconfigwidget.h", "kitmodel.cpp", "kitmodel.h", diff --git a/src/plugins/projectexplorer/projectimporter.cpp b/src/plugins/projectexplorer/projectimporter.cpp index 174f6a7472..ba1114a2b6 100644 --- a/src/plugins/projectexplorer/projectimporter.cpp +++ b/src/plugins/projectexplorer/projectimporter.cpp @@ -73,7 +73,7 @@ static bool hasOtherUsers(Core::Id id, const QVariant &v, Kit *k) ProjectImporter::ProjectImporter(const Utils::FileName &path) : m_projectPath(path) { - useTemporaryKitInformation(ToolChainKitInformation::id(), + useTemporaryKitAspect(ToolChainKitAspect::id(), [this](Kit *k, const QVariantList &vl) { cleanupTemporaryToolChains(k, vl); }, [this](Kit *k, const QVariantList &vl) { persistTemporaryToolChains(k, vl); }); } @@ -167,7 +167,7 @@ Target *ProjectImporter::preferredTarget(const QList<Target *> &possibleTargets) return t; if (pickedFallback) continue; - if (DeviceTypeKitInformation::deviceTypeId(t->kit()) == Constants::DESKTOP_DEVICE_TYPE) { + if (DeviceTypeKitAspect::deviceTypeId(t->kit()) == Constants::DESKTOP_DEVICE_TYPE) { activeTarget = t; pickedFallback = true; } @@ -294,13 +294,13 @@ Kit *ProjectImporter::createTemporaryKit(const KitSetupFunction &setup) const k->setUnexpandedDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter", "Imported Kit"));; // Set up values: - foreach (KitInformation *ki, KitManager::kitInformation()) - ki->setup(kptr); + for (KitAspect *aspect : KitManager::kitAspects()) + aspect->setup(kptr); setup(kptr); - foreach (KitInformation *ki, KitManager::kitInformation()) - ki->fix(kptr); + for (KitAspect *aspect : KitManager::kitAspects()) + aspect->fix(kptr); markKitAsTemporary(kptr); addProject(kptr); @@ -326,7 +326,7 @@ void ProjectImporter::cleanupTemporaryToolChains(Kit *k, const QVariantList &vl) ToolChain *tc = toolChainFromVariant(v); QTC_ASSERT(tc, continue); ToolChainManager::deregisterToolChain(tc); - ToolChainKitInformation::setToolChain(k, nullptr); + ToolChainKitAspect::setToolChain(k, nullptr); } } @@ -335,13 +335,13 @@ void ProjectImporter::persistTemporaryToolChains(Kit *k, const QVariantList &vl) for (const QVariant &v : vl) { ToolChain *tmpTc = toolChainFromVariant(v); QTC_ASSERT(tmpTc, continue); - ToolChain *actualTc = ToolChainKitInformation::toolChain(k, tmpTc->language()); + ToolChain *actualTc = ToolChainKitAspect::toolChain(k, tmpTc->language()); if (tmpTc && actualTc != tmpTc) ToolChainManager::deregisterToolChain(tmpTc); } } -void ProjectImporter::useTemporaryKitInformation(Core::Id id, +void ProjectImporter::useTemporaryKitAspect(Core::Id id, ProjectImporter::CleanupFunction cleanup, ProjectImporter::PersistFunction persist) { @@ -400,7 +400,7 @@ ProjectImporter::findOrCreateToolChains(const Utils::FileName &toolChainPath, }); for (const ToolChain *tc : result.tcs) { const QByteArray tcId = tc->id(); - result.areTemporary = result.areTemporary ? true : hasKitWithTemporaryData(ToolChainKitInformation::id(), tcId); + result.areTemporary = result.areTemporary ? true : hasKitWithTemporaryData(ToolChainKitAspect::id(), tcId); } if (!result.tcs.isEmpty()) return result; diff --git a/src/plugins/projectexplorer/projectimporter.h b/src/plugins/projectexplorer/projectimporter.h index c7df542a7a..133cb811dd 100644 --- a/src/plugins/projectexplorer/projectimporter.h +++ b/src/plugins/projectexplorer/projectimporter.h @@ -103,7 +103,7 @@ protected: // Handle temporary additions to Kits (Qt Versions, ToolChains, etc.) using CleanupFunction = std::function<void(Kit *, const QVariantList &)>; using PersistFunction = std::function<void(Kit *, const QVariantList &)>; - void useTemporaryKitInformation(Core::Id id, + void useTemporaryKitAspect(Core::Id id, CleanupFunction cleanup, PersistFunction persist); void addTemporaryData(Core::Id id, const QVariant &cleanupData, Kit *k) const; // Does *any* kit feature the requested data yet? diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index d90e349524..46c98d164b 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -32,17 +32,31 @@ #include "session.h" #include "target.h" +#include <coreplugin/documentmanager.h> #include <coreplugin/fileiconprovider.h> +#include <coreplugin/icore.h> +#include <coreplugin/iversioncontrol.h> +#include <coreplugin/vcsmanager.h> #include <utils/utilsicons.h> #include <utils/algorithm.h> #include <utils/dropsupport.h> +#include <utils/pathchooser.h> #include <utils/stringutils.h> #include <utils/theme/theme.h> +#include <QButtonGroup> +#include <QDialog> +#include <QDialogButtonBox> #include <QFileInfo> #include <QFont> +#include <QHBoxLayout> +#include <QLabel> +#include <QMessageBox> #include <QMimeData> #include <QLoggingCategory> +#include <QPushButton> +#include <QRadioButton> +#include <QVBoxLayout> #include <functional> @@ -188,6 +202,8 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const // either folder or file node if (node->supportsAction(Rename, node)) f = f | Qt::ItemIsEditable; + } else if (node->supportsAction(ProjectAction::AddExistingFile, node)) { + f |= Qt::ItemIsDropEnabled; } } return f; @@ -408,7 +424,7 @@ QStringList FlatModel::mimeTypes() const QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const { - auto data = new Utils::DropMimeData; + auto data = new DropMimeData; foreach (const QModelIndex &index, indexes) { if (Node *node = nodeForIndex(index)) { if (node->asFileNode()) @@ -419,6 +435,307 @@ QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const return data; } +bool FlatModel::canDropMimeData(const QMimeData *data, Qt::DropAction, int, int, + const QModelIndex &) const +{ + // For now, we support only drops of Qt Creator file nodes. + const auto * const dropData = dynamic_cast<const DropMimeData *>(data); + if (!dropData) + return false; + QTC_ASSERT(!dropData->values().empty(), return false); + return dropData->files().size() == dropData->values().size(); +} + +enum class DropAction { Copy, CopyWithFiles, Move, MoveWithFiles }; + +class DropFileDialog : public QDialog +{ + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::Internal::FlatModel) +public: + DropFileDialog(const FileName &defaultTargetDir) + : m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), + m_buttonGroup(new QButtonGroup(this)) + { + setWindowTitle(tr("Please choose a drop action")); + const bool offerFileIo = !defaultTargetDir.isEmpty(); + auto * const layout = new QVBoxLayout(this); + layout->addWidget(new QLabel(tr("You just dragged some files from one project node to " + "another.\nWhat should Qt Creator do now?"), this)); + auto * const copyButton = new QRadioButton(this); + m_buttonGroup->addButton(copyButton, int(DropAction::Copy)); + layout->addWidget(copyButton); + auto * const moveButton = new QRadioButton(this); + m_buttonGroup->addButton(moveButton, int(DropAction::Move)); + layout->addWidget(moveButton); + if (offerFileIo) { + copyButton->setText(tr("Copy only the file references")); + moveButton->setText(tr("Move only the file references")); + auto * const copyWithFilesButton + = new QRadioButton(tr("Copy file references and files"), this); + m_buttonGroup->addButton(copyWithFilesButton, int(DropAction::CopyWithFiles)); + layout->addWidget(copyWithFilesButton); + auto * const moveWithFilesButton + = new QRadioButton(tr("Move file references and files"), this); + m_buttonGroup->addButton(moveWithFilesButton, int(DropAction::MoveWithFiles)); + layout->addWidget(moveWithFilesButton); + moveWithFilesButton->setChecked(true); + auto * const targetDirLayout = new QHBoxLayout; + layout->addLayout(targetDirLayout); + targetDirLayout->addWidget(new QLabel(tr("Target directory:"), this)); + m_targetDirChooser = new PathChooser(this); + m_targetDirChooser->setExpectedKind(PathChooser::ExistingDirectory); + m_targetDirChooser->setFileName(defaultTargetDir); + connect(m_targetDirChooser, &PathChooser::validChanged, this, [this](bool valid) { + m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); + }); + targetDirLayout->addWidget(m_targetDirChooser); + connect(m_buttonGroup, + static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), + this, [this] { + switch (dropAction()) { + case DropAction::CopyWithFiles: + case DropAction::MoveWithFiles: + m_targetDirChooser->setEnabled(true); + m_buttonBox->button(QDialogButtonBox::Ok) + ->setEnabled(m_targetDirChooser->isValid()); + break; + case DropAction::Copy: + case DropAction::Move: + m_targetDirChooser->setEnabled(false); + m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + break; + } + }); + } else { + copyButton->setText(tr("Copy the file references")); + moveButton->setText(tr("Move the file references")); + moveButton->setChecked(true); + } + connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + layout->addWidget(m_buttonBox); + } + + DropAction dropAction() const { return static_cast<DropAction>(m_buttonGroup->checkedId()); } + FileName targetDir() const + { + return m_targetDirChooser ? m_targetDirChooser->fileName() : FileName(); + } + +private: + PathChooser *m_targetDirChooser = nullptr; + QDialogButtonBox * const m_buttonBox; + QButtonGroup * const m_buttonGroup; +}; + + +bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) +{ + Q_UNUSED(action); + + const auto * const dropData = dynamic_cast<const DropMimeData *>(data); + QTC_ASSERT(dropData, return false); + + auto fileNodes = transform<QList<const Node *>>(dropData->values(), + [](const QVariant &v) { return v.value<Node *>(); }); + QTC_ASSERT(!fileNodes.empty(), return true); + + // The drag operation does not block event handling, so it's possible that the project + // was reparsed and the nodes in the drop data are now invalid. If that happens for any node, + // we chicken out and abort the entire operation. + // Note: In theory, it might be possible that the memory was reused in such an unlucky + // way that the pointers refer to different project nodes now, but... + if (!allOf(fileNodes, [](const Node *n) { return ProjectTree::hasNode(n); })) + return true; + + // We handle only proper file nodes, i.e. no project or folder nodes and no "pseudo" + // file nodes that represent the project file. + fileNodes = filtered(fileNodes, [](const Node *n) { + return n->asFileNode() && n->asFileNode()->fileType() != FileType::Project; + }); + if (fileNodes.empty()) + return true; + + // We can handle more than one file being dropped, as long as they have the same parent node. + ProjectNode * const sourceProjectNode = fileNodes.first()->parentProjectNode(); + QTC_ASSERT(sourceProjectNode, return true); + if (anyOf(fileNodes, [sourceProjectNode](const Node *n) { + return n->parentProjectNode() != sourceProjectNode; })) { + return true; + } + Node *targetNode = nodeForIndex(index(row, column, parent)); + if (!targetNode) + targetNode = nodeForIndex(parent); + QTC_ASSERT(targetNode, return true); + ProjectNode *targetProjectNode = targetNode->asProjectNode(); + if (!targetProjectNode) + targetProjectNode = targetNode->parentProjectNode(); + QTC_ASSERT(targetProjectNode, return true); + if (sourceProjectNode == targetProjectNode) + return true; + + // Node weirdness: Sometimes the "file path" is a directory, sometimes it's a file... + const auto dirForProjectNode = [](const ProjectNode *pNode) { + const FileName dir = pNode->filePath(); + if (dir.toFileInfo().isDir()) + return dir; + return FileName::fromString(dir.toFileInfo().path()); + }; + FileName targetDir = dirForProjectNode(targetProjectNode); + + // Ask the user what to do now: Copy or add? With or without file transfer? + DropFileDialog dlg(targetDir == dirForProjectNode(sourceProjectNode) ? FileName() : targetDir); + if (dlg.exec() != QDialog::Accepted) + return true; + if (!dlg.targetDir().isEmpty()) + targetDir = dlg.targetDir(); + + // Check the nodes again. + if (!allOf(fileNodes, [](const Node *n) { return ProjectTree::hasNode(n); })) + return true; + + // Some helper functions for the file operations. + const auto targetFilePath = [&targetDir](const QString &sourceFilePath) { + FileName targetFile = targetDir; + targetFile.appendPath(QFileInfo(sourceFilePath).fileName()); + return targetFile.toString(); + }; + + struct VcsInfo { + Core::IVersionControl *vcs = nullptr; + QString repoDir; + bool operator==(const VcsInfo &other) const { + return vcs == other.vcs && repoDir == other.repoDir; + } + }; + QHash<QString, VcsInfo> vcsHash; + const auto vcsInfoForFile = [&vcsHash](const QString &filePath) { + const QString dir = QFileInfo(filePath).path(); + const auto it = vcsHash.constFind(dir); + if (it != vcsHash.constEnd()) + return it.value(); + VcsInfo vcsInfo; + vcsInfo.vcs = Core::VcsManager::findVersionControlForDirectory(dir, &vcsInfo.repoDir); + vcsHash.insert(dir, vcsInfo); + return vcsInfo; + }; + + // Now do the actual work. + const QStringList sourceFiles = transform(fileNodes, [](const Node *n) { + return n->filePath().toString(); + }); + QStringList failedRemoveFromProject; + QStringList failedAddToProject; + QStringList failedCopyOrMove; + QStringList failedDelete; + QStringList failedVcsOp; + switch (dlg.dropAction()) { + case DropAction::CopyWithFiles: { + QStringList filesToAdd; + Core::IVersionControl * const vcs = Core::VcsManager::findVersionControlForDirectory( + targetDir.toString()); + const bool addToVcs = vcs && vcs->supportsOperation(Core::IVersionControl::AddOperation); + for (const QString &sourceFile : sourceFiles) { + const QString targetFile = targetFilePath(sourceFile); + if (QFile::copy(sourceFile, targetFile)) { + filesToAdd << targetFile; + if (addToVcs && !vcs->vcsAdd(targetFile)) + failedVcsOp << targetFile; + } else { + failedCopyOrMove << sourceFile; + } + } + targetProjectNode->addFiles(filesToAdd, &failedAddToProject); + break; + } + case DropAction::Copy: + targetProjectNode->addFiles(sourceFiles, &failedAddToProject); + break; + case DropAction::MoveWithFiles: { + QStringList filesToAdd; + QStringList filesToRemove; + const VcsInfo targetVcs = vcsInfoForFile(targetDir.toString()); + const bool vcsAddPossible = targetVcs.vcs + && targetVcs.vcs->supportsOperation(Core::IVersionControl::AddOperation); + for (const QString &sourceFile : sourceFiles) { + const QString targetFile = targetFilePath(sourceFile); + const VcsInfo sourceVcs = vcsInfoForFile(sourceFile); + if (sourceVcs.vcs && targetVcs.vcs && sourceVcs == targetVcs + && sourceVcs.vcs->supportsOperation(Core::IVersionControl::MoveOperation)) { + if (sourceVcs.vcs->vcsMove(sourceFile, targetFile)) { + filesToAdd << targetFile; + filesToRemove << sourceFile; + } else { + failedCopyOrMove << sourceFile; + } + continue; + } + if (!QFile::copy(sourceFile, targetFile)) { + failedCopyOrMove << sourceFile; + continue; + } + filesToAdd << targetFile; + filesToRemove << sourceFile; + Core::FileChangeBlocker changeGuard(sourceFile); + if (sourceVcs.vcs && sourceVcs.vcs->supportsOperation( + Core::IVersionControl::DeleteOperation) + && !sourceVcs.vcs->vcsDelete(sourceFile)) { + failedVcsOp << sourceFile; + } + if (QFile::exists(sourceFile) && !QFile::remove(sourceFile)) + failedDelete << sourceFile; + if (vcsAddPossible && !targetVcs.vcs->vcsAdd(targetFile)) + failedVcsOp << targetFile; + } + sourceProjectNode->removeFiles(filesToRemove, &failedRemoveFromProject); + targetProjectNode->addFiles(filesToAdd, &failedAddToProject); + break; + } + case DropAction::Move: + sourceProjectNode->removeFiles(sourceFiles, &failedRemoveFromProject); + targetProjectNode->addFiles(sourceFiles, &failedAddToProject); + break; + } + + // Summary for the user in case anything went wrong. + const auto makeUserFileList = [](const QStringList &files) { + return transform(files, [](const QString &f) { return QDir::toNativeSeparators(f); }) + .join("\n "); + }; + if (!failedAddToProject.empty() || !failedRemoveFromProject.empty() + || !failedCopyOrMove.empty() || !failedDelete.empty() || !failedVcsOp.empty()) { + QString message = tr("Not all operations finished successfully."); + if (!failedCopyOrMove.empty()) { + message.append('\n').append(tr("The following files could not be copied or moved:")) + .append("\n ").append(makeUserFileList(failedCopyOrMove)); + } + if (!failedRemoveFromProject.empty()) { + message.append('\n').append(tr("The following files could not be removed from the " + "project file:")) + .append("\n ").append(makeUserFileList(failedRemoveFromProject)); + } + if (!failedAddToProject.empty()) { + message.append('\n').append(tr("The following files could not be added to the " + "project file:")) + .append("\n ").append(makeUserFileList(failedAddToProject)); + } + if (!failedDelete.empty()) { + message.append('\n').append(tr("The following files could not be deleted:")) + .append("\n ").append(makeUserFileList(failedDelete)); + } + if (!failedVcsOp.empty()) { + message.append('\n').append(tr("A version control operation failed for the following " + "files. Please check your repository.")) + .append("\n ").append(makeUserFileList(failedVcsOp)); + } + QMessageBox::warning(Core::ICore::mainWindow(), tr("Failure Updating Project"), + message); + } + + return true; +} + WrapperNode *FlatModel::wrapperForNode(const Node *node) const { return findNonRootItem([node](WrapperNode *item) { diff --git a/src/plugins/projectexplorer/projectmodels.h b/src/plugins/projectexplorer/projectmodels.h index 952fc09651..5805efe3ea 100644 --- a/src/plugins/projectexplorer/projectmodels.h +++ b/src/plugins/projectexplorer/projectmodels.h @@ -67,6 +67,10 @@ public: Qt::DropActions supportedDragActions() const override; QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; + bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) const override; + bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) override; Node *nodeForIndex(const QModelIndex &index) const; WrapperNode *wrapperForNode(const Node *node) const; diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 641c1de40e..d42f2758fa 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -149,7 +149,9 @@ public: setEditTriggers(QAbstractItemView::EditKeyPressed); setContextMenuPolicy(Qt::CustomContextMenu); setDragEnabled(true); - setDragDropMode(QAbstractItemView::DragOnly); + setDragDropMode(QAbstractItemView::DragDrop); + viewport()->setAcceptDrops(true); + setDropIndicatorShown(true); m_context = new IContext(this); m_context->setContext(Context(ProjectExplorer::Constants::C_PROJECT_TREE)); m_context->setWidget(this); diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index 2cbb9a9b9d..8d7896532d 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -340,7 +340,7 @@ public: }; for (int i = 0; i < 3; ++i) { const QString &action = actions.at(i); - const int ww = fm.width(action); + const int ww = fm.horizontalAdvance(action); const QRect actionRect(xx, yy - 10, ww, 15); const bool isForcedDisabled = (i != 0 && sessionName == "default"); const bool isActive = actionRect.contains(mousePos) && !isForcedDisabled; @@ -475,7 +475,8 @@ public: QString projectName = idx.data(Qt::DisplayRole).toString(); QString projectPath = idx.data(ProjectModel::FilePathRole).toString(); QFontMetrics fm(sizedFont(13, option.widget)); - int width = std::max(fm.width(projectName), fm.width(projectPath)) + 36; + int width = std::max(fm.horizontalAdvance(projectName), + fm.horizontalAdvance(projectPath)) + 36; return QSize(width, 48); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 2c8e238495..9b58ab701c 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -435,9 +435,9 @@ QString RunConfigurationFactory::decoratedTargetName(const QString &targetName, QString displayName; if (!targetName.isEmpty()) displayName = QFileInfo(targetName).completeBaseName(); - Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target->kit()); + Core::Id devType = DeviceTypeKitAspect::deviceTypeId(target->kit()); if (devType != Constants::DESKTOP_DEVICE_TYPE) { - if (IDevice::ConstPtr dev = DeviceKitInformation::device(target->kit())) { + if (IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit())) { if (displayName.isEmpty()) { //: Shown in Run configuration if no executable is given, %1 is device name displayName = RunConfiguration::tr("Run on %1").arg(dev->displayName()); @@ -524,7 +524,7 @@ bool RunConfigurationFactory::canHandle(Target *target) const if (!m_supportedTargetDeviceTypes.isEmpty()) if (!m_supportedTargetDeviceTypes.contains( - DeviceTypeKitInformation::deviceTypeId(kit))) + DeviceTypeKitAspect::deviceTypeId(kit))) return false; return true; @@ -796,7 +796,7 @@ public: outputFormatter = runConfiguration->createOutputFormatter(); device = runnable.device; if (!device) - device = DeviceKitInformation::device(runConfiguration->target()->kit()); + device = DeviceKitAspect::device(runConfiguration->target()->kit()); project = runConfiguration->target()->project(); } else { outputFormatter = new OutputFormatter(); diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index 70d742e34e..f8f34f9cc1 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -452,7 +452,7 @@ void Target::setOverlayIcon(const QIcon &icon) QString Target::overlayIconToolTip() { - IDevice::ConstPtr current = DeviceKitInformation::device(kit()); + IDevice::ConstPtr current = DeviceKitAspect::device(kit()); return current.isNull() ? QString() : formatDeviceInfo(current->deviceInformation()); } @@ -682,7 +682,7 @@ QVariant Target::additionalData(Core::Id id) const void Target::updateDeviceState() { - IDevice::ConstPtr current = DeviceKitInformation::device(kit()); + IDevice::ConstPtr current = DeviceKitAspect::device(kit()); QIcon overlay; static const QIcon disconnected = Icons::DEVICE_DISCONNECTED_INDICATOR_OVERLAY.icon(); diff --git a/src/plugins/projectexplorer/targetsetupwidget.cpp b/src/plugins/projectexplorer/targetsetupwidget.cpp index 88e5b4ab06..2bab82f245 100644 --- a/src/plugins/projectexplorer/targetsetupwidget.cpp +++ b/src/plugins/projectexplorer/targetsetupwidget.cpp @@ -29,7 +29,6 @@ #include "buildinfo.h" #include "projectexplorerconstants.h" #include "kit.h" -#include "kitconfigwidget.h" #include "kitmanager.h" #include "kitoptionspage.h" @@ -73,7 +72,7 @@ TargetSetupWidget::TargetSetupWidget(Kit *k, const QString &projectPath) : auto panel = new Utils::FadingWidget(m_detailsWidget); auto panelLayout = new QHBoxLayout(panel); - m_manageButton = new QPushButton(KitConfigWidget::msgManage()); + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); panelLayout->addWidget(m_manageButton); m_detailsWidget->setToolWidget(panel); diff --git a/src/plugins/projectexplorer/taskmodel.cpp b/src/plugins/projectexplorer/taskmodel.cpp index dcdf1554c8..3a1ecda5c3 100644 --- a/src/plugins/projectexplorer/taskmodel.cpp +++ b/src/plugins/projectexplorer/taskmodel.cpp @@ -294,7 +294,7 @@ int TaskModel::sizeOfFile(const QFont &font) if (pos != -1) filename = filename.mid(pos +1); - m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename)); + m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.horizontalAdvance(filename)); } m_lastMaxSizeIndex = count - 1; return m_maxSizeOfFileName; @@ -305,7 +305,7 @@ int TaskModel::sizeOfLineNumber(const QFont &font) if (m_sizeOfLineNumber == 0 || font != m_lineMeasurementFont) { QFontMetrics fm(font); m_lineMeasurementFont = font; - m_sizeOfLineNumber = fm.width(QLatin1String("88888")); + m_sizeOfLineNumber = fm.horizontalAdvance(QLatin1String("88888")); } return m_sizeOfLineNumber; } diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 7d8010aa27..2f1920a68b 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -786,7 +786,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QString bottom = index.data(TaskModel::Description).toString().split(QLatin1Char('\n')).first(); painter->setClipRect(positions.textArea()); painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(), bottom); - if (fm.width(bottom) > positions.textAreaWidth()) { + if (fm.horizontalAdvance(bottom) > positions.textAreaWidth()) { // draw a gradient to mask the text int gradientStart = positions.textAreaRight() - ELLIPSIS_GRADIENT_WIDTH + 1; QLinearGradient lg(gradientStart, 0, gradientStart + ELLIPSIS_GRADIENT_WIDTH, 0); @@ -840,7 +840,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const int pos = file.lastIndexOf(QLatin1Char('/')); if (pos != -1) file = file.mid(pos +1); - const int realFileWidth = fm.width(file); + const int realFileWidth = fm.horizontalAdvance(file); painter->setClipRect(positions.fileArea()); painter->drawText(qMin(positions.fileAreaLeft(), positions.fileAreaRight() - realFileWidth), positions.top() + fm.ascent(), file); @@ -877,7 +877,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, } painter->setClipRect(positions.lineArea()); - const int realLineWidth = fm.width(lineText); + const int realLineWidth = fm.horizontalAdvance(lineText); painter->drawText(positions.lineAreaRight() - realLineWidth, positions.top() + fm.ascent(), lineText); painter->setClipRect(opt.rect); diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index a014d7a758..513a163ed6 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -76,7 +76,7 @@ static QString extractToolchainPrefix(QString *compilerName) static QString targetPlatform(const ProjectExplorer::Abi &abi, const ProjectExplorer::Kit *k) { - const Core::Id device = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k); + const Core::Id device = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId(k); switch (abi.os()) { case ProjectExplorer::Abi::WindowsOS: return QLatin1String("windows"); @@ -195,7 +195,7 @@ QVariantMap DefaultPropertyProvider::properties(const ProjectExplorer::Kit *k, { QTC_ASSERT(k, return defaultData); QVariantMap data = autoGeneratedProperties(k, defaultData); - const QVariantMap customProperties = QbsKitInformation::properties(k); + const QVariantMap customProperties = QbsKitAspect::properties(k); for (QVariantMap::ConstIterator it = customProperties.constBegin(); it != customProperties.constEnd(); ++it) { data.insert(it.key(), it.value()); @@ -222,14 +222,14 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor { QVariantMap data = defaultData; - const QString sysroot = ProjectExplorer::SysRootKitInformation::sysRoot(k).toUserOutput(); + const QString sysroot = ProjectExplorer::SysRootKitAspect::sysRoot(k).toUserOutput(); if (!sysroot.isEmpty()) data.insert(QLatin1String(QBS_SYSROOT), sysroot); ProjectExplorer::ToolChain *tcC - = ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID); + = ProjectExplorer::ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID); ProjectExplorer::ToolChain *tcCxx - = ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + = ProjectExplorer::ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!tcC && !tcCxx) return data; diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp index 21e24cffa8..e501d3b56e 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp @@ -399,7 +399,7 @@ QbsBuildConfigurationFactory::QbsBuildConfigurationFactory() setSupportedProjectType(Constants::PROJECT_ID); setSupportedProjectMimeTypeName(Constants::MIME_TYPE); setIssueReporter([](Kit *k, const QString &projectPath, const QString &buildDir) -> QList<Task> { - const QtSupport::BaseQtVersion * const version = QtSupport::QtKitInformation::qtVersion(k); + const QtSupport::BaseQtVersion * const version = QtSupport::QtKitAspect::qtVersion(k); return version ? version->reportIssues(projectPath, buildDir) : QList<ProjectExplorer::Task>(); }); diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 45eb7535ce..7ce52bddef 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -573,8 +573,6 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) : &QbsBuildStepConfigWidget::changeForceProbes); connect(m_ui->qmlDebuggingLibraryCheckBox, &QAbstractButton::toggled, this, &QbsBuildStepConfigWidget::linkQmlDebuggingLibraryChecked); - connect(QtSupport::QtVersionManager::instance(), &QtSupport::QtVersionManager::dumpUpdatedFor, - this, &QbsBuildStepConfigWidget::updateQmlDebuggingOption); updateState(); } diff --git a/src/plugins/qbsprojectmanager/qbskitinformation.cpp b/src/plugins/qbsprojectmanager/qbskitinformation.cpp index 95242e5e37..b317fd88e8 100644 --- a/src/plugins/qbsprojectmanager/qbskitinformation.cpp +++ b/src/plugins/qbsprojectmanager/qbskitinformation.cpp @@ -27,7 +27,6 @@ #include "customqbspropertiesdialog.h" -#include <projectexplorer/kitconfigwidget.h> #include <projectexplorer/kitmanager.h> #include <utils/elidinglabel.h> @@ -42,49 +41,44 @@ using namespace ProjectExplorer; namespace QbsProjectManager { namespace Internal { -class ConfigWidget final : public KitConfigWidget +class AspectWidget final : public KitAspectWidget { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(QbsProjectManager::Internal::AspectWidget) public: - ConfigWidget(Kit *kit, const KitInformation *kitInfo) - : KitConfigWidget(kit, kitInfo), + AspectWidget(Kit *kit, const KitAspect *kitInfo) + : KitAspectWidget(kit, kitInfo), m_contentLabel(new Utils::ElidingLabel), m_changeButton(new QPushButton(tr("Change..."))) { - connect(m_changeButton, &QPushButton::clicked, this, &ConfigWidget::changeProperties); + connect(m_changeButton, &QPushButton::clicked, this, &AspectWidget::changeProperties); } private: - QString displayName() const override { return QbsKitInformation::displayName(); } void makeReadOnly() override { m_changeButton->setEnabled(false); } - void refresh() override { m_contentLabel->setText(QbsKitInformation::representation(kit())); } + void refresh() override { m_contentLabel->setText(QbsKitAspect::representation(kit())); } QWidget *mainWidget() const override { return m_contentLabel; } QWidget *buttonWidget() const override { return m_changeButton; } void changeProperties() { - CustomQbsPropertiesDialog dlg(QbsKitInformation::properties(kit())); + CustomQbsPropertiesDialog dlg(QbsKitAspect::properties(kit())); if (dlg.exec() == QDialog::Accepted) - QbsKitInformation::setProperties(kit(), dlg.properties()); + QbsKitAspect::setProperties(kit(), dlg.properties()); } QLabel * const m_contentLabel; QPushButton * const m_changeButton; }; -QbsKitInformation::QbsKitInformation() +QbsKitAspect::QbsKitAspect() { - setObjectName(QLatin1String("QbsKitInformation")); - setId(QbsKitInformation::id()); + setObjectName(QLatin1String("QbsKitAspect")); + setId(QbsKitAspect::id()); + setDisplayName(tr("Additional Qbs Profile Settings")); setPriority(22000); } -QString QbsKitInformation::displayName() -{ - return tr("Additional Qbs Profile Settings"); -} - -QString QbsKitInformation::representation(const Kit *kit) +QString QbsKitAspect::representation(const Kit *kit) { const QVariantMap props = properties(kit); QString repr; @@ -96,37 +90,35 @@ QString QbsKitInformation::representation(const Kit *kit) return repr; } -QVariantMap QbsKitInformation::properties(const Kit *kit) +QVariantMap QbsKitAspect::properties(const Kit *kit) { QTC_ASSERT(kit, return QVariantMap()); return kit->value(id()).toMap(); } -void QbsKitInformation::setProperties(Kit *kit, const QVariantMap &properties) +void QbsKitAspect::setProperties(Kit *kit, const QVariantMap &properties) { QTC_ASSERT(kit, return); kit->setValue(id(), properties); } -Core::Id QbsKitInformation::id() +Core::Id QbsKitAspect::id() { return "Qbs.KitInformation"; } -QVariant QbsKitInformation::defaultValue(const Kit *) const { return QString(); } -QList<Task> QbsKitInformation::validate(const Kit *) const { return QList<Task>(); } +QVariant QbsKitAspect::defaultValue(const Kit *) const { return QString(); } +QList<Task> QbsKitAspect::validate(const Kit *) const { return QList<Task>(); } -KitInformation::ItemList QbsKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList QbsKitAspect::toUserOutput(const Kit *k) const { return ItemList({qMakePair(displayName(), representation(k))}); } -KitConfigWidget *QbsKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *QbsKitAspect::createConfigWidget(Kit *k) const { - return new ConfigWidget(k, this); + return new AspectWidget(k, this); } } // namespace Internal } // namespace QbsProjectManager - -#include <qbskitinformation.moc> diff --git a/src/plugins/qbsprojectmanager/qbskitinformation.h b/src/plugins/qbsprojectmanager/qbskitinformation.h index ef5a5b9351..b6bd1b1984 100644 --- a/src/plugins/qbsprojectmanager/qbskitinformation.h +++ b/src/plugins/qbsprojectmanager/qbskitinformation.h @@ -30,14 +30,13 @@ namespace QbsProjectManager { namespace Internal { -class QbsKitInformation final : public ProjectExplorer::KitInformation +class QbsKitAspect final : public ProjectExplorer::KitAspect { Q_OBJECT public: - QbsKitInformation(); + QbsKitAspect(); - static QString displayName(); static QString representation(const ProjectExplorer::Kit *kit); static QVariantMap properties(const ProjectExplorer::Kit *kit); static void setProperties(ProjectExplorer::Kit *kit, const QVariantMap &properties); @@ -48,7 +47,7 @@ private: QVariant defaultValue(const ProjectExplorer::Kit *) const override; QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *) const override; ItemList toUserOutput(const ProjectExplorer::Kit *) const override; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *) const override; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *) const override; }; } // namespace Internal diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index 0ea82d6f40..2a2d706db5 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -693,7 +693,7 @@ void QbsProject::configureAsExampleProject(const QSet<Id> &platforms) }; foreach (Kit *k, kits) { const QtSupport::BaseQtVersion * const qtVersion - = QtSupport::QtKitInformation::qtVersion(k); + = QtSupport::QtKitAspect::qtVersion(k); if (!qtVersion || !qtVersionMatchesPlatform(qtVersion)) continue; if (auto factory = BuildConfigurationFactory::find(k, projectFilePath().toString())) diff --git a/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp b/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp index 7e3f37d0a8..72f576f8d1 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp @@ -163,14 +163,14 @@ bool QbsProjectImporter::matchKit(void *directoryData, const Kit *k) const const auto * const bgData = static_cast<BuildGraphData *>(directoryData); qCDebug(qbsPmLog) << "matching kit" << k->displayName() << "against imported build" << bgData->bgFilePath.toUserOutput(); - if (ToolChainKitInformation::toolChains(k).isEmpty() && bgData->cCompilerPath.isEmpty() + if (ToolChainKitAspect::toolChains(k).isEmpty() && bgData->cCompilerPath.isEmpty() && bgData->cxxCompilerPath.isEmpty()) { return true; } const ToolChain * const cToolchain - = ToolChainKitInformation::toolChain(k, Constants::C_LANGUAGE_ID); + = ToolChainKitAspect::toolChain(k, Constants::C_LANGUAGE_ID); const ToolChain * const cxxToolchain - = ToolChainKitInformation::toolChain(k, Constants::CXX_LANGUAGE_ID); + = ToolChainKitAspect::toolChain(k, Constants::CXX_LANGUAGE_ID); if (!bgData->cCompilerPath.isEmpty()) { if (!cToolchain) return false; @@ -183,14 +183,14 @@ bool QbsProjectImporter::matchKit(void *directoryData, const Kit *k) const if (bgData->cxxCompilerPath != cxxToolchain->compilerCommand()) return false; } - const QtSupport::BaseQtVersion * const qtVersion = QtSupport::QtKitInformation::qtVersion(k); + const QtSupport::BaseQtVersion * const qtVersion = QtSupport::QtKitAspect::qtVersion(k); if (!bgData->qtBinPath.isEmpty()) { if (!qtVersion) return false; if (bgData->qtBinPath != qtVersion->binPath()) return false; } - if (bgData->sysroot != SysRootKitInformation::sysRoot(k)) + if (bgData->sysroot != SysRootKitAspect::sysRoot(k)) return false; qCDebug(qbsPmLog) << "Kit matches"; @@ -215,9 +215,9 @@ Kit *QbsProjectImporter::createKit(void *directoryData) const tcData << findOrCreateToolChains(bgData->cCompilerPath, Constants::C_LANGUAGE_ID); foreach (const ToolChainData &tc, tcData) { if (!tc.tcs.isEmpty()) - ToolChainKitInformation::setToolChain(k, tc.tcs.first()); + ToolChainKitAspect::setToolChain(k, tc.tcs.first()); } - SysRootKitInformation::setSysRoot(k, bgData->sysroot); + SysRootKitAspect::setSysRoot(k, bgData->sysroot); }); } diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanager.cpp index b82a93987f..41cbe1763b 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.cpp @@ -165,7 +165,7 @@ void QbsManager::addProfile(const QString &name, const QVariantMap &data) void QbsManager::addQtProfileFromKit(const QString &profileName, const ProjectExplorer::Kit *k) { - if (const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitInformation::qtVersion(k)) { + if (const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(k)) { qbs::Profile(profileName, settings()).setValue("moduleProviders.Qt.qmakeFilePaths", qt->qmakeCommand().toString()); } diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 3087dfc7a9..62d802a388 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -112,7 +112,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * Core::HelpManager::registerDocumentation({Core::HelpManager::documentationPath() + "/qbs.qch"}); ProjectManager::registerProjectType<QbsProject>(QmlJSTools::Constants::QBS_MIMETYPE); - KitManager::registerKitInformation<QbsKitInformation>(); + KitManager::registerKitAspect<QbsKitAspect>(); //menus // Build Menu: diff --git a/src/plugins/qmakeprojectmanager/externaleditors.cpp b/src/plugins/qmakeprojectmanager/externaleditors.cpp index 39de1e8ac7..5924afb6a0 100644 --- a/src/plugins/qmakeprojectmanager/externaleditors.cpp +++ b/src/plugins/qmakeprojectmanager/externaleditors.cpp @@ -172,17 +172,17 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, data->workingDirectory = project->projectDirectory().toString(); // active kit if (const Target *target = project->activeTarget()) { - qtVersionsToCheck << QtSupport::QtKitInformation::qtVersion(target->kit()); + qtVersionsToCheck << QtSupport::QtKitAspect::qtVersion(target->kit()); } // all kits of project qtVersionsToCheck += Utils::transform<QVector>(project->targets(), [](Target *t) { - return QTC_GUARD(t) ? QtSupport::QtKitInformation::qtVersion(t->kit()) : nullptr; + return QTC_GUARD(t) ? QtSupport::QtKitAspect::qtVersion(t->kit()) : nullptr; }); } // default kit - qtVersionsToCheck << QtSupport::QtKitInformation::qtVersion(KitManager::defaultKit()); + qtVersionsToCheck << QtSupport::QtKitAspect::qtVersion(KitManager::defaultKit()); // all kits - qtVersionsToCheck += Utils::transform<QVector>(KitManager::kits(), QtSupport::QtKitInformation::qtVersion); + qtVersionsToCheck += Utils::transform<QVector>(KitManager::kits(), QtSupport::QtKitAspect::qtVersion); qtVersionsToCheck = Utils::filteredUnique(qtVersionsToCheck); // can still contain nullptr data->binary = findFirstCommand(qtVersionsToCheck, m_commandForQtVersion); // fallback diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index 9435155b44..a2a187194c 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -140,7 +140,7 @@ void QmakeBuildConfiguration::initialize(const BuildInfo &info) cleanSteps->appendStep(new QmakeMakeStep(cleanSteps)); const QmakeExtraBuildInfo qmakeExtra = info.extraInfo.value<QmakeExtraBuildInfo>(); - BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *version = QtKitAspect::qtVersion(target()->kit()); BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig(); if (info.buildType == BuildConfiguration::Debug) @@ -165,7 +165,7 @@ void QmakeBuildConfiguration::initialize(const BuildInfo &info) setBuildDirectory(directory); - if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) + if (DeviceTypeKitAspect::deviceTypeId(target()->kit()) == Android::Constants::ANDROID_DEVICE_TYPE) { buildSteps->appendStep(Android::Constants::ANDROID_PACKAGE_INSTALLATION_STEP_ID); buildSteps->appendStep(Android::Constants::ANDROID_BUILD_APK_ID); @@ -210,13 +210,13 @@ void QmakeBuildConfiguration::kitChanged() void QmakeBuildConfiguration::toolChainUpdated(ToolChain *tc) { - if (ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID) == tc) + if (ToolChainKitAspect::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID) == tc) emitProFileEvaluateNeeded(); } void QmakeBuildConfiguration::qtVersionsChanged(const QList<int> &,const QList<int> &, const QList<int> &changed) { - if (changed.contains(QtKitInformation::qtVersionId(target()->kit()))) + if (changed.contains(QtKitAspect::qtVersionId(target()->kit()))) emitProFileEvaluateNeeded(); } @@ -301,7 +301,7 @@ void QmakeBuildConfiguration::emitQMakeBuildConfigurationChanged() QStringList QmakeBuildConfiguration::configCommandLineArguments() const { QStringList result; - BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *version = QtKitAspect::qtVersion(target()->kit()); BaseQtVersion::QmakeBuildConfigs defaultBuildConfiguration = version ? version->defaultBuildConfig() : BaseQtVersion::QmakeBuildConfigs(BaseQtVersion::DebugBuild | BaseQtVersion::BuildAll); BaseQtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration; @@ -364,7 +364,7 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF return MakefileMissing; } - BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *version = QtKitAspect::qtVersion(target()->kit()); if (!version) { qCDebug(logs) << "**No qt version in kit"; return MakefileForWrongProject; @@ -567,7 +567,7 @@ QmakeBuildConfigurationFactory::QmakeBuildConfigurationFactory() setSupportedProjectType(Constants::QMAKEPROJECT_ID); setSupportedProjectMimeTypeName(Constants::PROFILE_MIMETYPE); setIssueReporter([](Kit *k, const QString &projectPath, const QString &buildDir) { - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); QList<Task> issues; if (version) issues << version->reportIssues(projectPath, buildDir); @@ -594,7 +594,7 @@ BuildInfo QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k, const QString &projectPath, BuildConfiguration::BuildType type) const { - BaseQtVersion *version = QtKitInformation::qtVersion(k); + BaseQtVersion *version = QtKitAspect::qtVersion(k); QmakeExtraBuildInfo extraInfo; BuildInfo info(this); QString suffix; @@ -662,7 +662,7 @@ QList<BuildInfo> QmakeBuildConfigurationFactory::availableBuilds(const Target *p const QString projectFilePath = parent->project()->projectFilePath().toString(); foreach (BuildConfiguration::BuildType buildType, - availableBuildTypes(QtKitInformation::qtVersion(parent->kit()))) { + availableBuildTypes(QtKitAspect::qtVersion(parent->kit()))) { BuildInfo info = createBuildInfo(parent->kit(), projectFilePath, buildType); info.displayName.clear(); // ask for a name info.buildDirectory.clear(); // This depends on the displayName @@ -675,7 +675,7 @@ QList<BuildInfo> QmakeBuildConfigurationFactory::availableBuilds(const Target *p QList<BuildInfo> QmakeBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const { QList<BuildInfo> result; - BaseQtVersion *qtVersion = QtKitInformation::qtVersion(k); + BaseQtVersion *qtVersion = QtKitAspect::qtVersion(k); if (!qtVersion || !qtVersion->isValid()) return result; @@ -704,7 +704,7 @@ void QmakeBuildConfiguration::addToEnvironment(Environment &env) const void QmakeBuildConfiguration::setupBuildEnvironment(Kit *k, Environment &env) { prependCompilerPathToEnvironment(k, env); - const BaseQtVersion *qt = QtKitInformation::qtVersion(k); + const BaseQtVersion *qt = QtKitAspect::qtVersion(k); if (qt && !qt->binPath().isEmpty()) env.prependOrSetPath(qt->binPath().toString()); } @@ -712,11 +712,11 @@ void QmakeBuildConfiguration::setupBuildEnvironment(Kit *k, Environment &env) QmakeBuildConfiguration::LastKitState::LastKitState() = default; QmakeBuildConfiguration::LastKitState::LastKitState(Kit *k) - : m_qtVersion(QtKitInformation::qtVersionId(k)), - m_sysroot(SysRootKitInformation::sysRoot(k).toString()), - m_mkspec(QmakeKitInformation::mkspec(k).toString()) + : m_qtVersion(QtKitAspect::qtVersionId(k)), + m_sysroot(SysRootKitAspect::sysRoot(k).toString()), + m_mkspec(QmakeKitAspect::mkspec(k).toString()) { - ToolChain *tc = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); m_toolchain = tc ? tc->id() : QByteArray(); } diff --git a/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.cpp b/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.cpp index ba90baf6f1..6675cbca5e 100644 --- a/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.cpp +++ b/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.cpp @@ -34,51 +34,51 @@ namespace QmakeProjectManager { namespace Internal { -QmakeKitConfigWidget::QmakeKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki) : - ProjectExplorer::KitConfigWidget(k, ki), +QmakeKitAspectWidget::QmakeKitAspectWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitAspect *ki) : + ProjectExplorer::KitAspectWidget(k, ki), m_lineEdit(new QLineEdit) { refresh(); // set up everything according to kit m_lineEdit->setToolTip(toolTip()); - connect(m_lineEdit, &QLineEdit::textEdited, this, &QmakeKitConfigWidget::mkspecWasChanged); + connect(m_lineEdit, &QLineEdit::textEdited, this, &QmakeKitAspectWidget::mkspecWasChanged); } -QmakeKitConfigWidget::~QmakeKitConfigWidget() +QmakeKitAspectWidget::~QmakeKitAspectWidget() { delete m_lineEdit; } -QWidget *QmakeKitConfigWidget::mainWidget() const +QWidget *QmakeKitAspectWidget::mainWidget() const { return m_lineEdit; } -QString QmakeKitConfigWidget::displayName() const +QString QmakeKitAspectWidget::displayName() const { return tr("Qt mkspec"); } -QString QmakeKitConfigWidget::toolTip() const +QString QmakeKitAspectWidget::toolTip() const { return tr("The mkspec to use when building the project with qmake.<br>" "This setting is ignored when using other build systems."); } -void QmakeKitConfigWidget::makeReadOnly() +void QmakeKitAspectWidget::makeReadOnly() { m_lineEdit->setEnabled(false); } -void QmakeKitConfigWidget::refresh() +void QmakeKitAspectWidget::refresh() { if (!m_ignoreChange) - m_lineEdit->setText(QmakeKitInformation::mkspec(m_kit).toUserOutput()); + m_lineEdit->setText(QmakeKitAspect::mkspec(m_kit).toUserOutput()); } -void QmakeKitConfigWidget::mkspecWasChanged(const QString &text) +void QmakeKitAspectWidget::mkspecWasChanged(const QString &text) { m_ignoreChange = true; - QmakeKitInformation::setMkspec(m_kit, Utils::FileName::fromString(text)); + QmakeKitAspect::setMkspec(m_kit, Utils::FileName::fromString(text)); m_ignoreChange = false; } diff --git a/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.h b/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.h deleted file mode 100644 index f1faa861f1..0000000000 --- a/src/plugins/qmakeprojectmanager/qmakekitconfigwidget.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <projectexplorer/kitconfigwidget.h> - -QT_BEGIN_NAMESPACE -class QLineEdit; -QT_END_NAMESPACE - -namespace QmakeProjectManager { -namespace Internal { - -class QmakeKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT - -public: - QmakeKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki); - ~QmakeKitConfigWidget() override; - - QWidget *mainWidget() const override; - QString displayName() const override; - QString toolTip() const override; - - void makeReadOnly() override; - void refresh() override; - -private: - void mkspecWasChanged(const QString &text); - int findQtVersion(const int id) const; - - QLineEdit *m_lineEdit = nullptr; - bool m_ignoreChange = false; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp b/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp index 94f3efcbe7..00b2bccb64 100644 --- a/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp +++ b/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp @@ -25,7 +25,6 @@ #include "qmakekitinformation.h" -#include "qmakekitconfigwidget.h" #include "qmakeprojectmanagerconstants.h" #include <projectexplorer/projectexplorerconstants.h> @@ -37,30 +36,73 @@ #include <utils/algorithm.h> #include <utils/qtcassert.h> +#include <QLineEdit> + using namespace ProjectExplorer; using namespace Utils; namespace QmakeProjectManager { +namespace Internal { + +class QmakeKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(QmakeProjectManager::Internal::QmakeKitAspect) + +public: + QmakeKitAspectWidget(Kit *k, const KitAspect *ki) + : KitAspectWidget(k, ki), m_lineEdit(new QLineEdit) + { + refresh(); // set up everything according to kit + m_lineEdit->setToolTip(ki->description()); + connect(m_lineEdit, &QLineEdit::textEdited, this, &QmakeKitAspectWidget::mkspecWasChanged); + } + + ~QmakeKitAspectWidget() override { delete m_lineEdit; } + +private: + QWidget *mainWidget() const override { return m_lineEdit; } + void makeReadOnly() override { m_lineEdit->setEnabled(false); } + + void refresh() override + { + if (!m_ignoreChange) + m_lineEdit->setText(QmakeKitAspect::mkspec(m_kit).toUserOutput()); + } + + void mkspecWasChanged(const QString &text) + { + m_ignoreChange = true; + QmakeKitAspect::setMkspec(m_kit, Utils::FileName::fromString(text)); + m_ignoreChange = false; + } + + QLineEdit *m_lineEdit = nullptr; + bool m_ignoreChange = false; +}; + -QmakeKitInformation::QmakeKitInformation() +QmakeKitAspect::QmakeKitAspect() { - setObjectName(QLatin1String("QmakeKitInformation")); - setId(QmakeKitInformation::id()); + setObjectName(QLatin1String("QmakeKitAspect")); + setId(QmakeKitAspect::id()); + setDisplayName(tr("Qt mkspec")); + setDescription(tr("The mkspec to use when building the project with qmake.<br>" + "This setting is ignored when using other build systems.")); setPriority(24000); } -QVariant QmakeKitInformation::defaultValue(const Kit *k) const +QVariant QmakeKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k); return QString(); } -QList<Task> QmakeKitInformation::validate(const Kit *k) const +QList<Task> QmakeKitAspect::validate(const Kit *k) const { QList<Task> result; - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); - FileName mkspec = QmakeKitInformation::mkspec(k); + FileName mkspec = QmakeKitAspect::mkspec(k); if (!version && !mkspec.isEmpty()) result << Task(Task::Warning, tr("No Qt version set, so mkspec is ignored."), FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); @@ -70,9 +112,9 @@ QList<Task> QmakeKitInformation::validate(const Kit *k) const return result; } -void QmakeKitInformation::setup(Kit *k) +void QmakeKitAspect::setup(Kit *k) { - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (!version) return; @@ -80,11 +122,11 @@ void QmakeKitInformation::setup(Kit *k) if (version->type() == "Boot2Qt.QtVersionType" || version->type() == "Qdb.EmbeddedLinuxQt") return; - FileName spec = QmakeKitInformation::mkspec(k); + FileName spec = QmakeKitAspect::mkspec(k); if (spec.isEmpty()) spec = version->mkspec(); - ToolChain *tc = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!tc || (!tc->suggestedMkspecList().empty() && !tc->suggestedMkspecList().contains(spec))) { const QList<ToolChain *> possibleTcs = ToolChainManager::toolChains( @@ -110,42 +152,42 @@ void QmakeKitInformation::setup(Kit *k) bestTc = goodTcs.isEmpty() ? possibleTcs.last() : goodTcs.last(); } if (bestTc) - ToolChainKitInformation::setAllToolChainsToMatch(k, bestTc); + ToolChainKitAspect::setAllToolChainsToMatch(k, bestTc); } } } -KitConfigWidget *QmakeKitInformation::createConfigWidget(Kit *k) const +KitAspectWidget *QmakeKitAspect::createConfigWidget(Kit *k) const { - return new Internal::QmakeKitConfigWidget(k, this); + return new Internal::QmakeKitAspectWidget(k, this); } -KitInformation::ItemList QmakeKitInformation::toUserOutput(const Kit *k) const +KitAspect::ItemList QmakeKitAspect::toUserOutput(const Kit *k) const { return ItemList() << qMakePair(tr("mkspec"), mkspec(k).toUserOutput()); } -void QmakeKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const +void QmakeKitAspect::addToMacroExpander(Kit *kit, MacroExpander *expander) const { expander->registerVariable("Qmake:mkspec", tr("Mkspec configured for qmake by the Kit."), [kit]() -> QString { - return QmakeKitInformation::mkspec(kit).toUserOutput(); + return QmakeKitAspect::mkspec(kit).toUserOutput(); }); } -Core::Id QmakeKitInformation::id() +Core::Id QmakeKitAspect::id() { return Constants::KIT_INFORMATION_ID; } -FileName QmakeKitInformation::mkspec(const Kit *k) +FileName QmakeKitAspect::mkspec(const Kit *k) { if (!k) return FileName(); - return FileName::fromString(k->value(QmakeKitInformation::id()).toString()); + return FileName::fromString(k->value(QmakeKitAspect::id()).toString()); } -FileName QmakeKitInformation::effectiveMkspec(const Kit *k) +FileName QmakeKitAspect::effectiveMkspec(const Kit *k) { if (!k) return FileName(); @@ -155,20 +197,21 @@ FileName QmakeKitInformation::effectiveMkspec(const Kit *k) return spec; } -void QmakeKitInformation::setMkspec(Kit *k, const FileName &fn) +void QmakeKitAspect::setMkspec(Kit *k, const FileName &fn) { QTC_ASSERT(k, return); - k->setValue(QmakeKitInformation::id(), fn == defaultMkspec(k) ? QString() : fn.toString()); + k->setValue(QmakeKitAspect::id(), fn == defaultMkspec(k) ? QString() : fn.toString()); } -FileName QmakeKitInformation::defaultMkspec(const Kit *k) +FileName QmakeKitAspect::defaultMkspec(const Kit *k) { - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (!version) // No version, so no qmake return FileName(); - return version->mkspecFor(ToolChainKitInformation::toolChain(k, + return version->mkspecFor(ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID)); } +} // namespace Internal } // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/qmakekitinformation.h b/src/plugins/qmakeprojectmanager/qmakekitinformation.h index 686ece1246..6cb2318a21 100644 --- a/src/plugins/qmakeprojectmanager/qmakekitinformation.h +++ b/src/plugins/qmakeprojectmanager/qmakekitinformation.h @@ -25,25 +25,23 @@ #pragma once -#include "qmakeprojectmanager_global.h" - #include <projectexplorer/kitmanager.h> namespace QmakeProjectManager { +namespace Internal { -class QMAKEPROJECTMANAGER_EXPORT QmakeKitInformation : public ProjectExplorer::KitInformation +class QmakeKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - QmakeKitInformation(); + QmakeKitAspect(); QVariant defaultValue(const ProjectExplorer::Kit *k) const override; - QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override; void setup(ProjectExplorer::Kit *k) override; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; ItemList toUserOutput(const ProjectExplorer::Kit *k) const override; @@ -56,4 +54,5 @@ public: static Utils::FileName defaultMkspec(const ProjectExplorer::Kit *k); }; +} // namespace Internal } // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp index be03c1affc..86bd85359a 100644 --- a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp @@ -156,7 +156,7 @@ bool QmakeMakeStep::init() pp->resolveAll(); setOutputParser(new ProjectExplorer::GnuMakeParser()); - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), + ToolChain *tc = ToolChainKitAspect::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (tc && tc->targetAbi().os() == Abi::DarwinOS) appendOutputParser(new XcodebuildParser); diff --git a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp index b4e3b28abb..4953a65946 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp @@ -201,7 +201,7 @@ std::unique_ptr<QmakeProFileNode> QmakeNodeTreeBuilder::buildTree(QmakeProject * // Remove qmake implementation details that litter up the project data: Target *t = project->activeTarget(); Kit *k = t ? t->kit() : KitManager::defaultKit(); - BaseQtVersion *qt = k ? QtKitInformation::qtVersion(k) : nullptr; + BaseQtVersion *qt = k ? QtKitAspect::qtVersion(k) : nullptr; const FileNameList toExclude = qt ? qt->directoriesToIgnoreInProjectTree() : FileNameList(); diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 6e92cf45d2..25352190d8 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -582,11 +582,11 @@ void QmakeProject::buildFinished(bool success) QList<Task> QmakeProject::projectIssues(const Kit *k) const { QList<Task> result = Project::projectIssues(k); - if (!QtSupport::QtKitInformation::qtVersion(k)) + if (!QtSupport::QtKitAspect::qtVersion(k)) result.append(createProjectTask(Task::TaskType::Error, tr("No Qt version set in kit."))); - else if (!QtSupport::QtKitInformation::qtVersion(k)->isValid()) + else if (!QtSupport::QtKitAspect::qtVersion(k)->isValid()) result.append(createProjectTask(Task::TaskType::Error, tr("Qt version is invalid."))); - if (!ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID)) + if (!ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID)) result.append(createProjectTask(Task::TaskType::Error, tr("No C++ compiler set in kit."))); return result; } @@ -665,8 +665,8 @@ QtSupport::ProFileReader *QmakeProject::createProFileReader(const QmakeProFile * k->addToEnvironment(env); } - QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k); - m_qmakeSysroot = SysRootKitInformation::sysRoot(k).toString(); + QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(k); + m_qmakeSysroot = SysRootKitAspect::sysRoot(k).toString(); if (qtVersion && qtVersion->isValid()) { m_qmakeGlobals->qmake_abslocation = QDir::cleanPath(qtVersion->qmakeCommand().toString()); @@ -962,7 +962,7 @@ void QmakeProject::configureAsExampleProject(const QSet<Core::Id> &platforms) QList<BuildInfo> infoList; QList<Kit *> kits = KitManager::kits(); foreach (Kit *k, kits) { - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (!version || (!platforms.isEmpty() && !Utils::contains(version->targetDeviceTypes(), [platforms](Core::Id i) { return platforms.contains(i); }))) @@ -1061,7 +1061,7 @@ void QmakeProject::updateBuildSystemData() libraryPaths.append(dir); } } - QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target->kit()); + QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(target->kit()); if (qtVersion) libraryPaths.append(qtVersion->librarySearchPath().toString()); @@ -1137,7 +1137,7 @@ void QmakeProject::collectLibraryData(const QmakeProFile *file, DeploymentData & if (targetPath.isEmpty()) return; const Kit * const kit = activeTarget()->kit(); - const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + const ToolChain * const toolchain = ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!toolchain) return; @@ -1224,7 +1224,7 @@ void QmakeProject::collectLibraryData(const QmakeProFile *file, DeploymentData & bool QmakeProject::matchesKit(const Kit *kit) { FileName filePath = projectFilePath(); - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit); return QtSupport::QtVersionManager::version([&filePath, version](const QtSupport::BaseQtVersion *v) { return v->isValid() && v->isSubProject(filePath) && v == version; @@ -1299,16 +1299,16 @@ void QmakeProject::warnOnToolChainMismatch(const QmakeProFile *pro) const if (!bc) return; - testToolChain(ToolChainKitInformation::toolChain(t->kit(), ProjectExplorer::Constants::C_LANGUAGE_ID), + testToolChain(ToolChainKitAspect::toolChain(t->kit(), ProjectExplorer::Constants::C_LANGUAGE_ID), getFullPathOf(pro, Variable::QmakeCc, bc)); - testToolChain(ToolChainKitInformation::toolChain(t->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID), + testToolChain(ToolChainKitAspect::toolChain(t->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID), getFullPathOf(pro, Variable::QmakeCxx, bc)); } QString QmakeProject::executableFor(const QmakeProFileNode *node) { const Kit *const kit = activeTarget() ? activeTarget()->kit() : nullptr; - const ToolChain *const tc = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + const ToolChain *const tc = ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (!tc) return QString(); diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp index 241bd5a4f5..17dc6d578b 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp @@ -210,7 +210,7 @@ void QmakeProjectConfigWidget::updateProblemLabel() const QString proFileName = m_buildConfiguration->target()->project()->projectFilePath().toString(); // Check for Qt version: - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (!version) { setProblemLabel(tr("This kit cannot build this project since it does not define a Qt version.")); return; diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp index c97bab5a38..b5a29ba620 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp @@ -203,9 +203,9 @@ bool QmakeProjectImporter::matchKit(void *directoryData, const Kit *k) const auto *data = static_cast<DirectoryData *>(directoryData); const QLoggingCategory &logs = MakeFileParse::logging(); - BaseQtVersion *kitVersion = QtKitInformation::qtVersion(k); - FileName kitSpec = QmakeKitInformation::mkspec(k); - ToolChain *tc = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + BaseQtVersion *kitVersion = QtKitAspect::qtVersion(k); + FileName kitSpec = QmakeKitAspect::mkspec(k); + ToolChain *tc = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (kitSpec.isEmpty() && kitVersion) kitSpec = kitVersion->mkspecFor(tc); QMakeStepConfig::TargetArchConfig kitTargetArch = QMakeStepConfig::NoArch; @@ -288,9 +288,9 @@ Kit *QmakeProjectImporter::createTemporaryKit(const QtProjectImporter::QtVersion Q_UNUSED(osType); // TODO use this to select the right toolchain? return QtProjectImporter::createTemporaryKit(data, [&data, parsedSpec, archConfig](Kit *k) -> void { - ToolChainKitInformation::setToolChain(k, preferredToolChain(data.qt, parsedSpec, archConfig)); + ToolChainKitAspect::setToolChain(k, preferredToolChain(data.qt, parsedSpec, archConfig)); if (parsedSpec != data.qt->mkspec()) - QmakeKitInformation::setMkspec(k, parsedSpec); + QmakeKitAspect::setMkspec(k, parsedSpec); }); } diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro index b831a594d0..b08bc4e87c 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro @@ -7,7 +7,6 @@ DEFINES += \ HEADERS += \ qmakebuildinfo.h \ qmakekitinformation.h \ - qmakekitconfigwidget.h \ qmakeparsernodes.h \ qmakeprojectimporter.h \ qmakeprojectmanagerplugin.h \ @@ -46,7 +45,6 @@ HEADERS += \ qmakemakestep.h SOURCES += \ - qmakekitconfigwidget.cpp \ qmakekitinformation.cpp \ qmakeparsernodes.cpp \ qmakeprojectimporter.cpp \ diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs index 2b0e99f353..21670d086f 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs @@ -36,7 +36,6 @@ Project { "profilehighlighter.cpp", "profilehighlighter.h", "profilehoverhandler.cpp", "profilehoverhandler.h", "qmakebuildinfo.h", - "qmakekitconfigwidget.cpp", "qmakekitconfigwidget.h", "qmakekitinformation.cpp", "qmakekitinformation.h", "qmakemakestep.cpp", "qmakemakestep.h", "qmakeparser.cpp", "qmakeparser.h", diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index 46ffcec047..feeb03f2b9 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -140,7 +140,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString //create and register objects ProjectManager::registerProjectType<QmakeProject>(QmakeProjectManager::Constants::PROFILE_MIMETYPE); - ProjectExplorer::KitManager::registerKitInformation<QmakeKitInformation>(); + ProjectExplorer::KitManager::registerKitAspect<QmakeKitAspect>(); IWizardFactory::registerFactoryCreator([] { return QList<IWizardFactory *> { diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index c9bdbb96bf..35a05d8f54 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -136,18 +136,18 @@ QMakeStepConfig QMakeStep::deducedArguments() const ProjectExplorer::Kit *kit = target()->kit(); QMakeStepConfig config; ProjectExplorer::ToolChain *tc - = ProjectExplorer::ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + = ProjectExplorer::ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); ProjectExplorer::Abi targetAbi; if (tc) { targetAbi = tc->targetAbi(); if (HostOsInfo::isWindowsHost() && tc->typeId() == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID) { - config.sysRoot = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString(); + config.sysRoot = ProjectExplorer::SysRootKitAspect::sysRoot(kit).toString(); config.targetTriple = tc->originalTargetTriple(); } } - BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *version = QtKitAspect::qtVersion(target()->kit()); config.archConfig = QMakeStepConfig::targetArchFor(targetAbi, version); config.osType = QMakeStepConfig::osTypeFor(targetAbi, version); @@ -166,7 +166,7 @@ QMakeStepConfig QMakeStep::deducedArguments() const bool QMakeStep::init() { QmakeBuildConfiguration *qmakeBc = qmakeBuildConfiguration(); - const BaseQtVersion *qtVersion = QtKitInformation::qtVersion(target()->kit()); + const BaseQtVersion *qtVersion = QtKitAspect::qtVersion(target()->kit()); if (!qtVersion) { emit addOutput(tr("No Qt version configured."), BuildStep::OutputFormat::ErrorMessage); @@ -452,7 +452,7 @@ QString QMakeStep::makeArguments(const QString &makefile) const QString QMakeStep::effectiveQMakeCall() const { - BaseQtVersion *qtVersion = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *qtVersion = QtKitAspect::qtVersion(target()->kit()); QString qmake = qtVersion ? qtVersion->qmakeCommand().toUserOutput() : QString(); if (qmake.isEmpty()) qmake = tr("<no Qt version>"); @@ -474,7 +474,7 @@ QString QMakeStep::effectiveQMakeCall() const QStringList QMakeStep::parserArguments() { QStringList result; - BaseQtVersion *qt = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *qt = QtKitAspect::qtVersion(target()->kit()); QTC_ASSERT(qt, return QStringList()); for (QtcProcess::ConstArgIterator ait(allArguments(qt, ArgumentFlag::Expand)); ait.next(); ) { if (ait.isSimple()) @@ -499,7 +499,7 @@ FileName QMakeStep::mkspec() const } } - return QmakeProjectManager::QmakeKitInformation::effectiveMkspec(target()->kit()); + return QmakeKitAspect::effectiveMkspec(target()->kit()); } QVariantMap QMakeStep::toMap() const @@ -588,8 +588,6 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) connect(step->qmakeBuildConfiguration(), &QmakeBuildConfiguration::qmakeBuildConfigurationChanged, this, &QMakeStepConfigWidget::qmakeBuildConfigChanged); connect(step->target(), &Target::kitChanged, this, &QMakeStepConfigWidget::qtVersionChanged); - connect(QtVersionManager::instance(), &QtVersionManager::dumpUpdatedFor, - this, &QMakeStepConfigWidget::qtVersionChanged); auto chooser = new Core::VariableChooser(m_ui->qmakeAdditonalArgumentsLineEdit); chooser->addMacroExpanderProvider([step] { return step->macroExpander(); }); chooser->addSupportedWidget(m_ui->qmakeAdditonalArgumentsLineEdit); @@ -743,7 +741,7 @@ void QMakeStepConfigWidget::separateDebugInfoChecked(bool checked) void QMakeStepConfigWidget::updateSummaryLabel() { - BaseQtVersion *qtVersion = QtKitInformation::qtVersion(m_step->target()->kit()); + BaseQtVersion *qtVersion = QtKitAspect::qtVersion(m_step->target()->kit()); if (!qtVersion) { setSummaryText(tr("<b>qmake:</b> No Qt version set. Cannot run qmake.")); return; diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index 9ed1939f1a..d22d8da89d 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -196,11 +196,11 @@ int BaseQmakeProjectWizardDialog::addTargetSetupPage(int id) const Core::Id platform = selectedPlatform(); QSet<Core::Id> features = {QtSupport::Constants::FEATURE_DESKTOP}; if (!platform.isValid()) - m_targetSetupPage->setPreferredKitPredicate(QtKitInformation::qtVersionPredicate(features)); + m_targetSetupPage->setPreferredKitPredicate(QtKitAspect::qtVersionPredicate(features)); else - m_targetSetupPage->setPreferredKitPredicate(QtKitInformation::platformPredicate(platform)); + m_targetSetupPage->setPreferredKitPredicate(QtKitAspect::platformPredicate(platform)); - m_targetSetupPage->setRequiredKitPredicate(QtKitInformation::qtVersionPredicate(requiredFeatures())); + m_targetSetupPage->setRequiredKitPredicate(QtKitAspect::qtVersionPredicate(requiredFeatures())); resize(900, 450); if (id >= 0) @@ -262,7 +262,7 @@ bool BaseQmakeProjectWizardDialog::isQtPlatformSelected(Core::Id platform) const { QList<Core::Id> selectedKitList = selectedKits(); - return Utils::contains(KitManager::kits(QtKitInformation::platformPredicate(platform)), + return Utils::contains(KitManager::kits(QtKitAspect::platformPredicate(platform)), [selectedKitList](const Kit *k) { return selectedKitList.contains(k->id()); }); } diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index 2cc524c799..86fd3ce94d 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -260,7 +260,7 @@ static void paintTextInPlaceHolderForInvisbleItem(QPainter *painter, QFontMetrics fm(font); painter->rotate(90); - if (fm.width(displayText) > (boundingRect.height() - 32) && displayText.length() > 4) { + if (fm.horizontalAdvance(displayText) > (boundingRect.height() - 32) && displayText.length() > 4) { displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect.height() - 32, Qt::TextShowMnemonic); } diff --git a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp index 089a540b8f..8739ec64a8 100644 --- a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp +++ b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp @@ -137,7 +137,7 @@ static QRect drawText(QPainter *painter, displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace); displayStringOffset = QPoint(5 + iconOffset, -5); - width = styleOption.fontMetrics.width(displayString); + width = styleOption.fontMetrics.horizontalAdvance(displayString); QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset; painter->drawText(textPosition, displayString); diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp index aa7cfe1bb0..8c0c322858 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp @@ -28,6 +28,7 @@ #include "qmlanchorbindingproxy.h" #include "propertyeditorview.h" +#include <exception.h> #include <nodeproperty.h> #include <nodelistproperty.h> #include <variantproperty.h> @@ -35,8 +36,10 @@ #include <nodemetainfo.h> #include <rewritertransaction.h> +#include <utils/qtcassert.h> + GradientModel::GradientModel(QObject *parent) : - QAbstractListModel(parent), m_locked(false) + QAbstractListModel(parent) { } @@ -139,38 +142,38 @@ void GradientModel::addGradient() return; if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) { + try { - QColor color = m_itemNode.instanceValue("color").value<QColor>(); + QColor color = m_itemNode.instanceValue("color").value<QColor>(); - if (!color.isValid()) - color = QColor(Qt::white); + if (!color.isValid()) + color = QColor(Qt::white); - QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient")); + QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient")); - QmlDesigner::ModelNode gradientNode = - m_itemNode.modelNode().view()->createModelNode("QtQuick.Gradient", - m_itemNode.modelNode().view()->majorQtQuickVersion(), 0); - m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).reparentHere(gradientNode); + QmlDesigner::ModelNode gradientNode = createGradientNode(); + m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).reparentHere(gradientNode); - QmlDesigner::ModelNode gradientStopNode = - m_itemNode.modelNode().view()->createModelNode("QtQuick.GradientStop", - m_itemNode.modelNode().view()->majorQtQuickVersion(), 0); - gradientStopNode.variantProperty("position").setValue(0.0); - gradientStopNode.variantProperty("color").setValue(color); - gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode); + QmlDesigner::ModelNode gradientStopNode = view()->createModelNode("QtQuick.GradientStop", view()->majorQtQuickVersion(), 0); + gradientStopNode.variantProperty("position").setValue(0.0); + gradientStopNode.variantProperty("color").setValue(color); + gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode); - gradientStopNode = m_itemNode.modelNode().view()->createModelNode( - "QtQuick.GradientStop", - m_itemNode.modelNode().view()->majorQtQuickVersion(), 0); - gradientStopNode.variantProperty("position").setValue(1.0); - gradientStopNode.variantProperty("color").setValue(QColor(Qt::black)); - gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode); + gradientStopNode = view()->createModelNode("QtQuick.GradientStop", view()->majorQtQuickVersion(), 0); + gradientStopNode.variantProperty("position").setValue(1.0); + gradientStopNode.variantProperty("color").setValue(QColor(Qt::black)); + gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode); + + } catch (const QmlDesigner::Exception &e) { + e.showException(); + } } setupModel(); emit hasGradientChanged(); + emit gradientTypeChanged(); } void GradientModel::setColor(int index, const QColor &color) @@ -231,7 +234,7 @@ qreal GradientModel::getPosition(int index) const void GradientModel::removeStop(int index) { if (index < rowCount() - 1 && index != 0) { - QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop")); + QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop")); QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode(); QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index); if (stop.isValid()) { @@ -255,7 +258,7 @@ void GradientModel::deleteGradient() if (m_itemNode.isInBaseState()) { if (modelNode.hasProperty(gradientPropertyName().toUtf8())) { - QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::deleteGradient")); + QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::deleteGradient")); QmlDesigner::ModelNode gradientNode = modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode(); if (QmlDesigner::QmlObjectNode(gradientNode).isValid()) QmlDesigner::QmlObjectNode(gradientNode).destroy(); @@ -263,6 +266,7 @@ void GradientModel::deleteGradient() } emit hasGradientChanged(); + emit gradientTypeChanged(); } void GradientModel::lock() @@ -280,6 +284,22 @@ void GradientModel::registerDeclarativeType() qmlRegisterType<GradientModel>("HelperWidgets",2,0,"GradientModel"); } +qreal GradientModel::readGradientProperty(const QString &propertyName) const +{ + if (!m_itemNode.isValid()) + return 0; + + QmlDesigner::QmlObjectNode gradient; + + if (m_itemNode.modelNode().hasProperty(gradientPropertyName().toUtf8())) + gradient = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode(); + + if (!gradient.isValid()) + return 0; + + return gradient.modelValue(propertyName.toUtf8()).toReal(); +} + void GradientModel::setupModel() { m_locked = true; @@ -299,12 +319,17 @@ void GradientModel::setAnchorBackend(const QVariant &anchorBackend) if (backendCasted) m_itemNode = backendCasted->getItemNode(); + if (m_itemNode.isValid() + && m_itemNode.modelNode().hasProperty(gradientPropertyName().toUtf8())) + m_gradientTypeName = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode().simplifiedTypeName(); + setupModel(); m_locked = true; emit anchorBackendChanged(); emit hasGradientChanged(); + emit gradientTypeChanged(); m_locked = false; } @@ -319,6 +344,16 @@ void GradientModel::setGradientPropertyName(const QString &name) m_gradientPropertyName = name; } +QString GradientModel::gradientTypeName() const +{ + return m_gradientTypeName; +} + +void GradientModel::setGradientTypeName(const QString &name) +{ + m_gradientTypeName = name; +} + bool GradientModel::hasGradient() const { return m_itemNode.isValid() @@ -330,10 +365,114 @@ bool GradientModel::locked() const if (m_locked) return true; - auto view = qobject_cast<QmlDesigner::PropertyEditorView*>(m_itemNode.view()); + auto editorView = qobject_cast<QmlDesigner::PropertyEditorView*>(view()); - if (view && view->locked()) - return true; + return editorView && editorView->locked(); +} + +bool GradientModel::hasShapesImport() const +{ + if (m_itemNode.isValid()) { + QmlDesigner::Import import = QmlDesigner::Import::createLibraryImport("QtQuick.Shapes", "1.0"); + return model()->hasImport(import, true, true); + } return false; } + +void GradientModel::ensureShapesImport() +{ + if (!hasShapesImport()) { + QmlDesigner::Import timelineImport = QmlDesigner::Import::createLibraryImport("QtQuick.Shapes", "1.0"); + model()->changeImports({timelineImport}, {}); + } +} + +void GradientModel::setupGradientProperties(const QmlDesigner::ModelNode &gradient) +{ + QTC_ASSERT(m_itemNode.isValid(), return); + + QTC_ASSERT(gradient.isValid(), return); + + if (m_gradientTypeName == "Gradient") { + } else if (m_gradientTypeName == "LinearGradient") { + gradient.variantProperty("x1").setValue(0); + gradient.variantProperty("x2").setValue(m_itemNode.instanceValue("width")); + gradient.variantProperty("y1").setValue(0); + gradient.variantProperty("y2").setValue(m_itemNode.instanceValue("height")); + } else if (m_gradientTypeName == "RadialGradient") { + qreal width = m_itemNode.instanceValue("width").toReal(); + qreal height = m_itemNode.instanceValue("height").toReal(); + gradient.variantProperty("centerX").setValue(width / 2.0); + gradient.variantProperty("centerY").setValue(height / 2.0); + + gradient.variantProperty("focalX").setValue(width / 2.0); + gradient.variantProperty("focalY").setValue(height / 2.0); + + qreal radius = qMin(width, height) / 2; + + gradient.variantProperty("centerRadius").setValue(radius); + gradient.variantProperty("focalRadius").setValue(0); + + } else if (m_gradientTypeName == "ConicalGradient") { + qreal width = m_itemNode.instanceValue("width").toReal(); + qreal height = m_itemNode.instanceValue("height").toReal(); + gradient.variantProperty("centerX").setValue(width / 2.0); + gradient.variantProperty("centerY").setValue(height / 2.0); + + gradient.variantProperty("angle").setValue(0); + } +} + +QmlDesigner::Model *GradientModel::model() const +{ + QTC_ASSERT(m_itemNode.isValid(), return nullptr); + return m_itemNode.view()->model(); +} + +QmlDesigner::AbstractView *GradientModel::view() const +{ + QTC_ASSERT(m_itemNode.isValid(), return nullptr); + return m_itemNode.view(); +} + +QmlDesigner::ModelNode GradientModel::createGradientNode() +{ + QByteArray fullTypeName = m_gradientTypeName.toUtf8(); + + if (m_gradientTypeName == "Gradient") { + fullTypeName.prepend("QtQuick."); + } else { + fullTypeName.prepend("QtQuick.Shapes."); + ensureShapesImport(); + } + + auto metaInfo = model()->metaInfo(fullTypeName); + + int minorVersion = metaInfo.minorVersion(); + int majorVersion = metaInfo.majorVersion(); + + auto gradientNode = view()->createModelNode(fullTypeName, majorVersion, minorVersion); + + setupGradientProperties(gradientNode); + + return gradientNode; +} + +void GradientModel::setGradientProperty(const QString &propertyName, qreal value) +{ + QTC_ASSERT(m_itemNode.isValid(), return); + + QmlDesigner::QmlObjectNode gradient; + + if (m_itemNode.modelNode().hasProperty(gradientPropertyName().toUtf8())) + gradient = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode(); + + QTC_ASSERT(gradient.isValid(), return); + + try { + gradient.setVariantProperty(propertyName.toUtf8(), value); + } catch (const QmlDesigner::Exception &e) { + e.showException(); + } +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h index 2ca8b93c42..ecb9ba53fd 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h @@ -37,6 +37,7 @@ class GradientModel : public QAbstractListModel Q_PROPERTY(QVariant anchorBackendProperty READ anchorBackend WRITE setAnchorBackend NOTIFY anchorBackendChanged) Q_PROPERTY(QString gradientPropertyName READ gradientPropertyName WRITE setGradientPropertyName) + Q_PROPERTY(QString gradientTypeName READ gradientTypeName WRITE setGradientTypeName NOTIFY gradientTypeChanged) Q_PROPERTY(int count READ rowCount) Q_PROPERTY(bool hasGradient READ hasGradient NOTIFY hasGradientChanged) @@ -65,9 +66,14 @@ public: static void registerDeclarativeType(); + Q_INVOKABLE qreal readGradientProperty(const QString &property) const; + + Q_INVOKABLE void setGradientProperty(const QString &propertyName, qreal value); + signals: void anchorBackendChanged(); void hasGradientChanged(); + void gradientTypeChanged(); private: void setupModel(); @@ -75,14 +81,22 @@ private: QVariant anchorBackend() const {return QVariant(); } QString gradientPropertyName() const; void setGradientPropertyName(const QString &name); + QString gradientTypeName() const; + void setGradientTypeName(const QString &name); bool hasGradient() const; bool locked() const; + QmlDesigner::ModelNode createGradientNode(); private: QmlDesigner::QmlItemNode m_itemNode; QString m_gradientPropertyName; - bool m_locked; - + QString m_gradientTypeName = {"Gradient"}; + bool m_locked = false; + bool hasShapesImport() const; + void ensureShapesImport(); + void setupGradientProperties(const QmlDesigner::ModelNode &gradient); + QmlDesigner::Model *model() const; + QmlDesigner::AbstractView *view() const; }; QML_DECLARE_TYPE(GradientModel) diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp index 8ab932e8b1..4f5be1a03d 100644 --- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp +++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp @@ -90,7 +90,7 @@ QHash<Core::Id, PuppetCreator::PuppetType> PuppetCreator::m_qml2PuppetForKitPupp QByteArray PuppetCreator::qtHash() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); if (currentQtVersion) { return QCryptographicHash::hash(currentQtVersion->qmakeProperty("QT_INSTALL_DATA").toUtf8(), QCryptographicHash::Sha1) @@ -102,7 +102,7 @@ QByteArray PuppetCreator::qtHash() const QDateTime PuppetCreator::qtLastModified() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); if (currentQtVersion) return QFileInfo(currentQtVersion->qmakeProperty("QT_INSTALL_LIBS")).lastModified(); @@ -419,7 +419,7 @@ QProcessEnvironment PuppetCreator::processEnvironment() const Utils::Environment environment = Utils::Environment::systemEnvironment(); if (!useOnlyFallbackPuppet()) m_kit->addToEnvironment(environment); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(m_kit); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(m_kit); if (QTC_GUARD(qt)) { // Kits without a Qt version should not have a puppet! // Update PATH to include QT_HOST_BINS const Utils::FileName qtBinPath = qt->binPath(); @@ -497,7 +497,7 @@ QString PuppetCreator::buildCommand() const m_kit->addToEnvironment(environment); ProjectExplorer::ToolChain *toolChain - = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit, + = ProjectExplorer::ToolChainKitAspect::toolChain(m_kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (toolChain) @@ -508,7 +508,7 @@ QString PuppetCreator::buildCommand() const QString PuppetCreator::qmakeCommand() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); if (currentQtVersion) return currentQtVersion->qmakeCommand().toString(); @@ -595,7 +595,7 @@ static bool nonEarlyQt5Version(const QtSupport::QtVersionNumber ¤tQtVersio bool PuppetCreator::qtIsSupported() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); return currentQtVersion && currentQtVersion->isValid() diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index c2dfea0e73..c5e9b284f1 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -48,10 +48,10 @@ #include <qmljs/qmljscheck.h> #include <qmljs/qmljsutils.h> #include <qmljs/qmljsmodelmanagerinterface.h> -#include <qmljs/qmljsqrcparser.h> #include <qmljs/qmljsinterpreter.h> #include <qmljs/qmljsvalueowner.h> +#include <utils/qrcparser.h> #include <utils/qtcassert.h> #include <QSet> @@ -456,7 +456,7 @@ public: if (!name.isEmpty() && name != QLatin1String(".")) typeName.prepend(name + QLatin1Char('.')); } else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) { - QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path()); + QString path = Utils::QrcParser::normalizedQrcDirectoryPath(importInfo.path()); path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1)); const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.')); if (!name.isEmpty()) diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp index f9a948fb14..2a0f5fb417 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp @@ -54,7 +54,7 @@ CanvasStyleDialog::CanvasStyleDialog(const CanvasStyle &style, QWidget *parent) m_handleLineWidth->setValue(style.handleLineWidth); m_curveWidth->setValue(style.curveWidth); - int labelWidth = QFontMetrics(this->font()).width("Inter Handle ColorXX"); + int labelWidth = QFontMetrics(this->font()).horizontalAdvance("Inter Handle ColorXX"); auto addControl = [labelWidth](QVBoxLayout *layout, const QString &name, QWidget *control) { auto *hbox = new QHBoxLayout; diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp index 203da8bacd..8ea7692e3d 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp @@ -32,7 +32,6 @@ #include <QAbstractButton> #include <QApplication> #include <QContextMenuEvent> -#include <QDebug> #include <QMenu> #include <QMessageBox> #include <QPainter> @@ -42,11 +41,12 @@ #include <QString> #include <coreplugin/icore.h> +#include <theme.h> namespace QmlDesigner { -constexpr int iconWidth = 64; -constexpr int iconHeight = 64; +constexpr int iconWidth = 86; +constexpr int iconHeight = 86; constexpr int itemFrame = 3; constexpr int itemWidth = iconWidth + 2 * itemFrame; constexpr int unsavedMarkSize = 18; @@ -77,15 +77,15 @@ void PresetItemDelegate::paint(QPainter *painter, auto textRect = QRect(option.rect.topLeft(), textSize); textRect.moveBottom(option.rect.bottom()); - QFontMetrics fm(option.font); - option.text = fm.elidedText(option.text, Qt::ElideRight, textRect.width()); + option.font.setPixelSize(Theme::instance()->smallFontPixelSize()); + painter->save(); painter->fillRect(option.rect, canvasBackground); if (option.text.isEmpty()) painter->fillRect(textRect, canvasBackground); else - painter->fillRect(textRect, labelBackground); + painter->fillRect(textRect, Theme::instance()->qmlDesignerButtonColor()); style->drawControl(QStyle::CE_ItemViewItem, &option, painter, option.widget); @@ -108,6 +108,7 @@ void PresetItemDelegate::paint(QPainter *painter, painter->drawText(asteriskRect, Qt::AlignTop | Qt::AlignRight, "*"); } } + painter->restore(); } QSize PresetItemDelegate::sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const @@ -185,6 +186,8 @@ PresetList::PresetList(QSettings::Scope scope, QWidget *parent) setWrapping(true); + setTextElideMode(Qt::ElideMiddle); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } @@ -278,6 +281,7 @@ void PresetList::readPresets() auto *item = new QStandardItem(paintPreview(curves[i].curve()), curves[i].name()); item->setData(curveData, ItemRole_Data); item->setEditable(m_scope == QSettings::UserScope); + item->setToolTip(curves[i].name()); simodel->setItem(i, item); } @@ -318,6 +322,7 @@ void PresetList::revert(const QModelIndex &index) item->setData(false, ItemRole_Dirty); item->setData(paintPreview(curve.curve()), Qt::DecorationRole); item->setData(QVariant::fromValue(curve.curve()), ItemRole_Data); + item->setToolTip(name); return; } } @@ -357,6 +362,16 @@ void PresetList::contextMenuEvent(QContextMenuEvent *event) menu.exec(event->globalPos()); } +void PresetList::dataChanged(const QModelIndex &topLeft, + const QModelIndex &bottomRight, + const QVector<int> &roles) +{ + if (topLeft == bottomRight && roles.contains(0)) { + QVariant name = model()->data(topLeft, 0); + model()->setData(topLeft, name, Qt::ToolTipRole); + } +} + void PresetList::createItem() { EasingCurve curve; @@ -368,6 +383,7 @@ void PresetList::createItem(const QString &name, const EasingCurve &curve) { auto *item = new QStandardItem(paintPreview(curve), name); item->setData(QVariant::fromValue(curve), ItemRole_Data); + item->setToolTip(name); int row = model()->rowCount(); qobject_cast<QStandardItemModel *>(model())->setItem(row, item); diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h index e1907af99c..6fab3e7adb 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h @@ -99,6 +99,10 @@ public: protected: void contextMenuEvent(QContextMenuEvent *event) override; + void dataChanged(const QModelIndex &topLeft, + const QModelIndex &bottomRight, + const QVector<int> &roles = QVector<int>()) override; + private: QStringList allNames() const; diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp index c34e6d3848..c84923f7c2 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp @@ -120,8 +120,10 @@ void TimelineGraphicsLayout::setTimeline(const QmlTimeline &timeline) if (timeline.isValid()) { for (const ModelNode &target : timeline.allTargets()) { - auto item = TimelineSectionItem::create(timeline, target, this); - m_layout->addItem(item); + if (target.isValid()) { + auto item = TimelineSectionItem::create(timeline, target, this); + m_layout->addItem(item); + } } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp index 41b428661b..f4cab3aa05 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp @@ -703,7 +703,7 @@ void TimelineRulerSectionItem::paintTicks(QPainter *painter) QFontMetrics fm(painter->font()); - int minSpacingText = fm.width(QString("X%1X").arg(rulerDuration())); + int minSpacingText = fm.horizontalAdvance(QString("X%1X").arg(rulerDuration())); int minSpacingLine = 5; int deltaText = 0; diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp index bbc4963955..5eaee4e791 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp @@ -295,9 +295,11 @@ void TimelineSettingsModel::updateTimeline(int row) propertyChanges.modelNode().variantProperty("enabled").setValue(false); } - QmlPropertyChanges propertyChanges(modelState.propertyChanges(timeline)); - if (propertyChanges.isValid()) - propertyChanges.modelNode().variantProperty("enabled").setValue(true); + if (timeline.isValid()) { /* If timeline is invalid 'none' was selected */ + QmlPropertyChanges propertyChanges(modelState.propertyChanges(timeline)); + if (propertyChanges.isValid()) + propertyChanges.modelNode().variantProperty("enabled").setValue(true); + } } } catch (Exception &e) { @@ -345,9 +347,11 @@ void TimelineSettingsModel::updateAnimation(int row) } } - QmlPropertyChanges propertyChanges(modelState.propertyChanges(animation)); - if (propertyChanges.isValid()) - propertyChanges.modelNode().variantProperty("running").setValue(true); + if (animation.isValid()) { /* If animation is invalid 'none' was selected */ + QmlPropertyChanges propertyChanges(modelState.propertyChanges(animation)); + if (propertyChanges.isValid()) + propertyChanges.modelNode().variantProperty("running").setValue(true); + } } } catch (Exception &e) { m_exceptionError = e.description(); diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp index 6479ba13ad..9cea65e3ef 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.cpp +++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp @@ -43,9 +43,9 @@ #include <qmljs/parser/qmljsast_p.h> #include <qmljs/parser/qmljsastfwd_p.h> #include <qmljs/qmljsutils.h> -#include <qmljs/qmljsqrcparser.h> #include <texteditor/texteditor.h> #include <utils/executeondestruction.h> +#include <utils/qrcparser.h> #include <utils/tooltip/tooltip.h> #include <QDir> @@ -133,7 +133,7 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.')); return name; } else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) { - QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path()); + QString path = Utils::QrcParser::normalizedQrcDirectoryPath(importInfo.path()); path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1)); const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.')); return name; diff --git a/src/plugins/qmljstools/qmljsbundleprovider.cpp b/src/plugins/qmljstools/qmljsbundleprovider.cpp index 7fb0a03a26..176d66b33d 100644 --- a/src/plugins/qmljstools/qmljsbundleprovider.cpp +++ b/src/plugins/qmljstools/qmljsbundleprovider.cpp @@ -98,7 +98,7 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit bundles.mergeBundleForLanguage(Dialect::QmlTypeInfo, defaultQmltypesBundle()); bundles.mergeBundleForLanguage(Dialect::QmlProject, defaultQmlprojectBundle()); - QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit); + QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit); if (!qtVersion) { QmlBundle b2(defaultQt5QtQuick2Bundle()); bundles.mergeBundleForLanguage(Dialect::Qml, b2); diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index d328886f9e..af47d2eef3 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -98,7 +98,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( activeTarget = project->activeTarget(); } Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit(); - QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(activeKit); + QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(activeKit); bool preferDebugDump = false; bool setPreferDump = false; diff --git a/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp b/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp index 95ed107fea..f08f3aeaaa 100644 --- a/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp +++ b/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp @@ -101,7 +101,7 @@ QString QmlPreviewFileOnTargetFinder::findPath(const QString &filePath, bool *su if (success) { // On desktop, if there is no "remote" path, then the application will load the local path. - *success = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(m_target->kit()) + *success = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId(m_target->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } return filePath; diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp index b60996ae1f..a1c497756a 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp +++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp @@ -111,7 +111,7 @@ bool QmlPreviewPlugin::initialize(const QStringList &arguments, QString *errorSt auto constraint = [](RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) == Constants::DESKTOP_DEVICE_TYPE; + return DeviceTypeKitAspect::deviceTypeId(kit) == Constants::DESKTOP_DEVICE_TYPE; }; RunControl::registerWorker<LocalQmlPreviewSupport>(Constants::QML_PREVIEW_RUN_MODE, constraint); diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp b/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp index 392bf15927..43b1d500a0 100644 --- a/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp @@ -56,7 +56,7 @@ QmlProfilerAttachDialog::QmlProfilerAttachDialog(QWidget *parent) : d->kitChooser = new KitChooser(this); d->kitChooser->setKitPredicate([](const Kit *kit) { - return DeviceKitInformation::device(kit) != nullptr; + return DeviceKitAspect::device(kit) != nullptr; }); d->kitChooser->populate(); diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index e3a2a1aa3f..92a4fe0a44 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -105,7 +105,7 @@ void QmlProfilerPlugin::extensionsInitialized() auto constraint = [](RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) + return DeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; }; diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index e1e476df36..09f3945cbe 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -206,7 +206,7 @@ static QUrl localServerUrl(RunControl *runControl) QUrl serverUrl; RunConfiguration *runConfiguration = runControl->runConfiguration(); Kit *kit = runConfiguration->target()->kit(); - const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); + const QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit); if (version) { if (version->qtVersion() >= QtSupport::QtVersionNumber(5, 6, 0)) serverUrl = Utils::urlFromLocalSocket(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 3ea47f8638..20798fd8c3 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -543,7 +543,7 @@ ProjectExplorer::RunControl *QmlProfilerTool::attachToWaitingApplication() QUrl serverUrl; - IDevice::ConstPtr device = DeviceKitInformation::device(kit); + IDevice::ConstPtr device = DeviceKitAspect::device(kit); QTC_ASSERT(device, return nullptr); QUrl toolControl = device->toolControlChannel(IDevice::QmlControlChannel); serverUrl.setScheme(Utils::urlTcpScheme()); diff --git a/src/plugins/qmlprofiler/tests/qmlprofilerdetailsrewriter_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilerdetailsrewriter_test.cpp index 9a2dede657..88965ca4f2 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilerdetailsrewriter_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilerdetailsrewriter_test.cpp @@ -226,7 +226,7 @@ void QmlProfilerDetailsRewriterTest::seedRewriter() QVERIFY(!doc->source().isEmpty()); auto kit = std::make_unique<ProjectExplorer::Kit>(); - ProjectExplorer::SysRootKitInformation::setSysRoot( + ProjectExplorer::SysRootKitAspect::setSysRoot( kit.get(), Utils::FileName::fromLatin1("/nowhere")); DummyProject *project = new DummyProject(Utils::FileName::fromString(filename)); diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index e516862617..6082a61682 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -188,7 +188,7 @@ void QmlProject::setMainFile(const QString &mainFilePath) Utils::FileName QmlProject::targetDirectory(const Target *target) const { - if (DeviceTypeKitInformation::deviceTypeId(target->kit()) + if (DeviceTypeKitAspect::deviceTypeId(target->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) return canonicalProjectDir(); @@ -277,11 +277,11 @@ QList<Task> QmlProject::projectIssues(const Kit *k) const { QList<Task> result = Project::projectIssues(k); - const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + const QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (!version) result.append(createProjectTask(Task::TaskType::Error, tr("No Qt version set in kit."))); - IDevice::ConstPtr dev = DeviceKitInformation::device(k); + IDevice::ConstPtr dev = DeviceKitAspect::device(k); if (dev.isNull()) result.append(createProjectTask(Task::TaskType::Error, tr("Kit has no device."))); @@ -371,7 +371,7 @@ void QmlProject::updateDeploymentData(ProjectExplorer::Target *target) if (!m_projectItem) return; - if (DeviceTypeKitInformation::deviceTypeId(target->kit()) + if (DeviceTypeKitAspect::deviceTypeId(target->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { return; } diff --git a/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp b/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp index 0a81e39bf4..2502747f2e 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp @@ -56,7 +56,7 @@ Environment QmlProjectEnvironmentAspect::baseEnvironment() const QmlProjectEnvironmentAspect::QmlProjectEnvironmentAspect(Target *target) : m_target(target) { - if (DeviceTypeKitInformation::deviceTypeId(target->kit()) + if (DeviceTypeKitAspect::deviceTypeId(target->kit()) == Constants::DESKTOP_DEVICE_TYPE) addPreferredBaseEnvironment(SystemEnvironmentBase, tr("System Environment")); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index c973bdd8b9..27aadb2de1 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -313,7 +313,7 @@ QString QmlProjectRunConfiguration::disabledReason() const { if (mainScript().isEmpty()) return tr("No script file to execute."); - if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) + if (DeviceTypeKitAspect::deviceTypeId(target()->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE && !QFileInfo::exists(executable())) { return tr("No qmlscene found."); @@ -329,11 +329,11 @@ QString QmlProjectRunConfiguration::executable() const if (!qmlViewer.isEmpty()) return qmlViewer; - BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit()); + BaseQtVersion *version = QtKitAspect::qtVersion(target()->kit()); if (!version) // No Qt version in Kit. Don't try to run qmlscene. return QString(); - const Id deviceType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); + const Id deviceType = DeviceTypeKitAspect::deviceTypeId(target()->kit()); if (deviceType == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { // If not given explicitly by Qt Version, try to pick it from $PATH. return version->type() == QtSupport::Constants::DESKTOPQT @@ -341,7 +341,7 @@ QString QmlProjectRunConfiguration::executable() const : QString("qmlscene"); } - IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); + IDevice::ConstPtr dev = DeviceKitAspect::device(target()->kit()); if (dev.isNull()) // No device set. We don't know where to run qmlscene. return QString(); @@ -355,7 +355,7 @@ QString QmlProjectRunConfiguration::commandLineArguments() const // arguments in .user file QString args = aspect<ArgumentsAspect>()->arguments(macroExpander()); const Target *currentTarget = target(); - const IDevice::ConstPtr device = DeviceKitInformation::device(currentTarget->kit()); + const IDevice::ConstPtr device = DeviceKitAspect::device(currentTarget->kit()); const Utils::OsType osType = device ? device->osType() : Utils::HostOsInfo::hostOs(); // arguments from .qmlproject file diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index eee23e08ca..ac292b42c6 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -10,7 +10,6 @@ SOURCES += qnxplugin.cpp \ qnxrunconfiguration.cpp \ qnxanalyzesupport.cpp \ qnxdebugsupport.cpp \ - qnxqtversionfactory.cpp \ qnxqtversion.cpp \ qnxdevice.cpp \ qnxdevicetester.cpp \ @@ -35,7 +34,6 @@ HEADERS += qnxplugin.h\ qnxrunconfiguration.h \ qnxanalyzesupport.h \ qnxdebugsupport.h \ - qnxqtversionfactory.h \ qnxqtversion.h \ qnxdevice.h \ qnxdevicetester.h \ diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index 2f29172038..143a1f10aa 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -57,8 +57,6 @@ QtcPlugin { "qnxplugin.h", "qnxqtversion.cpp", "qnxqtversion.h", - "qnxqtversionfactory.cpp", - "qnxqtversionfactory.h", "qnxrunconfiguration.cpp", "qnxrunconfiguration.h", "qnxutils.cpp", diff --git a/src/plugins/qnx/qnxconfiguration.cpp b/src/plugins/qnx/qnxconfiguration.cpp index 0619b439b7..5da58989b1 100644 --- a/src/plugins/qnx/qnxconfiguration.cpp +++ b/src/plugins/qnx/qnxconfiguration.cpp @@ -177,8 +177,8 @@ void QnxConfiguration::deactivate() foreach (Kit *kit, KitManager::kits()) { if (kit->isAutoDetected() - && DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_QNX_OS_TYPE - && toolChainsToRemove.contains(ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID))) + && DeviceTypeKitAspect::deviceTypeId(kit) == Constants::QNX_QNX_OS_TYPE + && toolChainsToRemove.contains(ToolChainKitAspect::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID))) KitManager::deregisterKit(kit); } @@ -304,14 +304,14 @@ ProjectExplorer::Kit *QnxConfiguration::createKit( auto kit = std::make_unique<Kit>(); Kit *kptr = kit.get(); - QtKitInformation::setQtVersion(kptr, qnxQt); - ToolChainKitInformation::setToolChain(kptr, toolChain); - ToolChainKitInformation::clearToolChain(kptr, ProjectExplorer::Constants::C_LANGUAGE_ID); + QtKitAspect::setQtVersion(kptr, qnxQt); + ToolChainKitAspect::setToolChain(kptr, toolChain); + ToolChainKitAspect::clearToolChain(kptr, ProjectExplorer::Constants::C_LANGUAGE_ID); if (debugger.isValid()) - DebuggerKitInformation::setDebugger(kptr, debugger); + DebuggerKitAspect::setDebugger(kptr, debugger); - DeviceTypeKitInformation::setDeviceTypeId(kptr, Constants::QNX_QNX_OS_TYPE); + DeviceTypeKitAspect::setDeviceTypeId(kptr, Constants::QNX_QNX_OS_TYPE); // TODO: Add sysroot? kit->setUnexpandedDisplayName( @@ -323,12 +323,12 @@ ProjectExplorer::Kit *QnxConfiguration::createKit( kit->setAutoDetected(true); kit->setAutoDetectionSource(envFile().toString()); - kit->setMutable(DeviceKitInformation::id(), true); + kit->setMutable(DeviceKitAspect::id(), true); - kit->setSticky(ToolChainKitInformation::id(), true); - kit->setSticky(DeviceTypeKitInformation::id(), true); - kit->setSticky(SysRootKitInformation::id(), true); - kit->setSticky(DebuggerKitInformation::id(), true); + kit->setSticky(ToolChainKitAspect::id(), true); + kit->setSticky(DeviceTypeKitAspect::id(), true); + kit->setSticky(SysRootKitAspect::id(), true); + kit->setSticky(DebuggerKitAspect::id(), true); kit->setSticky(QmakeProjectManager::Constants::KIT_INFORMATION_ID, true); // add kit with device and qt version not sticky diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp index f53b27df36..2eeda6db6f 100644 --- a/src/plugins/qnx/qnxdebugsupport.cpp +++ b/src/plugins/qnx/qnxdebugsupport.cpp @@ -72,7 +72,7 @@ namespace Internal { static QStringList searchPaths(Kit *kit) { - auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(kit)); + auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(kit)); if (!qtVersion) return {}; @@ -157,7 +157,7 @@ QnxDebugSupport::QnxDebugSupport(RunControl *runControl) setCloseMode(KillAtClose); setUseCtrlCStub(true); setSolibSearchPath(searchPaths(k)); - if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(k))) + if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(k))) setSysRoot(qtVersion->qnxTarget()); } @@ -241,7 +241,7 @@ void QnxAttachDebugSupport::showProcessesDialog() { auto kitChooser = new KitChooser; kitChooser->setKitPredicate([](const Kit *k) { - return k->isValid() && DeviceTypeKitInformation::deviceTypeId(k) == Constants::QNX_QNX_OS_TYPE; + return k->isValid() && DeviceTypeKitAspect::deviceTypeId(k) == Constants::QNX_QNX_OS_TYPE; }); QnxAttachDebugDialog dlg(kitChooser); @@ -279,7 +279,7 @@ void QnxAttachDebugSupport::showProcessesDialog() // setRunControlName(tr("Remote: \"%1\" - Process %2").arg(remoteChannel).arg(m_process.pid)); debugger->setRunControlName(tr("Remote QNX process %1").arg(pid)); debugger->setSolibSearchPath(searchPaths(kit)); - if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(kit))) + if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(kit))) debugger->setSysRoot(qtVersion->qnxTarget()); debugger->setUseContinueInsteadOfRun(true); diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp index e316742f2c..3d64e720bf 100644 --- a/src/plugins/qnx/qnxplugin.cpp +++ b/src/plugins/qnx/qnxplugin.cpp @@ -32,7 +32,6 @@ #include "qnxdevice.h" #include "qnxdevicefactory.h" #include "qnxqtversion.h" -#include "qnxqtversionfactory.h" #include "qnxrunconfiguration.h" #include "qnxsettingspage.h" #include "qnxtoolchain.h" @@ -138,7 +137,7 @@ bool QnxPlugin::initialize(const QStringList &arguments, QString *errorString) return false; } - auto dev = DeviceKitInformation::device(runConfig->target()->kit()) + auto dev = DeviceKitAspect::device(runConfig->target()->kit()) .dynamicCast<const QnxDevice>(); return !dev.isNull(); }; @@ -176,9 +175,9 @@ void QnxPluginPrivate::updateDebuggerActions() { bool hasValidQnxKit = false; - auto matcher = DeviceTypeKitInformation::deviceTypePredicate(Constants::QNX_QNX_OS_TYPE); + auto matcher = DeviceTypeKitAspect::deviceTypePredicate(Constants::QNX_QNX_OS_TYPE); foreach (Kit *qnxKit, KitManager::kits(matcher)) { - if (qnxKit->isValid() && !DeviceKitInformation::device(qnxKit).isNull()) { + if (qnxKit->isValid() && !DeviceKitAspect::device(qnxKit).isNull()) { hasValidQnxKit = true; break; } diff --git a/src/plugins/qnx/qnxqtversion.cpp b/src/plugins/qnx/qnxqtversion.cpp index 7e8540139b..7269a09b9f 100644 --- a/src/plugins/qnx/qnxqtversion.cpp +++ b/src/plugins/qnx/qnxqtversion.cpp @@ -46,13 +46,6 @@ static char SDP_PATH_KEY[] = "SDKPath"; QnxQtVersion::QnxQtVersion() = default; -QnxQtVersion::QnxQtVersion(const Utils::FileName &path, bool isAutoDetected, - const QString &autoDetectionSource) : - QtSupport::BaseQtVersion(path, isAutoDetected, autoDetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - QnxQtVersion *QnxQtVersion::clone() const { return new QnxQtVersion(*this); @@ -138,7 +131,7 @@ void QnxQtVersion::fromMap(const QVariantMap &map) QList<ProjectExplorer::Abi> QnxQtVersion::detectQtAbis() const { ensureMkSpecParsed(); - return QnxUtils::convertAbis(qtAbisFromLibrary(qtCorePaths())); + return QnxUtils::convertAbis(BaseQtVersion::detectQtAbis()); } void QnxQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const @@ -206,5 +199,16 @@ QList<Utils::EnvironmentItem> QnxQtVersion::environment() const return QnxUtils::qnxEnvironment(sdpPath()); } + +// Factory + +QnxQtVersionFactory::QnxQtVersionFactory() +{ + setQtVersionCreator([] { return new QnxQtVersion; }); + setSupportedType(Constants::QNX_QNX_QT); + setPriority(50); + setRestrictionChecker([](const SetupData &setup) { return setup.isQnx; }); +} + } // namespace Internal } // namespace Qnx diff --git a/src/plugins/qnx/qnxqtversion.h b/src/plugins/qnx/qnxqtversion.h index 6bea0ed4b1..939beedb86 100644 --- a/src/plugins/qnx/qnxqtversion.h +++ b/src/plugins/qnx/qnxqtversion.h @@ -29,6 +29,7 @@ #include "qnxqtversion.h" #include <qtsupport/baseqtversion.h> +#include <qtsupport/qtversionfactory.h> #include <utils/environment.h> @@ -39,9 +40,7 @@ class QnxQtVersion : public QtSupport::BaseQtVersion { public: QnxQtVersion(); - QnxQtVersion(const Utils::FileName &path, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()); + QnxQtVersion *clone() const override; QString type() const override; @@ -87,5 +86,11 @@ private: mutable QList<Utils::EnvironmentItem> m_qnxEnv; }; +class QnxQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + QnxQtVersionFactory(); +}; + } // namespace Internal } // namespace Qnx diff --git a/src/plugins/qnx/qnxqtversionfactory.cpp b/src/plugins/qnx/qnxqtversionfactory.cpp deleted file mode 100644 index abf2743cc8..0000000000 --- a/src/plugins/qnx/qnxqtversionfactory.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BlackBerry Limited. All rights reserved. -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "qnxqtversionfactory.h" - -#include "qnxconstants.h" -#include "qnxutils.h" -#include "qnxqtversion.h" - -#include <qtsupport/profilereader.h> - -#include <QFileInfo> - -using namespace Qnx; -using namespace Qnx::Internal; - -QnxQtVersionFactory::QnxQtVersionFactory(QObject *parent) : - QtSupport::QtVersionFactory(parent) -{ -} - -QnxQtVersionFactory::~QnxQtVersionFactory() = default; - -bool QnxQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::QNX_QNX_QT); -} - -QtSupport::BaseQtVersion *QnxQtVersionFactory::restore(const QString &type, const QVariantMap &data) -{ - if (!canRestore(type)) - return nullptr; - auto v = new QnxQtVersion; - v->fromMap(data); - return v; -} - -int QnxQtVersionFactory::priority() const -{ - return 50; -} - -QtSupport::BaseQtVersion *QnxQtVersionFactory::create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected, - const QString &autoDetectionSource) -{ - QFileInfo fi = qmakePath.toFileInfo(); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return nullptr; - - if (evaluator->contains(QLatin1String("QNX_CPUDIR"))) { - return new QnxQtVersion(qmakePath, isAutoDetected, autoDetectionSource); - } - - return nullptr; -} diff --git a/src/plugins/qnx/qnxqtversionfactory.h b/src/plugins/qnx/qnxqtversionfactory.h deleted file mode 100644 index e15165be42..0000000000 --- a/src/plugins/qnx/qnxqtversionfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BlackBerry Limited. All rights reserved. -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <qtsupport/qtversionfactory.h> - -namespace Qnx { -namespace Internal { - -class QnxQtVersionFactory : public QtSupport::QtVersionFactory -{ - Q_OBJECT -public: - explicit QnxQtVersionFactory(QObject *parent = nullptr); - ~QnxQtVersionFactory() override; - - bool canRestore(const QString &type) override; - QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data) override; - - int priority() const override; - QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()) override; -}; - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 3790005a7c..bd046a81ec 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -193,17 +193,19 @@ bool QtVersionNumber::operator >=(const QtVersionNumber &b) const // BaseQtVersion /////////////// -BaseQtVersion::BaseQtVersion(const FileName &qmakeCommand, bool isAutodetected, const QString &autodetectionSource) - : m_id(QtVersionManager::getUniqueId()), - m_isAutodetected(isAutodetected), - m_autodetectionSource(autodetectionSource), - m_qmakeCommand(qmakeCommand) -{ } BaseQtVersion::BaseQtVersion(const BaseQtVersion &other) = default; BaseQtVersion::BaseQtVersion() = default; BaseQtVersion::~BaseQtVersion() = default; +void BaseQtVersion::setupQmakePathAndId(const FileName &qmakeCommand) +{ + m_id = QtVersionManager::getUniqueId(); + QTC_CHECK(m_qmakeCommand.isEmpty()); // Should only be used once. + m_qmakeCommand = qmakeCommand; + setUnexpandedDisplayName(defaultUnexpandedDisplayName(m_qmakeCommand, false)); +} + QString BaseQtVersion::defaultUnexpandedDisplayName(const FileName &qmakePath, bool fromPath) { QString location; @@ -347,14 +349,14 @@ QList<Task> BaseQtVersion::validateKit(const Kit *k) { QList<Task> result; - BaseQtVersion *version = QtKitInformation::qtVersion(k); + BaseQtVersion *version = QtKitAspect::qtVersion(k); Q_ASSERT(version == this); const QList<Abi> qtAbis = version->qtAbis(); if (qtAbis.isEmpty()) // No need to test if Qt does not know anyway... return result; - const Id dt = DeviceTypeKitInformation::deviceTypeId(k); + const Id dt = DeviceTypeKitAspect::deviceTypeId(k); const QSet<Id> tdt = targetDeviceTypes(); if (!tdt.isEmpty() && !tdt.contains(dt)) { result << Task(Task::Warning, @@ -363,7 +365,7 @@ QList<Task> BaseQtVersion::validateKit(const Kit *k) FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); } - ToolChain *tc = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChain *tc = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (tc) { Abi targetAbi = tc->targetAbi(); bool fuzzyMatch = false; @@ -498,6 +500,11 @@ void BaseQtVersion::setId(int id) m_id = id; } +void BaseQtVersion::setIsAutodetected(bool isAutodetected) +{ + m_isAutodetected = isAutodetected; +} + void BaseQtVersion::fromMap(const QVariantMap &map) { m_id = map.value(Constants::QTVERSIONID).toInt(); @@ -612,6 +619,11 @@ QList<Abi> BaseQtVersion::qtAbis() const return m_qtAbis; } +QList<Abi> BaseQtVersion::detectQtAbis() const +{ + return qtAbisFromLibrary(qtCorePaths()); +} + bool BaseQtVersion::equals(BaseQtVersion *other) { if (m_qmakeCommand != other->m_qmakeCommand) @@ -744,17 +756,12 @@ QString BaseQtVersion::toHtml(bool verbose) const return rc; } -void BaseQtVersion::updateSourcePath() const -{ - if (!m_sourcePath.isEmpty()) - return; - updateVersionInfo(); - m_sourcePath = sourcePath(m_versionInfo); -} - FileName BaseQtVersion::sourcePath() const { - updateSourcePath(); + if (m_sourcePath.isEmpty()) { + updateVersionInfo(); + m_sourcePath = sourcePath(m_versionInfo); + } return m_sourcePath; } @@ -1175,151 +1182,151 @@ BaseQtVersion::createMacroExpander(const std::function<const BaseQtVersion *()> }; }; std::unique_ptr<Utils::MacroExpander> expander(new Utils::MacroExpander); - expander->setDisplayName(QtKitInformation::tr("Qt version")); + expander->setDisplayName(QtKitAspect::tr("Qt version")); expander->registerVariable( "Qt:Version", - QtKitInformation::tr("The version string of the current Qt version."), + QtKitAspect::tr("The version string of the current Qt version."), versionProperty([](const BaseQtVersion *version) { return version->qtVersionString(); })); expander->registerVariable( "Qt:Type", - QtKitInformation::tr("The type of the current Qt version."), + QtKitAspect::tr("The type of the current Qt version."), versionProperty([](const BaseQtVersion *version) { return version->type(); })); expander->registerVariable( "Qt:Mkspec", - QtKitInformation::tr("The mkspec of the current Qt version."), + QtKitAspect::tr("The mkspec of the current Qt version."), versionProperty([](const BaseQtVersion *version) { return version->mkspec().toUserOutput(); })); expander->registerVariable( "Qt:QT_INSTALL_PREFIX", - QtKitInformation::tr("The installation prefix of the current Qt version."), + QtKitAspect::tr("The installation prefix of the current Qt version."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_PREFIX"); })); expander->registerVariable( "Qt:QT_INSTALL_DATA", - QtKitInformation::tr("The installation location of the current Qt version's data."), + QtKitAspect::tr("The installation location of the current Qt version's data."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_DATA"); })); expander->registerVariable( "Qt:QT_INSTALL_HEADERS", - QtKitInformation::tr("The installation location of the current Qt version's header files."), + QtKitAspect::tr("The installation location of the current Qt version's header files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_HEADERS"); })); expander->registerVariable( "Qt:QT_INSTALL_LIBS", - QtKitInformation::tr("The installation location of the current Qt version's library files."), + QtKitAspect::tr("The installation location of the current Qt version's library files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_LIBS"); })); expander->registerVariable( "Qt:QT_INSTALL_DOCS", - QtKitInformation::tr("The installation location of the current Qt version's documentation files."), + QtKitAspect::tr("The installation location of the current Qt version's documentation files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_DOCS"); })); expander->registerVariable( "Qt:QT_INSTALL_BINS", - QtKitInformation::tr("The installation location of the current Qt version's executable files."), + QtKitAspect::tr("The installation location of the current Qt version's executable files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_BINS"); })); expander->registerVariable( "Qt:QT_INSTALL_PLUGINS", - QtKitInformation::tr("The installation location of the current Qt version's plugins."), + QtKitAspect::tr("The installation location of the current Qt version's plugins."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_PLUGINS"); })); expander->registerVariable( "Qt:QT_INSTALL_QML", - QtKitInformation::tr("The installation location of the current Qt version's QML files."), + QtKitAspect::tr("The installation location of the current Qt version's QML files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_QML"); })); expander->registerVariable( "Qt:QT_INSTALL_IMPORTS", - QtKitInformation::tr("The installation location of the current Qt version's imports."), + QtKitAspect::tr("The installation location of the current Qt version's imports."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_IMPORTS"); })); expander->registerVariable( "Qt:QT_INSTALL_TRANSLATIONS", - QtKitInformation::tr("The installation location of the current Qt version's translation files."), + QtKitAspect::tr("The installation location of the current Qt version's translation files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_TRANSLATIONS"); })); expander->registerVariable( "Qt:QT_INSTALL_CONFIGURATION", - QtKitInformation::tr("The installation location of the current Qt version's translation files."), + QtKitAspect::tr("The installation location of the current Qt version's translation files."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_CONFIGURATION"); })); expander->registerVariable( "Qt:QT_INSTALL_EXAMPLES", - QtKitInformation::tr("The installation location of the current Qt version's examples."), + QtKitAspect::tr("The installation location of the current Qt version's examples."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_EXAMPLES"); })); expander->registerVariable( "Qt:QT_INSTALL_DEMOS", - QtKitInformation::tr("The installation location of the current Qt version's demos."), + QtKitAspect::tr("The installation location of the current Qt version's demos."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QT_INSTALL_DEMOS"); })); expander->registerVariable( "Qt:QMAKE_MKSPECS", - QtKitInformation::tr("The current Qt version's default mkspecs (Qt 4)."), + QtKitAspect::tr("The current Qt version's default mkspecs (Qt 4)."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QMAKE_MKSPECS"); })); expander->registerVariable( "Qt:QMAKE_SPEC", - QtKitInformation::tr("The current Qt version's default mkspec (Qt 5; host system)."), + QtKitAspect::tr("The current Qt version's default mkspec (Qt 5; host system)."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QMAKE_SPEC"); })); expander->registerVariable( "Qt:QMAKE_XSPEC", - QtKitInformation::tr("The current Qt version's default mkspec (Qt 5; target system)."), + QtKitAspect::tr("The current Qt version's default mkspec (Qt 5; target system)."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QMAKE_XSPEC"); })); expander->registerVariable( "Qt:QMAKE_VERSION", - QtKitInformation::tr("The current Qt's qmake version."), + QtKitAspect::tr("The current Qt's qmake version."), versionProperty([](const BaseQtVersion *version) { return version->qmakeProperty(version->m_versionInfo, "QMAKE_VERSION"); })); // FIXME: Re-enable once we can detect expansion loops. // expander->registerVariable("Qt:Name", - // QtKitInformation::tr("The display name of the current Qt version."), + // QtKitAspect::tr("The display name of the current Qt version."), // versionProperty([](BaseQtVersion *version) { // return version->displayName(); // })); @@ -1362,9 +1369,9 @@ void BaseQtVersion::populateQmlFileFinder(FileInProjectFinder *finder, const Tar // ... and find the sysroot and qml directory if we have any target at all. const ProjectExplorer::Kit *kit = target ? target->kit() : nullptr; - const Utils::FileName activeSysroot = ProjectExplorer::SysRootKitInformation::sysRoot(kit); + const Utils::FileName activeSysroot = ProjectExplorer::SysRootKitAspect::sysRoot(kit); const QtSupport::BaseQtVersion *qtVersion = QtVersionManager::isLoaded() - ? QtSupport::QtKitInformation::qtVersion(kit) : nullptr; + ? QtSupport::QtKitAspect::qtVersion(kit) : nullptr; Utils::FileNameList additionalSearchDirectories = qtVersion ? Utils::FileNameList({qtVersion->qmlPath()}) : Utils::FileNameList(); @@ -1706,7 +1713,7 @@ bool BaseQtVersion::isSubProject(const Utils::FileName &filePath) const bool BaseQtVersion::isQmlDebuggingSupported(Kit *k, QString *reason) { QTC_ASSERT(k, return false); - BaseQtVersion *version = QtKitInformation::qtVersion(k); + BaseQtVersion *version = QtKitAspect::qtVersion(k); if (!version) { if (reason) *reason = QCoreApplication::translate("BaseQtVersion", "No Qt version."); @@ -1735,7 +1742,7 @@ bool BaseQtVersion::isQmlDebuggingSupported(QString *reason) const bool BaseQtVersion::isQtQuickCompilerSupported(Kit *k, QString *reason) { QTC_ASSERT(k, return false); - BaseQtVersion *version = QtKitInformation::qtVersion(k); + BaseQtVersion *version = QtKitAspect::qtVersion(k); if (!version) { if (reason) *reason = QCoreApplication::translate("BaseQtVersion", "No Qt version."); diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h index 34627bfb62..ca8837cf93 100644 --- a/src/plugins/qtsupport/baseqtversion.h +++ b/src/plugins/qtsupport/baseqtversion.h @@ -138,7 +138,7 @@ public: virtual QString toHtml(bool verbose) const; QList<ProjectExplorer::Abi> qtAbis() const; - virtual QList<ProjectExplorer::Abi> detectQtAbis() const = 0; + virtual QList<ProjectExplorer::Abi> detectQtAbis() const; enum PropertyVariant { PropertyVariantDev, PropertyVariantGet, PropertyVariantSrc }; QString qmakeProperty(const QByteArray &name, @@ -148,16 +148,16 @@ public: virtual Utils::Environment qmakeRunEnvironment() const; // source path defined by qmake property QT_INSTALL_PREFIX/src or by qmake.stash QT_SOURCE_TREE - virtual Utils::FileName sourcePath() const; + Utils::FileName sourcePath() const; // returns source path for installed qt packages and empty string for self build qt Utils::FileName qtPackageSourcePath() const; bool isInSourceDirectory(const Utils::FileName &filePath); bool isSubProject(const Utils::FileName &filePath) const; // used by UiCodeModelSupport - virtual QString uicCommand() const; - virtual QString designerCommand() const; - virtual QString linguistCommand() const; + QString uicCommand() const; + QString designerCommand() const; + QString linguistCommand() const; QString qscxmlcCommand() const; QString qtVersionString() const; @@ -172,7 +172,7 @@ public: bool hasDemos() const; QString demosPath() const; - virtual QString frameworkInstallPath() const; + QString frameworkInstallPath() const; // former local functions Utils::FileName qmakeCommand() const; @@ -208,11 +208,11 @@ public: static bool isQtQuickCompilerSupported(ProjectExplorer::Kit *k, QString *reason = nullptr); bool isQtQuickCompilerSupported(QString *reason = nullptr) const; - virtual QString qmlDumpTool(bool debugVersion) const; + QString qmlDumpTool(bool debugVersion) const; - virtual bool hasQmlDump() const; - virtual bool hasQmlDumpWithRelocatableFlag() const; - virtual bool needsQmlDump() const; + bool hasQmlDump() const; + bool hasQmlDumpWithRelocatableFlag() const; + bool needsQmlDump() const; virtual QtConfigWidget *createConfigurationWidget() const; @@ -253,10 +253,12 @@ public: const ProjectExplorer::Target *target); QSet<Core::Id> features() const; + void setIsAutodetected(bool isAutodetected); + protected: virtual QSet<Core::Id> availableFeatures() const; + BaseQtVersion(); - BaseQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); BaseQtVersion(const BaseQtVersion &other); virtual QList<ProjectExplorer::Task> reportIssuesImpl(const QString &proFile, const QString &buildDir) const; @@ -269,8 +271,8 @@ protected: virtual void parseMkSpec(ProFileEvaluator *) const; private: + void setupQmakePathAndId(const Utils::FileName &path); void setAutoDetectionSource(const QString &autodetectionSource); - void updateSourcePath() const; void updateVersionInfo() const; enum HostBinaries { Designer, Linguist, Uic, QScxmlc }; QString findHostBinary(HostBinaries binary) const; diff --git a/src/plugins/qtsupport/codegensettingspage.cpp b/src/plugins/qtsupport/codegensettingspage.cpp index 39e64db8a2..8f45c02a14 100644 --- a/src/plugins/qtsupport/codegensettingspage.cpp +++ b/src/plugins/qtsupport/codegensettingspage.cpp @@ -94,7 +94,7 @@ CodeGenSettingsPage::CodeGenSettingsPage(QObject *parent) : { m_parameters.fromSettings(Core::ICore::settings()); setId(Constants::CODEGEN_SETTINGS_PAGE_ID); - setDisplayName(QCoreApplication::translate("QtSupport", Constants::CODEGEN_SETTINGS_PAGE_NAME)); + setDisplayName(QCoreApplication::translate("QtSupport", "Qt Class Generation")); setCategory(CppTools::Constants::CPP_SETTINGS_CATEGORY); } diff --git a/src/plugins/qtsupport/desktopqtversion.cpp b/src/plugins/qtsupport/desktopqtversion.cpp index fa7ae205bc..7349f46e5b 100644 --- a/src/plugins/qtsupport/desktopqtversion.cpp +++ b/src/plugins/qtsupport/desktopqtversion.cpp @@ -38,7 +38,7 @@ #include <QCoreApplication> #include <QFileInfo> -using namespace QtSupport; +namespace QtSupport { DesktopQtVersion::DesktopQtVersion() : BaseQtVersion() @@ -46,12 +46,6 @@ DesktopQtVersion::DesktopQtVersion() } -DesktopQtVersion::DesktopQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) - : BaseQtVersion(path, isAutodetected, autodetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - DesktopQtVersion *DesktopQtVersion::clone() const { return new DesktopQtVersion(*this); @@ -72,11 +66,6 @@ QStringList DesktopQtVersion::warningReason() const return ret; } -QList<ProjectExplorer::Abi> DesktopQtVersion::detectQtAbis() const -{ - return qtAbisFromLibrary(qtCorePaths()); -} - QString DesktopQtVersion::description() const { return QCoreApplication::translate("QtVersion", "Desktop", "Qt Version is meant for the desktop"); @@ -101,6 +90,7 @@ QSet<Core::Id> DesktopQtVersion::targetDeviceTypes() const void DesktopQtVersion::fromMap(const QVariantMap &map) { BaseQtVersion::fromMap(map); + // Clear the cached qmlscene command, it might not match the restored path anymore. m_qmlsceneCommand.clear(); } @@ -108,28 +98,34 @@ QString DesktopQtVersion::qmlsceneCommand() const { if (!isValid()) return QString(); + if (!m_qmlsceneCommand.isNull()) return m_qmlsceneCommand; - m_qmlsceneCommand = findTargetBinary(QmlScene); + + ensureMkSpecParsed(); + + QString path = + qmlBinPath().appendPath(Utils::HostOsInfo::withExecutableSuffix("qmlscene")).toString(); + + m_qmlsceneCommand = QFileInfo(path).isFile() ? path : QString(); + return m_qmlsceneCommand; } DesktopQtVersion::DesktopQtVersion(const DesktopQtVersion &other) = default; -QString DesktopQtVersion::findTargetBinary(TargetBinaries binary) const -{ - QString path; - ensureMkSpecParsed(); - switch (binary) { - case QmlScene: - path = qmlBinPath().appendPath( - Utils::HostOsInfo::withExecutableSuffix("qmlscene")).toString(); - break; - default: - // Can't happen - QTC_ASSERT(false, return QString()); - } +namespace Internal { + +// Factory - return QFileInfo(path).isFile() ? path : QString(); +DesktopQtVersionFactory::DesktopQtVersionFactory() +{ + setQtVersionCreator([] { return new DesktopQtVersion; }); + setSupportedType(QtSupport::Constants::DESKTOPQT); + setPriority(0); // Lowest of all, we want to be the fallback + // No further restrictions. We are the fallback :) so we don't care what kind of qt it is. } + +} // Internal +} // QtSupport diff --git a/src/plugins/qtsupport/desktopqtversion.h b/src/plugins/qtsupport/desktopqtversion.h index 3ab82689ae..3aeee960ef 100644 --- a/src/plugins/qtsupport/desktopqtversion.h +++ b/src/plugins/qtsupport/desktopqtversion.h @@ -25,6 +25,8 @@ #pragma once +#include <qtsupport/qtversionfactory.h> + #include "baseqtversion.h" namespace QtSupport { @@ -33,15 +35,13 @@ class QTSUPPORT_EXPORT DesktopQtVersion : public BaseQtVersion { public: DesktopQtVersion(); - DesktopQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + DesktopQtVersion *clone() const override; QString type() const override; QStringList warningReason() const override; - QList<ProjectExplorer::Abi> detectQtAbis() const override; - QString description() const override; QSet<Core::Id> availableFeatures() const override; @@ -55,11 +55,16 @@ protected: DesktopQtVersion(const DesktopQtVersion &other); private: + mutable QString m_qmlsceneCommand; +}; - enum TargetBinaries { QmlScene }; - QString findTargetBinary(TargetBinaries binary) const; +namespace Internal { - mutable QString m_qmlsceneCommand; +class DesktopQtVersionFactory : public QtVersionFactory +{ +public: + DesktopQtVersionFactory(); }; +} // Internal } // QtSupport diff --git a/src/plugins/qtsupport/desktopqtversionfactory.cpp b/src/plugins/qtsupport/desktopqtversionfactory.cpp deleted file mode 100644 index ac633aa58c..0000000000 --- a/src/plugins/qtsupport/desktopqtversionfactory.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "desktopqtversionfactory.h" -#include "desktopqtversion.h" -#include <qtsupport/qtsupportconstants.h> - -#include <QFileInfo> - -using namespace QtSupport; -using namespace QtSupport::Internal; - -DesktopQtVersionFactory::DesktopQtVersionFactory(QObject *parent) - : QtVersionFactory(parent) -{ - -} - -DesktopQtVersionFactory::~DesktopQtVersionFactory() = default; - -bool DesktopQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::DESKTOPQT); -} - -BaseQtVersion *DesktopQtVersionFactory::restore(const QString &type, const QVariantMap &data) -{ - if (!canRestore(type)) - return nullptr; - auto v = new DesktopQtVersion; - v->fromMap(data); - return v; -} - -int DesktopQtVersionFactory::priority() const -{ - // Lowest of all, we want to be the fallback - return 0; -} - -BaseQtVersion *DesktopQtVersionFactory::create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) -{ - Q_UNUSED(evaluator); - // we are the fallback :) so we don't care what kind of qt it is - QFileInfo fi = qmakePath.toFileInfo(); - if (fi.exists() && fi.isExecutable() && fi.isFile()) - return new DesktopQtVersion(qmakePath, isAutoDetected, autoDetectionSource); - return nullptr; -} diff --git a/src/plugins/qtsupport/desktopqtversionfactory.h b/src/plugins/qtsupport/desktopqtversionfactory.h deleted file mode 100644 index 7f5f476d45..0000000000 --- a/src/plugins/qtsupport/desktopqtversionfactory.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtversionfactory.h" - -namespace QtSupport { -namespace Internal { - -class DesktopQtVersionFactory : public QtVersionFactory -{ -public: - explicit DesktopQtVersionFactory(QObject *parent = nullptr); - ~DesktopQtVersionFactory() override; - - bool canRestore(const QString &type) override; - BaseQtVersion *restore(const QString &type, const QVariantMap &data) override; - - int priority() const override; - BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, - bool isAutoDetected = false, const QString &autoDetectionSource = QString()) override; -}; - -} // Internal -} // QtSupport diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index f83496ef54..ee0d88088a 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -504,7 +504,7 @@ void ExampleSetModel::updateQtVersionList() // prioritize default qt version ProjectExplorer::Kit *defaultKit = ProjectExplorer::KitManager::defaultKit(); - BaseQtVersion *defaultVersion = QtKitInformation::qtVersion(defaultKit); + BaseQtVersion *defaultVersion = QtKitAspect::qtVersion(defaultKit); if (defaultVersion && versions.contains(defaultVersion)) versions.move(versions.indexOf(defaultVersion), 0); diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 943b9d08bd..00748deafa 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -544,7 +544,7 @@ public: int xx = 0; int yy = y + tagsBase; for (const QString &tag : item.tags) { - const int ww = tagsFontMetrics.width(tag) + 5; + const int ww = tagsFontMetrics.horizontalAdvance(tag) + 5; if (xx + ww > w - 30) { yy += 15; xx = 0; diff --git a/src/plugins/qtsupport/qmldumptool.cpp b/src/plugins/qtsupport/qmldumptool.cpp index 045353d004..dc9f766144 100644 --- a/src/plugins/qtsupport/qmldumptool.cpp +++ b/src/plugins/qtsupport/qmldumptool.cpp @@ -85,7 +85,7 @@ void QmlDumpTool::pathAndEnvironment(const ProjectExplorer::Kit *k, bool preferD if (!k) return; - const BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); + const BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (version && !version->hasQmlDump()) return; diff --git a/src/plugins/qtsupport/qscxmlcgenerator.cpp b/src/plugins/qtsupport/qscxmlcgenerator.cpp index 7874cde57d..4d1fc8e50a 100644 --- a/src/plugins/qtsupport/qscxmlcgenerator.cpp +++ b/src/plugins/qtsupport/qscxmlcgenerator.cpp @@ -77,9 +77,9 @@ Utils::FileName QScxmlcGenerator::command() const QtSupport::BaseQtVersion *version = nullptr; Target *target; if ((target = project()->activeTarget())) - version = QtSupport::QtKitInformation::qtVersion(target->kit()); + version = QtSupport::QtKitAspect::qtVersion(target->kit()); else - version = QtSupport::QtKitInformation::qtVersion(KitManager::defaultKit()); + version = QtSupport::QtKitAspect::qtVersion(KitManager::defaultKit()); if (!version) return Utils::FileName(); diff --git a/src/plugins/qtsupport/qtcppkitinfo.cpp b/src/plugins/qtsupport/qtcppkitinfo.cpp index 2028400ee4..07e404cce4 100644 --- a/src/plugins/qtsupport/qtcppkitinfo.cpp +++ b/src/plugins/qtsupport/qtcppkitinfo.cpp @@ -35,7 +35,7 @@ using namespace CppTools; CppKitInfo::CppKitInfo(ProjectExplorer::Project *project) : KitInfo(project) { - if (kit && (qtVersion = QtKitInformation::qtVersion(kit))) { + if (kit && (qtVersion = QtKitAspect::qtVersion(kit))) { if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) projectPartQtVersion = ProjectPart::Qt4; else diff --git a/src/plugins/qtsupport/qtkitconfigwidget.cpp b/src/plugins/qtsupport/qtkitconfigwidget.cpp index 8b32ba44de..e2376074dc 100644 --- a/src/plugins/qtsupport/qtkitconfigwidget.cpp +++ b/src/plugins/qtsupport/qtkitconfigwidget.cpp @@ -40,8 +40,8 @@ namespace QtSupport { namespace Internal { -QtKitConfigWidget::QtKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki) : - KitConfigWidget(k, ki) +QtKitAspectWidget::QtKitAspectWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitAspect *ki) : + KitAspectWidget(k, ki) { m_combo = new QComboBox; m_combo->setSizePolicy(QSizePolicy::Ignored, m_combo->sizePolicy().verticalPolicy()); @@ -50,54 +50,54 @@ QtKitConfigWidget::QtKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplo QList<int> versionIds = Utils::transform(QtVersionManager::versions(), &BaseQtVersion::uniqueId); versionsChanged(versionIds, QList<int>(), QList<int>()); - m_manageButton = new QPushButton(KitConfigWidget::msgManage()); + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); refresh(); m_combo->setToolTip(toolTip()); connect(m_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &QtKitConfigWidget::currentWasChanged); + this, &QtKitAspectWidget::currentWasChanged); connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged, - this, &QtKitConfigWidget::versionsChanged); + this, &QtKitAspectWidget::versionsChanged); - connect(m_manageButton, &QAbstractButton::clicked, this, &QtKitConfigWidget::manageQtVersions); + connect(m_manageButton, &QAbstractButton::clicked, this, &QtKitAspectWidget::manageQtVersions); } -QtKitConfigWidget::~QtKitConfigWidget() +QtKitAspectWidget::~QtKitAspectWidget() { delete m_combo; delete m_manageButton; } -QString QtKitConfigWidget::displayName() const +QString QtKitAspectWidget::displayName() const { return tr("Qt version"); } -QString QtKitConfigWidget::toolTip() const +QString QtKitAspectWidget::toolTip() const { return tr("The Qt library to use for all projects using this kit.<br>" "A Qt version is required for qmake-based projects " "and optional when using other build systems."); } -void QtKitConfigWidget::makeReadOnly() +void QtKitAspectWidget::makeReadOnly() { m_combo->setEnabled(false); } -void QtKitConfigWidget::refresh() +void QtKitAspectWidget::refresh() { - m_combo->setCurrentIndex(findQtVersion(QtKitInformation::qtVersionId(m_kit))); + m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit))); } -QWidget *QtKitConfigWidget::mainWidget() const +QWidget *QtKitAspectWidget::mainWidget() const { return m_combo; } -QWidget *QtKitConfigWidget::buttonWidget() const +QWidget *QtKitAspectWidget::buttonWidget() const { return m_manageButton; } @@ -111,7 +111,7 @@ static QString itemNameFor(const BaseQtVersion *v) return name; } -void QtKitConfigWidget::versionsChanged(const QList<int> &added, const QList<int> &removed, +void QtKitAspectWidget::versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed) { foreach (const int id, added) { @@ -133,17 +133,17 @@ void QtKitConfigWidget::versionsChanged(const QList<int> &added, const QList<int } } -void QtKitConfigWidget::manageQtVersions() +void QtKitAspectWidget::manageQtVersions() { Core::ICore::showOptionsDialog(Constants::QTVERSION_SETTINGS_PAGE_ID, buttonWidget()); } -void QtKitConfigWidget::currentWasChanged(int idx) +void QtKitAspectWidget::currentWasChanged(int idx) { - QtKitInformation::setQtVersionId(m_kit, m_combo->itemData(idx).toInt()); + QtKitAspect::setQtVersionId(m_kit, m_combo->itemData(idx).toInt()); } -int QtKitConfigWidget::findQtVersion(const int id) const +int QtKitAspectWidget::findQtVersion(const int id) const { for (int i = 0; i < m_combo->count(); ++i) { if (id == m_combo->itemData(i).toInt()) diff --git a/src/plugins/qtsupport/qtkitconfigwidget.h b/src/plugins/qtsupport/qtkitconfigwidget.h deleted file mode 100644 index 76cd30d5b5..0000000000 --- a/src/plugins/qtsupport/qtkitconfigwidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <projectexplorer/kitconfigwidget.h> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QPushButton; -QT_END_NAMESPACE - -namespace QtSupport { -namespace Internal { - -class QtKitConfigWidget : public ProjectExplorer::KitConfigWidget -{ - Q_OBJECT - -public: - QtKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki); - ~QtKitConfigWidget() override; - - QString displayName() const override; - - void makeReadOnly() override; - - void refresh() override; - QWidget *mainWidget() const override; - QWidget *buttonWidget() const override; - QString toolTip() const override; - -private: - void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed); - void manageQtVersions(); - void currentWasChanged(int idx); - int findQtVersion(const int id) const; - - QComboBox *m_combo; - QPushButton *m_manageButton; -}; - -} // namespace Internal -} // namespace Debugger diff --git a/src/plugins/qtsupport/qtkitinformation.cpp b/src/plugins/qtsupport/qtkitinformation.cpp index 3e55fb3fd0..64eb3b5ca0 100644 --- a/src/plugins/qtsupport/qtkitinformation.cpp +++ b/src/plugins/qtsupport/qtkitinformation.cpp @@ -27,35 +27,140 @@ #include <QRegExp> -#include "qtkitconfigwidget.h" #include "qtsupportconstants.h" #include "qtversionmanager.h" #include "qtparser.h" +#include <coreplugin/icore.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/task.h> - #include <utils/algorithm.h> #include <utils/buildablehelperlibrary.h> #include <utils/macroexpander.h> #include <utils/qtcassert.h> +#include <QComboBox> +#include <QPushButton> + using namespace ProjectExplorer; using namespace Utils; namespace QtSupport { +namespace Internal { + +class QtKitAspectWidget : public KitAspectWidget +{ + Q_DECLARE_TR_FUNCTIONS(QtSupport::QtKitAspectWidget) +public: + QtKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki) + { + m_combo = new QComboBox; + m_combo->setSizePolicy(QSizePolicy::Ignored, m_combo->sizePolicy().verticalPolicy()); + m_combo->addItem(tr("None"), -1); + + QList<int> versionIds = Utils::transform(QtVersionManager::versions(), &BaseQtVersion::uniqueId); + versionsChanged(versionIds, QList<int>(), QList<int>()); + + m_manageButton = new QPushButton(KitAspectWidget::msgManage()); + + refresh(); + m_combo->setToolTip(ki->description()); + + connect(m_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &QtKitAspectWidget::currentWasChanged); + + connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged, + this, &QtKitAspectWidget::versionsChanged); + + connect(m_manageButton, &QAbstractButton::clicked, this, &QtKitAspectWidget::manageQtVersions); + } + + ~QtKitAspectWidget() override + { + delete m_combo; + delete m_manageButton; + } + +private: + void makeReadOnly() override { m_combo->setEnabled(false); } + QWidget *mainWidget() const override { return m_combo; } + QWidget *buttonWidget() const override { return m_manageButton; } + + void refresh() override + { + m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit))); + } + +private: + static QString itemNameFor(const BaseQtVersion *v) + { + QTC_ASSERT(v, return QString()); + QString name = v->displayName(); + if (!v->isValid()) + name = QCoreApplication::translate("QtSupport::Internal::QtKitConfigWidget", "%1 (invalid)").arg(v->displayName()); + return name; + } + + void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed) + { + foreach (const int id, added) { + BaseQtVersion *v = QtVersionManager::version(id); + QTC_CHECK(v); + QTC_CHECK(findQtVersion(id) < 0); + m_combo->addItem(itemNameFor(v), id); + } + foreach (const int id, removed) { + int pos = findQtVersion(id); + if (pos >= 0) // We do not include invalid Qt versions, so do not try to remove those. + m_combo->removeItem(pos); + } + foreach (const int id, changed) { + BaseQtVersion *v = QtVersionManager::version(id); + int pos = findQtVersion(id); + QTC_CHECK(pos >= 0); + m_combo->setItemText(pos, itemNameFor(v)); + } + } + + void manageQtVersions() + { + Core::ICore::showOptionsDialog(Constants::QTVERSION_SETTINGS_PAGE_ID, buttonWidget()); + } + + void currentWasChanged(int idx) + { + QtKitAspect::setQtVersionId(m_kit, m_combo->itemData(idx).toInt()); + } + + int findQtVersion(const int id) const + { + for (int i = 0; i < m_combo->count(); ++i) { + if (id == m_combo->itemData(i).toInt()) + return i; + } + return -1; + } + + QComboBox *m_combo; + QPushButton *m_manageButton; +}; +} // namespace Internal -QtKitInformation::QtKitInformation() +QtKitAspect::QtKitAspect() { - setObjectName(QLatin1String("QtKitInformation")); - setId(QtKitInformation::id()); + setObjectName(QLatin1String("QtKitAspect")); + setId(QtKitAspect::id()); + setDisplayName(tr("Qt version")); + setDescription(tr("The Qt library to use for all projects using this kit.<br>" + "A Qt version is required for qmake-based projects " + "and optional when using other build systems.")); setPriority(26000); connect(KitManager::instance(), &KitManager::kitsLoaded, - this, &QtKitInformation::kitsWereLoaded); + this, &QtKitAspect::kitsWereLoaded); } -QVariant QtKitInformation::defaultValue(const Kit *k) const +QVariant QtKitAspect::defaultValue(const Kit *k) const { Q_UNUSED(k); @@ -71,7 +176,7 @@ QVariant QtKitInformation::defaultValue(const Kit *k) const return result ? result->uniqueId() : -1; } -QList<ProjectExplorer::Task> QtKitInformation::validate(const ProjectExplorer::Kit *k) const +QList<ProjectExplorer::Task> QtKitAspect::validate(const ProjectExplorer::Kit *k) const { QTC_ASSERT(QtVersionManager::isLoaded(), return { }); BaseQtVersion *version = qtVersion(k); @@ -81,7 +186,7 @@ QList<ProjectExplorer::Task> QtKitInformation::validate(const ProjectExplorer::K return version->validateKit(k); } -void QtKitInformation::fix(ProjectExplorer::Kit *k) +void QtKitAspect::fix(ProjectExplorer::Kit *k) { QTC_ASSERT(QtVersionManager::isLoaded(), return); BaseQtVersion *version = qtVersion(k); @@ -91,33 +196,33 @@ void QtKitInformation::fix(ProjectExplorer::Kit *k) } } -ProjectExplorer::KitConfigWidget *QtKitInformation::createConfigWidget(ProjectExplorer::Kit *k) const +ProjectExplorer::KitAspectWidget *QtKitAspect::createConfigWidget(ProjectExplorer::Kit *k) const { QTC_ASSERT(k, return nullptr); - return new Internal::QtKitConfigWidget(k, this); + return new Internal::QtKitAspectWidget(k, this); } -QString QtKitInformation::displayNamePostfix(const ProjectExplorer::Kit *k) const +QString QtKitAspect::displayNamePostfix(const ProjectExplorer::Kit *k) const { BaseQtVersion *version = qtVersion(k); return version ? version->displayName() : QString(); } -ProjectExplorer::KitInformation::ItemList -QtKitInformation::toUserOutput(const ProjectExplorer::Kit *k) const +ProjectExplorer::KitAspect::ItemList +QtKitAspect::toUserOutput(const ProjectExplorer::Kit *k) const { BaseQtVersion *version = qtVersion(k); return ItemList() << qMakePair(tr("Qt version"), version ? version->displayName() : tr("None")); } -void QtKitInformation::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const +void QtKitAspect::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const { BaseQtVersion *version = qtVersion(k); if (version) version->addToEnvironment(k, env); } -ProjectExplorer::IOutputParser *QtKitInformation::createOutputParser(const ProjectExplorer::Kit *k) const +ProjectExplorer::IOutputParser *QtKitAspect::createOutputParser(const ProjectExplorer::Kit *k) const { if (qtVersion(k)) return new QtParser; @@ -129,7 +234,7 @@ class QtMacroSubProvider public: QtMacroSubProvider(Kit *kit) : expander(BaseQtVersion::createMacroExpander( - [kit] { return QtKitInformation::qtVersion(kit); })) + [kit] { return QtKitAspect::qtVersion(kit); })) {} MacroExpander *operator()() const @@ -140,7 +245,7 @@ public: std::shared_ptr<MacroExpander> expander; }; -void QtKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const +void QtKitAspect::addToMacroExpander(Kit *kit, MacroExpander *expander) const { QTC_ASSERT(kit, return); expander->registerSubProvider(QtMacroSubProvider(kit)); @@ -157,18 +262,18 @@ void QtKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) con }); } -Core::Id QtKitInformation::id() +Core::Id QtKitAspect::id() { return "QtSupport.QtInformation"; } -int QtKitInformation::qtVersionId(const ProjectExplorer::Kit *k) +int QtKitAspect::qtVersionId(const ProjectExplorer::Kit *k) { if (!k) return -1; int id = -1; - QVariant data = k->value(QtKitInformation::id(), -1); + QVariant data = k->value(QtKitAspect::id(), -1); if (data.type() == QVariant::Int) { bool ok; id = data.toInt(&ok); @@ -183,18 +288,18 @@ int QtKitInformation::qtVersionId(const ProjectExplorer::Kit *k) return id; } -void QtKitInformation::setQtVersionId(ProjectExplorer::Kit *k, const int id) +void QtKitAspect::setQtVersionId(ProjectExplorer::Kit *k, const int id) { QTC_ASSERT(k, return); - k->setValue(QtKitInformation::id(), id); + k->setValue(QtKitAspect::id(), id); } -BaseQtVersion *QtKitInformation::qtVersion(const ProjectExplorer::Kit *k) +BaseQtVersion *QtKitAspect::qtVersion(const ProjectExplorer::Kit *k) { return QtVersionManager::version(qtVersionId(k)); } -void QtKitInformation::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v) +void QtKitAspect::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v) { if (!v) setQtVersionId(k, -1); @@ -202,7 +307,7 @@ void QtKitInformation::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion setQtVersionId(k, v->uniqueId()); } -void QtKitInformation::qtVersionsChanged(const QList<int> &addedIds, +void QtKitAspect::qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changedIds) { @@ -216,29 +321,29 @@ void QtKitInformation::qtVersionsChanged(const QList<int> &addedIds, } } -void QtKitInformation::kitsWereLoaded() +void QtKitAspect::kitsWereLoaded() { foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) fix(k); connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged, - this, &QtKitInformation::qtVersionsChanged); + this, &QtKitAspect::qtVersionsChanged); } -Kit::Predicate QtKitInformation::platformPredicate(Core::Id platform) +Kit::Predicate QtKitAspect::platformPredicate(Core::Id platform) { return [platform](const Kit *kit) -> bool { - BaseQtVersion *version = QtKitInformation::qtVersion(kit); + BaseQtVersion *version = QtKitAspect::qtVersion(kit); return version && version->targetDeviceTypes().contains(platform); }; } -Kit::Predicate QtKitInformation::qtVersionPredicate(const QSet<Core::Id> &required, +Kit::Predicate QtKitAspect::qtVersionPredicate(const QSet<Core::Id> &required, const QtVersionNumber &min, const QtVersionNumber &max) { return [required, min, max](const Kit *kit) -> bool { - BaseQtVersion *version = QtKitInformation::qtVersion(kit); + BaseQtVersion *version = QtKitAspect::qtVersion(kit); if (!version) return false; QtVersionNumber current = version->qtVersion(); @@ -250,15 +355,15 @@ Kit::Predicate QtKitInformation::qtVersionPredicate(const QSet<Core::Id> &requir }; } -QSet<Core::Id> QtKitInformation::supportedPlatforms(const Kit *k) const +QSet<Core::Id> QtKitAspect::supportedPlatforms(const Kit *k) const { - BaseQtVersion *version = QtKitInformation::qtVersion(k); + BaseQtVersion *version = QtKitAspect::qtVersion(k); return version ? version->targetDeviceTypes() : QSet<Core::Id>(); } -QSet<Core::Id> QtKitInformation::availableFeatures(const Kit *k) const +QSet<Core::Id> QtKitAspect::availableFeatures(const Kit *k) const { - BaseQtVersion *version = QtKitInformation::qtVersion(k); + BaseQtVersion *version = QtKitAspect::qtVersion(k); return version ? version->features() : QSet<Core::Id>(); } diff --git a/src/plugins/qtsupport/qtkitinformation.h b/src/plugins/qtsupport/qtkitinformation.h index 459b9b2440..56f79cee03 100644 --- a/src/plugins/qtsupport/qtkitinformation.h +++ b/src/plugins/qtsupport/qtkitinformation.h @@ -35,19 +35,19 @@ namespace Utils { class MacroExpander; } namespace QtSupport { -class QTSUPPORT_EXPORT QtKitInformation : public ProjectExplorer::KitInformation +class QTSUPPORT_EXPORT QtKitAspect : public ProjectExplorer::KitAspect { Q_OBJECT public: - QtKitInformation(); + QtKitAspect(); QVariant defaultValue(const ProjectExplorer::Kit *k) const override; QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override; void fix(ProjectExplorer::Kit *) override; - ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; + ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; QString displayNamePostfix(const ProjectExplorer::Kit *k) const override; diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index f891f38184..37e64acde8 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -156,7 +156,7 @@ QtOptionsPage::QtOptionsPage() : m_widget(0) { setId(Constants::QTVERSION_SETTINGS_PAGE_ID); - setDisplayName(QCoreApplication::translate("QtSupport", Constants::QTVERSION_SETTINGS_PAGE_NAME)); + setDisplayName(QCoreApplication::translate("QtSupport", "Qt Versions")); setCategory(ProjectExplorer::Constants::KITS_SETTINGS_CATEGORY); } @@ -258,9 +258,6 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent) userChangedCurrentVersion(); updateCleanUpButton(); - connect(QtVersionManager::instance(), &QtVersionManager::dumpUpdatedFor, - this, &QtOptionsPageWidget::qtVersionsDumpUpdated); - connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged, this, &QtOptionsPageWidget::updateQtVersions); @@ -333,19 +330,6 @@ void QtOptionsPageWidget::toolChainsUpdated() }); } -void QtOptionsPageWidget::qtVersionsDumpUpdated(const FileName &qmakeCommand) -{ - m_model->forItemsAtLevel<2>([qmakeCommand](QtVersionItem *item) { - if (item->version()->qmakeCommand() == qmakeCommand) - item->version()->recheckDumper(); - }); - - if (currentVersion() && currentVersion()->qmakeCommand() == qmakeCommand) { - updateWidgets(); - updateDescriptionLabel(); - } -} - void QtOptionsPageWidget::setInfoWidgetVisibility() { m_ui->versionInfoWidget->setVisible(m_ui->infoWidget->state() == DetailsWidget::Collapsed); diff --git a/src/plugins/qtsupport/qtoptionspage.h b/src/plugins/qtsupport/qtoptionspage.h index fc7899c9e0..04af543355 100644 --- a/src/plugins/qtsupport/qtoptionspage.h +++ b/src/plugins/qtsupport/qtoptionspage.h @@ -95,7 +95,6 @@ private: void cleanUpQtVersions(); void toolChainsUpdated(); - void qtVersionsDumpUpdated(const Utils::FileName &qmakeCommand); void setInfoWidgetVisibility(); void infoAnchorClicked(const QUrl &); diff --git a/src/plugins/qtsupport/qtprojectimporter.cpp b/src/plugins/qtsupport/qtprojectimporter.cpp index a218ee2b5e..0350995736 100644 --- a/src/plugins/qtsupport/qtprojectimporter.cpp +++ b/src/plugins/qtsupport/qtprojectimporter.cpp @@ -47,7 +47,7 @@ namespace QtSupport { QtProjectImporter::QtProjectImporter(const Utils::FileName &path) : ProjectImporter(path) { - useTemporaryKitInformation(QtKitInformation::id(), + useTemporaryKitAspect(QtKitAspect::id(), [this](Kit *k, const QVariantList &vl) {cleanupTemporaryQt(k, vl);}, [this](Kit *k, const QVariantList &vl) {persistTemporaryQt(k, vl);}); } @@ -60,7 +60,7 @@ QtProjectImporter::findOrCreateQtVersion(const Utils::FileName &qmakePath) const if (result.qt) { // Check if version is a temporary qt const int qtId = result.qt->uniqueId(); - result.isTemporary = hasKitWithTemporaryData(QtKitInformation::id(), qtId); + result.isTemporary = hasKitWithTemporaryData(QtKitAspect::id(), qtId); return result; } @@ -80,10 +80,10 @@ Kit *QtProjectImporter::createTemporaryKit(const QtVersionData &versionData, const ProjectImporter::KitSetupFunction &additionalSetup) const { return ProjectImporter::createTemporaryKit([&additionalSetup, &versionData, this](Kit *k) -> void { - QtKitInformation::setQtVersion(k, versionData.qt); + QtKitAspect::setQtVersion(k, versionData.qt); if (versionData.qt) { if (versionData.isTemporary) - addTemporaryData(QtKitInformation::id(), versionData.qt->uniqueId(), k); + addTemporaryData(QtKitAspect::id(), versionData.qt->uniqueId(), k); k->setUnexpandedDisplayName(versionData.qt->displayName());; } @@ -108,7 +108,7 @@ void QtProjectImporter::cleanupTemporaryQt(Kit *k, const QVariantList &vl) BaseQtVersion *version = versionFromVariant(vl.at(0)); QTC_ASSERT(version, return); QtVersionManager::removeVersion(version); - QtKitInformation::setQtVersion(k, nullptr); // Always mark Kit as not using this Qt + QtKitAspect::setQtVersion(k, nullptr); // Always mark Kit as not using this Qt } void QtProjectImporter::persistTemporaryQt(Kit *k, const QVariantList &vl) @@ -118,7 +118,7 @@ void QtProjectImporter::persistTemporaryQt(Kit *k, const QVariantList &vl) QTC_ASSERT(vl.count() == 1, return); const QVariant data = vl.at(0); BaseQtVersion *tmpVersion = versionFromVariant(data); - BaseQtVersion *actualVersion = QtKitInformation::qtVersion(k); + BaseQtVersion *actualVersion = QtKitAspect::qtVersion(k); // User changed Kit away from temporary Qt that was set up: if (tmpVersion && actualVersion != tmpVersion) @@ -228,7 +228,7 @@ Kit *TestQtProjectImporter::createKit(void *directoryData) const // New temporary kit: return createTemporaryKit(findOrCreateQtVersion(dd->qmakePath), [dd](Kit *k) { - BaseQtVersion *qt = QtKitInformation::qtVersion(k); + BaseQtVersion *qt = QtKitAspect::qtVersion(k); QMap<Core::Id, QVariant> toKeep; for (const Core::Id &key : k->allKeys()) { if (key.toString().startsWith("PE.tmp.")) @@ -237,7 +237,7 @@ Kit *TestQtProjectImporter::createKit(void *directoryData) const k->copyFrom(dd->kit); for (auto i = toKeep.constBegin(); i != toKeep.constEnd(); ++i) k->setValue(i.key(), i.value()); - QtKitInformation::setQtVersion(k, qt); + QtKitAspect::setQtVersion(k, qt); }); } @@ -362,7 +362,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() Kit *defaultKit = KitManager::defaultKit(); QVERIFY(defaultKit); - BaseQtVersion *defaultQt = QtKitInformation::qtVersion(defaultKit); + BaseQtVersion *defaultQt = QtKitAspect::qtVersion(defaultKit); QVERIFY(defaultQt); const Utils::TemporaryDirectory tempDir1("tmp1"); @@ -373,10 +373,10 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() // Templates referrenced by test data: QVector<Kit *> kitTemplates = {defaultKit, defaultKit->clone(), defaultKit->clone()}; // Customize kit numbers 1 and 2: - QtKitInformation::setQtVersion(kitTemplates[1], nullptr); - QtKitInformation::setQtVersion(kitTemplates[2], nullptr); - SysRootKitInformation::setSysRoot(kitTemplates[1], Utils::FileName::fromString("/some/path")); - SysRootKitInformation::setSysRoot(kitTemplates[2], Utils::FileName::fromString("/some/other/path")); + QtKitAspect::setQtVersion(kitTemplates[1], nullptr); + QtKitAspect::setQtVersion(kitTemplates[2], nullptr); + SysRootKitAspect::setSysRoot(kitTemplates[1], Utils::FileName::fromString("/some/path")); + SysRootKitAspect::setSysRoot(kitTemplates[2], Utils::FileName::fromString("/some/other/path")); QVector<Utils::FileName> qmakePaths = {defaultQt->qmakeCommand(), setupQmake(defaultQt, tempDir1.path()), @@ -445,7 +445,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() Kit *newKit = KitManager::kit(bi.kitId); QVERIFY(newKit); - const int newQtId = QtKitInformation::qtVersionId(newKit); + const int newQtId = QtKitAspect::qtVersionId(newKit); // VALIDATE: Qt id is unchanged (unless it is a new Qt) if (!dd->isNewQt) @@ -468,7 +468,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() QCOMPARE(templateKeys.count(), newKitKeys.count()); // existing kit needs to be unchanged! for (Core::Id id : templateKeys) { - if (id == QtKitInformation::id()) + if (id == QtKitAspect::id()) continue; // with the exception of the Qt one... QVERIFY(newKit->hasValue(id)); QVERIFY(dd->kit->value(id) == newKit->value(id)); @@ -497,7 +497,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() templateKit = defaultKit; } else { templateKit = dd->kit->clone(true); - QtKitInformation::setQtVersionId(templateKit, QtKitInformation::qtVersionId(newKit)); + QtKitAspect::setQtVersionId(templateKit, QtKitAspect::qtVersionId(newKit)); } const QList<Core::Id> templateKitKeys = templateKit->allKeys(); @@ -522,7 +522,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() const QList<Core::Id> newKitKeys = newKit->allKeys(); const Core::Id newKitId = newKit->id(); - const int qtId = QtKitInformation::qtVersionId(newKit); + const int qtId = QtKitAspect::qtVersionId(newKit); // VALIDATE: Kit Id has not changed QCOMPARE(newKitId, newKitIdAfterImport); @@ -539,7 +539,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() // VALIDATE: All the kit values are as set up in the template before QCOMPARE(newKitKeys.count(), templateKitKeys.count()); for (Core::Id id : templateKitKeys) { - if (id == QtKitInformation::id()) + if (id == QtKitAspect::id()) continue; QVERIFY(newKit->hasValue(id)); QVERIFY(newKit->value(id) == templateKit->value(id)); @@ -553,7 +553,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() // VALIDATE: All keys that got added during import are gone QCOMPARE(newKitKeys.count(), templateKitKeys.count()); for (Core::Id id : newKitKeys) { - if (id == QtKitInformation::id()) + if (id == QtKitAspect::id()) continue; // Will be checked by Qt version later QVERIFY(templateKit->hasValue(id)); QVERIFY(newKit->value(id) == templateKit->value(id)); @@ -562,7 +562,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() if (qtIsPersistent) { // VALIDATE: Qt is used in the Kit: - QVERIFY(QtKitInformation::qtVersionId(newKit) == qtId); + QVERIFY(QtKitAspect::qtVersionId(newKit) == qtId); // VALIDATE: Qt is still in QtVersionManager QVERIFY(QtVersionManager::version(qtId)); @@ -571,10 +571,10 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() QCOMPARE(QtVersionManager::version(qtId)->qmakeCommand(), dd->qmakePath); // VALIDATE: Kit uses the expected Qt - QCOMPARE(QtKitInformation::qtVersionId(newKit), qtId); + QCOMPARE(QtKitAspect::qtVersionId(newKit), qtId); } else { // VALIDATE: Qt was reset in the kit - QVERIFY(QtKitInformation::qtVersionId(newKit) == -1); + QVERIFY(QtKitAspect::qtVersionId(newKit) == -1); // VALIDATE: New kit is still visible in KitManager QVERIFY(KitManager::kit(newKitId)); // Cleanup Kit does not unregister Kits, so it does @@ -584,7 +584,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() QVERIFY(!QtVersionManager::version(qtId)); // VALIDATE: Qt version was reset on the kit - QVERIFY(newKit->value(QtKitInformation::id()).toInt() == -1); // new Qt will be reset to invalid! + QVERIFY(newKit->value(QtKitAspect::id()).toInt() == -1); // new Qt will be reset to invalid! } if (templateKit != defaultKit) diff --git a/src/plugins/qtsupport/qtsupport.pro b/src/plugins/qtsupport/qtsupport.pro index 17797f6294..78832697ea 100644 --- a/src/plugins/qtsupport/qtsupport.pro +++ b/src/plugins/qtsupport/qtsupport.pro @@ -15,7 +15,6 @@ HEADERS += \ qtprojectimporter.h \ qtsupportplugin.h \ qtsupport_global.h \ - qtkitconfigwidget.h \ qtkitinformation.h \ qtoutputformatter.h \ qtversionmanager.h \ @@ -29,7 +28,6 @@ HEADERS += \ exampleslistmodel.h \ screenshotcropper.h \ qtconfigwidget.h \ - desktopqtversionfactory.h \ desktopqtversion.h \ uicgenerator.h \ qscxmlcgenerator.h @@ -42,7 +40,6 @@ SOURCES += \ qtcppkitinfo.cpp \ qtprojectimporter.cpp \ qtsupportplugin.cpp \ - qtkitconfigwidget.cpp \ qtkitinformation.cpp \ qtoutputformatter.cpp \ qtversionmanager.cpp \ @@ -55,7 +52,6 @@ SOURCES += \ exampleslistmodel.cpp \ screenshotcropper.cpp \ qtconfigwidget.cpp \ - desktopqtversionfactory.cpp \ desktopqtversion.cpp \ uicgenerator.cpp \ qscxmlcgenerator.cpp diff --git a/src/plugins/qtsupport/qtsupport.qbs b/src/plugins/qtsupport/qtsupport.qbs index d4a140b2ae..25cba7a70c 100644 --- a/src/plugins/qtsupport/qtsupport.qbs +++ b/src/plugins/qtsupport/qtsupport.qbs @@ -76,8 +76,6 @@ Project { "qmldumptool.h", "qscxmlcgenerator.cpp", "qscxmlcgenerator.h", - "qtkitconfigwidget.cpp", - "qtkitconfigwidget.h", "qtkitinformation.cpp", "qtkitinformation.h", "qtoptionspage.cpp", @@ -106,8 +104,8 @@ Project { Group { name: "QtVersion" files: [ - "desktopqtversion.cpp", "desktopqtversion.h", - "desktopqtversionfactory.cpp", "desktopqtversionfactory.h", + "desktopqtversion.cpp", + "desktopqtversion.h", ] } diff --git a/src/plugins/qtsupport/qtsupportconstants.h b/src/plugins/qtsupport/qtsupportconstants.h index 202378ef2e..f8a453d13d 100644 --- a/src/plugins/qtsupport/qtsupportconstants.h +++ b/src/plugins/qtsupport/qtsupportconstants.h @@ -30,10 +30,7 @@ namespace Constants { // Qt settings pages const char QTVERSION_SETTINGS_PAGE_ID[] = "H.Qt Versions"; -const char QTVERSION_SETTINGS_PAGE_NAME[] = QT_TRANSLATE_NOOP("QtSupport", "Qt Versions"); - const char CODEGEN_SETTINGS_PAGE_ID[] = "Class Generation"; -const char CODEGEN_SETTINGS_PAGE_NAME[] = QT_TRANSLATE_NOOP("QtSupport", "Qt Class Generation"); // QtVersions const char DESKTOPQT[] = "Qt4ProjectManager.QtVersion.Desktop"; diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 2d99d01e38..daa32ce870 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -27,14 +27,17 @@ #include "codegenerator.h" #include "codegensettingspage.h" -#include "desktopqtversionfactory.h" +#include "desktopqtversion.h" #include "gettingstartedwelcomepage.h" #include "qtkitinformation.h" #include "qtoptionspage.h" +#include "qtsupportconstants.h" +#include "qtversionfactory.h" #include "qtversionmanager.h" #include "uicgenerator.h" #include "qscxmlcgenerator.h" +#include "desktopqtversion.h" #include "profilereader.h" #include <coreplugin/icore.h> @@ -84,7 +87,7 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes d = new QtSupportPluginPrivate; - ProjectExplorer::KitManager::registerKitInformation<QtKitInformation>(); + ProjectExplorer::KitManager::registerKitAspect<QtKitAspect>(); (void) new UicGeneratorFactory(this); (void) new QScxmlcGeneratorFactory(this); @@ -100,7 +103,7 @@ static QString qmakeProperty(const char *propertyName) if (!project || !project->activeTarget()) return QString(); - const BaseQtVersion *qtVersion = QtKitInformation::qtVersion(project->activeTarget()->kit()); + const BaseQtVersion *qtVersion = QtKitAspect::qtVersion(project->activeTarget()->kit()); if (!qtVersion) return QString(); return qtVersion->qmakeProperty(propertyName); diff --git a/src/plugins/qtsupport/qtversionfactory.cpp b/src/plugins/qtsupport/qtversionfactory.cpp index ebc8ae36ee..d517ff89e0 100644 --- a/src/plugins/qtsupport/qtversionfactory.cpp +++ b/src/plugins/qtsupport/qtversionfactory.cpp @@ -30,16 +30,19 @@ #include <proparser/qmakevfs.h> #include <extensionsystem/pluginmanager.h> + #include <utils/algorithm.h> #include <utils/environment.h> +#include <utils/qtcassert.h> + +#include <QFileInfo> using namespace QtSupport; using namespace QtSupport::Internal; static QList<QtVersionFactory *> g_qtVersionFactories; -QtVersionFactory::QtVersionFactory(QObject *parent) : - QObject(parent) +QtVersionFactory::QtVersionFactory() { g_qtVersionFactories.append(this); } @@ -54,6 +57,20 @@ const QList<QtVersionFactory *> QtVersionFactory::allQtVersionFactories() return g_qtVersionFactories; } +bool QtVersionFactory::canRestore(const QString &type) +{ + return type == m_supportedType; +} + +BaseQtVersion *QtVersionFactory::restore(const QString &type, const QVariantMap &data) +{ + QTC_ASSERT(canRestore(type), return nullptr); + QTC_ASSERT(m_creator, return nullptr); + BaseQtVersion *version = m_creator(); + version->fromMap(data); + return version; +} + BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileName &qmakePath, bool isAutoDetected, const QString &autoDetectionSource, QString *error) { QHash<ProKey, ProString> versionInfo; @@ -76,15 +93,51 @@ BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileN return l->priority() > r->priority(); }); + QFileInfo fi = qmakePath.toFileInfo(); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) + return nullptr; + + SetupData setup; + setup.config = evaluator.values("CONFIG"); + setup.platforms = evaluator.values("QMAKE_PLATFORM"); // It's a list in general. + setup.isQnx = !evaluator.value("QNX_CPUDIR").isEmpty(); + foreach (QtVersionFactory *factory, factories) { - BaseQtVersion *ver = factory->create(qmakePath, &evaluator, isAutoDetected, autoDetectionSource); - if (ver) { + if (!factory->m_restrictionChecker || factory->m_restrictionChecker(setup)) { + QTC_ASSERT(factory->m_creator, continue); + BaseQtVersion *ver = factory->m_creator(); + QTC_ASSERT(ver, continue); + ver->setupQmakePathAndId(qmakePath); + ver->setAutoDetectionSource(autoDetectionSource); + ver->setIsAutodetected(isAutoDetected); ProFileCacheManager::instance()->decRefCount(); return ver; } } ProFileCacheManager::instance()->decRefCount(); - if (error) - *error = tr("No factory found for qmake: \"%1\"").arg(qmakePath.toUserOutput()); + if (error) { + *error = QCoreApplication::translate("QtSupport::QtVersionFactory", + "No factory found for qmake: \"%1\"").arg(qmakePath.toUserOutput()); + } return 0; } + +void QtVersionFactory::setQtVersionCreator(const std::function<BaseQtVersion *()> &creator) +{ + m_creator = creator; +} + +void QtVersionFactory::setRestrictionChecker(const std::function<bool(const SetupData &)> &checker) +{ + m_restrictionChecker = checker; +} + +void QtVersionFactory::setSupportedType(const QString &type) +{ + m_supportedType = type; +} + +void QtVersionFactory::setPriority(int priority) +{ + m_priority = priority; +} diff --git a/src/plugins/qtsupport/qtversionfactory.h b/src/plugins/qtsupport/qtversionfactory.h index fad90280cd..9a34196d3a 100644 --- a/src/plugins/qtsupport/qtversionfactory.h +++ b/src/plugins/qtsupport/qtversionfactory.h @@ -27,45 +27,52 @@ #include "qtsupport_global.h" -#include <QObject> #include <QVariantMap> -QT_BEGIN_NAMESPACE -class QSettings; -class ProFileEvaluator; -QT_END_NAMESPACE - namespace Utils { class FileName; } namespace QtSupport { class BaseQtVersion; -class QTSUPPORT_EXPORT QtVersionFactory : public QObject +class QTSUPPORT_EXPORT QtVersionFactory { - Q_OBJECT - public: - explicit QtVersionFactory(QObject *parent = nullptr); - ~QtVersionFactory() override; + QtVersionFactory(); + virtual ~QtVersionFactory(); static const QList<QtVersionFactory *> allQtVersionFactories(); - virtual bool canRestore(const QString &type) = 0; - virtual BaseQtVersion *restore(const QString &type, const QVariantMap &data) = 0; + bool canRestore(const QString &type); + BaseQtVersion *restore(const QString &type, const QVariantMap &data); /// factories with higher priority are asked first to identify /// a qtversion, the priority of the desktop factory is 0 and /// the desktop factory claims to handle all paths - virtual int priority() const = 0; - virtual BaseQtVersion *create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()) = 0; + int priority() const { return m_priority; } static BaseQtVersion *createQtVersionFromQMakePath( const Utils::FileName &qmakePath, bool isAutoDetected = false, const QString &autoDetectionSource = QString(), QString *error = nullptr); + +protected: + struct SetupData + { + QStringList platforms; + QStringList config; + bool isQnx = false; // eeks... + }; + + void setQtVersionCreator(const std::function<BaseQtVersion *()> &creator); + void setRestrictionChecker(const std::function<bool(const SetupData &)> &checker); + void setSupportedType(const QString &type); + void setPriority(int priority); + +private: + std::function<BaseQtVersion *()> m_creator; + std::function<bool(const SetupData &)> m_restrictionChecker; + QString m_supportedType; + int m_priority = 0; }; } // namespace QtSupport diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp index c67edb4a36..fe4fce618d 100644 --- a/src/plugins/qtsupport/qtversionmanager.cpp +++ b/src/plugins/qtsupport/qtversionmanager.cpp @@ -483,15 +483,6 @@ static void updateDocumentation() Core::HelpManager::registerDocumentation(files); } -void QtVersionManager::updateDumpFor(const FileName &qmakeCommand) -{ - foreach (BaseQtVersion *v, versions()) { - if (v->qmakeCommand() == qmakeCommand) - v->recheckDumper(); - } - emit dumpUpdatedFor(qmakeCommand); -} - int QtVersionManager::getUniqueId() { return m_idcount++; diff --git a/src/plugins/qtsupport/qtversionmanager.h b/src/plugins/qtsupport/qtversionmanager.h index 790dc543ff..76969b478e 100644 --- a/src/plugins/qtsupport/qtversionmanager.h +++ b/src/plugins/qtsupport/qtversionmanager.h @@ -67,13 +67,9 @@ public: signals: // content of BaseQtVersion objects with qmake path might have changed - void dumpUpdatedFor(const Utils::FileName &qmakeCommand); void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changedIds); void qtVersionsLoaded(); -public slots: - void updateDumpFor(const Utils::FileName &qmakeCommand); - private: void updateFromInstaller(bool emitSignal = true); void triggerQtVersionRestore(); diff --git a/src/plugins/qtsupport/uicgenerator.cpp b/src/plugins/qtsupport/uicgenerator.cpp index 89e8713b22..2029d69a56 100644 --- a/src/plugins/qtsupport/uicgenerator.cpp +++ b/src/plugins/qtsupport/uicgenerator.cpp @@ -55,9 +55,9 @@ Utils::FileName UicGenerator::command() const QtSupport::BaseQtVersion *version = nullptr; Target *target; if ((target = project()->activeTarget())) - version = QtSupport::QtKitInformation::qtVersion(target->kit()); + version = QtSupport::QtKitAspect::qtVersion(target->kit()); else - version = QtSupport::QtKitInformation::qtVersion(KitManager::defaultKit()); + version = QtSupport::QtKitAspect::qtVersion(KitManager::defaultKit()); if (!version) return Utils::FileName(); diff --git a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp index 8877af9045..728aea666d 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp @@ -114,7 +114,7 @@ bool AbstractRemoteLinuxDeployService::hasRemoteFileChanged( void AbstractRemoteLinuxDeployService::setTarget(Target *target) { d->target = target; - d->deviceConfiguration = DeviceKitInformation::device(profile()); + d->deviceConfiguration = DeviceKitAspect::device(profile()); } void AbstractRemoteLinuxDeployService::setDevice(const IDevice::ConstPtr &device) diff --git a/src/plugins/remotelinux/deploymenttimeinfo.cpp b/src/plugins/remotelinux/deploymenttimeinfo.cpp index d3b9dcee61..e43dd75ca7 100644 --- a/src/plugins/remotelinux/deploymenttimeinfo.cpp +++ b/src/plugins/remotelinux/deploymenttimeinfo.cpp @@ -88,8 +88,8 @@ public: QString host; if (kit) { - systemRoot = SysRootKitInformation::sysRoot(kit).toString(); - const IDevice::ConstPtr deviceConfiguration = DeviceKitInformation::device(kit); + systemRoot = SysRootKitAspect::sysRoot(kit).toString(); + const IDevice::ConstPtr deviceConfiguration = DeviceKitAspect::device(kit); host = deviceConfiguration->sshParameters().host(); } diff --git a/src/plugins/remotelinux/embeddedlinuxqtversion.cpp b/src/plugins/remotelinux/embeddedlinuxqtversion.cpp index 1aad59919c..a163f418c4 100644 --- a/src/plugins/remotelinux/embeddedlinuxqtversion.cpp +++ b/src/plugins/remotelinux/embeddedlinuxqtversion.cpp @@ -35,13 +35,6 @@ namespace RemoteLinux { namespace Internal { -EmbeddedLinuxQtVersion::EmbeddedLinuxQtVersion(const Utils::FileName &path, bool isAutodetected, - const QString &autodetectionSource) - : BaseQtVersion(path, isAutodetected, autodetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - EmbeddedLinuxQtVersion *EmbeddedLinuxQtVersion::clone() const { return new EmbeddedLinuxQtVersion(*this); @@ -52,11 +45,6 @@ QString EmbeddedLinuxQtVersion::type() const return QLatin1String(RemoteLinux::Constants::EMBEDDED_LINUX_QT); } -QList<ProjectExplorer::Abi> EmbeddedLinuxQtVersion::detectQtAbis() const -{ - return qtAbisFromLibrary(qtCorePaths()); -} - QString EmbeddedLinuxQtVersion::description() const { return QCoreApplication::translate("QtVersion", "Embedded Linux", "Qt Version is used for embedded Linux development"); @@ -67,5 +55,25 @@ QSet<Core::Id> EmbeddedLinuxQtVersion::targetDeviceTypes() const return {Constants::GenericLinuxOsType}; } + +// Factory + +EmbeddedLinuxQtVersionFactory::EmbeddedLinuxQtVersionFactory() +{ + setQtVersionCreator([] { return new EmbeddedLinuxQtVersion; }); + setSupportedType(RemoteLinux::Constants::EMBEDDED_LINUX_QT); + setPriority(10); + + setRestrictionChecker([](const SetupData &) { + EmbeddedLinuxQtVersion tempVersion; + QList<ProjectExplorer::Abi> abis = tempVersion.qtAbis(); + + // Note: This fails for e.g. intel/meego cross builds on x86 linux machines. + return abis.count() == 1 + && abis.at(0).os() == ProjectExplorer::Abi::LinuxOS + && !ProjectExplorer::Abi::hostAbi().isCompatibleWith(abis.at(0)); + }); +} + } // namespace Internal } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/embeddedlinuxqtversion.h b/src/plugins/remotelinux/embeddedlinuxqtversion.h index f9b823e428..d929d81215 100644 --- a/src/plugins/remotelinux/embeddedlinuxqtversion.h +++ b/src/plugins/remotelinux/embeddedlinuxqtversion.h @@ -26,6 +26,7 @@ #pragma once #include <qtsupport/baseqtversion.h> +#include <qtsupport/qtversionfactory.h> namespace RemoteLinux { namespace Internal { @@ -34,18 +35,21 @@ class EmbeddedLinuxQtVersion : public QtSupport::BaseQtVersion { public: EmbeddedLinuxQtVersion() = default; - EmbeddedLinuxQtVersion(const Utils::FileName &path, bool isAutodetected = false, - const QString &autodetectionSource = QString()); + EmbeddedLinuxQtVersion *clone() const override; QString type() const override; - QList<ProjectExplorer::Abi> detectQtAbis() const override; - QString description() const override; QSet<Core::Id> targetDeviceTypes() const override; }; +class EmbeddedLinuxQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + EmbeddedLinuxQtVersionFactory(); +}; + } // namespace Internal } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/embeddedlinuxqtversionfactory.cpp b/src/plugins/remotelinux/embeddedlinuxqtversionfactory.cpp deleted file mode 100644 index c804c0a012..0000000000 --- a/src/plugins/remotelinux/embeddedlinuxqtversionfactory.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "embeddedlinuxqtversionfactory.h" - -#include "embeddedlinuxqtversion.h" -#include "remotelinux_constants.h" - -#include <QFileInfo> - -namespace RemoteLinux { -namespace Internal { - -EmbeddedLinuxQtVersionFactory::EmbeddedLinuxQtVersionFactory(QObject *parent) - : QtSupport::QtVersionFactory(parent) -{ -} - -EmbeddedLinuxQtVersionFactory::~EmbeddedLinuxQtVersionFactory() = default; - -bool EmbeddedLinuxQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(RemoteLinux::Constants::EMBEDDED_LINUX_QT); -} - -QtSupport::BaseQtVersion *EmbeddedLinuxQtVersionFactory::restore(const QString &type, const QVariantMap &data) -{ - if (!canRestore(type)) - return nullptr; - auto v = new EmbeddedLinuxQtVersion; - v->fromMap(data); - return v; -} - -int EmbeddedLinuxQtVersionFactory::priority() const -{ - return 10; -} - -QtSupport::BaseQtVersion *EmbeddedLinuxQtVersionFactory::create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected, - const QString &autoDetectionSource) -{ - Q_UNUSED(evaluator); - - QFileInfo fi = qmakePath.toFileInfo(); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return nullptr; - - auto version = new EmbeddedLinuxQtVersion(qmakePath, isAutoDetected, autoDetectionSource); - - QList<ProjectExplorer::Abi> abis = version->qtAbis(); - // Note: This fails for e.g. intel/meego cross builds on x86 linux machines. - if (abis.count() == 1 - && abis.at(0).os() == ProjectExplorer::Abi::LinuxOS - && !ProjectExplorer::Abi::hostAbi().isCompatibleWith(abis.at(0))) - return version; - - delete version; - return nullptr; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/embeddedlinuxqtversionfactory.h b/src/plugins/remotelinux/embeddedlinuxqtversionfactory.h deleted file mode 100644 index 7737a8de7a..0000000000 --- a/src/plugins/remotelinux/embeddedlinuxqtversionfactory.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <qtsupport/qtversionfactory.h> - -namespace RemoteLinux { -namespace Internal { - -class EmbeddedLinuxQtVersionFactory : public QtSupport::QtVersionFactory -{ -public: - explicit EmbeddedLinuxQtVersionFactory(QObject *parent = nullptr); - ~EmbeddedLinuxQtVersionFactory() override; - - bool canRestore(const QString &type) override; - QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data) override; - - int priority() const override; - QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()) override; -}; - -} // Internal -} // RemoteLinux diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 027cc59b22..b1cab71cfa 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -4,7 +4,6 @@ include(../../qtcreatorplugin.pri) HEADERS += \ embeddedlinuxqtversion.h \ - embeddedlinuxqtversionfactory.h \ remotelinuxenvironmentaspect.h \ remotelinuxenvironmentaspectwidget.h \ remotelinuxplugin.h \ @@ -49,7 +48,6 @@ HEADERS += \ SOURCES += \ embeddedlinuxqtversion.cpp \ - embeddedlinuxqtversionfactory.cpp \ remotelinuxenvironmentaspect.cpp \ remotelinuxenvironmentaspectwidget.cpp \ remotelinuxplugin.cpp \ diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 1f553d662b..7eebf0b3f8 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -29,8 +29,6 @@ Project { "deploymenttimeinfo.h", "embeddedlinuxqtversion.cpp", "embeddedlinuxqtversion.h", - "embeddedlinuxqtversionfactory.cpp", - "embeddedlinuxqtversionfactory.h", "genericdirectuploadservice.cpp", "genericdirectuploadservice.h", "genericdirectuploadstep.cpp", diff --git a/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp b/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp index 11723a5a25..5f2ad0b594 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp @@ -63,11 +63,11 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory() addInitialStep(RemoteLinuxCheckForFreeDiskSpaceStep::stepId()); addInitialStep(RemoteLinuxKillAppStep::stepId()); addInitialStep(RsyncDeployStep::stepId(), [](Target *target) { - auto device = DeviceKitInformation::device(target->kit()).staticCast<const LinuxDevice>(); + auto device = DeviceKitAspect::device(target->kit()).staticCast<const LinuxDevice>(); return device && device->supportsRSync(); }); addInitialStep(GenericDirectUploadStep::stepId(), [](Target *target) { - auto device = DeviceKitInformation::device(target->kit()).staticCast<const LinuxDevice>(); + auto device = DeviceKitAspect::device(target->kit()).staticCast<const LinuxDevice>(); return device && !device->supportsRSync(); }); } diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp index 4f06d741e7..28e87fd880 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp @@ -50,7 +50,7 @@ RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget (RemoteLinuxEnvironmentAspect *aspect, Target *target) : EnvironmentAspectWidget(aspect, new QPushButton) { - IDevice::ConstPtr device = DeviceKitInformation::device(target->kit()); + IDevice::ConstPtr device = DeviceKitAspect::device(target->kit()); deviceEnvReader = new RemoteLinuxEnvironmentReader(device, this); connect(target, &ProjectExplorer::Target::kitChanged, diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 25b8eb5e89..e305e472e2 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -25,7 +25,7 @@ #include "remotelinuxplugin.h" -#include "embeddedlinuxqtversionfactory.h" +#include "embeddedlinuxqtversion.h" #include "genericlinuxdeviceconfigurationfactory.h" #include "remotelinux_constants.h" #include "remotelinuxqmltoolingsupport.h" @@ -103,7 +103,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments, QString *errorM dd = new RemoteLinuxPluginPrivate; auto constraint = [](RunConfiguration *runConfig) { - const Core::Id devType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId( + const Core::Id devType = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId( runConfig->target()->kit()); if (devType != Constants::GenericLinuxOsType) diff --git a/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp b/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp index 56068064ec..86a9d608fa 100644 --- a/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp +++ b/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp @@ -126,7 +126,7 @@ bool TypeSpecificDeviceConfigurationListModel::deviceMatches(IDevice::ConstPtr d { if (dev.isNull()) return false; - Core::Id typeId = DeviceTypeKitInformation::deviceTypeId(target()->kit()); + Core::Id typeId = DeviceTypeKitAspect::deviceTypeId(target()->kit()); return dev->type() == typeId; } diff --git a/src/plugins/texteditor/refactoroverlay.cpp b/src/plugins/texteditor/refactoroverlay.cpp index 65ef1dae0a..33a18f818f 100644 --- a/src/plugins/texteditor/refactoroverlay.cpp +++ b/src/plugins/texteditor/refactoroverlay.cpp @@ -81,8 +81,9 @@ void RefactorOverlay::paintMarker(const RefactorMarker& marker, QPainter *painte icon = m_icon; const qreal devicePixelRatio = painter->device()->devicePixelRatio(); - const QSize proposedIconSize = QSize(m_editor->fontMetrics().width(QLatin1Char(' ')) + 3, - cursorRect.height()) * devicePixelRatio; + const QSize proposedIconSize = + QSize(m_editor->fontMetrics().horizontalAdvance(QLatin1Char(' ')) + 3, + cursorRect.height()) * devicePixelRatio; const QSize actualIconSize = icon.actualSize(proposedIconSize) / devicePixelRatio; const int y = cursorRect.top() + ((cursorRect.height() - actualIconSize.height()) / 2); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 235ac7f673..0eadd070e3 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3722,7 +3722,7 @@ QTextBlock TextEditorWidgetPrivate::foldedBlockAt(const QPoint &pos, QRect *box) QRectF collapseRect(lineRect.right() + 12, lineRect.top(), - q->fontMetrics().width(replacement), + q->fontMetrics().horizontalAdvance(replacement), lineRect.height()); if (collapseRect.contains(pos)) { QTextBlock result = block; @@ -4213,7 +4213,7 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data, const qreal itemOffset = q->fontMetrics().lineSpacing(); const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2; - const qreal minimalContentWidth = q->fontMetrics().width('X') + const qreal minimalContentWidth = q->fontMetrics().horizontalAdvance('X') * m_displaySettings.m_minimalAnnotationContent; qreal offset = initialOffset; qreal x = 0; @@ -4529,7 +4529,7 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP QString text = data.block.text(); const TabSettings tabSettings = m_document->tabSettings(); const qreal spacew = QFontMetricsF(q->font()).width(QLatin1Char(' ')); - const int cursorw = q->overwriteMode() ? QFontMetrics(q->font()).width(QLatin1Char(' ')) + const int cursorw = q->overwriteMode() ? QFontMetrics(q->font()).horizontalAdvance(QLatin1Char(' ')) : q->cursorWidth(); int startOffset = 0; @@ -4688,7 +4688,7 @@ void TextEditorWidgetPrivate::paintReplacement(PaintEventData &data, QPainter &p QRectF collapseRect(lineRect.right() + 12, lineRect.top(), - q->fontMetrics().width(rectReplacement), + q->fontMetrics().horizontalAdvance(rectReplacement), lineRect.height()); painter.setRenderHint(QPainter::Antialiasing, true); painter.translate(.5, .5); @@ -5084,7 +5084,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const fnt.setItalic(currentLineNumberFormat.font().italic()); const QFontMetrics linefm(fnt); - space += linefm.width(QLatin1Char('9')) * lineNumberDigits(); + space += linefm.horizontalAdvance(QLatin1Char('9')) * lineNumberDigits(); } int markWidth = 0; @@ -6620,7 +6620,7 @@ void TextEditorAnimator::init(const QTextCursor &cursor, const QFont &f, const Q m_palette = pal; m_text = cursor.selectedText(); QFontMetrics fm(m_font); - m_size = QSizeF(fm.width(m_text), fm.height()); + m_size = QSizeF(fm.horizontalAdvance(m_text), fm.height()); } void TextEditorAnimator::draw(QPainter *p, const QPointF &pos) @@ -6630,7 +6630,7 @@ void TextEditorAnimator::draw(QPainter *p, const QPointF &pos) QFont f = m_font; f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2)); QFontMetrics fm(f); - int width = fm.width(m_text); + int width = fm.horizontalAdvance(m_text); QRectF r((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height()); r.translate(pos); p->fillRect(r, m_palette.base()); @@ -6648,7 +6648,7 @@ QRectF TextEditorAnimator::rect() const QFont f = m_font; f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2)); QFontMetrics fm(f); - int width = fm.width(m_text); + int width = fm.horizontalAdvance(m_text); return QRectF((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height()); } @@ -8261,11 +8261,7 @@ void TextEditorWidgetPrivate::updateTabStops() // to be set as an int. A work around is to access directly the QTextOption. qreal charWidth = QFontMetricsF(q->font()).width(QLatin1Char(' ')); QTextOption option = q->document()->defaultTextOption(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) option.setTabStopDistance(charWidth * m_document->tabSettings().m_tabSize); -#else - option.setTabStop(charWidth * m_document->tabSettings().m_tabSize); -#endif q->document()->setDefaultTextOption(option); } diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 49ce797f88..a881480d95 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -182,7 +182,7 @@ TextMark::AnnotationRects TextMark::annotationRects(const QRectF &boundingRect, if (drawIcon) rects.iconRect.setWidth(rects.iconRect.height() * m_widthFactor); rects.textRect = QRectF(rects.iconRect.right() + margin, boundingRect.top(), - qreal(fm.width(rects.text)), boundingRect.height()); + qreal(fm.horizontalAdvance(rects.text)), boundingRect.height()); rects.annotationRect.setRight(rects.textRect.right() + margin); if (rects.annotationRect.right() > boundingRect.right()) { rects.textRect.setRight(boundingRect.right() - margin); diff --git a/src/plugins/valgrind/callgrindcostdelegate.cpp b/src/plugins/valgrind/callgrindcostdelegate.cpp index 32fa1e9185..ff70a5f98b 100644 --- a/src/plugins/valgrind/callgrindcostdelegate.cpp +++ b/src/plugins/valgrind/callgrindcostdelegate.cpp @@ -154,7 +154,7 @@ QSize CostDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd initStyleOption(&opt, index); const QString text = d->displayText(index, opt.locale); - const QSize size = QSize(option.fontMetrics.width(text), + const QSize size = QSize(option.fontMetrics.horizontalAdvance(text), option.fontMetrics.height()); return size; } diff --git a/src/plugins/valgrind/callgrindvisualisation.cpp b/src/plugins/valgrind/callgrindvisualisation.cpp index b96bdd71b8..f7ba16931c 100644 --- a/src/plugins/valgrind/callgrindvisualisation.cpp +++ b/src/plugins/valgrind/callgrindvisualisation.cpp @@ -139,7 +139,7 @@ void FunctionGraphicsTextItem::paint(QPainter *painter, painter->save(); int textLeft = 0; int textTop = 0; - const int textWidth = painter->fontMetrics().width(m_staticText.text()); + const int textWidth = painter->fontMetrics().horizontalAdvance(m_staticText.text()); textLeft = -textWidth/2; textTop = (maxHeight - textHeight)/2; painter->drawStaticText(textLeft, textTop, m_staticText); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index aaea6ba4d5..c32a2a1ab7 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -709,14 +709,14 @@ void MemcheckTool::heobAction() if (RunConfiguration *rc = target->activeRunConfiguration()) { kit = target->kit(); if (kit) { - abi = ToolChainKitInformation::targetAbi(kit); + abi = ToolChainKitAspect::targetAbi(kit); const Runnable runnable = rc->runnable(); sr = runnable; const IDevice::ConstPtr device = sr.device; hasLocalRc = device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; if (!hasLocalRc) - hasLocalRc = DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; + hasLocalRc = DeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } } } @@ -1512,7 +1512,7 @@ void HeobData::processFinished() auto debugger = new DebuggerRunTool(m_runControl, m_kit); debugger->setAttachPid(ProcessHandle(m_data[1])); debugger->setRunControlName(tr("Process %1").arg(m_data[1])); - debugger->setInferiorDevice(DeviceKitInformation::device(m_kit)); + debugger->setInferiorDevice(DeviceKitAspect::device(m_kit)); debugger->setStartMode(AttachExternal); debugger->setCloseMode(DetachAtClose); debugger->setContinueAfterAttach(true); diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro index 15b4a3bb98..313dbba189 100644 --- a/src/plugins/winrt/winrt.pro +++ b/src/plugins/winrt/winrt.pro @@ -10,7 +10,6 @@ HEADERS += \ winrtphoneqtversion.h \ winrtplugin.h \ winrtqtversion.h \ - winrtqtversionfactory.h \ winrtrunconfiguration.h \ winrtruncontrol.h \ winrtrunnerhelper.h @@ -24,7 +23,6 @@ SOURCES += \ winrtphoneqtversion.cpp \ winrtplugin.cpp \ winrtqtversion.cpp \ - winrtqtversionfactory.cpp \ winrtrunconfiguration.cpp \ winrtruncontrol.cpp \ winrtrunnerhelper.cpp diff --git a/src/plugins/winrt/winrt.qbs b/src/plugins/winrt/winrt.qbs index 9053161c5c..931f29545c 100644 --- a/src/plugins/winrt/winrt.qbs +++ b/src/plugins/winrt/winrt.qbs @@ -29,8 +29,6 @@ QtcPlugin { "winrtplugin.h", "winrtqtversion.cpp", "winrtqtversion.h", - "winrtqtversionfactory.cpp", - "winrtqtversionfactory.h", "winrtrunconfiguration.cpp", "winrtrunconfiguration.h", "winrtruncontrol.cpp", diff --git a/src/plugins/winrt/winrtpackagedeploymentstep.cpp b/src/plugins/winrt/winrtpackagedeploymentstep.cpp index 6798338227..093947c64d 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstep.cpp +++ b/src/plugins/winrt/winrtpackagedeploymentstep.cpp @@ -87,7 +87,7 @@ bool WinRtPackageDeploymentStep::init() if (!m_targetDirPath.endsWith(QLatin1Char('/'))) m_targetDirPath += QLatin1Char('/'); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit()); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target()->kit()); if (!qt) return false; @@ -116,7 +116,7 @@ bool WinRtPackageDeploymentStep::init() void WinRtPackageDeploymentStep::doRun() { - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit()); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target()->kit()); if (!qt) return; diff --git a/src/plugins/winrt/winrtphoneqtversion.cpp b/src/plugins/winrt/winrtphoneqtversion.cpp index e3e2aa65e5..c1a657dc61 100644 --- a/src/plugins/winrt/winrtphoneqtversion.cpp +++ b/src/plugins/winrt/winrtphoneqtversion.cpp @@ -35,12 +35,6 @@ namespace WinRt { namespace Internal { -WinRtPhoneQtVersion::WinRtPhoneQtVersion(const Utils::FileName &path, bool isAutodetected, - const QString &autodetectionSource) - : WinRtQtVersion(path, isAutodetected, autodetectionSource) -{ -} - QString WinRtPhoneQtVersion::description() const { return tr("Windows Phone"); @@ -61,5 +55,25 @@ QSet<Core::Id> WinRtPhoneQtVersion::targetDeviceTypes() const return {Constants::WINRT_DEVICE_TYPE_PHONE, Constants::WINRT_DEVICE_TYPE_EMULATOR}; } +QSet<Core::Id> WinRtPhoneQtVersion::availableFeatures() const +{ + QSet<Core::Id> features = QtSupport::BaseQtVersion::availableFeatures(); + features.insert(QtSupport::Constants::FEATURE_MOBILE); + features.remove(QtSupport::Constants::FEATURE_QT_CONSOLE); + features.remove(Core::Id::versionedId(QtSupport::Constants::FEATURE_QT_QUICK_CONTROLS_PREFIX, 1)); + features.remove(QtSupport::Constants::FEATURE_QT_WEBKIT); + return features; +} + +// Factory + +WinRtPhoneQtVersionFactory::WinRtPhoneQtVersionFactory() +{ + setQtVersionCreator([] { return new WinRtPhoneQtVersion; }); + setSupportedType(Constants::WINRT_WINPHONEQT); + setRestrictionChecker([](const SetupData &setup) { return setup.platforms.contains("winphone"); }); + setPriority(10); +} + } // Internal } // WinRt diff --git a/src/plugins/winrt/winrtphoneqtversion.h b/src/plugins/winrt/winrtphoneqtversion.h index bbb8bd9764..c99c0e9c35 100644 --- a/src/plugins/winrt/winrtphoneqtversion.h +++ b/src/plugins/winrt/winrtphoneqtversion.h @@ -30,18 +30,24 @@ namespace WinRt { namespace Internal { -class WinRtPhoneQtVersion : public WinRtQtVersion +class WinRtPhoneQtVersion : public QtSupport::BaseQtVersion { Q_DECLARE_TR_FUNCTIONS(WinRt::Internal::WinRtQtVersion) public: WinRtPhoneQtVersion() = default; - WinRtPhoneQtVersion(const Utils::FileName &path, bool isAutodetected, - const QString &autodetectionSource); - QString description() const; - BaseQtVersion *clone() const; - QString type() const; - QSet<Core::Id> targetDeviceTypes() const; + QSet<Core::Id> availableFeatures() const override; + + QString description() const override; + BaseQtVersion *clone() const override; + QString type() const override; + QSet<Core::Id> targetDeviceTypes() const override; +}; + +class WinRtPhoneQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + WinRtPhoneQtVersionFactory(); }; } // Internal diff --git a/src/plugins/winrt/winrtplugin.cpp b/src/plugins/winrt/winrtplugin.cpp index e2156b6d82..d1479014ad 100644 --- a/src/plugins/winrt/winrtplugin.cpp +++ b/src/plugins/winrt/winrtplugin.cpp @@ -28,7 +28,8 @@ #include "winrtdevice.h" #include "winrtdevicefactory.h" #include "winrtdeployconfiguration.h" -#include "winrtqtversionfactory.h" +#include "winrtqtversion.h" +#include "winrtphoneqtversion.h" #include "winrtrunconfiguration.h" #include "winrtruncontrol.h" #include "winrtdebugsupport.h" @@ -48,6 +49,7 @@ class WinRtPluginRunData public: WinRtRunConfigurationFactory runConfigFactory; WinRtQtVersionFactory qtVersionFactory; + WinRtPhoneQtVersionFactory phoneQtVersionFactory; WinRtAppDeployConfigurationFactory appDeployConfigFactory; WinRtPhoneDeployConfigurationFactory phoneDeployConfigFactory; WinRtEmulatorDeployConfigurationFactory emulatorDeployFactory; @@ -75,14 +77,14 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage m_runData = new WinRtPluginRunData; auto runConstraint = [](RunConfiguration *runConfig) { - IDevice::ConstPtr device = DeviceKitInformation::device(runConfig->target()->kit()); + IDevice::ConstPtr device = DeviceKitAspect::device(runConfig->target()->kit()); if (!device) return false; return qobject_cast<WinRtRunConfiguration *>(runConfig) != nullptr; }; auto debugConstraint = [](RunConfiguration *runConfig) { - IDevice::ConstPtr device = DeviceKitInformation::device(runConfig->target()->kit()); + IDevice::ConstPtr device = DeviceKitAspect::device(runConfig->target()->kit()); if (!device) return false; if (device->type() != Internal::Constants::WINRT_DEVICE_TYPE_LOCAL) diff --git a/src/plugins/winrt/winrtqtversion.cpp b/src/plugins/winrt/winrtqtversion.cpp index 082eafd1e9..24e13cfec3 100644 --- a/src/plugins/winrt/winrtqtversion.cpp +++ b/src/plugins/winrt/winrtqtversion.cpp @@ -33,13 +33,6 @@ namespace WinRt { namespace Internal { -WinRtQtVersion::WinRtQtVersion(const Utils::FileName &path, bool isAutodetected, - const QString &autodetectionSource) - : BaseQtVersion(path, isAutodetected, autodetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - QtSupport::BaseQtVersion *WinRtQtVersion::clone() const { return new WinRtQtVersion(*this); @@ -65,14 +58,20 @@ QSet<Core::Id> WinRtQtVersion::availableFeatures() const return features; } -QList<ProjectExplorer::Abi> WinRtQtVersion::detectQtAbis() const +QSet<Core::Id> WinRtQtVersion::targetDeviceTypes() const { - return qtAbisFromLibrary(qtCorePaths()); + return {Constants::WINRT_DEVICE_TYPE_LOCAL, Constants::WINRT_DEVICE_TYPE_EMULATOR}; } -QSet<Core::Id> WinRtQtVersion::targetDeviceTypes() const + +// Factory + +WinRtQtVersionFactory::WinRtQtVersionFactory() { - return {Constants::WINRT_DEVICE_TYPE_LOCAL, Constants::WINRT_DEVICE_TYPE_EMULATOR}; + setQtVersionCreator([] { return new WinRtQtVersion; }); + setSupportedType(Constants::WINRT_WINRTQT); + setRestrictionChecker([](const SetupData &setup) { return setup.platforms.contains("winrt"); }); + setPriority(10); } } // Internal diff --git a/src/plugins/winrt/winrtqtversion.h b/src/plugins/winrt/winrtqtversion.h index f3a4fc9d3b..e966df6901 100644 --- a/src/plugins/winrt/winrtqtversion.h +++ b/src/plugins/winrt/winrtqtversion.h @@ -26,6 +26,7 @@ #pragma once #include <qtsupport/baseqtversion.h> +#include <qtsupport/qtversionfactory.h> namespace WinRt { namespace Internal { @@ -35,16 +36,19 @@ class WinRtQtVersion : public QtSupport::BaseQtVersion Q_DECLARE_TR_FUNCTIONS(WinRt::Internal::WinRtQtVersion) public: WinRtQtVersion() = default; - WinRtQtVersion(const Utils::FileName &path, bool isAutodetected, - const QString &autodetectionSource); - BaseQtVersion *clone() const; - QString type() const; - QString description() const; - QSet<Core::Id> availableFeatures() const; - QList<ProjectExplorer::Abi> detectQtAbis() const; + BaseQtVersion *clone() const override; + QString type() const override; + QString description() const override; + QSet<Core::Id> availableFeatures() const override; - QSet<Core::Id> targetDeviceTypes() const; + QSet<Core::Id> targetDeviceTypes() const override; +}; + +class WinRtQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + WinRtQtVersionFactory(); }; } // Internal diff --git a/src/plugins/winrt/winrtqtversionfactory.cpp b/src/plugins/winrt/winrtqtversionfactory.cpp deleted file mode 100644 index 2daf2e3612..0000000000 --- a/src/plugins/winrt/winrtqtversionfactory.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "winrtqtversionfactory.h" - -#include "winrtconstants.h" -#include "winrtphoneqtversion.h" - -#include <proparser/profileevaluator.h> - -#include <QFileInfo> - -namespace WinRt { -namespace Internal { - -WinRtQtVersionFactory::WinRtQtVersionFactory(QObject *parent) - : QtSupport::QtVersionFactory(parent) -{ -} - -WinRtQtVersionFactory::~WinRtQtVersionFactory() -{ -} - -bool WinRtQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::WINRT_WINRTQT) - || type == QLatin1String(Constants::WINRT_WINPHONEQT); -} - -QtSupport::BaseQtVersion *WinRtQtVersionFactory::restore(const QString &type, - const QVariantMap &data) -{ - if (!canRestore(type)) - return nullptr; - WinRtQtVersion *v = nullptr; - if (type == QLatin1String(Constants::WINRT_WINPHONEQT)) - v = new WinRtPhoneQtVersion; - else - v = new WinRtQtVersion; - v->fromMap(data); - return v; -} - -int WinRtQtVersionFactory::priority() const -{ - return 10; -} - -QtSupport::BaseQtVersion *WinRtQtVersionFactory::create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) -{ - QFileInfo fi = qmakePath.toFileInfo(); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return nullptr; - - bool isWinRt = false; - bool isPhone = false; - foreach (const QString &value, evaluator->values(QLatin1String("QMAKE_PLATFORM"))) { - if (value == QStringLiteral("winrt")) { - isWinRt = true; - } else if (value == QStringLiteral("winphone")) { - isWinRt = true; - isPhone = true; - break; - } - } - - if (!isWinRt) - return nullptr; - - return isPhone ? new WinRtPhoneQtVersion(qmakePath, isAutoDetected, autoDetectionSource) - : new WinRtQtVersion(qmakePath, isAutoDetected, autoDetectionSource); -} - -} // Internal -} // WinRt diff --git a/src/plugins/winrt/winrtrunconfiguration.cpp b/src/plugins/winrt/winrtrunconfiguration.cpp index 09986bd95b..663ffdea91 100644 --- a/src/plugins/winrt/winrtrunconfiguration.cpp +++ b/src/plugins/winrt/winrtrunconfiguration.cpp @@ -71,7 +71,7 @@ WinRtRunConfiguration::WinRtRunConfiguration(Target *target, Core::Id id) addAspect<UninstallAfterStopAspect>(); const QtSupport::BaseQtVersion *qt - = QtSupport::QtKitInformation::qtVersion(target->kit()); + = QtSupport::QtKitAspect::qtVersion(target->kit()); if (qt && qt->qtVersion() >= QtSupport::QtVersionNumber(5, 12, 0)) { addAspect<LoopbackExemptClientAspect>(); addAspect<LoopbackExemptServerAspect>(); diff --git a/src/plugins/winrt/winrtruncontrol.cpp b/src/plugins/winrt/winrtruncontrol.cpp index d8faa0ab48..c5a365edef 100644 --- a/src/plugins/winrt/winrtruncontrol.cpp +++ b/src/plugins/winrt/winrtruncontrol.cpp @@ -41,7 +41,7 @@ #include <QTimer> -using ProjectExplorer::DeviceKitInformation; +using ProjectExplorer::DeviceKitAspect; using ProjectExplorer::IDevice; using ProjectExplorer::RunControl; using Core::Id; diff --git a/src/plugins/winrt/winrtrunnerhelper.cpp b/src/plugins/winrt/winrtrunnerhelper.cpp index 1ddc49c005..bbb17f67b3 100644 --- a/src/plugins/winrt/winrtrunnerhelper.cpp +++ b/src/plugins/winrt/winrtrunnerhelper.cpp @@ -55,7 +55,7 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr ProjectExplorer::Target *target = runConfiguration->target(); m_device = runWorker->device().dynamicCast<const WinRtDevice>(); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target->kit()); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit()); if (!qt) { *errorMessage = tr("The current kit has no Qt version."); return; |