From 6d394c9f55bdf62afc32529ceae1645ae7c1ab86 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 10 Feb 2025 19:41:19 +0100 Subject: [PATCH] Added for channel composer default size settings --- .../src/gui/common/GroupTreeWidget.cpp | 26 +++ .../src/gui/common/GroupTreeWidget.h | 3 + .../src/gui/gxs/GxsGroupFrameDialog.cpp | 19 -- .../src/gui/gxs/GxsGroupFrameDialog.h | 3 +- .../src/gui/settings/MessagePage.ui | 164 ++++++++++-------- retroshare-gui/src/util/RichTextEdit.cpp | 23 +++ retroshare-gui/src/util/RichTextEdit.h | 2 + 7 files changed, 149 insertions(+), 91 deletions(-) diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 0597a652c..f84010016 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -67,6 +68,8 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) : connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int))); } + updateFontSize(); + int H = QFontMetricsF(ui->treeWidget->font()).height() ; #if QT_VERSION < QT_VERSION_CHECK(5,11,0) int W = QFontMetricsF(ui->treeWidget->font()).width("_") ; @@ -667,3 +670,26 @@ void GroupTreeWidget::sort() { ui->treeWidget->resort(); } + +void GroupTreeWidget::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void GroupTreeWidget::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->treeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->treeWidget->setFont(newFont); + } +} + diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index b27c37014..7c95ec757 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -30,6 +30,7 @@ class QToolButton; class RshareSettings; class RSTreeWidgetItemCompareRole; class RSTreeWidget; +class QShowEvent; #define GROUPTREEWIDGET_COLOR_STANDARD -1 #define GROUPTREEWIDGET_COLOR_CATEGORY 0 @@ -142,6 +143,7 @@ signals: protected: void changeEvent(QEvent *e); + virtual void showEvent(QShowEvent *) override; private slots: void customContextMenuRequested(const QPoint &pos); @@ -151,6 +153,7 @@ private slots: void distantSearch(); void sort(); + void updateFontSize(); private: void calculateScore(QTreeWidgetItem *item, const QString &filterText); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index a4789b7d9..069c51b79 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -193,9 +193,6 @@ void GxsGroupFrameDialog::showEvent(QShowEvent* /*event*/) bool empty = mCachedGroupMetas.empty() || children==0; updateDisplay( empty ); - - updateFontSize(); - } void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe) @@ -1277,19 +1274,3 @@ void GxsGroupFrameDialog::distantRequestGroupData() checkRequestGroup(group_id) ; } -void GxsGroupFrameDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->groupTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->groupTreeWidget->setFont(newFont); - } -} - - diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index a70e6c890..81bba553d 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -110,8 +110,7 @@ protected: void updateGroupStatisticsReal(const RsGxsGroupId &groupId); void updateMessageSummaryListReal(RsGxsGroupId groupId); - void updateFontSize(); - + private slots: void todo(); diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index d2c44e69e..a0579ab69 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -17,43 +17,14 @@ - - - - Distant messages: - - - - - - - Everyone - - - - - Contacts - - - - - Nobody - - - - - - - - Accept encrypted distant messages from - - - - - - + + + 0 + 0 + + Reading @@ -65,40 +36,6 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Minimum font size - - - - - - - 10 - - - 64 - - - - - @@ -130,7 +67,7 @@ - + Tags @@ -206,6 +143,93 @@ + + + + Distant messages: + + + + + + + Everyone + + + + + Contacts + + + + + Nobody + + + + + + + + Accept encrypted distant messages from + + + + + + + + + + + 0 + 0 + + + + Fonts + + + + + + + + Qt::LeftToRight + + + Minimum font size + + + + + + + 10 + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/retroshare-gui/src/util/RichTextEdit.cpp b/retroshare-gui/src/util/RichTextEdit.cpp index 9d4596a82..9d88d989f 100644 --- a/retroshare-gui/src/util/RichTextEdit.cpp +++ b/retroshare-gui/src/util/RichTextEdit.cpp @@ -614,3 +614,26 @@ void RichTextEdit::checkLength(){ void RichTextEdit::setPlaceHolderTextPosted() { f_textedit->setPlaceholderText(tr("Text (optional)")); } + +void RichTextEdit::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void RichTextEdit::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 = f_textedit->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + f_textedit->setFont(newFont); + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(newFont.pointSize()))); + } +} diff --git a/retroshare-gui/src/util/RichTextEdit.h b/retroshare-gui/src/util/RichTextEdit.h index aae9d20ab..a621a8514 100644 --- a/retroshare-gui/src/util/RichTextEdit.h +++ b/retroshare-gui/src/util/RichTextEdit.h @@ -69,6 +69,7 @@ signals: void insertImage(); void textSource(); void checkLength(); + void updateFontSize(); protected: void mergeFormatOnWordOrSelection(const QTextCharFormat &format); @@ -78,6 +79,7 @@ signals: void list(bool checked, QTextListFormat::Style style); void indent(int delta); void focusInEvent(QFocusEvent *event); + virtual void showEvent(QShowEvent *); QStringList m_paragraphItems; int m_fontsize_h1;