From 7a726589635e7ed1e987bbc43430a3bde96d5365 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Thu, 9 Jan 2025 14:32:01 -0500 Subject: [PATCH] refactor: copy more info with the about dialog info's copy button --- src/apps/deskflow-gui/dialogs/AboutDialog.cpp | 18 ++++++++++++------ src/apps/deskflow-gui/dialogs/AboutDialog.h | 1 - 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/apps/deskflow-gui/dialogs/AboutDialog.cpp b/src/apps/deskflow-gui/dialogs/AboutDialog.cpp index f36865aea..189578306 100644 --- a/src/apps/deskflow-gui/dialogs/AboutDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/AboutDialog.cpp @@ -42,16 +42,16 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) connect(btnCopyVersion, &QPushButton::clicked, this, &AboutDialog::copyVersionText); // Set up the displayed version number - m_versionString = QString(kVersion); - if (m_versionString.endsWith(QStringLiteral(".0"))) { - m_versionString.chop(2); + auto versionString = QString(kVersion); + if (versionString.endsWith(QStringLiteral(".0"))) { + versionString.chop(2); } else { - m_versionString.append(QStringLiteral(" (%1)").arg(kVersionGitSha)); + versionString.append(QStringLiteral(" (%1)").arg(kVersionGitSha)); } auto versionLayout = new QHBoxLayout(); versionLayout->addWidget(new QLabel(tr("Version:"))); - versionLayout->addWidget(new QLabel(m_versionString, this)); + versionLayout->addWidget(new QLabel(versionString, this)); versionLayout->addWidget(btnCopyVersion); versionLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); @@ -89,5 +89,11 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) void AboutDialog::copyVersionText() { - QGuiApplication::clipboard()->setText(m_versionString); + QString infoString = QStringLiteral("Deskflow: %1 (%2)\nQt: %3\nSystem: %4") + .arg(kVersion, kVersionGitSha, qVersion(), QSysInfo::prettyProductName()); +#ifdef Q_OS_LINUX + infoString.append(QStringLiteral("\nSession: %1 (%2)") + .arg(qEnvironmentVariable("XDG_CURRENT_DESKTOP"), qEnvironmentVariable("XDG_SESSION_TYPE"))); +#endif + QGuiApplication::clipboard()->setText(infoString); } diff --git a/src/apps/deskflow-gui/dialogs/AboutDialog.h b/src/apps/deskflow-gui/dialogs/AboutDialog.h index 4e2060836..81e704825 100644 --- a/src/apps/deskflow-gui/dialogs/AboutDialog.h +++ b/src/apps/deskflow-gui/dialogs/AboutDialog.h @@ -31,7 +31,6 @@ public: private: void copyVersionText(); - QString m_versionString; 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");