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);
}