1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

feat(chat): add the ui settings to alter font and size for chat messages

This commit is contained in:
Nils Fenner 2016-06-28 17:34:13 +02:00
parent 67136e29ed
commit 41c96eb159
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
3 changed files with 150 additions and 53 deletions

View File

@ -35,6 +35,7 @@
#include <QStyleFactory>
#include <QTime>
#include <QFileDialog>
#include <QFont>
#include <QStandardPaths>
#include <QDebug>
@ -109,6 +110,8 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI = new Ui::GeneralSettings;
bodyUI->setupUi(this);
Settings& s = Settings::getInstance();
bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED);
bodyUI->checkUpdates->setChecked(Settings::getInstance().getCheckUpdates());
@ -118,6 +121,8 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
bodyUI->txtChatFont->setCurrentFont(s.getChatMessageFont());
bodyUI->txtChatFontSize->setValue(s.getChatMessageFont().pixelSize());
bodyUI->markdownComboBox->setCurrentIndex(Settings::getInstance().getMarkdownPreference());
bodyUI->cbAutorun->setChecked(Settings::getInstance().getAutorun());
@ -571,3 +576,26 @@ void GeneralForm::retranslateUi()
bodyUI->styleBrowser->setItemText(0, tr("None"));
}
void GeneralForm::on_txtChatFont_currentFontChanged(const QFont& f)
{
QFont tmpFont = f;
const int fontSize = bodyUI->txtChatFontSize->value();
if (tmpFont.pixelSize() != fontSize)
tmpFont.setPixelSize(fontSize);
Settings::getInstance().setChatMessageFont(tmpFont);
}
void GeneralForm::on_txtChatFontSize_valueChanged(int arg1)
{
Settings& s = Settings::getInstance();
QFont tmpFont = s.getChatMessageFont();
if (tmpFont.pixelSize() != arg1)
{
tmpFont.setPixelSize(arg1);
s.setChatMessageFont(tmpFont);
}
}

View File

@ -74,6 +74,9 @@ private slots:
void onGroupchatPositionChanged();
void onThemeColorChanged(int);
void on_txtChatFont_currentFontChanged(const QFont& f);
void on_txtChatFontSize_valueChanged(int arg1);
private:
void retranslateUi();

View File

@ -304,6 +304,113 @@ instead of closing itself.</string>
<string>Chat</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Base font:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="txtChatFont"/>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="txtChatFontSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="prefix">
<string>Size: </string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="transLabel_2">
<property name="toolTip">
<string>New Markdown preference may not load until qTox restarts.</string>
</property>
<property name="text">
<string>Markdown format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<spacer name="generalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="markdownComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select Markdown preference.</string>
</property>
<item>
<property name="text">
<string>Plaintext</string>
</property>
</item>
<item>
<property name="text">
<string>Show formatting characters</string>
</property>
</item>
<item>
<property name="text">
<string>Don't show formatting characters</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
@ -374,59 +481,11 @@ instead of closing itself.</string>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="generalLayout_2">
<item>
<widget class="QLabel" name="transLabel_2">
<property name="toolTip">
<string>New Markdown preference may not load until qTox restarts.</string>
</property>
<property name="text">
<string>Text formatting (Markdown):</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="markdownComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select Markdown preference.</string>
</property>
<item>
<property name="text">
<string>Plaintext</string>
</property>
</item>
<item>
<property name="text">
<string>Show formatting characters</string>
</property>
</item>
<item>
<property name="text">
<string>Don't show formatting characters</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="generalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="statusChanges">
@ -476,6 +535,13 @@ will be sent to them when they appear online to you.</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>