Unify code for about dialog image and attribution

It is the same for all components so define it at one place.
This commit is contained in:
Martchus 2022-08-25 20:35:02 +02:00
parent f2b1a0fe88
commit 01f722c690
5 changed files with 28 additions and 19 deletions

View File

@ -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 "<br>Syncthing icons from <a href=\"https://syncthing.net\">Syncthing project</a><br>Using "
"icons from <a href=\"https://forkaweso.me\">Fork "
"Awesome</a> (see <a href=\"https://forkaweso.me/Fork-Awesome/license\">their license</a>)"),
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);

View File

@ -2,6 +2,9 @@
#include "resources/qtconfig.h"
// use meta-data of syncthingtray application here
#include "resources/../../tray/resources/config.h"
#include <qtutilities/misc/compat.h>
#include <qtforkawesome/icon.h>
@ -330,4 +333,18 @@ IconManager &IconManager::instance(const QPalette *palette)
return iconManager;
}
QString aboutDialogAttribution()
{
return QStringLiteral(
"<p>Developed by " APP_AUTHOR
"<br>Fallback icons from KDE/Breeze project<br>Syncthing icons from <a href=\"https://syncthing.net\">Syncthing project</a><br>Using "
"icons from <a href=\"https://forkaweso.me\">Fork "
"Awesome</a> (see <a href=\"https://forkaweso.me/Fork-Awesome/license\">their license</a>)</p>");
}
QImage aboutDialogImage()
{
return renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage();
}
} // namespace Data

View File

@ -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

View File

@ -370,12 +370,8 @@ void SyncthingApplet::showOwnDeviceId()
void SyncthingApplet::showAboutDialog()
{
if (!m_aboutDlg) {
m_aboutDlg = new AboutDialog(nullptr, QStringLiteral(APP_NAME),
QStringLiteral("<p>Developed by " APP_AUTHOR "<br>Syncthing icons from <a href=\"https://syncthing.net\">Syncthing project</a><br>Using "
"icons from <a href=\"https://forkaweso.me\">Fork "
"Awesome</a> (see <a href=\"https://forkaweso.me/Fork-Awesome/license\">their license</a>)</p>"),
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);

View File

@ -264,13 +264,8 @@ void TrayWidget::showAboutDialog()
s_dialogParent = new QWidget();
}
if (!s_aboutDlg) {
s_aboutDlg = new AboutDialog(s_dialogParent, QString(),
QStringLiteral(
"<p>Developed by " APP_AUTHOR
"<br>Fallback icons from KDE/Breeze project<br>Syncthing icons from <a href=\"https://syncthing.net\">Syncthing project</a><br>Using "
"icons from <a href=\"https://forkaweso.me\">Fork "
"Awesome</a> (see <a href=\"https://forkaweso.me/Fork-Awesome/license\">their license</a>)</p>"),
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")));
}