Qt: Fix progress dialog cancelling

This commit is contained in:
Stenzek 2023-11-21 16:13:14 +10:00 committed by Connor McLaughlin
parent 7715d122c7
commit 15091cea54
3 changed files with 12 additions and 8 deletions

View File

@ -82,8 +82,8 @@ public:
virtual void PushState() override;
virtual void PopState() override;
bool IsCancelled() const;
bool IsCancellable() const;
virtual bool IsCancelled() const override;
virtual bool IsCancellable() const override;
virtual void SetCancellable(bool cancellable) override;
virtual void SetStatusText(const char* text) override;

View File

@ -34,16 +34,12 @@ QtModalProgressCallback::QtModalProgressCallback(QWidget* parent_widget, float s
m_dialog.setModal(parent_widget != nullptr);
m_dialog.setAutoClose(false);
m_dialog.setAutoReset(false);
connect(&m_dialog, &QProgressDialog::canceled, this, &QtModalProgressCallback::dialogCancelled);
checkForDelayedShow();
}
QtModalProgressCallback::~QtModalProgressCallback() = default;
bool QtModalProgressCallback::IsCancelled() const
{
return m_dialog.wasCanceled();
}
void QtModalProgressCallback::SetCancellable(bool cancellable)
{
if (m_cancellable == cancellable)
@ -123,6 +119,11 @@ void QtModalProgressCallback::ModalInformation(const char* message)
QMessageBox::information(&m_dialog, tr("Information"), QString::fromUtf8(message));
}
void QtModalProgressCallback::dialogCancelled()
{
m_cancelled = true;
}
void QtModalProgressCallback::checkForDelayedShow()
{
if (m_dialog.isVisible())

View File

@ -29,7 +29,7 @@ public:
QtModalProgressCallback(QWidget* parent_widget, float show_delay = 0.0f);
~QtModalProgressCallback();
bool IsCancelled() const override;
QProgressDialog& GetDialog() { return m_dialog; }
void SetCancellable(bool cancellable) override;
void SetTitle(const char* title) override;
@ -46,6 +46,9 @@ public:
bool ModalConfirmation(const char* message) override;
void ModalInformation(const char* message) override;
private Q_SLOTS:
void dialogCancelled();
private:
void checkForDelayedShow();