Merge pull request #1938 from defnax/forum-fonts-settings

Added forum settings for Font size & contrast
This commit is contained in:
defnax 2020-05-14 14:29:13 +02:00 committed by GitHub
commit 4f25ab3fe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 25 deletions

View File

@ -1165,16 +1165,14 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
flags |= RSHTML_OPTIMIZEHTML_MASK; flags |= RSHTML_OPTIMIZEHTML_MASK;
QColor backgroundColor = ui->postText->palette().base().color(); QColor backgroundColor = ui->postText->palette().base().color();
qreal desiredContrast = Settings->valueFromGroup("Chat", qreal desiredContrast = Settings->valueFromGroup("Forum",
"MinimumContrast", 4.5).toDouble(); "MinimumContrast", 4.5).toDouble();
int desiredMinimumFontSize = Settings->valueFromGroup("Chat", int desiredMinimumFontSize = Settings->valueFromGroup("Forum",
"MinimumFontSize", 10).toInt(); "MinimumFontSize", 10).toInt();
QString extraTxt = RsHtml().formatText(ui->postText->document(), QString extraTxt = RsHtml().formatText(ui->postText->document(),
QString::fromUtf8(msg.mMsg.c_str()), flags QString::fromUtf8(msg.mMsg.c_str()), flags
#ifndef DEBUG_FORUMS \
, backgroundColor, desiredContrast, desiredMinimumFontSize , backgroundColor, desiredContrast, desiredMinimumFontSize
#endif
); );
ui->postText->setHtml(extraTxt); ui->postText->setHtml(extraTxt);
} }

View File

@ -506,6 +506,11 @@
<verstretch>10</verstretch> <verstretch>10</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="font">
<font>
<family>MS Sans Serif</family>
</font>
</property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>

View File

@ -35,6 +35,8 @@ ForumPage::ForumPage(QWidget * parent, Qt::WindowFlags flags)
connect(ui.expandNewMessages , SIGNAL(toggled(bool)), this, SLOT( updateExpandNewMessages())); connect(ui.expandNewMessages , SIGNAL(toggled(bool)), this, SLOT( updateExpandNewMessages()));
connect(ui.loadEmbeddedImages , SIGNAL(toggled(bool)), this, SLOT(updateLoadEmbeddedImages() )); connect(ui.loadEmbeddedImages , SIGNAL(toggled(bool)), this, SLOT(updateLoadEmbeddedImages() ));
connect(ui.loadEmoticons , SIGNAL(toggled(bool)), this, SLOT( updateLoadEmoticons() )); connect(ui.loadEmoticons , SIGNAL(toggled(bool)), this, SLOT( updateLoadEmoticons() ));
connect(ui.minimumFontSize , SIGNAL(valueChanged(int)), this, SLOT(updateFonts()));
connect(ui.minimumContrast , SIGNAL(valueChanged(int)), this, SLOT(updateFonts()));
ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Forum) ; ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Forum) ;
} }
@ -51,10 +53,22 @@ void ForumPage::updateLoadEmoticons() { Settings->setForumLoadEmoticons(
/** Loads the settings for this page */ /** Loads the settings for this page */
void ForumPage::load() void ForumPage::load()
{ {
Settings->beginGroup(QString("Forum"));
whileBlocking(ui.setMsgToReadOnActivate)->setChecked(Settings->getForumMsgSetToReadOnActivate()); whileBlocking(ui.setMsgToReadOnActivate)->setChecked(Settings->getForumMsgSetToReadOnActivate());
whileBlocking(ui.expandNewMessages)->setChecked(Settings->getForumExpandNewMessages()); whileBlocking(ui.expandNewMessages)->setChecked(Settings->getForumExpandNewMessages());
whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getForumLoadEmbeddedImages()); whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getForumLoadEmbeddedImages());
whileBlocking(ui.loadEmoticons)->setChecked(Settings->getForumLoadEmoticons()); whileBlocking(ui.loadEmoticons)->setChecked(Settings->getForumLoadEmoticons());
whileBlocking(ui.minimumFontSize)->setValue(Settings->value("MinimumFontSize", 10).toInt());
whileBlocking(ui.minimumContrast)->setValue(Settings->value("MinimumContrast", 4.5).toDouble());
Settings->endGroup();
ui.groupFrameSettingsWidget->loadSettings(GroupFrameSettings::Forum); ui.groupFrameSettingsWidget->loadSettings(GroupFrameSettings::Forum);
} }
void ForumPage::updateFonts()
{
Settings->beginGroup(QString("Forum"));
Settings->setValue("MinimumFontSize", ui.minimumFontSize->value());
Settings->setValue("MinimumContrast", ui.minimumContrast->value());
Settings->endGroup();
}

View File

@ -45,6 +45,9 @@ protected slots:
void updateLoadEmbeddedImages(); void updateLoadEmbeddedImages();
void updateLoadEmoticons(); void updateLoadEmoticons();
private slots:
void updateFonts();
private: private:
Ui::ForumPage ui; Ui::ForumPage ui;
}; };

View File

@ -17,6 +17,16 @@
<string>Misc</string> <string>Misc</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QCheckBox" name="loadEmoticons">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This option is costly and it's in the dev's plans to improve it. In the mean time it's disabled by default. If you enable it and long forum posts take a while to display, then disable it again. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Load emoticons (costly)</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="setMsgToReadOnActivate"> <widget class="QCheckBox" name="setMsgToReadOnActivate">
<property name="text"> <property name="text">
@ -38,15 +48,71 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="loadEmoticons"> <layout class="QGridLayout" name="gridLayout">
<property name="toolTip"> <item row="0" column="0">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This option is costly and it's in the dev's plans to improve it. In the mean time it's disabled by default. If you enable it and long forum posts take a while to display, then disable it again. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <widget class="QLabel" name="minimumFontSizeLabel">
</property> <property name="text">
<property name="text"> <string>Minimum font size</string>
<string>Load emoticons (costly)</string> </property>
</property> </widget>
</widget> </item>
<item row="0" column="1">
<widget class="QSpinBox" name="minimumFontSize">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="2">
<spacer name="minimumFontSizeHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>38</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="minimumContrastLabel">
<property name="text">
<string>Minimum text contrast</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="minimumContrast">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>21.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="GroupFrameSettingsWidget" name="groupFrameSettingsWidget" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -64,18 +130,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="0">
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="GroupFrameSettingsWidget" name="groupFrameSettingsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>