1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

Qt: properly hide and show progress indicator

This was previously always shown, since we never really re-used the progress dialogs.
This commit is contained in:
Megamouse 2024-05-04 23:09:02 +02:00
parent 281f248d91
commit 5745862fa8
4 changed files with 43 additions and 10 deletions

View File

@ -16,17 +16,7 @@ progress_dialog::progress_dialog(const QString& windowTitle, const QString& labe
SetDeleteOnClose();
}
// Try to find a window handle first
QWindow* handle = windowHandle();
for (QWidget* ancestor = this; !handle && ancestor;)
{
ancestor = static_cast<QWidget*>(ancestor->parent());
if (ancestor) handle = ancestor->windowHandle();
}
m_progress_indicator = std::make_unique<progress_indicator>(minimum, maximum);
m_progress_indicator->show(handle);
}
progress_dialog::~progress_dialog()
@ -61,3 +51,34 @@ void progress_dialog::SignalFailure() const
QApplication::beep();
}
void progress_dialog::show_progress_indicator()
{
// Try to find a window handle first
QWindow* handle = windowHandle();
for (QWidget* ancestor = this; !handle && ancestor;)
{
ancestor = static_cast<QWidget*>(ancestor->parent());
if (ancestor) handle = ancestor->windowHandle();
}
m_progress_indicator->show(handle);
}
void progress_dialog::setVisible(bool visible)
{
if (visible)
{
if (!isVisible())
{
show_progress_indicator();
}
}
else if (isVisible())
{
m_progress_indicator->hide();
}
QProgressDialog::setVisible(visible);
}

View File

@ -14,6 +14,10 @@ public:
void SetDeleteOnClose();
void SignalFailure() const;
void show_progress_indicator();
void setVisible(bool visible) override;
private:
std::unique_ptr<progress_indicator> m_progress_indicator;
};

View File

@ -46,6 +46,13 @@ void progress_indicator::show(QWindow* window)
#endif
}
void progress_indicator::hide()
{
#ifdef HAS_QT_WIN_STUFF
m_tb_button->progress()->hide();
#endif
}
int progress_indicator::value() const
{
#ifdef HAS_QT_WIN_STUFF

View File

@ -13,6 +13,7 @@ public:
~progress_indicator();
void show(QWindow* window);
void hide();
int value() const;