From 1f5f76cdf967e09ff33239784c186a79c212fb2a Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 14 Nov 2023 18:00:47 +0100 Subject: [PATCH] Core: Move generation of "about" text to ICore This introduces ICore::aboutInformationCompact() and ICore::aboutInformationHtml() and moves the existing code there. The former is used in the "System Information" dialog, the latter in "About". aboutInformationCompact() will be used for the "Copy and Close" feature in an follow-up patch. Task-number: QTCREATORBUG-29886 Change-Id: Iec818e376b3f02f52da00428285ad69b94d8adea Reviewed-by: Marcus Tillmanns Reviewed-by: Eike Ziller --- src/plugins/coreplugin/icore.cpp | 93 +++++++++++++++++++----- src/plugins/coreplugin/icore.h | 3 +- src/plugins/coreplugin/versiondialog.cpp | 44 +---------- 3 files changed, 77 insertions(+), 63 deletions(-) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 2e53dd9848e..cb6e2609030 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -810,16 +810,6 @@ QString ICore::versionString() ideVersionDescription); } -/*! - \internal -*/ -QString ICore::buildCompatibilityString() -{ - return Tr::tr("Based on Qt %1 (%2, %3)").arg(QLatin1String(qVersion()), - compilerString(), - QSysInfo::buildCpuArchitecture()); -} - /*! Returns the top level IContext of the current context, or \c nullptr if there is none. @@ -1006,15 +996,7 @@ void ICore::addPreCloseListener(const std::function &listener) */ QString ICore::systemInformation() { - QString result = PluginManager::systemInformation() + '\n'; - result += versionString() + '\n'; - result += buildCompatibilityString() + '\n'; - if (!Utils::appInfo().revision.isEmpty()) - result += QString("From revision %1\n").arg(Utils::appInfo().revision.left(10)); -#ifdef QTC_SHOW_BUILD_DATE - result += QString("Built on %1 %2\n").arg(QLatin1String(__DATE__), QLatin1String(__TIME__)); -#endif - return result; + return PluginManager::systemInformation() + '\n' + aboutInformationCompact() + '\n'; } static const QString &screenShotsPath() @@ -1146,6 +1128,79 @@ void ICore::appendAboutInformation(const QString &line) d->m_aboutInformation.append(line); } +/*! + \internal +*/ +QString ICore::aboutInformationCompact() +{ + QString information = QString("Product: %1\n").arg(versionString()); + information += QString("Based on: Qt %1 (%2, %3)\n") + .arg(QLatin1String(qVersion()), compilerString(), + QSysInfo::buildCpuArchitecture()); +#ifdef QTC_SHOW_BUILD_DATE + information += QString("Built on: %1 %2\n").arg(QLatin1String(__DATE__), + QLatin1String(__TIME__)); +#endif + const AppInfo &appInfo = Utils::appInfo(); + if (!appInfo.revision.isEmpty()) + information += QString("From revision: %1\n").arg(appInfo.revision.left(10)); + + return information; +} + +/*! + \internal +*/ +QString ICore::aboutInformationHtml() +{ + const QString buildCompatibilityString = Tr::tr("Based on Qt %1 (%2, %3)") + .arg(QLatin1String(qVersion()), compilerString(), + QSysInfo::buildCpuArchitecture()); + const AppInfo &appInfo = Utils::appInfo(); + QString ideRev; + if (!appInfo.revision.isEmpty()) + ideRev = Tr::tr("
From revision %1
") + .arg(appInfo.revisionUrl.isEmpty() + ? appInfo.revision + : QString::fromLatin1("%2") + .arg(appInfo.revisionUrl, appInfo.revision)); + QString buildDateInfo; +#ifdef QTC_SHOW_BUILD_DATE + buildDateInfo = Tr::tr("
Built on %1 %2
").arg(QLatin1String(__DATE__), + QLatin1String(__TIME__)); +#endif + + const QString br = QLatin1String("
"); + const QStringList additionalInfoLines = ICore::additionalAboutInformation(); + const QString additionalInfo = + QStringList(Utils::transform(additionalInfoLines, &QString::toHtmlEscaped)).join(br); + const QString information + = Tr::tr("

%1

" + "%2
" + "%3" + "%4" + "%5" + "
" + "Copyright 2008-%6 %7. All rights reserved.
" + "
" + "The program is provided AS IS with NO WARRANTY OF ANY KIND, " + "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A " + "PARTICULAR PURPOSE.
") + .arg(ICore::versionString(), + buildCompatibilityString, + buildDateInfo, + ideRev, + additionalInfo.isEmpty() ? QString() : br + additionalInfo + br, + appInfo.year, + appInfo.author) + + "
" + + Tr::tr("The Qt logo as well as Qt®, Qt Quick®, Built with Qt®, Boot to Qt®, " + "Qt Quick Compiler®, Qt Enterprise®, Qt Mobile® and Qt Embedded® are " + "registered trademarks of The Qt Company Ltd."); + + return information; +} + void ICore::updateNewItemDialogState() { static bool wasRunning = false; diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index cff938f5393..518939aeaae 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -136,6 +136,8 @@ public: static QStringList additionalAboutInformation(); static void clearAboutInformation(); static void appendAboutInformation(const QString &line); + static QString aboutInformationCompact(); + static QString aboutInformationHtml(); static QString systemInformation(); static void setupScreenShooter(const QString &name, QWidget *w, const QRect &rc = QRect()); static QString pluginPath(); @@ -146,7 +148,6 @@ public: static Utils::FilePath clazyStandaloneExecutable(const Utils::FilePath &clangBinDirectory); static Utils::FilePath clangIncludeDirectory(const QString &clangVersion, const Utils::FilePath &clangFallbackIncludeDir); - static QString buildCompatibilityString(); static QStatusBar *statusBar(); static void saveSettings(SaveSettingsReason reason); diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp index 833fc0a7071..0df1454849b 100644 --- a/src/plugins/coreplugin/versiondialog.cpp +++ b/src/plugins/coreplugin/versiondialog.cpp @@ -35,52 +35,10 @@ VersionDialog::VersionDialog(QWidget *parent) setWindowTitle(Tr::tr("About %1").arg(QGuiApplication::applicationDisplayName())); - const Utils::AppInfo appInfo = Utils::appInfo(); - QString ideRev; - if (!appInfo.revision.isEmpty()) - ideRev = Tr::tr("
From revision %1
") - .arg(appInfo.revisionUrl.isEmpty() - ? appInfo.revision - : QString::fromLatin1("%2") - .arg(appInfo.revisionUrl, appInfo.revision)); - QString buildDateInfo; -#ifdef QTC_SHOW_BUILD_DATE - buildDateInfo = Tr::tr("
Built on %1 %2
").arg(QLatin1String(__DATE__), QLatin1String(__TIME__)); -#endif - - const QString br = QLatin1String("
"); - const QStringList additionalInfoLines = ICore::additionalAboutInformation(); - const QString additionalInfo = - QStringList(Utils::transform(additionalInfoLines, &QString::toHtmlEscaped)).join(br); - - const QString description - = Tr::tr("

%1

" - "%2
" - "%3" - "%4" - "%5" - "
" - "Copyright 2008-%6 %7. All rights reserved.
" - "
" - "The program is provided AS IS with NO WARRANTY OF ANY KIND, " - "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A " - "PARTICULAR PURPOSE.
") - .arg(ICore::versionString(), - ICore::buildCompatibilityString(), - buildDateInfo, - ideRev, - additionalInfo.isEmpty() ? QString() : br + additionalInfo + br, - appInfo.year, - appInfo.author) - + "
" - + Tr::tr("The Qt logo as well as Qt®, Qt Quick®, Built with Qt®, Boot to Qt®, " - "Qt Quick Compiler®, Qt Enterprise®, Qt Mobile® and Qt Embedded® are " - "registered trademarks of The Qt Company Ltd."); - auto logoLabel = new QLabel; logoLabel->setPixmap(Icons::QTCREATORLOGO_BIG.pixmap()); - auto copyRightLabel = new QLabel(description); + auto copyRightLabel = new QLabel(ICore::aboutInformationHtml()); copyRightLabel->setWordWrap(true); copyRightLabel->setOpenExternalLinks(true); copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);