mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 18:40:36 +00:00
Qt: fix downloader taskbar progress
This commit is contained in:
parent
019fa390f2
commit
797b69fe8f
@ -106,7 +106,7 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p
|
||||
{
|
||||
m_progress_dialog->setWindowTitle(progress_dialog_title);
|
||||
m_progress_dialog->setAutoClose(!m_keep_progress_dialog_open);
|
||||
m_progress_dialog->setMaximum(maximum);
|
||||
m_progress_dialog->SetRange(0, maximum);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -209,8 +209,8 @@ void downloader::handle_buffer_update(int size, int max) const
|
||||
|
||||
if (m_progress_dialog)
|
||||
{
|
||||
m_progress_dialog->setMaximum(max > 0 ? max : m_progress_dialog->maximum());
|
||||
m_progress_dialog->setValue(size);
|
||||
m_progress_dialog->SetRange(0, max > 0 ? max : m_progress_dialog->maximum());
|
||||
m_progress_dialog->SetValue(size);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -10,8 +10,9 @@
|
||||
class progress_dialog : public QProgressDialog
|
||||
{
|
||||
public:
|
||||
progress_dialog(const QString &windowTitle, const QString &labelText, const QString &cancelButtonText, int minimum, int maximum, bool delete_on_close, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
progress_dialog(const QString& windowTitle, const QString& labelText, const QString& cancelButtonText, int minimum, int maximum, bool delete_on_close, QWidget* parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
~progress_dialog();
|
||||
void SetRange(int min, int max);
|
||||
void SetValue(int progress);
|
||||
void SignalFailure() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user