2026-02-06 06:37:30 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
2025-09-15 17:21:18 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2026-02-06 06:37:30 +01:00
|
|
|
#include <QLineEdit>
|
2025-10-28 03:46:47 +01:00
|
|
|
#include "frontend.h"
|
2025-09-15 17:21:18 +02:00
|
|
|
#include "qt_common/qt_common.h"
|
|
|
|
|
|
|
|
|
|
#ifdef YUZU_QT_WIDGETS
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#endif
|
|
|
|
|
|
2026-02-06 06:37:30 +01:00
|
|
|
#include <QAbstractButton>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
|
2025-09-15 17:21:18 +02:00
|
|
|
namespace QtCommon::Frontend {
|
|
|
|
|
|
|
|
|
|
StandardButton ShowMessage(
|
|
|
|
|
Icon icon, const QString &title, const QString &text, StandardButtons buttons, QObject *parent)
|
|
|
|
|
{
|
|
|
|
|
#ifdef YUZU_QT_WIDGETS
|
|
|
|
|
QMessageBox *box = new QMessageBox(icon, title, text, buttons, (QWidget *) parent);
|
|
|
|
|
return static_cast<QMessageBox::StandardButton>(box->exec());
|
|
|
|
|
#endif
|
|
|
|
|
// TODO(crueter): If Qt Widgets is disabled...
|
|
|
|
|
// need a way to reference icon/buttons too
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString GetOpenFileName(const QString &title,
|
|
|
|
|
const QString &dir,
|
|
|
|
|
const QString &filter,
|
|
|
|
|
QString *selectedFilter,
|
|
|
|
|
Options options)
|
|
|
|
|
{
|
|
|
|
|
#ifdef YUZU_QT_WIDGETS
|
2025-11-09 18:07:38 +01:00
|
|
|
return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter, options);
|
2025-09-15 17:21:18 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-15 04:54:41 +02:00
|
|
|
const QString GetSaveFileName(const QString &title,
|
|
|
|
|
const QString &dir,
|
|
|
|
|
const QString &filter,
|
|
|
|
|
QString *selectedFilter,
|
|
|
|
|
Options options)
|
|
|
|
|
{
|
|
|
|
|
#ifdef YUZU_QT_WIDGETS
|
2025-11-09 18:07:38 +01:00
|
|
|
return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter, options);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString GetExistingDirectory(const QString& caption, const QString& dir,
|
|
|
|
|
Options options) {
|
|
|
|
|
#ifdef YUZU_QT_WIDGETS
|
|
|
|
|
return QFileDialog::getExistingDirectory(rootObject, caption, dir, options);
|
2025-10-15 04:54:41 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-06 06:37:30 +01:00
|
|
|
int Choice(const QString& title, const QString& caption, const QStringList& options) {
|
|
|
|
|
QMessageBox box(rootObject);
|
|
|
|
|
box.setText(caption);
|
|
|
|
|
box.setWindowTitle(title);
|
|
|
|
|
|
|
|
|
|
for (const QString &opt : options) {
|
|
|
|
|
box.addButton(opt, QMessageBox::AcceptRole);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
box.addButton(QMessageBox::Cancel);
|
|
|
|
|
|
|
|
|
|
box.exec();
|
|
|
|
|
auto button = box.clickedButton();
|
|
|
|
|
return options.indexOf(button->text());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString GetTextInput(const QString& title, const QString& caption,
|
|
|
|
|
const QString& defaultText) {
|
|
|
|
|
return QInputDialog::getText(rootObject, title, caption, QLineEdit::Normal, defaultText);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-15 17:21:18 +02:00
|
|
|
} // namespace QtCommon::Frontend
|