diff --git a/qml/PageMain.qml b/qml/PageMain.qml index 967d9e6..fda82fc 100644 --- a/qml/PageMain.qml +++ b/qml/PageMain.qml @@ -51,7 +51,7 @@ WidgetScrollable { Button { text: qsTr("Browse...") onClicked: { - folderDialogInputPath.currentFolder = "file:///" + folderInputEdit.text; + folderDialogInputPath.currentFolder = appui.pathToUrl(folderInputEdit.text); folderDialogInputPath.open(); } } @@ -59,7 +59,7 @@ WidgetScrollable { FolderDialog { id: folderDialogInputPath - onAccepted: folderInputEdit.setTextValue(folderDialogInputPath.selectedFolder.toString().substring(8)) + onAccepted: folderInputEdit.setTextValue(appui.urlToPath(folderDialogInputPath.selectedFolder)) } } @@ -79,7 +79,7 @@ WidgetScrollable { Button { text: qsTr("Browse...") onClicked: { - folderDialogOutputPath.currentFolder = "file:///" + folderOutputEdit.text; + folderDialogOutputPath.currentFolder = appui.pathToUrl(folderOutputEdit.text); folderDialogOutputPath.open(); } } @@ -87,7 +87,7 @@ WidgetScrollable { FolderDialog { id: folderDialogOutputPath - onAccepted: folderOutputEdit.setTextValue(folderDialogOutputPath.selectedFolder.toString().substring(8)) + onAccepted: folderOutputEdit.setTextValue(appui.urlToPath(folderDialogOutputPath.selectedFolder)) } } diff --git a/src/QtApp/UIController.cpp b/src/QtApp/UIController.cpp index e2c8365..b2e6cb6 100644 --- a/src/QtApp/UIController.cpp +++ b/src/QtApp/UIController.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace D2ModGen { @@ -125,7 +126,7 @@ void UIController::generate() void UIController::saveConfig(QString filename) { - filename.replace("file:///", ""); + filename = QUrl(filename).toLocalFile(); if (m_configHandler.saveConfig(filename.toStdString())) { emit statusUpdate(tr("Saved.")); } else { @@ -135,7 +136,7 @@ void UIController::saveConfig(QString filename) void UIController::loadConfig(QString filename) { - filename.replace("file:///", ""); + filename = QUrl(filename).toLocalFile(); const auto result = m_configHandler.loadConfig(filename.toStdString()); if (result) { @@ -217,6 +218,16 @@ void UIController::browseToAppSettings() QProcess::startDetached("explorer.exe", QStringList() << QDir::toNativeSeparators(QString::fromStdString(path2string(m_configHandler.m_appData)))); } +QString UIController::urlToPath(const QUrl& url) const +{ + return url.toLocalFile(); +} + +QUrl UIController::pathToUrl(const QString& path) const +{ + return QUrl::fromLocalFile(path); +} + void UIController::newSeed() { m_configHandler.m_config.m_main.m_seed = 0; diff --git a/src/QtApp/UIController.hpp b/src/QtApp/UIController.hpp index e55093a..1dac6ba 100644 --- a/src/QtApp/UIController.hpp +++ b/src/QtApp/UIController.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -62,6 +63,9 @@ class UIController : public QObject { Q_INVOKABLE void copySaves(); Q_INVOKABLE QString getSaveFolder(); + Q_INVOKABLE QString urlToPath(const QUrl& url) const; + Q_INVOKABLE QUrl pathToUrl(const QString& path) const; + void sendDataChange(); signals: