qt: Add text input for specifying the portable directory.

This commit is contained in:
Steveice10 2024-01-21 15:09:30 -08:00
parent 398df56ac9
commit ab10d81a4c
3 changed files with 12 additions and 9 deletions

View File

@ -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());

View File

@ -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:

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Window.h"
#include <QInputDialog>
#include <QKeyEvent>
#include <QKeySequence>
#include <QMenuBar>
@ -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() {