From 01f722c690a8bebdfa84734efaec34e402aaae7f Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 25 Aug 2022 20:35:02 +0200 Subject: [PATCH] Unify code for about dialog image and attribution It is the same for all components so define it at one place. --- .../syncthingfileitemactionstaticdata.cpp | 8 ++------ model/syncthingicons.cpp | 17 +++++++++++++++++ model/syncthingicons.h | 5 +++++ plasmoid/lib/syncthingapplet.cpp | 8 ++------ tray/gui/traywidget.cpp | 9 ++------- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp b/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp index 5cd660a..4331a27 100644 --- a/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp +++ b/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp @@ -99,12 +99,8 @@ void SyncthingFileItemActionStaticData::rescanDir(const QString &dirId, const QS void SyncthingFileItemActionStaticData::showAboutDialog() { - auto *const aboutDialog = new AboutDialog(nullptr, QStringLiteral(APP_NAME), - QStringLiteral(APP_AUTHOR "
Syncthing icons from Syncthing project
Using " - "icons from Fork " - "Awesome (see their license)"), - QStringLiteral(APP_VERSION), CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION), - renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage()); + auto *const aboutDialog = new AboutDialog(nullptr, QStringLiteral(APP_NAME), aboutDialogAttribution(), QStringLiteral(APP_VERSION), + CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION), aboutDialogImage()); aboutDialog->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME)); aboutDialog->setWindowIcon(QIcon::fromTheme(QStringLiteral("syncthingtray"))); aboutDialog->setAttribute(Qt::WA_DeleteOnClose); diff --git a/model/syncthingicons.cpp b/model/syncthingicons.cpp index 125a9e3..eec4508 100644 --- a/model/syncthingicons.cpp +++ b/model/syncthingicons.cpp @@ -2,6 +2,9 @@ #include "resources/qtconfig.h" +// use meta-data of syncthingtray application here +#include "resources/../../tray/resources/config.h" + #include #include @@ -330,4 +333,18 @@ IconManager &IconManager::instance(const QPalette *palette) return iconManager; } +QString aboutDialogAttribution() +{ + return QStringLiteral( + "

Developed by " APP_AUTHOR + "
Fallback icons from KDE/Breeze project
Syncthing icons from Syncthing project
Using " + "icons from Fork " + "Awesome (see their license)

"); +} + +QImage aboutDialogImage() +{ + return renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage(); +} + } // namespace Data diff --git a/model/syncthingicons.h b/model/syncthingicons.h index 44059ac..4f8e0eb 100644 --- a/model/syncthingicons.h +++ b/model/syncthingicons.h @@ -12,6 +12,8 @@ QT_FORWARD_DECLARE_CLASS(QColor) QT_FORWARD_DECLARE_CLASS(QPalette) +QT_FORWARD_DECLARE_CLASS(QImage) +QT_FORWARD_DECLARE_CLASS(QString) namespace Data { @@ -215,6 +217,9 @@ inline const ForkAwesomeIcons &commonForkAwesomeIcons() return IconManager::instance().commonForkAwesomeIcons(); } +LIB_SYNCTHING_MODEL_EXPORT QString aboutDialogAttribution(); +LIB_SYNCTHING_MODEL_EXPORT QImage aboutDialogImage(); + } // namespace Data #endif // DATA_SYNCTHINGICONS_H diff --git a/plasmoid/lib/syncthingapplet.cpp b/plasmoid/lib/syncthingapplet.cpp index 51d26c3..0df38ef 100644 --- a/plasmoid/lib/syncthingapplet.cpp +++ b/plasmoid/lib/syncthingapplet.cpp @@ -370,12 +370,8 @@ void SyncthingApplet::showOwnDeviceId() void SyncthingApplet::showAboutDialog() { if (!m_aboutDlg) { - m_aboutDlg = new AboutDialog(nullptr, QStringLiteral(APP_NAME), - QStringLiteral("

Developed by " APP_AUTHOR "
Syncthing icons from Syncthing project
Using " - "icons from Fork " - "Awesome (see their license)

"), - QStringLiteral(APP_VERSION), CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION), - renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage()); + m_aboutDlg = new AboutDialog(nullptr, QStringLiteral(APP_NAME), aboutDialogAttribution(), QStringLiteral(APP_VERSION), + CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION), aboutDialogImage()); m_aboutDlg->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME)); m_aboutDlg->setWindowIcon(QIcon::fromTheme(QStringLiteral("syncthingtray"))); m_aboutDlg->setAttribute(Qt::WA_DeleteOnClose); diff --git a/tray/gui/traywidget.cpp b/tray/gui/traywidget.cpp index cf7071f..ade7fde 100644 --- a/tray/gui/traywidget.cpp +++ b/tray/gui/traywidget.cpp @@ -264,13 +264,8 @@ void TrayWidget::showAboutDialog() s_dialogParent = new QWidget(); } if (!s_aboutDlg) { - s_aboutDlg = new AboutDialog(s_dialogParent, QString(), - QStringLiteral( - "

Developed by " APP_AUTHOR - "
Fallback icons from KDE/Breeze project
Syncthing icons from Syncthing project
Using " - "icons from Fork " - "Awesome (see their license)

"), - QString(), {}, QStringLiteral(APP_URL), QString(), renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage()); + s_aboutDlg = new AboutDialog( + s_dialogParent, QString(), aboutDialogAttribution(), QString(), {}, QStringLiteral(APP_URL), QString(), aboutDialogImage()); s_aboutDlg->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME)); s_aboutDlg->setWindowIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg"))); }