From c019f4c7d529f34bb515996bb232cd4643841b4c Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Fri, 21 Feb 2020 11:14:29 +0100 Subject: [PATCH] [Gui]Redesign AboutDialog and unify version info Fixes: #7749 Fixes: #7704 --- changelog/unreleased/7749 | 8 ++ src/gui/CMakeLists.txt | 2 + src/gui/aboutdialog.cpp | 52 ++++++++++++ src/gui/aboutdialog.h | 43 ++++++++++ src/gui/aboutdialog.ui | 162 ++++++++++++++++++++++++++++++++++++ src/gui/generalsettings.cpp | 5 +- src/gui/generalsettings.ui | 18 ++-- src/gui/owncloudgui.cpp | 18 +--- src/libsync/theme.cpp | 97 ++++++++++----------- src/libsync/theme.h | 15 +++- 10 files changed, 341 insertions(+), 79 deletions(-) create mode 100644 changelog/unreleased/7749 create mode 100644 src/gui/aboutdialog.cpp create mode 100644 src/gui/aboutdialog.h create mode 100644 src/gui/aboutdialog.ui diff --git a/changelog/unreleased/7749 b/changelog/unreleased/7749 new file mode 100644 index 00000000000..fd981a2b7ad --- /dev/null +++ b/changelog/unreleased/7749 @@ -0,0 +1,8 @@ +Change: Redesign the About dialog + +We redesigned the way the About information is displayed and unified it +with the "--version" switch. + +https://github.com/owncloud/client/issues/7749 +https://github.com/owncloud/enterprise/issues/3787 +https://github.com/owncloud/client/issues/7704 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index a63dca06748..bfc7c5d47dc 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -5,6 +5,7 @@ find_package(Qt5 REQUIRED COMPONENTS Widgets) add_subdirectory(updater) set(client_UI_SRCS + aboutdialog.ui accountsettings.ui folderwizardsourcepage.ui folderwizardtargetpage.ui @@ -32,6 +33,7 @@ set(client_UI_SRCS ) set(client_SRCS + aboutdialog.cpp accountmanager.cpp accountsettings.cpp application.cpp diff --git a/src/gui/aboutdialog.cpp b/src/gui/aboutdialog.cpp new file mode 100644 index 00000000000..e019aa7ebef --- /dev/null +++ b/src/gui/aboutdialog.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) by Hannah von Reth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ +#include "aboutdialog.h" +#include "ui_aboutdialog.h" + +#include "theme.h" +#include "guiutility.h" + +namespace OCC { + +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent) + , ui(new Ui::AboutDialog) +{ + ui->setupUi(this); + setWindowTitle(tr("About %1").arg(Theme::instance()->appNameGUI())); + ui->aboutText->setText(Theme::instance()->about()); + ui->icon->setPixmap(Theme::instance()->applicationIcon().pixmap(256)); + ui->versionInfo->setText(Theme::instance()->aboutVersions(Theme::VersionFormat::RichText)); + + connect(ui->versionInfo, &QTextBrowser::anchorClicked, this, &AboutDialog::openBrowserFromUrl); + connect(ui->aboutText, &QLabel::linkActivated, this, &AboutDialog::openBrowser); + setAttribute(Qt::WA_DeleteOnClose); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} + +void AboutDialog::openBrowser(const QString &s) +{ + Utility::openBrowser(s, this); +} + +void AboutDialog::openBrowserFromUrl(const QUrl &s) +{ + return openBrowser(s.toString()); +} + +} diff --git a/src/gui/aboutdialog.h b/src/gui/aboutdialog.h new file mode 100644 index 00000000000..601291da684 --- /dev/null +++ b/src/gui/aboutdialog.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) by Hannah von Reth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + + +namespace OCC { + +namespace Ui { + class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = nullptr); + ~AboutDialog(); + +private: + void openBrowser(const QString &s); + void openBrowserFromUrl(const QUrl &s); + +private: + Ui::AboutDialog *ui; +}; + +} +#endif // ABOUTDIALOG_H diff --git a/src/gui/aboutdialog.ui b/src/gui/aboutdialog.ui new file mode 100644 index 00000000000..1c404165cc8 --- /dev/null +++ b/src/gui/aboutdialog.ui @@ -0,0 +1,162 @@ + + + OCC::AboutDialog + + + + 0 + 0 + 751 + 391 + + + + About + + + + + + 0 + + + + About + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 256 + 256 + + + + + + + :/client/theme/colored/owncloud-icon-256.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + TextLabel + + + + + + + + Versions + + + + + + false + + + false + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + OCC::AboutDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + OCC::AboutDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 93a22041581..96f683d4202 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -115,12 +115,9 @@ GeneralSettings::GeneralSettings(QWidget *parent) } #endif } - - _ui->versionLabel->setText(QStringLiteral("%1").arg(MIRALL_VERSION_STRING)); - QObject::connect(_ui->versionLabel, &QLabel::linkActivated, this, &GeneralSettings::showAbout); + connect(_ui->about_pushButton, &QPushButton::clicked, this, &GeneralSettings::showAbout); if (!Theme::instance()->aboutShowCopyright()) { - _ui->copyrightLabelDotBefore->hide(); _ui->copyrightLabel->hide(); } } diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index ce8696b0ac8..15332cd9867 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -25,7 +25,7 @@ 0 0 771 - 640 + 637 @@ -311,7 +311,7 @@ PointingHandCursor - Version 3.1.3 (build 37) + Qt::LinksAccessibleByMouse @@ -319,12 +319,12 @@ - + ArrowCursor - + Copyright ownCloud GmbH Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -332,15 +332,9 @@ - - - ArrowCursor - + - Copyright ownCloud GmbH - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + About diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 339138d5cf6..eb8d98b3785 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -27,6 +27,7 @@ #include "accountstate.h" #include "openfilemanager.h" #include "accountmanager.h" +#include "aboutdialog.h" #include "common/syncjournalfilerecord.h" #include "creds/abstractcredentials.h" @@ -1141,21 +1142,8 @@ void ownCloudGui::slotRemoveDestroyedShareDialogs() void ownCloudGui::slotAbout() { - const QString title = tr("About %1").arg(Theme::instance()->appNameGUI()); - QMessageBox *msgBox = new QMessageBox(this->_settingsDialog); -#ifdef Q_OS_MAC - // From Qt doc: "On macOS, the window title is ignored (as required by the macOS Guidelines)." - msgBox->setText(title); -#else - msgBox->setWindowTitle(title); -#endif - msgBox->setAttribute(Qt::WA_DeleteOnClose, true); - msgBox->setTextFormat(Qt::RichText); - msgBox->setTextInteractionFlags(Qt::TextBrowserInteraction); - msgBox->setInformativeText(QStringLiteral("%1").arg(Theme::instance()->about())); - msgBox->setStandardButtons(QMessageBox::Ok); - msgBox->setIconPixmap(Theme::instance()->applicationIcon().pixmap(qApp->primaryScreen()->availableSize().width() / 4)); - msgBox->show(); + auto about = new AboutDialog(_settingsDialog); + about->open(); } diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index f7864b3d227..cbc99acfe7d 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -288,52 +288,65 @@ bool Theme::wizardHideFolderSizeLimitCheckbox() const return false; } -QString Theme::gitSHA1() const +QString Theme::gitSHA1(VersionFormat format) const { - QString devString; #ifdef GIT_SHA1 - const QString githubPrefix(QStringLiteral( - "https://github.com/owncloud/client/commit/")); - const QString gitSha1(QStringLiteral(GIT_SHA1)); - devString = QCoreApplication::translate("ownCloudTheme::about()", - "

Built from Git revision %2" - " on %3, %4 using Qt %5, %6

") - .arg(githubPrefix + gitSha1, - gitSha1.left(6), - QStringLiteral(__DATE__), - QStringLiteral(__TIME__), - QString::fromUtf8(qVersion()), - QSslSocket::sslLibraryVersionString()); + const auto gitSha = QStringLiteral(GIT_SHA1); + const auto gitShahSort = gitSha.left(6); + const auto gitUrl = QStringLiteral("https://github.com/owncloud/client/commit/%1").arg(gitSha); + switch (format) { + case Theme::VersionFormat::Plain: + return gitShahSort; + case Theme::VersionFormat::Url: + return gitUrl; + case Theme::VersionFormat::RichText: + return QStringLiteral("%3").arg(gitUrl, gitShahSort); + } +#endif + return QString(); +} + +QString Theme::aboutVersions(Theme::VersionFormat format) const +{ +#ifdef GIT_SHA1 + const QString _version = QStringLiteral("%1 %2").arg(version(), gitSHA1(format)); +#else + const QString _version = version(); #endif - return devString; + const QString br = format == Theme::VersionFormat::RichText ? QStringLiteral("
") : QStringLiteral("\n"); + const QString qtVersion = QString::fromUtf8(qVersion()); + const QString qtVersionString = (QLatin1String(QT_VERSION_STR) == qtVersion ? qtVersion : tr("ownCloudTheme::qtVer", "%1 (Built against Qt %1)").arg(qtVersion, QStringLiteral(QT_VERSION_STR))); + return QCoreApplication::translate("ownCloudTheme::aboutVersions()", + "%1 %2 %3 %4%8" + "Libraries Qt %5, %6%8" + "Using virtual files plugin: %7") + .arg(appName(), _version, QStringLiteral(__DATE__), QStringLiteral(__TIME__), qtVersionString, QSslSocket::sslLibraryVersionString(), Vfs::modeToString(bestAvailableVfsMode()), br); } + QString Theme::about() const { QString vendor = QStringLiteral(APPLICATION_VENDOR); // Ideally, the vendor should be "ownCloud GmbH", but it cannot be changed without // changing the location of the settings and other registery keys. - if (vendor == QLatin1String("ownCloud")) vendor = QStringLiteral("ownCloud GmbH"); - - QString devString; - devString = tr("

