From da02fca602e36b6f819cd8853e6d14df7b014657 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 13 Aug 2024 11:29:59 +0100 Subject: [PATCH] Compare result of `clickedButton` instead of `exec` (#7438) * Compare result of `clickedButton` instead of `exec` to workaround Qt 6.5 bug * Update ChangeLog * Fixed typo * Add missing backticks * Init as nullptr --- ChangeLog | 9 +++++---- src/lib/gui/dialogs/UpgradeDialog.cpp | 16 ++++++++++++---- src/lib/gui/dialogs/UpgradeDialog.h | 5 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f522058d2..2f916a29e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ Enhancements: -- #7254 Bind client to a network interface with --address +- #7254 Bind client to a network interface with `--address` - #7262 Backward compatibility for M1 and M2 builds - #7263 Change name of Flatpak uploaded to snapshots - #7265 Remove obtrusive Linux key press log messages @@ -13,10 +13,10 @@ Enhancements: - #7284 Change session ID info log message to DEBUG2 - #7283 Update all workflows and fix broken macOS workflows - #7313 Fix CodeQL workflow: Failed to perl 404 Not Found -- #7317 Bump sonar-scanner-cli to 5.0.1.3006 +- #7317 Bump `sonar-scanner-cli` to 5.0.1.3006 - #7318 Remove Azure Pipelines config entirely - #7319 Remove workflows for slow self-hosted RPi runners -- #7320 Move build_version.py script to scripts dir +- #7320 Move `build_version.py` script to scripts dir - #7321 Switch to GitHub hosted Mac M1 runner - #7322 Use C++20 and add Windows CMake preset - #7323 Add Linux and macOS CMake presets @@ -41,7 +41,7 @@ Enhancements: - #7364 Format all source with Clang and introduce lint workflow - #7368 Make version check URL v1-specific and configurable - #7369 Re-implement packaging for GitHub workflows (Linux ARM) -- #7372 Add Git SHA to about screen and --version +- #7372 Add Git SHA to about screen and `--version` - #7373 Upgrade from Qt5 to Qt6 for more modern UI - #7374 Add missing DEB and RPM dependencies - #7376 Automated weekly build of Docker images for Linux runners @@ -80,6 +80,7 @@ Enhancements: - #7435 Add reset settings menu action and env var - #7436 Introduced new env vars for testing - #7437 Show message box explaining why settings are read-only +- #7438 Compare result of `clickedButton` instead of `exec` # 1.14.6 diff --git a/src/lib/gui/dialogs/UpgradeDialog.cpp b/src/lib/gui/dialogs/UpgradeDialog.cpp index 40a4b98ec..1c69255b2 100644 --- a/src/lib/gui/dialogs/UpgradeDialog.cpp +++ b/src/lib/gui/dialogs/UpgradeDialog.cpp @@ -24,14 +24,22 @@ UpgradeDialog::UpgradeDialog(QWidget *parent) : QMessageBox(parent) { setWindowTitle("Upgrade to access this feature"); - addButton("Cancel", QMessageBox::RejectRole); - addButton("Upgrade", QMessageBox::AcceptRole); + m_cancel = addButton("Cancel", QMessageBox::RejectRole); + m_upgrade = addButton("Upgrade", QMessageBox::AcceptRole); } void UpgradeDialog::showDialog(const QString &text) { setText(text); + exec(); - if (exec() == QMessageBox::Accepted) { - QDesktopServices::openUrl(QUrl(synergy::gui::kUrlUpgrade)); + if (clickedButton() == m_upgrade) { + const auto url = QUrl(synergy::gui::kUrlUpgrade); + if (QDesktopServices::openUrl(url)) { + qDebug("opened url: %s", qUtf8Printable(url.toString())); + } else { + qCritical("failed to open url: %s", qUtf8Printable(url.toString())); + } + } else { + qDebug("upgrade was declined"); } } diff --git a/src/lib/gui/dialogs/UpgradeDialog.h b/src/lib/gui/dialogs/UpgradeDialog.h index 85876d804..4292016e8 100644 --- a/src/lib/gui/dialogs/UpgradeDialog.h +++ b/src/lib/gui/dialogs/UpgradeDialog.h @@ -18,9 +18,14 @@ #pragma once #include +#include class UpgradeDialog : public QMessageBox { public: explicit UpgradeDialog(QWidget *parent = nullptr); void showDialog(const QString &text); + +private: + QPushButton *m_upgrade = nullptr; + QPushButton *m_cancel = nullptr; };