diff options
author | Eike Ziller <eike.ziller@qt.io> | 2021-01-29 10:01:03 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2021-01-29 15:04:05 +0000 |
commit | c245a642f24ce243fe5e39929f158c577d3c1cf1 (patch) | |
tree | b2983b527f7165a5f7e35a14ea74a86294d5c38c | |
parent | aae3ce15aa72631e290b4eb6d0e163706b10390b (diff) |
Share "auto-detected" UI string and add tool tip
No need to have the same translatable string repeated at all these
places.
Also add tooltip to expand a bit on what "auto-detected" actually means.
Task-number: QTCREATORBUG-25291
Change-Id: I25d43486758ba17256cf7e1ea2eea0ec3d567b62
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/libs/utils/treemodel.cpp | 7 | ||||
-rw-r--r-- | src/libs/utils/treemodel.h | 2 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakesettingspage.cpp | 4 | ||||
-rw-r--r-- | src/plugins/coreplugin/icore.cpp | 5 | ||||
-rw-r--r-- | src/plugins/coreplugin/icore.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggeritemmanager.cpp | 6 | ||||
-rw-r--r-- | src/plugins/mesonprojectmanager/settings/tools/toolsmodel.cpp | 7 | ||||
-rw-r--r-- | src/plugins/projectexplorer/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitmodel.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.pro | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.qbs | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorerconstants.cpp | 54 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorerconstants.h | 7 | ||||
-rw-r--r-- | src/plugins/projectexplorer/toolchainoptionspage.cpp | 5 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtoptionspage.cpp | 5 |
15 files changed, 102 insertions, 13 deletions
diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index 539577d88f..22e59b488f 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -1186,10 +1186,17 @@ StaticTreeItem::StaticTreeItem(const QString &display) { } +StaticTreeItem::StaticTreeItem(const QStringList &displays, const QStringList &toolTips) + : m_displays(displays) + , m_toolTips(toolTips) +{} + QVariant StaticTreeItem::data(int column, int role) const { if (role == Qt::DisplayRole && column >= 0 && column < m_displays.size()) return m_displays.at(column); + if (role == Qt::ToolTipRole && column >= 0 && column < m_toolTips.size()) + return m_toolTips.at(column); return QVariant(); } diff --git a/src/libs/utils/treemodel.h b/src/libs/utils/treemodel.h index c7406c2ebe..53a6a3900e 100644 --- a/src/libs/utils/treemodel.h +++ b/src/libs/utils/treemodel.h @@ -165,12 +165,14 @@ class QTCREATOR_UTILS_EXPORT StaticTreeItem : public TreeItem public: StaticTreeItem(const QStringList &displays); StaticTreeItem(const QString &display); + StaticTreeItem(const QStringList &displays, const QStringList &toolTips); QVariant data(int column, int role) const override; Qt::ItemFlags flags(int column) const override; private: QStringList m_displays; + QStringList m_toolTips; }; // A general purpose multi-level model where each item can have its diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp index 30e1a50dd3..2089f55745 100644 --- a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp +++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp @@ -232,7 +232,9 @@ public: CMakeToolItemModel::CMakeToolItemModel() { setHeader({tr("Name"), tr("Location")}); - rootItem()->appendChild(new StaticTreeItem(tr("Auto-detected"))); + rootItem()->appendChild( + new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()})); rootItem()->appendChild(new StaticTreeItem(tr("Manual"))); foreach (const CMakeTool *item, CMakeToolManager::cmakeTools()) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index dca6bde7be..01c66f2ec0 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -490,6 +490,11 @@ QString ICore::crashReportsPath() return libexecPath() + "/crashpad_reports/reports"; } +QString ICore::ideDisplayName() +{ + return Constants::IDE_DISPLAY_NAME; +} + static QString clangIncludePath(const QString &clangVersion) { return "/lib/clang/" + clangVersion + "/include"; diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index 7d8adbfa68..565e0b8faa 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -101,6 +101,8 @@ public: static QString libexecPath(); static QString crashReportsPath(); + static QString ideDisplayName(); + static QString versionString(); static QMainWindow *mainWindow(); diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index b814199c77..668b560793 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -223,8 +223,10 @@ const DebuggerItem *findDebugger(const Predicate &pred) DebuggerItemModel::DebuggerItemModel() { setHeader({tr("Name"), tr("Location"), tr("Type")}); - rootItem()->appendChild(new StaticTreeItem(tr("Auto-detected"))); - rootItem()->appendChild(new StaticTreeItem(tr("Manual"))); + rootItem()->appendChild( + new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()})); + rootItem()->appendChild(new StaticTreeItem(ProjectExplorer::Constants::msgManual())); } void DebuggerItemModel::addDebugger(const DebuggerItem &item, bool changed) diff --git a/src/plugins/mesonprojectmanager/settings/tools/toolsmodel.cpp b/src/plugins/mesonprojectmanager/settings/tools/toolsmodel.cpp index 6bdd0a54f8..8d24e40cc0 100644 --- a/src/plugins/mesonprojectmanager/settings/tools/toolsmodel.cpp +++ b/src/plugins/mesonprojectmanager/settings/tools/toolsmodel.cpp @@ -28,6 +28,7 @@ #include "tooltreeitem.h" #include "exewrappers/mesontools.h" +#include <projectexplorer/projectexplorerconstants.h> #include <utils/qtcassert.h> #include <utils/stringutils.h> @@ -37,8 +38,10 @@ namespace Internal { ToolsModel::ToolsModel() { setHeader({tr("Name"), tr("Location")}); - rootItem()->appendChild(new Utils::StaticTreeItem(tr("Auto-detected"))); - rootItem()->appendChild(new Utils::StaticTreeItem(tr("Manual"))); + rootItem()->appendChild( + new Utils::StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()})); + rootItem()->appendChild(new Utils::StaticTreeItem(ProjectExplorer::Constants::msgManual())); for (const auto &tool : MesonTools::tools()) { addMesonTool(tool); } diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index 87e3a45bfd..fbc61e9a1a 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -131,6 +131,7 @@ add_qtc_plugin(ProjectExplorer projectexplorer.cpp projectexplorer.h projectexplorer.qrc projectexplorer_export.h + projectexplorerconstants.cpp projectexplorerconstants.h projectexplorericons.cpp projectexplorericons.h projectexplorersettings.h diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index 5f157dcbb3..0bb09cf951 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -29,9 +29,10 @@ #include "kitmanagerconfigwidget.h" #include "kitmanager.h" -#include <utils/utilsicons.h> +#include <projectexplorer/projectexplorerconstants.h> #include <utils/algorithm.h> #include <utils/qtcassert.h> +#include <utils/utilsicons.h> #include <QApplication> #include <QLayout> @@ -106,8 +107,9 @@ KitModel::KitModel(QBoxLayout *parentLayout, QObject *parent) m_parentLayout(parentLayout) { setHeader(QStringList(tr("Name"))); - m_autoRoot = new StaticTreeItem(tr("Auto-detected")); - m_manualRoot = new StaticTreeItem(tr("Manual")); + m_autoRoot = new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()}); + m_manualRoot = new StaticTreeItem(ProjectExplorer::Constants::msgManual()); rootItem()->appendChild(m_autoRoot); rootItem()->appendChild(m_manualRoot); diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 520f63d227..89771190dd 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -212,6 +212,7 @@ SOURCES += projectexplorer.cpp \ ioutputparser.cpp \ projectconfiguration.cpp \ gnumakeparser.cpp \ + projectexplorerconstants.cpp \ task.cpp \ copytaskhandler.cpp \ showineditortaskhandler.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 002a620f01..204049eaed 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -111,6 +111,7 @@ Project { "projectexplorer.cpp", "projectexplorer.h", "projectexplorer.qrc", "projectexplorer_export.h", + "projectexplorerconstants.cpp", "projectexplorerconstants.h", "projectexplorericons.h", "projectexplorericons.cpp", "projectexplorersettings.h", diff --git a/src/plugins/projectexplorer/projectexplorerconstants.cpp b/src/plugins/projectexplorer/projectexplorerconstants.cpp new file mode 100644 index 0000000000..e3b609bca1 --- /dev/null +++ b/src/plugins/projectexplorer/projectexplorerconstants.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 "projectexplorerconstants.h" + +#include <coreplugin/icore.h> + +#include <QCoreApplication> +#include <QString> + +namespace ProjectExplorer { +namespace Constants { + +QString msgAutoDetected() +{ + return QCoreApplication::translate("ProjectExplorer", "Auto-detected"); +} + +QString msgAutoDetectedToolTip() +{ + return QCoreApplication::translate("ProjectExplorer", + "Automatically managed by %1 or the installer.") + .arg(Core::ICore::ideDisplayName()); +} + +QString msgManual() +{ + return QCoreApplication::translate("ProjectExplorer", "Manual"); +} + +} // namespace Constants +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index b91632e9b8..5bc3a8da3f 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -25,7 +25,7 @@ #pragma once -#include <QtGlobal> +#include "projectexplorer_export.h" namespace ProjectExplorer { namespace Constants { @@ -230,5 +230,10 @@ const char PROJECT_ROOT_PATH_KEY[] = "ProjectExplorer.Project.RootPath"; const char STARTUPSESSION_KEY[] = "ProjectExplorer/SessionToRestore"; const char LASTSESSION_KEY[] = "ProjectExplorer/StartupSession"; +// UI texts +PROJECTEXPLORER_EXPORT QString msgAutoDetected(); +PROJECTEXPLORER_EXPORT QString msgAutoDetectedToolTip(); +PROJECTEXPLORER_EXPORT QString msgManual(); + } // namespace Constants } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp index 42f1002608..470eaa02da 100644 --- a/src/plugins/projectexplorer/toolchainoptionspage.cpp +++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp @@ -161,8 +161,9 @@ public: [](ToolChainFactory *factory) { return factory->canCreate();}); m_model.setHeader({ToolChainOptionsPage::tr("Name"), ToolChainOptionsPage::tr("Type")}); - auto autoRoot = new StaticTreeItem(ToolChainOptionsPage::tr("Auto-detected")); - auto manualRoot = new StaticTreeItem(ToolChainOptionsPage::tr("Manual")); + auto autoRoot = new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()}); + auto manualRoot = new StaticTreeItem(ProjectExplorer::Constants::msgManual()); foreach (const Utils::Id &l, ToolChainManager::allLanguages()) { const QString dn = ToolChainManager::displayNameOfLanguageId(l); diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index f974a90685..b5a227f301 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -261,8 +261,9 @@ QtOptionsPageWidget::QtOptionsPageWidget() m_ui.versionInfoWidget->setWidget(versionInfoWidget); m_ui.versionInfoWidget->setState(DetailsWidget::NoSummary); - m_autoItem = new StaticTreeItem(tr("Auto-detected")); - m_manualItem = new StaticTreeItem(tr("Manual")); + m_autoItem = new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()}); + m_manualItem = new StaticTreeItem(ProjectExplorer::Constants::msgManual()); m_model = new TreeModel<TreeItem, TreeItem, QtVersionItem>(); m_model->setHeader({tr("Name"), tr("qmake Location")}); |