Version %2. For more information visit https://%4

" - "

For known issues and help, please visit: https://central.owncloud.org

" - "

By Klaas Freitag, Daniel Molkentin, Olivier Goffart, Markus Götz, " - " Jan-Christoph Borchardt, Thomas Müller, Dominik Schmidt, Hannah von Reth, and others.

") - .arg(Utility::escape(QStringLiteral(MIRALL_VERSION_STRING)), - Utility::escape(QStringLiteral("https://" MIRALL_STRINGIFY(APPLICATION_DOMAIN))), - Utility::escape(QStringLiteral(MIRALL_STRINGIFY(APPLICATION_DOMAIN)))); - devString += tr("

Copyright ownCloud GmbH

"); - devString += tr("

Distributed by %1 and licensed under the GNU General Public License (GPL) Version 2.0.
" - "%2 and the %2 logo are registered trademarks of %1 in the " - "United States, other countries, or both.

") - .arg(Utility::escape(vendor), Utility::escape(QStringLiteral(APPLICATION_NAME))); - - devString += gitSHA1(); - devString += QStringLiteral("

Using virtual files plugin: %1

") - .arg(Vfs::modeToString(bestAvailableVfsMode())); - - return devString; + if (vendor == QLatin1String("ownCloud")) { + vendor = QStringLiteral("ownCloud GmbH"); + } + return tr("

Version %1. For more information visit https://%3

" + "

For known issues and help, please visit: https://central.owncloud.org

" + "

By Klaas Freitag, Daniel Molkentin, Olivier Goffart, Markus Götz, " + " Jan-Christoph Borchardt, Thomas Müller, Dominik Schmidt, Michael Stingl, Hannah von Reth, and others.

" + "

Copyright ownCloud GmbH

" + "

Distributed by %4 and licensed under the GNU General Public License (GPL) Version 2.0.
" + "%5 and the %5 logo are registered trademarks of %4 in the " + "United States, other countries, or both.

" + "

%6

") + .arg(Utility::escape(version()), + Utility::escape(QStringLiteral("https://" MIRALL_STRINGIFY(APPLICATION_DOMAIN))), + Utility::escape(QStringLiteral(MIRALL_STRINGIFY(APPLICATION_DOMAIN))), + Utility::escape(vendor), + Utility::escape(appNameGUI()), + aboutVersions(Theme::VersionFormat::RichText)); } bool Theme::aboutShowCopyright() const @@ -519,17 +532,7 @@ QString Theme::openIdConnectScopes() const QString Theme::versionSwitchOutput() const { - QString helpText; - QTextStream stream(&helpText); - stream << appName() - << QLatin1String(" version ") - << version() << endl; -#ifdef GIT_SHA1 - stream << "Git revision " << GIT_SHA1 << endl; -#endif - stream << "Using Qt " << qVersion() << ", built against Qt " << QT_VERSION_STR << endl; - stream << "Using '" << QSslSocket::sslLibraryVersionString() << "'" << endl; - return helpText; + return aboutVersions(Theme::VersionFormat::Url); } bool Theme::showVirtualFilesOption() const diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 3bce73da149..082559e227c 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -43,6 +43,14 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject oCSetupBottom, oCSetupResultTop // ownCloud connect result page }; + Q_ENUM(CustomMediaType); + + enum class VersionFormat { + Plain, + Url, + RichText + }; + Q_ENUM(VersionFormat); /* returns a singleton instance. */ static Theme *instance(); @@ -195,7 +203,12 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject /** * The SHA sum of the released git commit */ - QString gitSHA1() const; + QString gitSHA1(VersionFormat format = VersionFormat::Plain) const; + + /** + * The used library versions + */ + QString aboutVersions(VersionFormat format = VersionFormat::Plain) const; /** * About dialog contents