mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-04 05:04:33 +00:00
Qt: Further tidy up for 4850471
This commit is contained in:
@@ -55,20 +55,15 @@ p, li { white-space: pre-wrap; }
|
||||
|
||||
AboutDialog::~AboutDialog() = default;
|
||||
|
||||
void AboutDialog::showThirdPartyNotices(QWidget* parent)
|
||||
void AboutDialog::openThirdPartyNotices(QWidget* parent)
|
||||
{
|
||||
QDialog* const dialog = new QDialog(parent);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setMinimumSize(700, 400);
|
||||
dialog->setWindowTitle(tr("DuckStation Third-Party Notices"));
|
||||
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/icons/duck.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
dialog->setWindowIcon(icon);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(dialog);
|
||||
|
||||
QTextBrowser* tb = new QTextBrowser(dialog);
|
||||
QVBoxLayout* const layout = new QVBoxLayout(dialog);
|
||||
QTextBrowser* const tb = new QTextBrowser(dialog);
|
||||
tb->setAcceptRichText(true);
|
||||
tb->setReadOnly(true);
|
||||
tb->setOpenExternalLinks(true);
|
||||
@@ -84,7 +79,7 @@ void AboutDialog::showThirdPartyNotices(QWidget* parent)
|
||||
}
|
||||
layout->addWidget(tb, 1);
|
||||
|
||||
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Close, dialog);
|
||||
QDialogButtonBox* const bb = new QDialogButtonBox(QDialogButtonBox::Close, dialog);
|
||||
connect(bb, &QDialogButtonBox::rejected, dialog, &QDialog::accept);
|
||||
layout->addWidget(bb, 0);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
explicit AboutDialog(QWidget* parent = nullptr);
|
||||
~AboutDialog();
|
||||
|
||||
static void showThirdPartyNotices(QWidget* parent);
|
||||
static void openThirdPartyNotices(QWidget* parent);
|
||||
|
||||
private:
|
||||
Ui::AboutDialog m_ui;
|
||||
|
||||
@@ -193,7 +193,7 @@ void ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked(int state)
|
||||
"have confirmed the bug also occurs with overclocking disabled.\n\nThis warning will only be shown once.");
|
||||
|
||||
QMessageBox* const mb = QtUtils::NewMessageBox(QMessageBox::Warning, tr("CPU Overclocking Warning"), message,
|
||||
QMessageBox::NoButton, QMessageBox::NoButton, Qt::WindowModal, this);
|
||||
QMessageBox::NoButton, QMessageBox::NoButton, this);
|
||||
const QPushButton* const yes_button =
|
||||
mb->addButton(tr("Yes, I will confirm bugs without overclocking before reporting."), QMessageBox::YesRole);
|
||||
const QPushButton* const no_button = mb->addButton(tr("No, take me back to safety."), QMessageBox::NoRole);
|
||||
@@ -217,7 +217,7 @@ void ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked(int state)
|
||||
Host::SetBaseBoolSettingValue("UI", "CPUOverclockingWarningShown", true);
|
||||
Host::CommitBaseSettingChanges();
|
||||
});
|
||||
mb->show();
|
||||
mb->open();
|
||||
}
|
||||
|
||||
m_ui.cpuClockSpeed->setEnabled(m_dialog->getEffectiveBoolValue("CPU", "OverclockEnable", false));
|
||||
|
||||
@@ -995,9 +995,10 @@ MultipleDeviceAutobindDialog::MultipleDeviceAutobindDialog(QWidget* parent, Cont
|
||||
: QDialog(parent), m_settings_window(settings_window), m_port(port)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(new QLabel(tr("Select the devices from the list below that you want to bind to this controller.")));
|
||||
layout->addWidget(
|
||||
new QLabel(tr("Select the devices from the list below that you want to bind to this controller."), this));
|
||||
|
||||
m_list = new QListWidget;
|
||||
m_list = new QListWidget(this);
|
||||
m_list->setSelectionMode(QListWidget::SingleSelection);
|
||||
layout->addWidget(m_list);
|
||||
|
||||
@@ -1012,7 +1013,7 @@ MultipleDeviceAutobindDialog::MultipleDeviceAutobindDialog(QWidget* parent, Cont
|
||||
m_list->addItem(item);
|
||||
}
|
||||
|
||||
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
connect(bb, &QDialogButtonBox::accepted, this, &MultipleDeviceAutobindDialog::doAutomaticBinding);
|
||||
connect(bb, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
layout->addWidget(bb);
|
||||
|
||||
@@ -157,7 +157,7 @@ void ControllerGlobalSettingsWidget::ledSettingsClicked()
|
||||
heading_layout->addWidget(heading, 1);
|
||||
main_layout->addLayout(heading_layout);
|
||||
|
||||
QScrollArea* const scroll_area = new QScrollArea;
|
||||
QScrollArea* const scroll_area = new QScrollArea(dlg);
|
||||
scroll_area->setWidgetResizable(true);
|
||||
scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
@@ -179,8 +179,8 @@ void ControllerGlobalSettingsWidget::ledSettingsClicked()
|
||||
|
||||
for (u32 active = 0; active < 2; active++)
|
||||
{
|
||||
gbox_layout->addWidget(new QLabel(active ? tr("Alternate Mode:") : tr("Normal Mode:")), static_cast<int>(active),
|
||||
0);
|
||||
gbox_layout->addWidget(new QLabel(active ? tr("Alternate Mode:") : tr("Normal Mode:"), dlg),
|
||||
static_cast<int>(active), 0);
|
||||
|
||||
ColorPickerButton* const button = new ColorPickerButton(gbox);
|
||||
button->setColor(SDLInputSource::ParseRGBForPlayerId(
|
||||
|
||||
@@ -400,7 +400,7 @@ void GameCheatSettingsWidget::checkForMasterDisable()
|
||||
QMessageBox::Warning, tr("Confirm Game Settings Enable"),
|
||||
tr("<h3>Game settings are currently disabled.</h3><p>This is <strong>not</strong> the default. Enabling this "
|
||||
"cheat will not have any effect until game settings are enabled. Do you want to do this now?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::WindowModal, this);
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, this);
|
||||
QCheckBox* cb = new QCheckBox(mbox);
|
||||
cb->setText(tr("Do not show again"));
|
||||
mbox->setCheckBox(cb);
|
||||
@@ -420,7 +420,7 @@ void GameCheatSettingsWidget::checkForMasterDisable()
|
||||
QMessageBox::Warning, tr("Confirm Cheat Enable"),
|
||||
tr("<h3>Cheats are not currently enabled for this game.</h3><p>Enabling this cheat will not have any "
|
||||
"effect until cheats are enabled for this game. Do you want to do this now?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::WindowModal, this);
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, this);
|
||||
QCheckBox* cb = new QCheckBox(mbox);
|
||||
cb->setText(tr("Do not show again"));
|
||||
cb->setChecked(m_master_enable_ignored);
|
||||
@@ -614,11 +614,10 @@ void GameCheatSettingsWidget::importCodes(const std::string& file_contents)
|
||||
|
||||
void GameCheatSettingsWidget::newCode()
|
||||
{
|
||||
std::unique_ptr<Cheats::CodeInfo> new_code = std::make_unique<Cheats::CodeInfo>();
|
||||
CheatCodeEditorDialog* const dlg = new CheatCodeEditorDialog(this, new_code.get(), getGroupNames());
|
||||
CheatCodeEditorDialog* const dlg = new CheatCodeEditorDialog(this, Cheats::CodeInfo(), getGroupNames());
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(dlg, &QDialog::accepted, this, [this, code = std::move(new_code)] {
|
||||
connect(dlg, &QDialog::accepted, this, [this] {
|
||||
// no need to reload cheats yet, it's not active. just refresh the list
|
||||
reloadList();
|
||||
g_emu_thread->reloadCheats(true, false, false, true);
|
||||
@@ -633,7 +632,7 @@ void GameCheatSettingsWidget::editCode(const std::string_view code_name)
|
||||
if (!code)
|
||||
return;
|
||||
|
||||
CheatCodeEditorDialog* const dlg = new CheatCodeEditorDialog(this, code, getGroupNames());
|
||||
CheatCodeEditorDialog* const dlg = new CheatCodeEditorDialog(this, *code, getGroupNames());
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(dlg, &QDialog::accepted, this, [this] {
|
||||
@@ -790,9 +789,9 @@ void GameCheatSettingsWidget::populateTreeWidgetItem(QStandardItem* parent, cons
|
||||
}
|
||||
}
|
||||
|
||||
CheatCodeEditorDialog::CheatCodeEditorDialog(GameCheatSettingsWidget* parent, Cheats::CodeInfo* code,
|
||||
CheatCodeEditorDialog::CheatCodeEditorDialog(GameCheatSettingsWidget* parent, Cheats::CodeInfo code,
|
||||
const QStringList& group_names)
|
||||
: QDialog(parent), m_parent(parent), m_code(code)
|
||||
: QDialog(parent), m_parent(parent), m_code(std::move(code))
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
setupAdditionalUi(group_names);
|
||||
@@ -881,48 +880,48 @@ void CheatCodeEditorDialog::saveClicked()
|
||||
}
|
||||
|
||||
// if the name has changed, then we need to make sure it hasn't already been used
|
||||
if (new_name != m_code->name && m_parent->hasCodeWithName(new_name))
|
||||
if (new_name != m_code.name && m_parent->hasCodeWithName(new_name))
|
||||
{
|
||||
QtUtils::MessageBoxCritical(this, tr("Error"),
|
||||
tr("A code with the name '%1' already exists.").arg(QString::fromStdString(new_name)));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string old_name = std::move(m_code->name);
|
||||
std::string old_name = std::move(m_code.name);
|
||||
|
||||
// cheats coming from the database need to be copied into the user's file
|
||||
if (m_code->from_database)
|
||||
if (m_code.from_database)
|
||||
{
|
||||
m_code->from_database = false;
|
||||
m_code.from_database = false;
|
||||
old_name.clear();
|
||||
}
|
||||
|
||||
m_code->name = std::move(new_name);
|
||||
m_code->description = QtUtils::NormalizeLineEndings(m_ui.description->toPlainText())
|
||||
.replace(QChar('\n'), QChar(' '))
|
||||
.trimmed()
|
||||
.toStdString();
|
||||
m_code->type = new_type;
|
||||
m_code->activation = new_activation;
|
||||
m_code->body = std::move(new_body);
|
||||
m_code.name = std::move(new_name);
|
||||
m_code.description = QtUtils::NormalizeLineEndings(m_ui.description->toPlainText())
|
||||
.replace(QChar('\n'), QChar(' '))
|
||||
.trimmed()
|
||||
.toStdString();
|
||||
m_code.type = new_type;
|
||||
m_code.activation = new_activation;
|
||||
m_code.body = std::move(new_body);
|
||||
|
||||
m_code->option_range_start = 0;
|
||||
m_code->option_range_end = 0;
|
||||
m_code->options = {};
|
||||
m_code.option_range_start = 0;
|
||||
m_code.option_range_end = 0;
|
||||
m_code.options = {};
|
||||
if (m_ui.optionsType->currentIndex() == 1)
|
||||
{
|
||||
// choices
|
||||
m_code->options = std::move(m_new_options);
|
||||
m_code.options = std::move(m_new_options);
|
||||
}
|
||||
else if (m_ui.optionsType->currentIndex() == 2)
|
||||
{
|
||||
// range
|
||||
m_code->option_range_start = static_cast<u16>(m_ui.rangeMin->value());
|
||||
m_code->option_range_end = static_cast<u16>(m_ui.rangeMax->value());
|
||||
m_code.option_range_start = static_cast<u16>(m_ui.rangeMin->value());
|
||||
m_code.option_range_end = static_cast<u16>(m_ui.rangeMax->value());
|
||||
}
|
||||
|
||||
std::string path = m_parent->getPathForSavingCheats();
|
||||
if (!Cheats::UpdateCodeInFile(path.c_str(), old_name, m_code, &error))
|
||||
if (!Cheats::UpdateCodeInFile(path.c_str(), old_name, &m_code, &error))
|
||||
{
|
||||
QtUtils::MessageBoxCritical(
|
||||
this, tr("Error"), tr("Failed to save cheat code:\n%1").arg(QString::fromStdString(error.GetDescription())));
|
||||
@@ -974,10 +973,10 @@ void CheatCodeEditorDialog::setupAdditionalUi(const QStringList& group_names)
|
||||
|
||||
void CheatCodeEditorDialog::fillUi()
|
||||
{
|
||||
m_ui.name->setText(QtUtils::StringViewToQString(m_code->GetNamePart()));
|
||||
m_ui.description->setPlainText(QString::fromStdString(m_code->description));
|
||||
m_ui.name->setText(QtUtils::StringViewToQString(m_code.GetNamePart()));
|
||||
m_ui.description->setPlainText(QString::fromStdString(m_code.description));
|
||||
|
||||
const std::string_view group = m_code->GetNameParentPart();
|
||||
const std::string_view group = m_code.GetNameParentPart();
|
||||
if (group.empty())
|
||||
{
|
||||
// ungrouped is always first
|
||||
@@ -997,16 +996,16 @@ void CheatCodeEditorDialog::fillUi()
|
||||
m_ui.group->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
m_ui.type->setCurrentIndex(static_cast<int>(m_code->type));
|
||||
m_ui.activation->setCurrentIndex(static_cast<int>(m_code->activation));
|
||||
m_ui.type->setCurrentIndex(static_cast<int>(m_code.type));
|
||||
m_ui.activation->setCurrentIndex(static_cast<int>(m_code.activation));
|
||||
|
||||
m_ui.instructions->setPlainText(QString::fromStdString(m_code->body));
|
||||
m_ui.instructions->setPlainText(QString::fromStdString(m_code.body));
|
||||
|
||||
m_ui.rangeMin->setValue(static_cast<int>(m_code->option_range_start));
|
||||
m_ui.rangeMax->setValue(static_cast<int>(m_code->option_range_end));
|
||||
m_new_options = m_code->options;
|
||||
m_ui.rangeMin->setValue(static_cast<int>(m_code.option_range_start));
|
||||
m_ui.rangeMax->setValue(static_cast<int>(m_code.option_range_end));
|
||||
m_new_options = m_code.options;
|
||||
|
||||
m_ui.optionsType->setCurrentIndex(m_code->HasOptionRange() ? 2 : (m_code->HasOptionChoices() ? 1 : 0));
|
||||
m_ui.optionsType->setCurrentIndex(m_code.HasOptionRange() ? 2 : (m_code.HasOptionChoices() ? 1 : 0));
|
||||
onOptionTypeChanged(m_ui.optionsType->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class CheatCodeEditorDialog final : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CheatCodeEditorDialog(GameCheatSettingsWidget* parent, Cheats::CodeInfo* code, const QStringList& group_names);
|
||||
CheatCodeEditorDialog(GameCheatSettingsWidget* parent, Cheats::CodeInfo code, const QStringList& group_names);
|
||||
~CheatCodeEditorDialog() override;
|
||||
|
||||
private:
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
GameCheatSettingsWidget* m_parent;
|
||||
Ui::GameCheatCodeEditorDialog m_ui;
|
||||
|
||||
Cheats::CodeInfo* m_code;
|
||||
Cheats::CodeInfo m_code;
|
||||
Cheats::CodeOptionList m_new_options;
|
||||
};
|
||||
|
||||
|
||||
@@ -1380,16 +1380,15 @@ void TextureReplacementSettingsDialog::onExportClicked()
|
||||
config.vram_write_dump_height_threshold = static_cast<u16>(m_ui.minDumpedVRAMWriteHeight->value());
|
||||
config.dump_vram_write_force_alpha_channel = m_ui.setTextureDumpAlphaChannel->isChecked();
|
||||
|
||||
QInputDialog idlg(this);
|
||||
idlg.resize(600, 400);
|
||||
idlg.setWindowTitle(tr("Texture Replacement Configuration"));
|
||||
idlg.setInputMode(QInputDialog::TextInput);
|
||||
idlg.setOption(QInputDialog::UsePlainTextEditForTextInput);
|
||||
idlg.setLabelText(tr("Texture Replacement Configuration (config.yaml)"));
|
||||
idlg.setTextValue(QString::fromStdString(config.ExportToYAML(false)));
|
||||
idlg.setOkButtonText(tr("Save As..."));
|
||||
if (idlg.exec() != QDialog::Rejected)
|
||||
{
|
||||
QInputDialog* const idlg = new QInputDialog(this);
|
||||
idlg->resize(600, 400);
|
||||
idlg->setWindowTitle(tr("Texture Replacement Configuration"));
|
||||
idlg->setInputMode(QInputDialog::TextInput);
|
||||
idlg->setOption(QInputDialog::UsePlainTextEditForTextInput);
|
||||
idlg->setLabelText(tr("Texture Replacement Configuration (config.yaml)"));
|
||||
idlg->setTextValue(QString::fromStdString(config.ExportToYAML(false)));
|
||||
idlg->setOkButtonText(tr("Save As..."));
|
||||
connect(idlg, &QDialog::accepted, [this, idlg]() {
|
||||
const QString path =
|
||||
QFileDialog::getSaveFileName(this, tr("Save Configuration"), QString(), tr("Configuration Files (config.yaml)"));
|
||||
if (path.isEmpty())
|
||||
@@ -1397,11 +1396,12 @@ void TextureReplacementSettingsDialog::onExportClicked()
|
||||
|
||||
Error error;
|
||||
if (!FileSystem::WriteStringToFile(QDir::toNativeSeparators(path).toUtf8().constData(),
|
||||
idlg.textValue().toStdString(), &error))
|
||||
idlg->textValue().toStdString(), &error))
|
||||
{
|
||||
QtUtils::MessageBoxCritical(this, tr("Write Failed"), QString::fromStdString(error.GetDescription()));
|
||||
}
|
||||
}
|
||||
});
|
||||
idlg->open();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ void InputBindingWidget::unhookInputManager()
|
||||
|
||||
void InputBindingWidget::openDialog()
|
||||
{
|
||||
QDialog* const dlg =
|
||||
InputBindingDialog* const dlg =
|
||||
new InputBindingDialog(m_sif, m_bind_type, m_section_name, m_key_name, m_bindings, QtUtils::GetRootWidget(this));
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(dlg, &QDialog::finished, this, &InputBindingWidget::reloadBinding);
|
||||
|
||||
@@ -1285,7 +1285,7 @@ void MainWindow::promptForDiscChange(const QString& path)
|
||||
QMessageBox* const mb =
|
||||
QtUtils::NewMessageBox(QMessageBox::Question, tr("Confirm Disc Change"),
|
||||
tr("Do you want to swap discs or boot the new image (via system reset)?"),
|
||||
QMessageBox::NoButton, QMessageBox::NoButton, Qt::WindowModal, lock.getDialogParent());
|
||||
QMessageBox::NoButton, QMessageBox::NoButton, lock.getDialogParent());
|
||||
|
||||
/*const QAbstractButton* const swap_button = */ mb->addButton(tr("Swap Disc"), QMessageBox::YesRole);
|
||||
const QAbstractButton* const reset_button = mb->addButton(tr("Reset"), QMessageBox::NoRole);
|
||||
@@ -1302,7 +1302,7 @@ void MainWindow::promptForDiscChange(const QString& path)
|
||||
g_emu_thread->changeDisc(path, reset_system, true);
|
||||
});
|
||||
|
||||
mb->show();
|
||||
mb->open();
|
||||
}
|
||||
|
||||
void MainWindow::onStartDiscActionTriggered()
|
||||
@@ -2535,7 +2535,7 @@ void MainWindow::connectSignals()
|
||||
connect(m_ui.actionGitHubRepository, &QAction::triggered, this, &MainWindow::onGitHubRepositoryActionTriggered);
|
||||
connect(m_ui.actionDiscordServer, &QAction::triggered, this, &MainWindow::onDiscordServerActionTriggered);
|
||||
connect(m_ui.actionViewThirdPartyNotices, &QAction::triggered, this,
|
||||
[this]() { AboutDialog::showThirdPartyNotices(this); });
|
||||
[this]() { AboutDialog::openThirdPartyNotices(this); });
|
||||
connect(m_ui.actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
|
||||
connect(m_ui.actionAbout, &QAction::triggered, this, &MainWindow::onAboutActionTriggered);
|
||||
connect(m_ui.actionCheckForUpdates, &QAction::triggered, this, &MainWindow::onCheckForUpdatesActionTriggered);
|
||||
@@ -3074,11 +3074,11 @@ void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b
|
||||
|
||||
SystemLock lock(pauseAndLockSystem());
|
||||
|
||||
QMessageBox* msgbox = QtUtils::NewMessageBox(
|
||||
QMessageBox::Question, quit_afterwards ? tr("Confirm Exit") : tr("Confirm Close"),
|
||||
quit_afterwards ? tr("Are you sure you want to exit the application?") :
|
||||
tr("Are you sure you want to close the current game?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes, Qt::WindowModal, lock.getDialogParent());
|
||||
QMessageBox* msgbox =
|
||||
QtUtils::NewMessageBox(QMessageBox::Question, quit_afterwards ? tr("Confirm Exit") : tr("Confirm Close"),
|
||||
quit_afterwards ? tr("Are you sure you want to exit the application?") :
|
||||
tr("Are you sure you want to close the current game?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes, lock.getDialogParent());
|
||||
|
||||
QCheckBox* const save_cb = new QCheckBox(tr("Save State For Resume"), msgbox);
|
||||
save_cb->setChecked(allow_save_to_state && save_state);
|
||||
@@ -3098,7 +3098,7 @@ void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b
|
||||
requestShutdown(false, allow_save_to_state, save_state, check_safety, check_pause, exit_fullscreen_ui,
|
||||
quit_afterwards);
|
||||
});
|
||||
msgbox->show();
|
||||
msgbox->open();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -704,7 +704,11 @@ void MemoryCardEditorWindow::doRenameSaveFile()
|
||||
MemoryCardRenameFileDialog* const dlg = new MemoryCardRenameFileDialog(this, fi->filename);
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(dlg, &QDialog::accepted, this, [=, this] {
|
||||
connect(dlg, &QDialog::accepted, this, [this, dlg] {
|
||||
const auto [card, fi] = getSelectedFile();
|
||||
if (!fi)
|
||||
return;
|
||||
|
||||
const std::string new_name = dlg->getNewName();
|
||||
if (new_name.empty())
|
||||
return;
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
#include "fmt/format.h"
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
#include <QtWidgets/QTreeWidgetItemIterator>
|
||||
#include <array>
|
||||
|
||||
@@ -2160,9 +2160,8 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message,
|
||||
no_text = QtUtils::StringViewToQString(no_text), needs_pause]() mutable {
|
||||
auto lock = g_main_window->pauseAndLockSystem();
|
||||
|
||||
QMessageBox* const msgbox =
|
||||
QtUtils::NewMessageBox(QMessageBox::Question, title, message, QMessageBox::NoButton, QMessageBox::NoButton,
|
||||
Qt::WindowModal, lock.getDialogParent());
|
||||
QMessageBox* const msgbox = QtUtils::NewMessageBox(QMessageBox::Question, title, message, QMessageBox::NoButton,
|
||||
QMessageBox::NoButton, lock.getDialogParent());
|
||||
|
||||
QPushButton* const yes_button = msgbox->addButton(yes_text, QMessageBox::AcceptRole);
|
||||
msgbox->addButton(no_text, QMessageBox::RejectRole);
|
||||
@@ -2180,7 +2179,7 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message,
|
||||
});
|
||||
}
|
||||
});
|
||||
msgbox->exec();
|
||||
msgbox->open();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ LOG_CHANNEL(Host);
|
||||
namespace QtUtils {
|
||||
|
||||
static bool TryMigrateWindowGeometry(SettingsInterface* si, std::string_view window_name, QWidget* widget);
|
||||
static void SetMessageBoxStyle(QMessageBox* const dlg, Qt::WindowModality modality);
|
||||
static void SetMessageBoxStyle(QMessageBox* const dlg);
|
||||
|
||||
static constexpr const char* WINDOW_GEOMETRY_CONFIG_SECTION = "UI";
|
||||
|
||||
@@ -242,9 +242,8 @@ void QtUtils::ResizePotentiallyFixedSizeWindow(QWidget* widget, int width, int h
|
||||
widget->resize(width, height);
|
||||
}
|
||||
|
||||
void QtUtils::SetMessageBoxStyle(QMessageBox* const dlg, Qt::WindowModality modality)
|
||||
void QtUtils::SetMessageBoxStyle(QMessageBox* const dlg)
|
||||
{
|
||||
dlg->setWindowModality(modality);
|
||||
#ifdef __APPLE__
|
||||
// Can't have a stylesheet set even if it doesn't affect the widget.
|
||||
if (QtHost::IsStyleSheetApplicationTheme() || QtHost::NativeThemeStylesheetNeedsUpdate())
|
||||
@@ -267,14 +266,15 @@ QMessageBox::StandardButton QtUtils::MessageBoxIcon(QWidget* parent, QMessageBox
|
||||
#endif
|
||||
|
||||
// NOTE: Must be application modal, otherwise will lock up on MacOS.
|
||||
SetMessageBoxStyle(&msgbox, Qt::ApplicationModal);
|
||||
SetMessageBoxStyle(&msgbox);
|
||||
msgbox.setWindowModality(Qt::ApplicationModal);
|
||||
msgbox.setDefaultButton(defaultButton);
|
||||
return static_cast<QMessageBox::StandardButton>(msgbox.exec());
|
||||
}
|
||||
|
||||
QMessageBox* QtUtils::NewMessageBox(QMessageBox::Icon icon, const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton,
|
||||
Qt::WindowModality modality, QWidget* parent)
|
||||
QWidget* parent, bool delete_on_close)
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
QMessageBox* msgbox = new QMessageBox(icon, title, text, buttons, parent ? QtUtils::GetRootWidget(parent) : nullptr);
|
||||
@@ -283,9 +283,10 @@ QMessageBox* QtUtils::NewMessageBox(QMessageBox::Icon icon, const QString& title
|
||||
new QMessageBox(icon, QString(), title, buttons, parent ? QtUtils::GetRootWidget(parent) : nullptr);
|
||||
msgbox->setInformativeText(text);
|
||||
#endif
|
||||
msgbox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
if (delete_on_close)
|
||||
msgbox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgbox->setIcon(icon);
|
||||
SetMessageBoxStyle(msgbox, modality);
|
||||
SetMessageBoxStyle(msgbox);
|
||||
return msgbox;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ QMessageBox::StandardButton MessageBoxIcon(QWidget* parent, QMessageBox::Icon ic
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
QMessageBox* NewMessageBox(QMessageBox::Icon icon, const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton,
|
||||
Qt::WindowModality modality, QWidget* parent);
|
||||
QWidget* parent, bool delete_on_close = true);
|
||||
|
||||
/// Styles a popup menu for the current theme.
|
||||
void StylePopupMenu(QMenu* menu);
|
||||
|
||||
Reference in New Issue
Block a user