mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12: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:
parent
281f248d91
commit
5745862fa8
4 changed files with 43 additions and 10 deletions
|
@ -16,17 +16,7 @@ progress_dialog::progress_dialog(const QString& windowTitle, const QString& labe
|
||||||
SetDeleteOnClose();
|
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 = std::make_unique<progress_indicator>(minimum, maximum);
|
||||||
m_progress_indicator->show(handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_dialog::~progress_dialog()
|
progress_dialog::~progress_dialog()
|
||||||
|
@ -61,3 +51,34 @@ void progress_dialog::SignalFailure() const
|
||||||
|
|
||||||
QApplication::beep();
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,10 @@ public:
|
||||||
void SetDeleteOnClose();
|
void SetDeleteOnClose();
|
||||||
void SignalFailure() const;
|
void SignalFailure() const;
|
||||||
|
|
||||||
|
void show_progress_indicator();
|
||||||
|
|
||||||
|
void setVisible(bool visible) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<progress_indicator> m_progress_indicator;
|
std::unique_ptr<progress_indicator> m_progress_indicator;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,6 +46,13 @@ void progress_indicator::show(QWindow* window)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void progress_indicator::hide()
|
||||||
|
{
|
||||||
|
#ifdef HAS_QT_WIN_STUFF
|
||||||
|
m_tb_button->progress()->hide();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int progress_indicator::value() const
|
int progress_indicator::value() const
|
||||||
{
|
{
|
||||||
#ifdef HAS_QT_WIN_STUFF
|
#ifdef HAS_QT_WIN_STUFF
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
~progress_indicator();
|
~progress_indicator();
|
||||||
|
|
||||||
void show(QWindow* window);
|
void show(QWindow* window);
|
||||||
|
void hide();
|
||||||
|
|
||||||
int value() const;
|
int value() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue