mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-13 20:22:13 +00:00
Launch an editor for the custom.json file. Also allow overriding of the system default editor
This commit is contained in:
18
MultiMC.cpp
18
MultiMC.cpp
@@ -8,6 +8,7 @@
|
||||
#include <QLibraryInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QStringList>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "gui/dialogs/VersionSelectDialog.h"
|
||||
#include "logic/lists/InstanceList.h"
|
||||
@@ -382,6 +383,9 @@ void MultiMC::initGlobalSettings()
|
||||
m_settings->registerSetting(new Setting("CentralModsDir", "mods"));
|
||||
m_settings->registerSetting(new Setting("LWJGLDir", "lwjgl"));
|
||||
|
||||
// Editors
|
||||
m_settings->registerSetting(new Setting("JsonEditor", QString()));
|
||||
|
||||
// Console
|
||||
m_settings->registerSetting(new Setting("ShowConsole", true));
|
||||
m_settings->registerSetting(new Setting("AutoCloseConsole", true));
|
||||
@@ -550,4 +554,18 @@ QString MultiMC::getExitUpdatePath() const
|
||||
return m_updateOnExitPath;
|
||||
}
|
||||
|
||||
void MultiMC::openJsonEditor(const QString &filename)
|
||||
{
|
||||
const QString file = QDir::current().absoluteFilePath(filename);
|
||||
if (m_settings->get("JsonEditor").toString().isEmpty())
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(file));
|
||||
}
|
||||
else
|
||||
{
|
||||
QProcess::startDetached(m_settings->get("JsonEditor").toString(),
|
||||
QStringList() << file);
|
||||
}
|
||||
}
|
||||
|
||||
#include "MultiMC.moc"
|
||||
|
||||
Reference in New Issue
Block a user