Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(chat): add the ui settings to alter font and size for chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
antis81 committed Jun 30, 2016
1 parent 67136e2 commit 41c96eb
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 53 deletions.
28 changes: 28 additions & 0 deletions src/widget/form/settings/generalform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QStyleFactory>
#include <QTime>
#include <QFileDialog>
#include <QFont>
#include <QStandardPaths>
#include <QDebug>

Expand Down Expand Up @@ -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());

Expand All @@ -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());

Expand Down Expand Up @@ -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);
}
}
3 changes: 3 additions & 0 deletions src/widget/form/settings/generalform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
172 changes: 119 additions & 53 deletions src/widget/form/settings/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 41c96eb

Please sign in to comment.