From b9b6bd85a6808fa5354607d2051fcdfa4e0a1442 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 4 Jun 2018 21:22:31 +0200 Subject: [PATCH] Qt/RSX: add taskbar progress in msg_dialog_frame for shader compilation --- rpcs3/Emu/Cell/Modules/cellMsgDialog.h | 3 + rpcs3/Emu/RSX/rsx_cache.h | 3 + rpcs3/rpcs3qt/msg_dialog_frame.cpp | 105 +++++++++++++++++-------- rpcs3/rpcs3qt/msg_dialog_frame.h | 6 +- 4 files changed, 83 insertions(+), 34 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 44ec5884ae..2cabed3772 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -78,6 +78,9 @@ public: MsgDialogType type{}; + // the progressbar that will be represented in the taskbar. Use -1 to combine the progress. + s32 taskbar_index = 0; + std::function on_close; std::function on_osk_input_entered; diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 6c73947ebd..6957006626 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -404,6 +404,8 @@ namespace rsx struct progress_dialog_helper { + s32 taskbar_index = -1; // -1 to combine all progressbars in the taskbar progress + std::shared_ptr dlg; atomic_t initialized{ false }; @@ -413,6 +415,7 @@ namespace rsx dlg->type.se_normal = true; dlg->type.bg_invisible = true; dlg->type.progress_bar_count = 2; + dlg->taskbar_index = taskbar_index; dlg->on_close = [](s32 status) { Emu.CallAfter([]() diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.cpp b/rpcs3/rpcs3qt/msg_dialog_frame.cpp index ed60e57883..fc36b019f8 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/msg_dialog_frame.cpp @@ -33,7 +33,7 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title) { text = new QLabel("", m_dialog); bar = new QProgressBar(m_dialog); - bar->setRange(0, m_gauge_max); + bar->setRange(0, 100); bar->setValue(0); bar->setFixedWidth(barWidth()); bar->setAlignment(Qt::AlignCenter); @@ -58,11 +58,11 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title) #ifdef _WIN32 m_tb_button = new QWinTaskbarButton(); m_tb_progress = m_tb_button->progress(); - m_tb_progress->setRange(0, m_gauge_max); + m_tb_progress->setRange(0, 100); m_tb_progress->setVisible(true); #elif HAVE_QTDBUS UpdateProgress(0); - progressValue = 0; + m_progress_value = 0; #endif } @@ -274,58 +274,101 @@ void msg_dialog_frame::ProgressBarSetMsg(u32 index, const std::string& msg) void msg_dialog_frame::ProgressBarReset(u32 index) { + if (!m_dialog) + { + return; + } + if (index == 0 && m_gauge1) { m_gauge1->setValue(0); -#ifdef _WIN32 - m_tb_progress->reset(); -#elif HAVE_QTDBUS - UpdateProgress(0); -#endif } if (index == 1 && m_gauge2) { m_gauge2->setValue(0); } + + if (index == taskbar_index) + { +#ifdef _WIN32 + if (m_tb_progress) + { + m_tb_progress->reset(); + } +#elif HAVE_QTDBUS + UpdateProgress(0); +#endif + } } void msg_dialog_frame::ProgressBarInc(u32 index, u32 delta) { - if (m_dialog) + if (!m_dialog) { - if (index == 0 && m_gauge1) - { - m_gauge1->setValue(m_gauge1->value() + delta); -#ifdef _WIN32 - m_tb_progress->setValue(m_tb_progress->value() + delta); -#elif HAVE_QTDBUS - progressValue += delta; - UpdateProgress(progressValue); -#endif - } + return; + } - if (index == 1 && m_gauge2) + if (index == 0 && m_gauge1) + { + m_gauge1->setValue(m_gauge1->value() + delta); + } + + if (index == 1 && m_gauge2) + { + m_gauge2->setValue(m_gauge2->value() + delta); + } + + if (index == taskbar_index || taskbar_index == -1) + { +#ifdef _WIN32 + if (m_tb_progress) { - m_gauge2->setValue(m_gauge2->value() + delta); + m_tb_progress->setValue(m_tb_progress->value() + delta); } +#elif HAVE_QTDBUS + m_progress_value += delta; + UpdateProgress(m_progress_value); +#endif } } void msg_dialog_frame::ProgressBarSetLimit(u32 index, u32 limit) { - if (m_dialog) + if (!m_dialog) { - if (index == 0 && m_gauge1) - { - m_gauge1->setMaximum(limit); - } - - if (index == 1 && m_gauge2) - { - m_gauge2->setMaximum(limit); - } + return; } + + if (index == 0 && m_gauge1) + { + m_gauge1->setMaximum(limit); + } + + if (index == 1 && m_gauge2) + { + m_gauge2->setMaximum(limit); + } + + bool set_taskbar_limit = false; + + if (index == taskbar_index) + { + m_gauge_max = limit; + set_taskbar_limit = true; + } + else if (taskbar_index == -1) + { + m_gauge_max += limit; + set_taskbar_limit = true; + } + +#ifdef _WIN32 + if (set_taskbar_limit && m_tb_progress) + { + m_tb_progress->setMaximum(m_gauge_max); + } +#endif } #ifdef HAVE_QTDBUS diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.h b/rpcs3/rpcs3qt/msg_dialog_frame.h index 7840ce978e..b3f388bf3b 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.h +++ b/rpcs3/rpcs3qt/msg_dialog_frame.h @@ -34,12 +34,12 @@ class msg_dialog_frame : public QObject, public MsgDialogBase { Q_OBJECT +private: #ifdef _WIN32 QWinTaskbarButton* m_tb_button = nullptr; QWinTaskbarProgress* m_tb_progress = nullptr; - #elif HAVE_QTDBUS - int progressValue = 0; + int m_progress_value = 0; #endif custom_dialog* m_dialog =nullptr; QLabel* m_text = nullptr; @@ -56,7 +56,7 @@ class msg_dialog_frame : public QObject, public MsgDialogBase custom_dialog* m_osk_dialog = nullptr; char16_t* m_osk_text_return; - const int m_gauge_max = 100; + int m_gauge_max = 0; public: msg_dialog_frame(QWindow* taskbarTarget);