From 8b3a3e4ac825689d1a8879a465c822c9c0065676 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 26 Sep 2021 00:51:18 +0200 Subject: [PATCH] Qt/Linux: Properly hide taskbar progress when done --- rpcs3/rpcs3qt/gs_frame.cpp | 15 ++++++--------- rpcs3/rpcs3qt/gs_frame.h | 2 +- rpcs3/rpcs3qt/msg_dialog_frame.cpp | 17 +++++++---------- rpcs3/rpcs3qt/msg_dialog_frame.h | 2 +- rpcs3/rpcs3qt/progress_dialog.cpp | 15 ++++++--------- rpcs3/rpcs3qt/progress_dialog.h | 2 +- 6 files changed, 22 insertions(+), 31 deletions(-) diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index a6f1b39dde..8235768ffe 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -124,7 +124,7 @@ gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, m_tb_progress->setVisible(false); #elif HAVE_QTDBUS - UpdateProgress(0); + UpdateProgress(0, false); m_progress_value = 0; #endif } @@ -801,7 +801,7 @@ void gs_frame::progress_reset(bool reset_limit) m_tb_progress->reset(); } #elif HAVE_QTDBUS - UpdateProgress(0); + UpdateProgress(0, false); #endif if (reset_limit) @@ -819,7 +819,7 @@ void gs_frame::progress_set_value(int value) } #elif HAVE_QTDBUS m_progress_value = std::clamp(value, 0, m_gauge_max); - UpdateProgress(m_progress_value); + UpdateProgress(m_progress_value, true); #endif } @@ -853,7 +853,7 @@ void gs_frame::progress_set_limit(int limit) } #ifdef HAVE_QTDBUS -void gs_frame::UpdateProgress(int progress, bool disable) +void gs_frame::UpdateProgress(int progress, bool progress_visible) { QDBusMessage message = QDBusMessage::createSignal ( @@ -862,12 +862,9 @@ void gs_frame::UpdateProgress(int progress, bool disable) QStringLiteral("Update") ); QVariantMap properties; - if (disable) - properties.insert(QStringLiteral("progress-visible"), false); - else - properties.insert(QStringLiteral("progress-visible"), true); - //Progress takes a value from 0.0 to 0.1 + // Progress takes a value from 0.0 to 0.1 properties.insert(QStringLiteral("progress"), 1. * progress / m_gauge_max); + properties.insert(QStringLiteral("progress-visible"), progress_visible); message << QStringLiteral("application://rpcs3.desktop") << properties; QDBusConnection::sessionBus().send(message); } diff --git a/rpcs3/rpcs3qt/gs_frame.h b/rpcs3/rpcs3qt/gs_frame.h index 700ce7b4b5..dec383267b 100644 --- a/rpcs3/rpcs3qt/gs_frame.h +++ b/rpcs3/rpcs3qt/gs_frame.h @@ -30,7 +30,7 @@ private: QWinTaskbarProgress* m_tb_progress = nullptr; #elif HAVE_QTDBUS int m_progress_value = 0; - void UpdateProgress(int progress, bool disable = false); + void UpdateProgress(int progress, bool progress_visible); #endif QRect m_initial_geometry; diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.cpp b/rpcs3/rpcs3qt/msg_dialog_frame.cpp index 63c5663c6a..9033fc8021 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/msg_dialog_frame.cpp @@ -66,7 +66,7 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title) m_tb_progress->setRange(0, 100); m_tb_progress->setVisible(true); #elif HAVE_QTDBUS - UpdateProgress(0); + UpdateProgress(0, true); m_progress_value = 0; #endif } @@ -249,7 +249,7 @@ void msg_dialog_frame::ProgressBarReset(u32 index) m_tb_progress->reset(); } #elif HAVE_QTDBUS - UpdateProgress(0); + UpdateProgress(0, false); #endif } } @@ -285,7 +285,7 @@ void msg_dialog_frame::ProgressBarInc(u32 index, u32 delta) } #elif HAVE_QTDBUS m_progress_value = std::min(m_progress_value + static_cast(delta), m_gauge_max); - UpdateProgress(m_progress_value); + UpdateProgress(m_progress_value, true); #endif } } @@ -321,7 +321,7 @@ void msg_dialog_frame::ProgressBarSetValue(u32 index, u32 value) } #elif HAVE_QTDBUS m_progress_value = std::min(static_cast(value), m_gauge_max); - UpdateProgress(m_progress_value); + UpdateProgress(m_progress_value, true); #endif } } @@ -370,19 +370,16 @@ void msg_dialog_frame::ProgressBarSetLimit(u32 index, u32 limit) } #ifdef HAVE_QTDBUS -void msg_dialog_frame::UpdateProgress(int progress, bool disable) +void msg_dialog_frame::UpdateProgress(int progress, bool progress_visible) { QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/"), QStringLiteral("com.canonical.Unity.LauncherEntry"), QStringLiteral("Update")); QVariantMap properties; - if (disable) - properties.insert(QStringLiteral("progress-visible"), false); - else - properties.insert(QStringLiteral("progress-visible"), true); // Progress takes a value from 0.0 to 0.1 - properties.insert(QStringLiteral("progress"), 1.* progress / m_gauge_max); + properties.insert(QStringLiteral("progress"), 1. * progress / m_gauge_max); + properties.insert(QStringLiteral("progress-visible"), progress_visible); message << QStringLiteral("application://rpcs3.desktop") << properties; QDBusConnection::sessionBus().send(message); } diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.h b/rpcs3/rpcs3qt/msg_dialog_frame.h index c51cb07806..67f0eaae17 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.h +++ b/rpcs3/rpcs3qt/msg_dialog_frame.h @@ -48,6 +48,6 @@ public: void ProgressBarSetLimit(u32 index, u32 limit) override; #ifdef HAVE_QTDBUS private: - void UpdateProgress(int progress, bool disable = false); + void UpdateProgress(int progress, bool progress_visible); #endif }; diff --git a/rpcs3/rpcs3qt/progress_dialog.cpp b/rpcs3/rpcs3qt/progress_dialog.cpp index cd59101d03..da9ca6f482 100644 --- a/rpcs3/rpcs3qt/progress_dialog.cpp +++ b/rpcs3/rpcs3qt/progress_dialog.cpp @@ -41,7 +41,7 @@ progress_dialog::progress_dialog(const QString& windowTitle, const QString& labe m_tb_progress->setRange(minimum, maximum); m_tb_progress->show(); #elif HAVE_QTDBUS - UpdateProgress(0); + UpdateProgress(0, true); #endif } @@ -60,8 +60,8 @@ progress_dialog::~progress_dialog() QStringLiteral("Update")); QVariantMap properties; properties.insert(QStringLiteral("urgent"), false); - properties.insert(QStringLiteral("progress-visible"), false); properties.insert(QStringLiteral("progress"), 0); + properties.insert(QStringLiteral("progress-visible"), false); message << QStringLiteral("application://rpcs3.desktop") << properties; QDBusConnection::sessionBus().send(message); #endif @@ -83,7 +83,7 @@ void progress_dialog::SetValue(int progress) #ifdef _WIN32 m_tb_progress->setValue(value); #elif HAVE_QTDBUS - UpdateProgress(value); + UpdateProgress(value, true); #endif QProgressDialog::setValue(value); @@ -108,19 +108,16 @@ void progress_dialog::SignalFailure() const } #ifdef HAVE_QTDBUS -void progress_dialog::UpdateProgress(int progress, bool disable) +void progress_dialog::UpdateProgress(int progress, bool progress_visible) { QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/"), QStringLiteral("com.canonical.Unity.LauncherEntry"), QStringLiteral("Update")); QVariantMap properties; - if (disable) - properties.insert(QStringLiteral("progress-visible"), false); - else - properties.insert(QStringLiteral("progress-visible"), true); - //Progress takes a value from 0.0 to 0.1 + // Progress takes a value from 0.0 to 0.1 properties.insert(QStringLiteral("progress"), 1. * progress / maximum()); + properties.insert(QStringLiteral("progress-visible"), progress_visible); message << QStringLiteral("application://rpcs3.desktop") << properties; QDBusConnection::sessionBus().send(message); } diff --git a/rpcs3/rpcs3qt/progress_dialog.h b/rpcs3/rpcs3qt/progress_dialog.h index 500112f325..a6a6d634a8 100644 --- a/rpcs3/rpcs3qt/progress_dialog.h +++ b/rpcs3/rpcs3qt/progress_dialog.h @@ -21,6 +21,6 @@ private: std::unique_ptr m_tb_button = nullptr; QWinTaskbarProgress* m_tb_progress = nullptr; #elif HAVE_QTDBUS - void UpdateProgress(int progress, bool disable = false); + void UpdateProgress(int progress, bool progress_visible); #endif };