From 93cd71d0462036f15fe2e433bbcd652104223d17 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Thu, 9 Jan 2025 14:17:37 -0500 Subject: [PATCH] refactor: Adjust the About dialog UI --- src/apps/deskflow-gui/dialogs/AboutDialog.cpp | 55 +-- src/apps/deskflow-gui/dialogs/AboutDialog.h | 9 +- src/apps/deskflow-gui/dialogs/AboutDialog.ui | 363 ++++++++++++++++++ 3 files changed, 387 insertions(+), 40 deletions(-) create mode 100644 src/apps/deskflow-gui/dialogs/AboutDialog.ui diff --git a/src/apps/deskflow-gui/dialogs/AboutDialog.cpp b/src/apps/deskflow-gui/dialogs/AboutDialog.cpp index 189578306..3f8f74b7c 100644 --- a/src/apps/deskflow-gui/dialogs/AboutDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/AboutDialog.cpp @@ -18,6 +18,7 @@ */ #include "AboutDialog.h" +#include "ui_AboutDialog.h" #include "common/constants.h" #include "gui/style_utils.h" @@ -29,17 +30,19 @@ #include #include -AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) +AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui{std::make_unique()} { - setWindowTitle(tr("About Deskflow")); + ui->setupUi(this); auto copyIcon = QIcon::fromTheme( QIcon::ThemeIcon::EditCopy, deskflow::gui::isDarkMode() ? QIcon(s_darkCopy) : QIcon(s_lightCopy) ); + ui->lblIcon->setFixedSize(fontMetrics().height() * 6, fontMetrics().height() * 6); + ui->lblIcon->setPixmap(QPixmap(QStringLiteral(":/icons/128x128/tray.png")) + .scaledToWidth(fontMetrics().height() * 6, Qt::SmoothTransformation)); - auto btnCopyVersion = new QPushButton(copyIcon, QString(), this); - btnCopyVersion->setFlat(true); - connect(btnCopyVersion, &QPushButton::clicked, this, &AboutDialog::copyVersionText); + ui->btnCopyVersion->setIcon(copyIcon); + connect(ui->btnCopyVersion, &QPushButton::clicked, this, &AboutDialog::copyVersionText); // Set up the displayed version number auto versionString = QString(kVersion); @@ -49,42 +52,18 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) versionString.append(QStringLiteral(" (%1)").arg(kVersionGitSha)); } - auto versionLayout = new QHBoxLayout(); - versionLayout->addWidget(new QLabel(tr("Version:"))); - versionLayout->addWidget(new QLabel(versionString, this)); - versionLayout->addWidget(btnCopyVersion); - versionLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); + ui->lblVersion->setText(versionString); - auto lblLogo = new QLabel(this); - lblLogo->setPixmap(deskflow::gui::isDarkMode() ? s_darkLogo : s_lightLogo); + ui->lblDescription->setText(kAppDescription); + ui->lblCopyright->setText(kCopyright); + ui->lblImportantDevs->setText(QStringLiteral("%1\n").arg(s_awesomeDevs.join(", "))); - auto lblCopyright = new QLabel(kCopyright, this); + ui->btnOk->setDefault(true); + connect(ui->btnOk, &QPushButton::clicked, this, [this] { close(); }); - auto boldFont = font(); - boldFont.setBold(true); - - auto lblDevsTitle = new QLabel(tr("Important developers")); - lblDevsTitle->setFont(boldFont); - - auto lblDevsBody = new QLabel(QStringLiteral("%1\n").arg(s_awesomeDevs.join(", "))); - lblDevsBody->setWordWrap(true); - - auto btnOk = new QPushButton(tr("Ok"), this); - btnOk->setDefault(true); - connect(btnOk, &QPushButton::clicked, this, [this] { close(); }); - - auto mainLayout = new QVBoxLayout(); - mainLayout->addWidget(lblLogo); - mainLayout->addLayout(versionLayout); - mainLayout->addWidget(new QLabel(tr("Keyboard and mouse sharing application"), this)); - mainLayout->addWidget(lblCopyright); - mainLayout->addWidget(lblDevsTitle); - mainLayout->addWidget(lblDevsBody); - mainLayout->addWidget(btnOk); - - setLayout(mainLayout); adjustSize(); - setFixedSize(size()); + resize(QSize(parent->width() * 0.65, height())); + setMinimumSize(size()); } void AboutDialog::copyVersionText() @@ -97,3 +76,5 @@ void AboutDialog::copyVersionText() #endif QGuiApplication::clipboard()->setText(infoString); } + +AboutDialog::~AboutDialog() = default; diff --git a/src/apps/deskflow-gui/dialogs/AboutDialog.h b/src/apps/deskflow-gui/dialogs/AboutDialog.h index 81e704825..ea76f9569 100644 --- a/src/apps/deskflow-gui/dialogs/AboutDialog.h +++ b/src/apps/deskflow-gui/dialogs/AboutDialog.h @@ -21,20 +21,23 @@ #include +namespace Ui { +class AboutDialog; +} + class AboutDialog : public QDialog { Q_OBJECT public: explicit AboutDialog(QWidget *parent = nullptr); - ~AboutDialog() = default; + ~AboutDialog() override; private: + std::unique_ptr ui; void copyVersionText(); inline static const auto s_lightCopy = QStringLiteral(":/icons/64x64/copy-light.png"); inline static const auto s_darkCopy = QStringLiteral(":/icons/64x64/copy-dark.png"); - inline static const auto s_lightLogo = QStringLiteral(":/image/logo-light.png"); - inline static const auto s_darkLogo = QStringLiteral(":/image/logo-dark.png"); inline static const auto s_awesomeDevs = QStringList{ // Chris is the ultimate creator, and the one who started it all in 2001. QStringLiteral("Chris Schoeneman"), diff --git a/src/apps/deskflow-gui/dialogs/AboutDialog.ui b/src/apps/deskflow-gui/dialogs/AboutDialog.ui new file mode 100644 index 000000000..55e8767d3 --- /dev/null +++ b/src/apps/deskflow-gui/dialogs/AboutDialog.ui @@ -0,0 +1,363 @@ + + + AboutDialog + + + Qt::WindowModality::ApplicationModal + + + + 0 + 0 + 493 + 475 + + + + + 0 + 0 + + + + About Deskflow + + + + + + true + + + + + + + 0 + 0 + + + + + 0 + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"><span style=" text-decoration: underline; color:#508ed8;">License: GNU GPL Version 2</a></span></p></body></html> + + + true + + + + + + + Qt::Orientation::Vertical + + + + 20 + 5 + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 10 + + + + + + + + + 28 + true + + + + Deskflow + + + false + + + Qt::AlignmentFlag::AlignBottom|Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft + + + 0 + + + false + + + + + + + false + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Version: + + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter + + + 0 + + + + + + + + 0 + 0 + + + + + 11 + + + + lbl_version + + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + Copy version info + + + + :/icons/64x64/copy-dark.png:/icons/64x64/copy-dark.png + + + true + + + + + + + + 0 + 0 + + + + Qt::Orientation::Horizontal + + + + 40 + 10 + + + + + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/deskflow/deskflow/graphs/contributors"><span style=" text-decoration: underline; color:#508ed8;">Code Contributors</span></a></p></body></html> + + + true + + + + + + + + + + + 0 + 0 + + + + lblDescription + + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + + + + + + + + 0 + 0 + + + + lblCopyright + + + + + + + + 0 + 0 + + + + Important developers + + + false + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 0 + 0 + + + + lblImportantDevs + + + true + + + + + + + + + + + 0 + + + 0 + + + + + + + + &Close + + + + + + + + + + + + +