mirror of https://github.com/mgba-emu/mgba.git
qt: Add text input for specifying the portable directory.
This commit is contained in:
parent
398df56ac9
commit
ab10d81a4c
|
@ -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());
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue