From ab10d81a4c39c388e12f75e713eea911a0a1249a Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Sun, 21 Jan 2024 15:09:30 -0800 Subject: [PATCH] qt: Add text input for specifying the portable directory. --- src/platform/qt/ConfigController.cpp | 4 ++-- src/platform/qt/ConfigController.h | 2 +- src/platform/qt/Window.cpp | 15 +++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 086fcdc8a..8c4a26cc1 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -365,8 +365,8 @@ void ConfigController::write() { mCoreConfigMap(&m_config, &m_opts); } -void ConfigController::makePortable() { - mCoreConfigMakePortable(&m_config, nullptr); +void ConfigController::makePortable(const char* path) { + mCoreConfigMakePortable(&m_config, path); QString fileName(configDir()); fileName.append(QDir::separator()); diff --git a/src/platform/qt/ConfigController.h b/src/platform/qt/ConfigController.h index 4c71c3943..1dd01c8a2 100644 --- a/src/platform/qt/ConfigController.h +++ b/src/platform/qt/ConfigController.h @@ -116,7 +116,7 @@ public slots: void setOption(const char* key, const QVariant& value); void setQtOption(const QString& key, const QVariant& value, const QString& group = QString()); - void makePortable(); + void makePortable(const char* path); void write(); private: diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 800453489..b18b0e5b3 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Window.h" +#include #include #include #include @@ -1117,12 +1118,14 @@ void Window::changeRenderer() { } void Window::tryMakePortable() { - QMessageBox* confirm = new QMessageBox(QMessageBox::Question, tr("Really make portable?"), - tr("This will make the emulator load its configuration from the same directory as the executable. Do you want to continue?"), - QMessageBox::Yes | QMessageBox::Cancel, this, Qt::Sheet); - confirm->setAttribute(Qt::WA_DeleteOnClose); - connect(confirm->button(QMessageBox::Yes), &QAbstractButton::clicked, m_config, &ConfigController::makePortable); - confirm->show(); + bool accepted; + QString text = QInputDialog::getText(this, tr("Make portable"), + tr("This will make the emulator load its configuration from the specified directory.\n\n" + "Portable Directory (leave empty for the executable directory):"), + QLineEdit::Normal, "", &accepted); + if (accepted) { + m_config->makePortable(text.toLocal8Bit().data()); + } } void Window::mustRestart() {