Qt: Remove QtModalProgressCallback

No longer needed.
This commit is contained in:
Stenzek
2025-11-28 14:40:03 +10:00
parent 8fcdf1049e
commit f6bfb739f4
3 changed files with 6 additions and 132 deletions

View File

@@ -7,6 +7,7 @@
#include "qtutils.h"
#include "util/cd_image.h"
#include "util/host.h"
#include "common/align.h"
#include "common/error.h"

View File

@@ -1,13 +1,13 @@
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#include "qtprogresscallback.h"
#include "qthost.h"
#include "qtutils.h"
#include "common/assert.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QProgressBar>
#include <QtWidgets/QPushButton>
@@ -16,97 +16,6 @@
#include "moc_qtprogresscallback.cpp"
QtModalProgressCallback::QtModalProgressCallback(QWidget* parent_widget, float show_delay)
: QObject(parent_widget), m_dialog(QString(), QString(), 0, 1, parent_widget), m_show_delay(show_delay)
{
m_dialog.setWindowTitle(tr("DuckStation"));
m_dialog.setMinimumSize(MINIMUM_WIDTH, MINIMUM_HEIGHT_WITHOUT_CANCEL);
if (parent_widget)
{
m_dialog.setWindowModality(Qt::WindowModal);
}
else
{
m_dialog.setModal(true);
m_dialog.setWindowModality(Qt::ApplicationModal);
}
m_dialog.setAutoClose(false);
m_dialog.setAutoReset(false);
m_dialog.setWindowFlag(Qt::CustomizeWindowHint, true);
m_dialog.setWindowFlag(Qt::WindowCloseButtonHint, false);
connect(&m_dialog, &QProgressDialog::canceled, this, &QtModalProgressCallback::dialogCancelled);
checkForDelayedShow();
}
QtModalProgressCallback::~QtModalProgressCallback() = default;
void QtModalProgressCallback::SetCancellable(bool cancellable)
{
if (m_cancellable == cancellable)
return;
ProgressCallback::SetCancellable(cancellable);
m_dialog.setWindowFlag(Qt::WindowCloseButtonHint, cancellable);
m_dialog.setMinimumHeight(cancellable ? MINIMUM_HEIGHT_WITH_CANCEL : MINIMUM_HEIGHT_WITHOUT_CANCEL);
m_dialog.setCancelButtonText(cancellable ? tr("Cancel") : QString());
}
void QtModalProgressCallback::SetTitle(const std::string_view title)
{
m_dialog.setWindowTitle(QtUtils::StringViewToQString(title));
}
void QtModalProgressCallback::SetStatusText(const std::string_view text)
{
ProgressCallback::SetStatusText(text);
checkForDelayedShow();
m_dialog.setLabelText(QtUtils::StringViewToQString(text));
}
void QtModalProgressCallback::SetProgressRange(u32 range)
{
ProgressCallback::SetProgressRange(range);
checkForDelayedShow();
if (m_dialog.isVisible())
m_dialog.setRange(0, m_progress_range);
}
void QtModalProgressCallback::SetProgressValue(u32 value)
{
ProgressCallback::SetProgressValue(value);
checkForDelayedShow();
if (m_dialog.isVisible() && static_cast<u32>(m_dialog.value()) != m_progress_range)
m_dialog.setValue(m_progress_value);
QCoreApplication::processEvents();
}
void QtModalProgressCallback::dialogCancelled()
{
m_cancelled = true;
}
void QtModalProgressCallback::checkForDelayedShow()
{
if (m_dialog.isVisible())
return;
if (m_show_timer.GetTimeSeconds() >= m_show_delay)
MakeVisible();
}
void QtModalProgressCallback::MakeVisible()
{
m_dialog.setRange(0, m_progress_range);
m_dialog.setValue(m_progress_value);
if (m_dialog.parent())
m_dialog.open();
else
m_dialog.show();
}
QtProgressCallback::QtProgressCallback(QObject* parent /* = nullptr */) : QObject(parent)
{
}

View File

@@ -1,56 +1,20 @@
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#pragma once
#include "qthost.h"
#include "common/progress_callback.h"
#include "common/timer.h"
#include <QtCore/QSemaphore>
#include <QtCore/QThread>
#include <QtWidgets/QDialog>
#include <QtWidgets/QProgressDialog>
#include <atomic>
class QAbstractButton;
class QDialogButtonBox;
class QLabel;
class QProgressBar;
class QPushButton;
class QtModalProgressCallback final : public QObject, public ProgressCallback
{
Q_OBJECT
public:
explicit QtModalProgressCallback(QWidget* parent_widget, float show_delay = 0.0f);
~QtModalProgressCallback();
QProgressDialog& GetDialog() { return m_dialog; }
void SetCancellable(bool cancellable) override;
void SetTitle(const std::string_view title) override;
void SetStatusText(const std::string_view text) override;
void SetProgressRange(u32 range) override;
void SetProgressValue(u32 value) override;
void MakeVisible();
private:
static constexpr int MINIMUM_WIDTH = 500;
static constexpr int MINIMUM_HEIGHT_WITHOUT_CANCEL = 70;
static constexpr int MINIMUM_HEIGHT_WITH_CANCEL = 100;
void checkForDelayedShow();
void dialogCancelled();
QProgressDialog m_dialog;
Timer m_show_timer;
float m_show_delay;
};
class QtProgressCallback final : public QObject, public ProgressCallback
{
Q_OBJECT