mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
Qt: Fix progress dialog cancelling
This commit is contained in:
parent
cc6f22163c
commit
365e3fb965
|
@ -16,16 +16,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)
|
||||
|
@ -105,6 +101,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())
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/progress_callback.h"
|
||||
#include "common/timer.h"
|
||||
#include <QtCore/QThread>
|
||||
|
||||
#include <QtCore/QSemaphore>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtWidgets/QProgressDialog>
|
||||
#include <atomic>
|
||||
|
||||
|
@ -17,7 +19,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;
|
||||
|
@ -34,6 +36,9 @@ public:
|
|||
bool ModalConfirmation(const char* message) override;
|
||||
void ModalInformation(const char* message) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void dialogCancelled();
|
||||
|
||||
private:
|
||||
void checkForDelayedShow();
|
||||
|
||||
|
|
Loading…
Reference in a new issue