From 3ffa36207998e2c2fccc969cf536d86f12c56e15 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 9 Feb 2025 18:05:36 +0100 Subject: [PATCH] Added for Composer fonts settings --- .../src/gui/msgs/MessageComposer.cpp | 23 ++++++++ retroshare-gui/src/gui/msgs/MessageComposer.h | 2 + .../src/gui/settings/MessagePage.cpp | 13 +++++ retroshare-gui/src/gui/settings/MessagePage.h | 1 + .../src/gui/settings/MessagePage.ui | 52 +++++++++++++++---- 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 4e0219b0c..bbca45bd3 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -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()))); + } +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 040681095..d89aecda5 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -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); diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index ff302317d..de4908088 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -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 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(); +} + diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index 774d31b95..c5b9f7544 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -60,6 +60,7 @@ private slots: void updateDistantMsgs() ; void updateMsgTags() ; void updateLoadEmoticons(); + void updateFontSize(); private: void handleEvent_main_thread(std::shared_ptr event); diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index fd55218e8..d2c44e69e 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -16,8 +16,8 @@ 0 - - + + Distant messages: @@ -52,7 +52,7 @@ - + Reading @@ -65,17 +65,37 @@ - - + + - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - Open messages in + Minimum font size - + + + 10 + + + 64 + + @@ -93,10 +113,24 @@ + + + + + + Open messages in + + + + + + + + - + Tags