From 41bd2a66345e670c3ff127584cae3f6766bac743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 11 Nov 2014 00:50:17 +0100 Subject: Add console font size setting and a preview\ Also moves the console settings from the minecraft page. --- gui/pages/LogPage.cpp | 8 ++- gui/pages/global/MinecraftPage.cpp | 8 --- gui/pages/global/MinecraftPage.ui | 41 +++-------- gui/pages/global/MultiMCPage.cpp | 53 ++++++++++++++ gui/pages/global/MultiMCPage.h | 11 ++- gui/pages/global/MultiMCPage.ui | 144 ++++++++++++++++++++++++++++++------- 6 files changed, 200 insertions(+), 65 deletions(-) (limited to 'gui/pages') diff --git a/gui/pages/LogPage.cpp b/gui/pages/LogPage.cpp index 16d4f941..957c2f72 100644 --- a/gui/pages/LogPage.cpp +++ b/gui/pages/LogPage.cpp @@ -21,7 +21,13 @@ LogPage::LogPage(MinecraftProcess *proc, QWidget *parent) // create the format and set its font defaultFormat = new QTextCharFormat(ui->text->currentCharFormat()); QString fontFamily = MMC->settings()->get("ConsoleFont").toString(); - defaultFormat->setFont(QFont(fontFamily)); + bool conversionOk = false; + int fontSize = MMC->settings()->get("ConsoleFontSize").toInt(&conversionOk); + if(!conversionOk) + { + fontSize = 11; + } + defaultFormat->setFont(QFont(fontFamily, fontSize)); auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this); connect(findShortcut, SIGNAL(activated()), SLOT(findActivated())); diff --git a/gui/pages/global/MinecraftPage.cpp b/gui/pages/global/MinecraftPage.cpp index ae772a07..3962f9c4 100644 --- a/gui/pages/global/MinecraftPage.cpp +++ b/gui/pages/global/MinecraftPage.cpp @@ -77,10 +77,6 @@ void MinecraftPage::applySettings() // Minecraft version updates s->set("AutoUpdateMinecraftVersions", ui->autoupdateMinecraft->isChecked()); - // Console - s->set("ShowConsole", ui->showConsoleCheck->isChecked()); - s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); - // Window Size s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); @@ -92,10 +88,6 @@ void MinecraftPage::loadSettings() auto s = MMC->settings(); // Minecraft version updates ui->autoupdateMinecraft->setChecked(s->get("AutoUpdateMinecraftVersions").toBool()); - - // Console - ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); - ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); // Window Size ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool()); diff --git a/gui/pages/global/MinecraftPage.ui b/gui/pages/global/MinecraftPage.ui index e938d09d..d91f27d6 100644 --- a/gui/pages/global/MinecraftPage.ui +++ b/gui/pages/global/MinecraftPage.ui @@ -7,7 +7,7 @@ 0 0 545 - 609 + 270 @@ -83,14 +83,20 @@ - Window height: + Window hei&ght: + + + windowHeightSpinBox - Window width: + W&indow width: + + + windowWidthSpinBox @@ -128,29 +134,6 @@ - - - - Console Settings - - - - - - Show console while the game is running? - - - - - - - Automatically close console when the game quits? - - - - - - @@ -158,8 +141,8 @@ - 20 - 40 + 0 + 0 @@ -176,8 +159,6 @@ maximizedCheckBox windowWidthSpinBox windowHeightSpinBox - showConsoleCheck - autoCloseConsoleCheck diff --git a/gui/pages/global/MultiMCPage.cpp b/gui/pages/global/MultiMCPage.cpp index 9e0a0ed8..2ecf1c96 100644 --- a/gui/pages/global/MultiMCPage.cpp +++ b/gui/pages/global/MultiMCPage.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -59,6 +60,8 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP resizer->addWidgetsFromLayout(ui->groupBox->layout(), 1); resizer->addWidgetsFromLayout(ui->foldersBox->layout(), 1); + defaultFormat = new QTextCharFormat(ui->fontPreview->currentCharFormat()); + loadSettings(); QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this, @@ -72,6 +75,8 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP { MMC->updateChecker()->updateChanList(false); } + connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview())); + connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview())); } MultiMCPage::~MultiMCPage() @@ -295,8 +300,11 @@ void MultiMCPage::applySettings() } // Console settings + s->set("ShowConsole", ui->showConsoleCheck->isChecked()); + s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); QString consoleFontFamily = ui->consoleFont->currentFont().family(); s->set("ConsoleFont", consoleFontFamily); + s->set("ConsoleFontSize", ui->fontSizeBox->value()); // FTB s->set("TrackFTBInstances", ui->trackFtbBox->isChecked()); @@ -372,10 +380,21 @@ void MultiMCPage::loadSettings() } // Console settings + ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); + ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); QString fontFamily = MMC->settings()->get("ConsoleFont").toString(); QFont consoleFont(fontFamily); ui->consoleFont->setCurrentFont(consoleFont); + bool conversionOk = true; + int fontSize = MMC->settings()->get("ConsoleFontSize").toInt(&conversionOk); + if(!conversionOk) + { + fontSize = 11; + } + ui->fontSizeBox->setValue(fontSize); + refreshFontPreview(); + // FTB ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool()); ui->ftbLauncherBox->setText(s->get("FTBLauncherRoot").toString()); @@ -398,3 +417,37 @@ void MultiMCPage::loadSettings() ui->sortByNameBtn->setChecked(true); } } + +void MultiMCPage::refreshFontPreview() +{ + int fontSize = ui->fontSizeBox->value(); + QString fontFamily = ui->consoleFont->currentFont().family(); + ui->fontPreview->clear(); + defaultFormat->setFont(QFont(fontFamily, fontSize)); + { + QTextCharFormat format(*defaultFormat); + format.setForeground(QColor("red")); + // append a paragraph/line + auto workCursor = ui->fontPreview->textCursor(); + workCursor.movePosition(QTextCursor::End); + workCursor.insertText(tr("[Something/ERROR] A spooky error!"), format); + workCursor.insertBlock(); + } + { + QTextCharFormat format(*defaultFormat); + // append a paragraph/line + auto workCursor = ui->fontPreview->textCursor(); + workCursor.movePosition(QTextCursor::End); + workCursor.insertText(tr("[Test/INFO] A harmless message..."), format); + workCursor.insertBlock(); + } + { + QTextCharFormat format(*defaultFormat); + format.setForeground(QColor("orange")); + // append a paragraph/line + auto workCursor = ui->fontPreview->textCursor(); + workCursor.movePosition(QTextCursor::End); + workCursor.insertText(tr("[Something/WARN] A not so spooky warning."), format); + workCursor.insertBlock(); + } +} \ No newline at end of file diff --git a/gui/pages/global/MultiMCPage.h b/gui/pages/global/MultiMCPage.h index e892aa94..c19f65a9 100644 --- a/gui/pages/global/MultiMCPage.h +++ b/gui/pages/global/MultiMCPage.h @@ -21,6 +21,7 @@ #include "logic/java/JavaChecker.h" #include "gui/pages/BasePage.h" +class QTextCharFormat; class SettingsObject; namespace Ui @@ -78,7 +79,12 @@ slots: */ void refreshUpdateChannelDesc(); - void updateChannelSelectionChanged(int index); + /*! + * Updates the font preview + */ + void refreshFontPreview(); + + void updateChannelSelectionChanged(int index); private: Ui::MultiMCPage *ui; @@ -87,4 +93,7 @@ private: * Stores the currently selected update channel. */ QString m_currentUpdateChannel; + + // default format for the font preview... + QTextCharFormat *defaultFormat; }; diff --git a/gui/pages/global/MultiMCPage.ui b/gui/pages/global/MultiMCPage.ui index 78e92592..38d1bb1d 100644 --- a/gui/pages/global/MultiMCPage.ui +++ b/gui/pages/global/MultiMCPage.ui @@ -6,8 +6,8 @@ 0 0 - 556 - 559 + 487 + 519 @@ -65,7 +65,10 @@ - Update Channel: + Up&date Channel: + + + updateChannelComboBox @@ -98,7 +101,10 @@ - Launcher: + &Launcher: + + + ftbLauncherBox @@ -117,6 +123,9 @@ Files: + + ftbBox + @@ -161,7 +170,10 @@ - Instances: + I&nstances: + + + instDirTextBox @@ -178,7 +190,10 @@ - Mods: + &Mods: + + + modsDirTextBox @@ -198,7 +213,10 @@ - LWJGL: + LW&JGL: + + + lwjglDirTextBox @@ -215,7 +233,10 @@ - Icons: + &Icons: + + + iconsDirTextBox @@ -236,8 +257,8 @@ - 20 - 40 + 0 + 0 @@ -369,13 +390,81 @@ + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + Console + + + + + + Console Settings + + + + + + Show console while the game is running? + + + + + + + Automatically close console when the game quits? + + + + + + + + + 0 + 0 + + Console font - - + + + + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOff + + + false + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + @@ -385,22 +474,22 @@ + + + + 5 + + + 16 + + + 11 + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -429,6 +518,11 @@ sortByNameBtn languageBox themeComboBox + showConsoleCheck + autoCloseConsoleCheck + consoleFont + fontSizeBox + fontPreview -- cgit v1.2.3