Use a combobox instead of a file dialog

This commit is contained in:
Jan Dalheimer 2014-02-16 11:56:02 +01:00
parent c88c639b8e
commit 2e64d0308c

View File

@ -3,6 +3,7 @@
#include <QDir> #include <QDir>
#include <QProcess> #include <QProcess>
#include <QFileDialog> #include <QFileDialog>
#include <QInputDialog>
#include "settingsobject.h" #include "settingsobject.h"
#include "logic/BaseInstance.h" #include "logic/BaseInstance.h"
@ -16,10 +17,12 @@ MCEditTool::MCEditTool(BaseInstance *instance, QObject *parent)
void MCEditTool::runImpl() void MCEditTool::runImpl()
{ {
const QString mceditPath = MMC->settings()->get("MCEditPath").toString(); const QString mceditPath = MMC->settings()->get("MCEditPath").toString();
const QString save = QFileDialog::getExistingDirectory( const QDir saves = QDir(m_instance->minecraftRoot() + "/saves");
MMC->activeWindow(), tr("MCEdit"), bool ok = true;
QDir(m_instance->minecraftRoot()).absoluteFilePath("saves")); const QString save = QInputDialog::getItem(
if (save.isEmpty()) MMC->activeWindow(), tr("MCEdit"), tr("Choose which world to open:"),
saves.entryList(QDir::Dirs | QDir::NoDotAndDotDot), 0, false, &ok);
if (save.isEmpty() || !ok)
{ {
return; return;
} }
@ -33,7 +36,7 @@ void MCEditTool::runImpl()
{ {
program = mceditDir.absoluteFilePath("mcedit.exe"); program = mceditDir.absoluteFilePath("mcedit.exe");
} }
QProcess::startDetached(program, QStringList() << save, mceditPath); QProcess::startDetached(program, QStringList() << saves.absoluteFilePath(save), mceditPath);
} }
void MCEditFactory::registerSettings(SettingsObject *settings) void MCEditFactory::registerSettings(SettingsObject *settings)