Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions qml/PageMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ WidgetScrollable {
Button {
text: qsTr("Browse...")
onClicked: {
folderDialogInputPath.currentFolder = "file:///" + folderInputEdit.text;
folderDialogInputPath.currentFolder = appui.pathToUrl(folderInputEdit.text);
folderDialogInputPath.open();
}
}
}

FolderDialog {
id: folderDialogInputPath
onAccepted: folderInputEdit.setTextValue(folderDialogInputPath.selectedFolder.toString().substring(8))
onAccepted: folderInputEdit.setTextValue(appui.urlToPath(folderDialogInputPath.selectedFolder))
}
}

Expand All @@ -79,15 +79,15 @@ WidgetScrollable {
Button {
text: qsTr("Browse...")
onClicked: {
folderDialogOutputPath.currentFolder = "file:///" + folderOutputEdit.text;
folderDialogOutputPath.currentFolder = appui.pathToUrl(folderOutputEdit.text);
folderDialogOutputPath.open();
}
}
}

FolderDialog {
id: folderDialogOutputPath
onAccepted: folderOutputEdit.setTextValue(folderDialogOutputPath.selectedFolder.toString().substring(8))
onAccepted: folderOutputEdit.setTextValue(appui.urlToPath(folderDialogOutputPath.selectedFolder))
}
}

Expand Down
15 changes: 13 additions & 2 deletions src/QtApp/UIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QDir>
#include <QSettings>
#include <QStandardPaths>
#include <QUrl>

namespace D2ModGen {

Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/QtApp/UIController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <QObject>
#include <QScopedPointer>
#include <QUrl>
#include <QVariant>
#include <QValidator>

Expand Down Expand Up @@ -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:
Expand Down
Loading