From 1dd8978f8c343936d95080b0f1b0d17069014026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 9 Nov 2014 20:49:23 +0100 Subject: [PATCH] Do not use QFont without Xorg --- MultiMC.cpp | 33 +++++++++++++++++++++------------ MultiMC.h | 4 ++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 149bb939..b7a68eea 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -56,7 +56,7 @@ static const int APPDATA_BUFFER_SIZE = 1024; using namespace Util::Commandline; -MultiMC::MultiMC(int &argc, char **argv, bool root_override) : QApplication(argc, argv) +MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, argv) { setOrganizationName("MultiMC"); setApplicationName("MultiMC5"); @@ -149,7 +149,8 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override) : QApplication(argc return; } - if (root_override) + // in test mode, root path is the same as the binary path. + if (test_mode) { rootPath = binPath; } @@ -198,7 +199,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override) : QApplication(argc QLOG_INFO() << "Static data path : " << staticDataPath; // load settings - initGlobalSettings(); + initGlobalSettings(test_mode); // load translations initTranslations(); @@ -362,7 +363,7 @@ void MultiMC::initLogger() bool loggerInitialized = false; -void MultiMC::initGlobalSettings() +void MultiMC::initGlobalSettings(bool test_mode) { m_settings.reset(new INISettingsObject("multimc.cfg", this)); // Updates @@ -379,14 +380,22 @@ void MultiMC::initGlobalSettings() // Remembered state m_settings->registerSetting("LastUsedGroupForNewInstance", QString()); - // Console settings - QFont consoleFont; - consoleFont.setFamily(""); - consoleFont.setStyleHint(QFont::Monospace); - consoleFont.setFixedPitch(true); - QFontInfo consoleFontInfo(consoleFont); - QString consoleFontFamily = consoleFontInfo.family(); - m_settings->registerSetting("ConsoleFont", consoleFontFamily); + // in test mode, we don't have UI. + if(!test_mode) + { + // Console settings + QFont consoleFont; + consoleFont.setFamily(""); + consoleFont.setStyleHint(QFont::Monospace); + consoleFont.setFixedPitch(true); + QFontInfo consoleFontInfo(consoleFont); + QString consoleFontFamily = consoleFontInfo.family(); + m_settings->registerSetting("ConsoleFont", consoleFontFamily); + } + else + { + m_settings->registerSetting("ConsoleFont", "Courier"); + } // FTB m_settings->registerSetting("TrackFTBInstances", false); diff --git a/MultiMC.h b/MultiMC.h index 0f141f68..8a87bc50 100644 --- a/MultiMC.h +++ b/MultiMC.h @@ -57,7 +57,7 @@ public: }; public: - MultiMC(int &argc, char **argv, bool root_override = false); + MultiMC(int &argc, char **argv, bool test_mode = false); virtual ~MultiMC(); std::shared_ptr settings() @@ -183,7 +183,7 @@ private slots: private: void initLogger(); - void initGlobalSettings(); + void initGlobalSettings(bool test_mode); void initHttpMetaCache();