diff --git a/launcher/Application.cpp b/launcher/Application.cpp index a641a9d8a..b0ef1405a 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -696,8 +696,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) m_settings->registerSetting("ConsoleMaxLines", 100000); m_settings->registerSetting("ConsoleOverflowStop", true); - logModel->setMaxLines(getConsoleMaxLines()); - logModel->setStopOnOverflow(shouldStopOnConsoleOverflow()); + logModel->setMaxLines(getConsoleMaxLines(settings())); + logModel->setStopOnOverflow(shouldStopOnConsoleOverflow(settings())); logModel->setOverflowMessage(tr("Cannot display this log since the log length surpassed %1 lines.").arg(logModel->getMaxLines())); // Folders @@ -1605,23 +1605,6 @@ void Application::updateIsRunning(bool running) m_updateRunning = running; } -int Application::getConsoleMaxLines() const -{ - auto lineSetting = settings()->getSetting("ConsoleMaxLines"); - bool conversionOk = false; - int maxLines = lineSetting->get().toInt(&conversionOk); - if (!conversionOk) { - maxLines = lineSetting->defValue().toInt(); - qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines; - } - return maxLines; -} - -bool Application::shouldStopOnConsoleOverflow() const -{ - return settings()->get("ConsoleOverflowStop").toBool(); -} - void Application::controllerSucceeded() { auto controller = qobject_cast(QObject::sender()); diff --git a/launcher/Application.h b/launcher/Application.h index 3c2c6e11c..548345c18 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -162,9 +162,6 @@ class Application : public QApplication { QString getModrinthAPIToken(); QString getUserAgent(); - int getConsoleMaxLines() const; - bool shouldStopOnConsoleOverflow() const; - /// this is the root of the 'installation'. Used for automatic updates const QString& root() { return m_rootPath; } diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp index f4bc7e30b..fdbcc11fe 100644 --- a/launcher/BaseInstance.cpp +++ b/launcher/BaseInstance.cpp @@ -53,6 +53,23 @@ #include "Commandline.h" #include "FileSystem.h" +int getConsoleMaxLines(SettingsObjectPtr settings) +{ + auto lineSetting = settings->getSetting("ConsoleMaxLines"); + bool conversionOk = false; + int maxLines = lineSetting->get().toInt(&conversionOk); + if (!conversionOk) { + maxLines = lineSetting->defValue().toInt(); + qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines; + } + return maxLines; +} + +bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings) +{ + return settings->get("ConsoleOverflowStop").toBool(); +} + BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir) : QObject() { m_settings = settings; @@ -184,23 +201,6 @@ void BaseInstance::copyManagedPack(BaseInstance& other) } } -int BaseInstance::getConsoleMaxLines() const -{ - auto lineSetting = m_settings->getSetting("ConsoleMaxLines"); - bool conversionOk = false; - int maxLines = lineSetting->get().toInt(&conversionOk); - if (!conversionOk) { - maxLines = lineSetting->defValue().toInt(); - qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines; - } - return maxLines; -} - -bool BaseInstance::shouldStopOnConsoleOverflow() const -{ - return m_settings->get("ConsoleOverflowStop").toBool(); -} - QStringList BaseInstance::getLinkedInstances() const { auto setting = m_settings->get("linkedInstances").toString(); diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 3509c0155..6baac4ce8 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -78,6 +78,10 @@ struct ShortcutData { ShortcutTarget target = ShortcutTarget::Other; }; +/// Console settings +int getConsoleMaxLines(SettingsObjectPtr settings); +bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings); + /*! * \brief Base class for instances. * This class implements many functions that are common between instances and @@ -272,9 +276,6 @@ class BaseInstance : public QObject, public std::enable_shared_from_this LaunchTask::getLogModel() { if (!m_logModel) { m_logModel.reset(new LogModel()); - m_logModel->setMaxLines(m_instance->getConsoleMaxLines()); - m_logModel->setStopOnOverflow(m_instance->shouldStopOnConsoleOverflow()); + m_logModel->setMaxLines(getConsoleMaxLines(m_instance->settings())); + m_logModel->setStopOnOverflow(shouldStopOnConsoleOverflow(m_instance->settings())); // FIXME: should this really be here? m_logModel->setOverflowMessage(tr("Stopped watching the game log because the log length surpassed %1 lines.\n" "You may have to fix your mods because the game is still logging to files and" diff --git a/launcher/ui/pages/instance/OtherLogsPage.cpp b/launcher/ui/pages/instance/OtherLogsPage.cpp index b1f0c6507..6f98db4a8 100644 --- a/launcher/ui/pages/instance/OtherLogsPage.cpp +++ b/launcher/ui/pages/instance/OtherLogsPage.cpp @@ -66,7 +66,7 @@ OtherLogsPage::OtherLogsPage(QString id, QString displayName, QString helpPage, m_proxy = new LogFormatProxyModel(this); if (m_instance) { m_model.reset(new LogModel(this)); - ui->trackLogCheckbox->setVisible(false); + ui->trackLogCheckbox->hide(); } else { m_model = APPLICATION->logModel; } @@ -85,8 +85,8 @@ OtherLogsPage::OtherLogsPage(QString id, QString displayName, QString helpPage, ui->text->setModel(m_proxy); if (m_instance) { - m_model->setMaxLines(m_instance->getConsoleMaxLines()); - m_model->setStopOnOverflow(m_instance->shouldStopOnConsoleOverflow()); + m_model->setMaxLines(getConsoleMaxLines(m_instance->settings())); + m_model->setStopOnOverflow(shouldStopOnConsoleOverflow(m_instance->settings())); m_model->setOverflowMessage(tr("Cannot display this log since the log length surpassed %1 lines.").arg(m_model->getMaxLines())); } else { modelStateToUI(); @@ -310,8 +310,8 @@ void OtherLogsPage::reload() ui->text->setModel(nullptr); if (!m_instance) { m_model.reset(new LogModel(this)); - m_model->setMaxLines(APPLICATION->getConsoleMaxLines()); - m_model->setStopOnOverflow(APPLICATION->shouldStopOnConsoleOverflow()); + m_model->setMaxLines(getConsoleMaxLines(APPLICATION->settings())); + m_model->setStopOnOverflow(shouldStopOnConsoleOverflow(APPLICATION->settings())); m_model->setOverflowMessage(tr("Cannot display this log since the log length surpassed %1 lines.").arg(m_model->getMaxLines())); } m_model->clear();