Added for Composer fonts settings

This commit is contained in:
defnax 2025-02-09 18:05:36 +01:00
parent b168110a58
commit 3ffa362079
5 changed files with 82 additions and 9 deletions

View File

@ -2933,3 +2933,26 @@ void MessageComposer::checkLength()
ui.actionSend->setEnabled(true);
}
}
void MessageComposer::showEvent(QShowEvent *event)
{
if (!event->spontaneous()) {
updateFontSize();
}
}
void MessageComposer::updateFontSize()
{
#if defined(Q_OS_DARWIN)
int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 13).toInt();
#else
int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 12).toInt();
#endif
QFont newFont = ui.msgText->font();
if (newFont.pointSize() != customFontSize) {
newFont.setPointSize(customFontSize);
QFontMetricsF fontMetrics(newFont);
ui.msgText->setFont(newFont);
ui.comboSize->setCurrentIndex(ui.comboSize->findText(QString::number(newFont.pointSize())));
}
}

View File

@ -95,6 +95,7 @@ public slots:
protected:
void closeEvent (QCloseEvent * event);
bool eventFilter(QObject *obj, QEvent *ev);
virtual void showEvent(QShowEvent *) ;
private slots:
/* toggle Contacts DockWidget */
@ -169,6 +170,7 @@ private slots:
static QString inviteMessage();
void checkLength();
void updateFontSize();
private:
static QString buildReplyHeader(const MessageInfo &msgInfo);

View File

@ -55,6 +55,7 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmbededImages() ));
connect(ui.openComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(updateMsgOpen() ));
connect(ui.emoticonscheckBox, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmoticons() ));
connect(ui.minimumFontSize_SB, SIGNAL(valueChanged(int)), this, SLOT(updateFontSize())) ;
mTagEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG );
@ -121,6 +122,11 @@ MessagePage::load()
whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getMsgLoadEmbeddedImages());
whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen()));
whileBlocking(ui.emoticonscheckBox)->setChecked(Settings->value("Emoticons", true).toBool());
#if defined(Q_OS_DARWIN)
whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt());
#else
whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 12 ).toInt());
#endif
Settings->endGroup();
// state of filter combobox
@ -298,3 +304,10 @@ void MessagePage::currentRowChangedTag(int row)
ui.deletepushButton->setEnabled(bDeleteEnable);
}
void MessagePage::updateFontSize()
{
Settings->beginGroup(QString("Messages"));
Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value());
Settings->endGroup();
}

View File

@ -60,6 +60,7 @@ private slots:
void updateDistantMsgs() ;
void updateMsgTags() ;
void updateLoadEmoticons();
void updateFontSize();
private:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);

View File

@ -16,8 +16,8 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Distant messages:</string>
@ -52,7 +52,7 @@
</layout>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Reading</string>
@ -65,17 +65,37 @@
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item row="0" column="1">
<layout class="QHBoxLayout" name="minimumFontSizeHLayout">
<item>
<widget class="QLabel" name="openLabel">
<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>
<widget class="QLabel" name="minimumFontSizeLabel">
<property name="text">
<string>Open messages in</string>
<string>Minimum font size </string>
</property>
</widget>
</item>
<item>
<widget class="RSComboBox" name="openComboBox"/>
<widget class="QSpinBox" name="minimumFontSize_SB">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
</layout>
</item>
@ -93,10 +113,24 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="openLabel">
<property name="text">
<string>Open messages in</string>
</property>
</widget>
</item>
<item>
<widget class="RSComboBox" name="openComboBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Tags</string>