mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-19 13:25:14 +00:00
Qt: fix downloader taskbar progress
This commit is contained in:
parent
019fa390f2
commit
797b69fe8f
3 changed files with 28 additions and 7 deletions
|
|
@ -10,7 +10,7 @@
|
|||
#include <QtDBus/QDBusConnection>
|
||||
#endif
|
||||
|
||||
progress_dialog::progress_dialog(const QString &windowTitle, const QString &labelText, const QString &cancelButtonText, int minimum, int maximum, bool delete_on_close, QWidget *parent, Qt::WindowFlags flags)
|
||||
progress_dialog::progress_dialog(const QString& windowTitle, const QString& labelText, const QString& cancelButtonText, int minimum, int maximum, bool delete_on_close, QWidget* parent, Qt::WindowFlags flags)
|
||||
: QProgressDialog(labelText, cancelButtonText, minimum, maximum, parent, flags)
|
||||
{
|
||||
setWindowTitle(windowTitle);
|
||||
|
|
@ -24,11 +24,22 @@ progress_dialog::progress_dialog(const QString &windowTitle, const QString &labe
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Try to find a window handle first
|
||||
QWindow* handle = windowHandle();
|
||||
|
||||
for (QWidget* ancestor = this; !handle && ancestor;)
|
||||
{
|
||||
if (ancestor = static_cast<QWidget*>(ancestor->parent()))
|
||||
{
|
||||
handle = ancestor->windowHandle();
|
||||
}
|
||||
}
|
||||
|
||||
m_tb_button = std::make_unique<QWinTaskbarButton>();
|
||||
m_tb_button->setWindow(parent ? parent->windowHandle() : windowHandle());
|
||||
m_tb_button->setWindow(handle);
|
||||
m_tb_progress = m_tb_button->progress();
|
||||
m_tb_progress->setRange(minimum, maximum);
|
||||
m_tb_progress->setVisible(true);
|
||||
m_tb_progress->show();
|
||||
#elif HAVE_QTDBUS
|
||||
UpdateProgress(0);
|
||||
#endif
|
||||
|
|
@ -47,6 +58,15 @@ progress_dialog::~progress_dialog()
|
|||
#endif
|
||||
}
|
||||
|
||||
void progress_dialog::SetRange(int min, int max)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
m_tb_progress->setRange(min, max);
|
||||
#endif
|
||||
|
||||
QProgressDialog::setRange(min, max);
|
||||
}
|
||||
|
||||
void progress_dialog::SetValue(int progress)
|
||||
{
|
||||
const int value = std::clamp(progress, minimum(), maximum());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue