summaryrefslogtreecommitdiffstats
path: root/gui/pages/global
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-11-11 00:50:17 +0100
committerPetr Mrázek <peterix@gmail.com>2014-11-15 19:45:49 +0100
commit41bd2a66345e670c3ff127584cae3f6766bac743 (patch)
tree8c136f8eca1d1c0b94049819466292839794b060 /gui/pages/global
parent5711b1be95a826daf0e11b64bec04c4b0d2ea5ef (diff)
downloadMultiMC-41bd2a66345e670c3ff127584cae3f6766bac743.tar
MultiMC-41bd2a66345e670c3ff127584cae3f6766bac743.tar.gz
MultiMC-41bd2a66345e670c3ff127584cae3f6766bac743.tar.lz
MultiMC-41bd2a66345e670c3ff127584cae3f6766bac743.tar.xz
MultiMC-41bd2a66345e670c3ff127584cae3f6766bac743.zip
Add console font size setting and a preview\
Also moves the console settings from the minecraft page.
Diffstat (limited to 'gui/pages/global')
-rw-r--r--gui/pages/global/MinecraftPage.cpp8
-rw-r--r--gui/pages/global/MinecraftPage.ui41
-rw-r--r--gui/pages/global/MultiMCPage.cpp53
-rw-r--r--gui/pages/global/MultiMCPage.h11
-rw-r--r--gui/pages/global/MultiMCPage.ui144
5 files changed, 193 insertions, 64 deletions
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 @@
<x>0</x>
<y>0</y>
<width>545</width>
- <height>609</height>
+ <height>270</height>
</rect>
</property>
<property name="sizePolicy">
@@ -83,14 +83,20 @@
<item row="1" column="0">
<widget class="QLabel" name="labelWindowHeight">
<property name="text">
- <string>Window height:</string>
+ <string>Window hei&amp;ght:</string>
+ </property>
+ <property name="buddy">
+ <cstring>windowHeightSpinBox</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelWindowWidth">
<property name="text">
- <string>Window width:</string>
+ <string>W&amp;indow width:</string>
+ </property>
+ <property name="buddy">
+ <cstring>windowWidthSpinBox</cstring>
</property>
</widget>
</item>
@@ -129,37 +135,14 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="consoleSettingsBox">
- <property name="title">
- <string>Console Settings</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QCheckBox" name="showConsoleCheck">
- <property name="text">
- <string>Show console while the game is running?</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="autoCloseConsoleCheck">
- <property name="text">
- <string>Automatically close console when the game quits?</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<spacer name="verticalSpacerMinecraft">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>20</width>
- <height>40</height>
+ <width>0</width>
+ <height>0</height>
</size>
</property>
</spacer>
@@ -176,8 +159,6 @@
<tabstop>maximizedCheckBox</tabstop>
<tabstop>windowWidthSpinBox</tabstop>
<tabstop>windowHeightSpinBox</tabstop>
- <tabstop>showConsoleCheck</tabstop>
- <tabstop>autoCloseConsoleCheck</tabstop>
</tabstops>
<resources/>
<connections/>
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 <QFileDialog>
#include <QMessageBox>
#include <QDir>
+#include <QTextCharFormat>
#include <pathutils.h>
@@ -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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>556</width>
- <height>559</height>
+ <width>487</width>
+ <height>519</height>
</rect>
</property>
<property name="sizePolicy">
@@ -65,7 +65,10 @@
<item>
<widget class="QLabel" name="updateChannelLabel">
<property name="text">
- <string>Update Channel:</string>
+ <string>Up&amp;date Channel:</string>
+ </property>
+ <property name="buddy">
+ <cstring>updateChannelComboBox</cstring>
</property>
</widget>
</item>
@@ -98,7 +101,10 @@
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
- <string>Launcher:</string>
+ <string>&amp;Launcher:</string>
+ </property>
+ <property name="buddy">
+ <cstring>ftbLauncherBox</cstring>
</property>
</widget>
</item>
@@ -117,6 +123,9 @@
<property name="text">
<string>Files:</string>
</property>
+ <property name="buddy">
+ <cstring>ftbBox</cstring>
+ </property>
</widget>
</item>
<item row="3" column="2">
@@ -161,7 +170,10 @@
<item row="0" column="0">
<widget class="QLabel" name="labelInstDir">
<property name="text">
- <string>Instances:</string>
+ <string>I&amp;nstances:</string>
+ </property>
+ <property name="buddy">
+ <cstring>instDirTextBox</cstring>
</property>
</widget>
</item>
@@ -178,7 +190,10 @@
<item row="1" column="0">
<widget class="QLabel" name="labelModsDir">
<property name="text">
- <string>Mods:</string>
+ <string>&amp;Mods:</string>
+ </property>
+ <property name="buddy">
+ <cstring>modsDirTextBox</cstring>
</property>
</widget>
</item>
@@ -198,7 +213,10 @@
<item row="2" column="0">
<widget class="QLabel" name="labelLWJGLDir">
<property name="text">
- <string>LWJGL:</string>
+ <string>LW&amp;JGL:</string>
+ </property>
+ <property name="buddy">
+ <cstring>lwjglDirTextBox</cstring>
</property>
</widget>
</item>
@@ -215,7 +233,10 @@
<item row="3" column="0">
<widget class="QLabel" name="labelIconsDir">
<property name="text">
- <string>Icons:</string>
+ <string>&amp;Icons:</string>
+ </property>
+ <property name="buddy">
+ <cstring>iconsDirTextBox</cstring>
</property>
</widget>
</item>
@@ -236,8 +257,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>20</width>
- <height>40</height>
+ <width>0</width>
+ <height>0</height>
</size>
</property>
</spacer>
@@ -370,12 +391,80 @@
</widget>
</item>
<item>
+ <spacer name="generalTabSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Console</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="consoleSettingsBox">
+ <property name="title">
+ <string>Console Settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QCheckBox" name="showConsoleCheck">
+ <property name="text">
+ <string>Show console while the game is running?</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="autoCloseConsoleCheck">
+ <property name="text">
+ <string>Automatically close console when the game quits?</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="themeBox_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="title">
<string>Console font</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="0" colspan="2">
+ <widget class="QTextEdit" name="fontPreview">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="undoRedoEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
<widget class="QFontComboBox" name="consoleFont">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -385,22 +474,22 @@
</property>
</widget>
</item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="fontSizeBox">
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ <property name="value">
+ <number>11</number>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
- <item>
- <spacer name="generalTabSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
</widget>
@@ -429,6 +518,11 @@
<tabstop>sortByNameBtn</tabstop>
<tabstop>languageBox</tabstop>
<tabstop>themeComboBox</tabstop>
+ <tabstop>showConsoleCheck</tabstop>
+ <tabstop>autoCloseConsoleCheck</tabstop>
+ <tabstop>consoleFont</tabstop>
+ <tabstop>fontSizeBox</tabstop>
+ <tabstop>fontPreview</tabstop>
</tabstops>
<resources/>
<connections/>