mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-15 19:48:57 +02:00
[desktop] Port some QtCommon changes from QML branch (#3703)
- Linker now resolves implementation differences - Remove unneeded ifdefs - Better abstractions overall Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3703 Reviewed-by: Lizzie <lizzie@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
This commit is contained in:
parent
07e3a2aa46
commit
0ff1d215c8
36 changed files with 405 additions and 371 deletions
|
|
@ -1,75 +1,27 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QLineEdit>
|
||||
#include "frontend.h"
|
||||
#include "qt_common/qt_common.h"
|
||||
|
||||
#ifdef YUZU_QT_WIDGETS
|
||||
#include <QFileDialog>
|
||||
#endif
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QInputDialog>
|
||||
|
||||
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
|
||||
return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter, options);
|
||||
#endif
|
||||
QString* selectedFilter) {
|
||||
return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter);
|
||||
}
|
||||
|
||||
const QStringList GetOpenFileNames(const QString& title, const QString& dir, const QString& filter,
|
||||
QString* selectedFilter, Options options) {
|
||||
#ifdef YUZU_QT_WIDGETS
|
||||
return QFileDialog::getOpenFileNames(rootObject, title, dir, filter, selectedFilter, options);
|
||||
#endif
|
||||
QString* selectedFilter) {
|
||||
return QFileDialog::getOpenFileNames(rootObject, title, dir, filter, selectedFilter);
|
||||
}
|
||||
|
||||
const QString GetSaveFileName(const QString& title, const QString& dir, const QString& filter,
|
||||
QString* selectedFilter, Options options) {
|
||||
#ifdef YUZU_QT_WIDGETS
|
||||
return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter, options);
|
||||
#endif
|
||||
QString* selectedFilter) {
|
||||
return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter);
|
||||
}
|
||||
|
||||
const QString GetExistingDirectory(const QString& caption, const QString& dir, Options options) {
|
||||
#ifdef YUZU_QT_WIDGETS
|
||||
return QFileDialog::getExistingDirectory(rootObject, caption, dir, options);
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
const QString GetExistingDirectory(const QString& caption, const QString& dir) {
|
||||
return QFileDialog::getExistingDirectory(rootObject, caption, dir);
|
||||
}
|
||||
|
||||
} // namespace QtCommon::Frontend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue