From e14fc66ca3df906e65471b35d7fd4d0cd092057c Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 5 Feb 2025 20:55:03 +0100 Subject: [PATCH 01/18] Settings for default tree & listwidget fonts --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 23 ++++++++++++++++ retroshare-gui/src/gui/ChatLobbyWidget.h | 3 +++ retroshare-gui/src/gui/Identity/IdDialog.cpp | 20 ++++++++++++++ retroshare-gui/src/gui/Identity/IdDialog.h | 2 ++ retroshare-gui/src/gui/MainWindow.cpp | 27 +++++++++++++++++++ retroshare-gui/src/gui/MainWindow.h | 3 +++ .../src/gui/chat/ChatLobbyDialog.cpp | 22 +++++++++++++++ retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 3 +++ .../src/gui/common/NewFriendList.cpp | 25 +++++++++++++++++ retroshare-gui/src/gui/common/NewFriendList.h | 3 +++ .../src/gui/gxs/GxsGroupFrameDialog.cpp | 19 +++++++++++++ .../src/gui/gxs/GxsGroupFrameDialog.h | 3 ++- .../src/gui/msgs/MessagesDialog.cpp | 25 +++++++++++++++++ retroshare-gui/src/gui/msgs/MessagesDialog.h | 3 +++ 14 files changed, 180 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 9682bc4c5..75894fea1 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -230,6 +230,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) int ltwH = misc::getFontSizeFactor("LobbyTreeWidget", 1.5).height(); ui.lobbyTreeWidget->setIconSize(QSize(ltwH,ltwH)); + updateFontSize(); } ChatLobbyWidget::~ChatLobbyWidget() @@ -1368,3 +1369,25 @@ int ChatLobbyWidget::getNumColVisible() } return iNumColVis; } + +void ChatLobbyWidget::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void ChatLobbyWidget::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.lobbyTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.lobbyTreeWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index a5055788e..ce451fe04 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -76,6 +76,8 @@ public: uint unreadCount(); + virtual void showEvent(QShowEvent *) ; + signals: void unreadCountChanged(uint unreadCount); @@ -112,6 +114,7 @@ private slots: void updateNotify(ChatLobbyId id, unsigned int count) ; void idChooserCurrentIndexChanged(int index); + void updateFontSize(); private: void autoSubscribeLobby(QTreeWidgetItem *item); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 032acaa2d..8a099aac8 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -956,6 +956,10 @@ void IdDialog::showEvent(QShowEvent *s) needUpdateCirclesOnNextShow = false; MainPage::showEvent(s); + + if (!s->spontaneous()) { + updateFontSize(); + } } void IdDialog::createExternalCircle() @@ -2599,3 +2603,19 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mExternalOtherCircleItem,1); restoreTopLevel(mMyCircleItem,2); } + +void IdDialog::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->idTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->idTreeWidget->setFont(newFont); + ui->treeWidget_membership->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 403b3a437..ea6095d63 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -113,6 +113,8 @@ private slots: static QString inviteMessage(); void sendInvite(); + void updateFontSize(); + private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index b1e4b1e69..0eb5b69c9 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -67,6 +67,7 @@ #include "notifyqt.h" #include "common/UserNotify.h" #include "gui/ServicePermissionDialog.h" +#include "gui/settings/rsharesettings.h" #ifdef UNFINISHED #include "unfinished/ApplicationWindow.h" @@ -1022,6 +1023,7 @@ void SetForegroundWindowInternal(HWND hWnd) /* Show the dialog. */ raiseWindow(); + /* Set the focus to the specified page. */ _instance->ui->stackPages->setCurrentPage(page); } @@ -1819,6 +1821,31 @@ void MainWindow::setCompactStatusMode(bool compact) //opModeStatus: TODO Show only ??? } +void MainWindow::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void MainWindow::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->listWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height()*1.5; + ui->listWidget->setFont(newFont); + ui->toolBarPage->setFont(newFont); + ui->listWidget->setIconSize(QSize(iconHeight, iconHeight)); + } +} + Gui_InputDialogReturn MainWindow::guiInputDialog(const QString& windowTitle, const QString& labelText, QLineEdit::EchoMode textEchoMode, bool modal) { diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index a7f3013f1..99219de42 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -204,6 +204,8 @@ public: static bool hiddenmode; + virtual void showEvent(QShowEvent *) ; + public slots: void receiveNewArgs(QStringList args); void displayErrorMessage(int,int,const QString&) ; @@ -307,6 +309,7 @@ private slots: void doQuit(); void updateTrayCombine(); + void updateFontSize(); private: void initStackedPage(); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 3b92883e8..56feb5f2f 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -1017,3 +1017,25 @@ void ChatLobbyDialog::setWindowed(bool windowed) if (chatLobbyPage)// If not defined, we are on autosubscribe loop of lobby widget constructor. So don't recall it. showDialog(RS_CHAT_FOCUS); } + +void ChatLobbyDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void ChatLobbyDialog::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.participantsList->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.participantsList->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 065abacee..7df0f01b9 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -54,6 +54,8 @@ public: inline bool isWindowed() const { return dynamic_cast(this->window()) != nullptr; } + virtual void showEvent(QShowEvent *) ; + public slots: void leaveLobby() ; private slots: @@ -64,6 +66,7 @@ private slots: void showInPeopleTab(); void toggleWindowed(){setWindowed(!isWindowed());} void setWindowed(bool windowed); + void updateFontSize(); signals: void typingEventReceived(ChatLobbyId) ; diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 6acb8da9a..9e5039f76 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -55,6 +55,7 @@ #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" #include "gui/notifyqt.h" +#include "gui/settings/rsharesettings.h" #include "NewFriendList.h" #include "ui_NewFriendList.h" @@ -1693,3 +1694,27 @@ void NewFriendList::expandGroup(const RsNodeGroupId& gid) QModelIndex index = mProxyModel->mapFromSource(mModel->getIndexOfGroup(gid)); ui->peerTreeWidget->setExpanded(index,true) ; } + +void NewFriendList::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void NewFriendList::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->peerTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height()*1.5; + ui->peerTreeWidget->setFont(newFont); + ui->peerTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); + } +} diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 7424bcfcf..4679b7804 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -54,6 +54,8 @@ public: explicit NewFriendList(QWidget *parent = 0); ~NewFriendList(); + virtual void showEvent(QShowEvent *) ; + // Add a tool button to the tool area void addToolButton(QToolButton *toolButton); void processSettings(bool load); @@ -95,6 +97,7 @@ private slots: void sortColumn(int col,Qt::SortOrder so); void itemExpanded(const QModelIndex&); void itemCollapsed(const QModelIndex&); + void updateFontSize(); protected: void changeEvent(QEvent *e); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 069c51b79..a4789b7d9 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -193,6 +193,9 @@ void GxsGroupFrameDialog::showEvent(QShowEvent* /*event*/) bool empty = mCachedGroupMetas.empty() || children==0; updateDisplay( empty ); + + updateFontSize(); + } void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe) @@ -1274,3 +1277,19 @@ 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 81bba553d..a70e6c890 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -110,7 +110,8 @@ protected: void updateGroupStatisticsReal(const RsGxsGroupId &groupId); void updateMessageSummaryListReal(RsGxsGroupId groupId); - + void updateFontSize(); + private slots: void todo(); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 85611b585..5cf408267 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -1660,3 +1660,28 @@ void MessagesDialog::updateInterface() ui.tabWidget->setTabIcon(0, FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); } } + +void MessagesDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void MessagesDialog::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.listWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.listWidget->setFont(newFont); + ui.quickViewWidget->setFont(newFont); + ui.messageTreeWidget->setFont(newFont); + } +} + diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 1d10137c2..753f910dd 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -54,6 +54,7 @@ public: // replaced by shortcut // virtual void keyPressEvent(QKeyEvent *) ; + virtual void showEvent(QShowEvent *) ; QColor textColorInbox() const { return mTextColorInbox; } @@ -110,6 +111,8 @@ private slots: void tabChanged(int tab); void tabCloseRequested(int tab); + void updateFontSize(); + private: void handleEvent_main_thread(std::shared_ptr event); void handleTagEvent_main_thread(std::shared_ptr event); From 18f4ef5574137ea3cb65186a36792d0503c05ab7 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 6 Feb 2025 19:02:40 +0100 Subject: [PATCH 02/18] Fix fonts --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 3 +++ .../src/gui/common/FriendSelectionWidget.cpp | 18 ++++++++++++++++++ .../src/gui/common/FriendSelectionWidget.h | 1 + 3 files changed, 22 insertions(+) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 8a099aac8..c69b71647 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -2617,5 +2617,8 @@ void IdDialog::updateFontSize() QFontMetricsF fontMetrics(newFont); ui->idTreeWidget->setFont(newFont); ui->treeWidget_membership->setFont(newFont); + contactsItem->setFont(RSID_COL_NICKNAME, newFont); + allItem->setFont(RSID_COL_NICKNAME, newFont); + ownItem->setFont(RSID_COL_NICKNAME, newFont); } } diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 4608d1796..2d42726c8 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -28,6 +28,7 @@ #include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/StatusDefs.h" +#include "gui/settings/rsharesettings.h" #include "util/qtthreadsutils.h" #include "gui/common/PeerDefs.h" #include "gui/common/GroupDefs.h" @@ -223,6 +224,8 @@ void FriendSelectionWidget::showEvent(QShowEvent */*e*/) { if(gxsIds.empty()) loadIdentities(); + + updateFontSize(); } void FriendSelectionWidget::start() { @@ -1271,3 +1274,18 @@ bool FriendSelectionWidget::isFilterConnected() { return mActionFilterConnected->isChecked(); } + +void FriendSelectionWidget::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->friendList->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->friendList->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index f10a748fc..cde084ede 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -144,6 +144,7 @@ private slots: void itemChanged(QTreeWidgetItem *item, int column); void selectAll() ; void deselectAll() ; + void updateFontSize(); private: void fillList(); From 533caea81e88da3b6ad96bdfc08b1499df25589f Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 6 Feb 2025 20:20:28 +0100 Subject: [PATCH 03/18] Added Fonts settings --- .../src/gui/settings/AppearancePage.cpp | 10 + .../src/gui/settings/AppearancePage.h | 2 + .../src/gui/settings/AppearancePage.ui | 307 ++++++++++-------- .../src/gui/settings/TransferPage.ui | 2 +- 4 files changed, 187 insertions(+), 134 deletions(-) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index a96df209d..6e7b7d63d 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -101,6 +101,9 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) connect(ui.mainPageButtonType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRbtPageOnToolBar() )); // connect(ui.menuItemsButtonType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionButtonLoc() )); + + connect(ui.minimumFontSize_SB, SIGNAL(valueChanged(int)), this, SLOT(updateFontSize())) ; + } void AppearancePage::switch_status_grpStatus(bool b) { switch_status(MainWindow::StatusGrpStatus ,"ShowStatusBar", b) ; } @@ -360,3 +363,10 @@ void AppearancePage::load() whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); } + +void AppearancePage::updateFontSize() +{ + Settings->beginGroup(QString("File")); + Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); + Settings->endGroup(); +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/settings/AppearancePage.h b/retroshare-gui/src/gui/settings/AppearancePage.h index 897563753..741bd752e 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.h +++ b/retroshare-gui/src/gui/settings/AppearancePage.h @@ -71,6 +71,8 @@ private slots: // void updateCmboListItemSize(); void updateStyle() ; + void updateFontSize(); + private: void switch_status(MainWindow::StatusElement s,const QString& key,bool b); diff --git a/retroshare-gui/src/gui/settings/AppearancePage.ui b/retroshare-gui/src/gui/settings/AppearancePage.ui index 96e5effe8..592113e01 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.ui +++ b/retroshare-gui/src/gui/settings/AppearancePage.ui @@ -14,22 +14,7 @@ Qt::NoContextMenu - - 6 - - - 6 - - - 6 - - - 6 - - - 0 - - + @@ -86,110 +71,12 @@ - - - - - 0 - 64 - - - - Qt::NoContextMenu - - - - - - Style - - - - - - - 150 - 0 - - - - Choose RetroShare's interface style - - - - - - - Qt::Horizontal - - - - 215 - 20 - - - - - - - - - - - - 0 - 64 - - - - Style Sheet - - - - - - - 150 - 0 - - - - - - - - Qt::Horizontal - - - - 215 - 20 - - - - - - - - - - - Qt::Vertical - - - - 361 - 61 - - - - - + 0 - 228 + 0 @@ -198,8 +85,8 @@ Tool Bar - - + + @@ -237,7 +124,7 @@ - + @@ -289,19 +176,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -352,10 +226,79 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + + + Fonts + + + + + + + + Minimum font size + + + + + + + 11 + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 188 + 96 + + + + + + + + Status Bar @@ -464,6 +407,104 @@ + + + + Qt::Vertical + + + + 361 + 61 + + + + + + + + + 0 + 64 + + + + Qt::NoContextMenu + + + + + + Style + + + + + + + 150 + 0 + + + + Choose RetroShare's interface style + + + + + + + Qt::Horizontal + + + + 215 + 20 + + + + + + + + + + + + 0 + 64 + + + + Style Sheet + + + + + + + 150 + 0 + + + + + + + + Qt::Horizontal + + + + 215 + 20 + + + + + + + diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index e77ee1742..4b48be012 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -14,7 +14,7 @@ - 1 + 0 From 7399c42dfbe43b2bd8d4eb0b166db3ee15a55743 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 8 Feb 2025 15:13:43 +0100 Subject: [PATCH 04/18] Fix settings --- retroshare-gui/src/gui/settings/AppearancePage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 6e7b7d63d..72b2a4bf7 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -362,6 +362,13 @@ void AppearancePage::load() whileBlocking(ui.checkBoxShowToasterDisable)->setChecked(Settings->valueFromGroup("StatusBar", "ShowToaster", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); + Settings->beginGroup(QString("File")); +#if defined(Q_OS_DARWIN) + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt()); +#else + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 11 ).toInt()); +#endif + Settings->endGroup(); } void AppearancePage::updateFontSize() From b168110a581440b39b2fdc2e53c858168b3f698a Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 8 Feb 2025 15:44:39 +0100 Subject: [PATCH 05/18] Added for settings list fonts settings --- .../src/gui/settings/rsettingswin.cpp | 22 +++++++++++++++++++ .../src/gui/settings/rsettingswin.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 1d3d4ecc3..663cc7d03 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -239,3 +239,25 @@ void SettingsPage::notifySettingsChanged() if (NotifyQt::getInstance()) NotifyQt::getInstance()->notifySettingsChanged(); } + +void SettingsPage::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void SettingsPage::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.listWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.listWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 74fb0d40c..64d8ebb52 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -53,6 +53,7 @@ protected: ~SettingsPage(); void addPage(ConfigPage*) ; + virtual void showEvent(QShowEvent *) override; public slots: //! Go to a specific part of the control panel. @@ -67,6 +68,7 @@ private slots: private: void initStackedWidget(); + void updateFontSize(); private: FloatingHelpBrowser *mHelpBrowser; From 3ffa36207998e2c2fccc969cf536d86f12c56e15 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 9 Feb 2025 18:05:36 +0100 Subject: [PATCH 06/18] 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 From 6d394c9f55bdf62afc32529ceae1645ae7c1ab86 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 10 Feb 2025 19:41:19 +0100 Subject: [PATCH 07/18] 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; From a5752ec4d38461155b4319fbbac4050014cf0da1 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 10 Feb 2025 20:03:43 +0100 Subject: [PATCH 08/18] Fixed alignment for the attachment counter --- retroshare-gui/src/gui/msgs/MessageModel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 6116e42b4..14b15479c 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -209,6 +209,8 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const std::cerr << "calling data(" << index << ") role=" << role << std::endl; #endif + int coln = index.column(); + if(!index.isValid()) return QVariant(); @@ -251,6 +253,14 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const return QVariant(font); } + + if (role == Qt::TextAlignmentRole) + { + if((coln == COLUMN_THREAD_ATTACHMENT)) + return int( Qt::AlignHCenter | Qt::AlignVCenter); + else + return QVariant(); + } #ifdef DEBUG_MESSAGE_MODEL std::cerr << " [ok]" << std::endl; From 5005c0303d5c4211a456b1edda172e478dc658c5 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 11 Feb 2025 18:51:20 +0100 Subject: [PATCH 09/18] Fixed to update the fonts for MainWindow ListWidget --- retroshare-gui/src/gui/MainWindow.cpp | 10 ++-------- retroshare-gui/src/gui/MainWindow.h | 2 -- retroshare-gui/src/gui/settings/AppearancePage.cpp | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 0eb5b69c9..69ba1494e 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1642,6 +1642,8 @@ void MainWindow::settingsChanged() ui->toolBarAction->setIconSize(QSize(toolSize,toolSize)); int itemSize = Settings->getListItemIconSize(); ui->listWidget->setIconSize(QSize(itemSize,itemSize)); + + updateFontSize(); } void MainWindow::externalLinkActivated(const QUrl &url) @@ -1821,13 +1823,6 @@ void MainWindow::setCompactStatusMode(bool compact) //opModeStatus: TODO Show only ??? } -void MainWindow::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - void MainWindow::updateFontSize() { #if defined(Q_OS_DARWIN) @@ -1841,7 +1836,6 @@ void MainWindow::updateFontSize() QFontMetricsF fontMetrics(newFont); int iconHeight = fontMetrics.height()*1.5; ui->listWidget->setFont(newFont); - ui->toolBarPage->setFont(newFont); ui->listWidget->setIconSize(QSize(iconHeight, iconHeight)); } } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 99219de42..56745d7d6 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -204,8 +204,6 @@ public: static bool hiddenmode; - virtual void showEvent(QShowEvent *) ; - public slots: void receiveNewArgs(QStringList args); void displayErrorMessage(int,int,const QString&) ; diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 72b2a4bf7..c471649cb 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -376,4 +376,6 @@ void AppearancePage::updateFontSize() Settings->beginGroup(QString("File")); Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); Settings->endGroup(); + + NotifyQt::getInstance()->notifySettingsChanged(); } \ No newline at end of file From 49242e185b91917a0410d7b1f73dde723d4ec084 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 12 Feb 2025 18:36:13 +0100 Subject: [PATCH 10/18] Fixed fonts update --- retroshare-gui/src/gui/common/GroupTreeWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index f84010016..3945037dd 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -30,6 +30,7 @@ #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/DateTime.h" +#include "gui/notifyqt.h" #include #include @@ -690,6 +691,8 @@ void GroupTreeWidget::updateFontSize() newFont.setPointSize(customFontSize); QFontMetricsF fontMetrics(newFont); ui->treeWidget->setFont(newFont); + int H = QFontMetricsF(ui->treeWidget->font()).height() ; + ui->treeWidget->setIconSize(QSize(H*1.8,H*1.8)); } } From cd338613c1583d0040f2f9d42cdb8ff5633ca85a Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 12 Feb 2025 19:26:16 +0100 Subject: [PATCH 11/18] Attempt for forums tree fonts settings --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 27 +++++++++++++++++++ .../src/gui/gxsforums/GxsForumThreadWidget.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 11d04fdd8..f19bfee5a 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -250,6 +250,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->setupUi(this); //setUpdateWhenInvisible(true); + updateFontSize(); //mUpdating = false; mUnreadCount = 0; @@ -367,6 +368,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget blankPost(); + + ui->subscribeToolButton->setToolTip(tr( "

Subscribing to the forum will gather \ available posts from your subscribed friends, and make the \ forum visible to all other friends.

Afterwards you can unsubscribe from the context menu of the forum list at left.

")); @@ -2099,3 +2102,27 @@ void GxsForumThreadWidget::showAuthorInPeople(const RsGxsForumMsg& msg) MainWindow::showWindow(MainWindow::People); idDialog->navigate(RsGxsId(msg.mMeta.mAuthorId)); } + +void GxsForumThreadWidget::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void GxsForumThreadWidget::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = ui->threadTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->threadTreeWidget->setFont(newFont); + int iconHeight = fontMetrics.height() * 1.4; + ui->threadTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); + } +} diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 322c64fae..b867c2399 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -97,6 +97,7 @@ public: protected: //bool eventFilter(QObject *obj, QEvent *ev); //void changeEvent(QEvent *e); + virtual void showEvent(QShowEvent *) override; /* RsGxsUpdateBroadcastWidget */ virtual void updateDisplay(bool complete); @@ -160,6 +161,8 @@ private slots: void filterColumnChanged(int column); void filterItems(const QString &text); + void updateFontSize(); + #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) void expandSubtree(); #endif From c61c939b2a6bdfa35c86bd758189ea505ef91f8b Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 18 Feb 2025 19:56:11 +0100 Subject: [PATCH 12/18] Fixed to get fonts work in forums tree --- retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index f19bfee5a..8a0357303 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -308,10 +308,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool))); /* Set own item delegate */ - RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - itemDelegate->setSpacing(QSize(0, 2)); - itemDelegate->setOnlyPlainText(true); - ui->threadTreeWidget->setItemDelegate(itemDelegate); + //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + //itemDelegate->setSpacing(QSize(0, 2)); + //itemDelegate->setOnlyPlainText(true); + //ui->threadTreeWidget->setItemDelegate(itemDelegate); /* add filter actions */ ui->filterLineEdit->addFilter(QIcon(), tr("Title"), RsGxsForumModel::COLUMN_THREAD_TITLE, tr("Search Title")); From 2644a0ccb79188b69da8fee7e0272020c02ba483 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 26 Feb 2025 17:56:38 +0100 Subject: [PATCH 13/18] Added for search list update fontsize --- .../src/gui/FileTransfer/SearchDialog.cpp | 38 ++++++++++++++++--- .../src/gui/FileTransfer/SearchDialog.h | 5 +++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index b3d74d6c4..db11ab613 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -38,6 +38,7 @@ #include "gui/common/RSTreeWidgetItem.h" #include "util/QtVersion.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" #include #include @@ -167,8 +168,8 @@ SearchDialog::SearchDialog(QWidget *parent) // To allow a proper sorting, be careful to pad at right with spaces. This // is achieved by using QString("%1").arg(number,15,10). // - ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; - ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; + //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; + //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; /* make it extended selection */ ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -255,8 +256,8 @@ SearchDialog::~SearchDialog() delete mSizeColumnDelegate; delete mAgeColumnDelegate; - ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); - ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); + //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); + //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); rsEvents->unregisterEventsHandler(mEventHandlerId); } @@ -1325,11 +1326,13 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s * to facilitate downloads we need to save the file size too */ - item->setText(SR_SIZE_COL, QString::number(file.size)); + item->setText(SR_SIZE_COL, misc::friendlyUnit(file.size)); item->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) file.size); - item->setText(SR_AGE_COL, QString::number(file.mtime)); + item->setText(SR_AGE_COL, misc::timeRelativeToNow(file.mtime)); item->setData(SR_AGE_COL, ROLE_SORT, file.mtime); item->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); + item->setTextAlignment( SR_AGE_COL, Qt::AlignCenter ); + int friendSource = 0; int anonymousSource = 0; if(searchType == FRIEND_SEARCH) @@ -1627,3 +1630,26 @@ void SearchDialog::openFolderSearch() } } } + +void SearchDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void SearchDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = ui.searchSummaryWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.searchSummaryWidget->setFont(newFont); + ui.searchResultWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index 8aa7bac64..aa5c4e2b4 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -66,6 +66,9 @@ public: void updateFiles(qulonglong request_id, const FileDetail& file) ; +protected: + virtual void showEvent(QShowEvent *) override; + private slots: /** Create the context popup menu and it's submenus */ @@ -116,6 +119,8 @@ private slots: void filterItems(); + void updateFontSize(); + private: /** render the results to the tree widget display */ void initSearchResult(const QString& txt,qulonglong searchId, int fileType, bool advanced) ; From 95ea588c9fa6587200a5bc6e755546e6b19ddc76 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 28 Feb 2025 17:38:14 +0100 Subject: [PATCH 14/18] Fixed Subject column fonts --- retroshare-gui/src/gui/msgs/MessagesDialog.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 5cf408267..196012070 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -163,9 +163,9 @@ MessagesDialog::MessagesDialog(QWidget *parent) changeBox(0); // set to inbox - RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - itemDelegate->setSpacing(QSize(0, 2)); - ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); + //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + //itemDelegate->setSpacing(QSize(0, 2)); + //ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ; ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_TO,new GxsIdTreeItemDelegate()) ; @@ -1679,9 +1679,13 @@ void MessagesDialog::updateFontSize() if (newFont.pointSize() != customFontSize) { newFont.setPointSize(customFontSize); QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height()*1.5; ui.listWidget->setFont(newFont); ui.quickViewWidget->setFont(newFont); ui.messageTreeWidget->setFont(newFont); + ui.listWidget->setIconSize(QSize(iconHeight, iconHeight)); + ui.quickViewWidget->setIconSize(QSize(iconHeight, iconHeight)); + ui.messageTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); } } From cab91819d69cbc1f52940b85ab5384c06f3af114 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Mon, 24 Mar 2025 23:24:08 +0100 Subject: [PATCH 15/18] Added set and get of font size on RshareSettings --- .../src/gui/settings/AppearancePage.cpp | 16 +++------- .../src/gui/settings/AppearancePage.ui | 2 +- .../src/gui/settings/MessagePage.cpp | 28 ++++++++-------- .../src/gui/settings/MessagePage.ui | 19 ++++++++--- .../src/gui/settings/rsharesettings.cpp | 32 +++++++++++++++++++ .../src/gui/settings/rsharesettings.h | 6 ++++ 6 files changed, 72 insertions(+), 31 deletions(-) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index c471649cb..2aecd6024 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -362,20 +362,12 @@ void AppearancePage::load() whileBlocking(ui.checkBoxShowToasterDisable)->setChecked(Settings->valueFromGroup("StatusBar", "ShowToaster", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); - Settings->beginGroup(QString("File")); -#if defined(Q_OS_DARWIN) - whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt()); -#else - whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 11 ).toInt()); -#endif - Settings->endGroup(); + whileBlocking(ui.minimumFontSize_SB)->setValue(Settings->getFontSize()); } void AppearancePage::updateFontSize() { - Settings->beginGroup(QString("File")); - Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); - Settings->endGroup(); - + Settings->setFontSize(ui.minimumFontSize_SB->value()); + NotifyQt::getInstance()->notifySettingsChanged(); -} \ No newline at end of file +} diff --git a/retroshare-gui/src/gui/settings/AppearancePage.ui b/retroshare-gui/src/gui/settings/AppearancePage.ui index 592113e01..13dc7a48e 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.ui +++ b/retroshare-gui/src/gui/settings/AppearancePage.ui @@ -260,7 +260,7 @@ - 11 + 5 64 diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index de4908088..be8b515ff 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -18,6 +18,8 @@ * * *******************************************************************************/ +#include + #include "rshare.h" #include "rsharesettings.h" #include "retroshare/rsmsgs.h" @@ -28,6 +30,7 @@ #include #include "NewTag.h" #include "util/qtthreadsutils.h" +#include "gui/notifyqt.h" MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) : ConfigPage(parent, flags) @@ -48,14 +51,20 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB); ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW); - + + // Font size + QFontDatabase db; + foreach(int size, db.standardSizes()) { + ui.minimumFontSize->addItem(QString::number(size), size); + } + connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantMsgsComboBoxChanged(int))); connect(ui.setMsgToReadOnActivate,SIGNAL(toggled(bool)), this,SLOT(updateMsgToReadOnActivate())); 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())) ; + connect(ui.minimumFontSize, SIGNAL(activated(QString)), this, SLOT(updateFontSize())) ; mTagEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG ); @@ -117,17 +126,11 @@ void MessagePage::updateMsgTags() void MessagePage::load() { - Settings->beginGroup(QString("Messages")); whileBlocking(ui.setMsgToReadOnActivate)->setChecked(Settings->getMsgSetToReadOnActivate()); 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(); + whileBlocking(ui.minimumFontSize)->setCurrentIndex(ui.minimumFontSize->findData(Settings->getMessageFontSize())); // state of filter combobox @@ -306,8 +309,7 @@ void MessagePage::currentRowChangedTag(int row) void MessagePage::updateFontSize() { - Settings->beginGroup(QString("Messages")); - Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); - Settings->endGroup(); -} + Settings->setMessageFontSize(ui.minimumFontSize->currentData().toInt()); + NotifyQt::getInstance()->notifySettingsChanged(); +} diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index a0579ab69..3e5ab3842 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -203,12 +203,21 @@ - - - 10 + + + + MS Sans Serif + 10 + - - 64 + + Qt::ClickFocus + + + Font size + + + true diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index e811acd4a..119ea9566 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -1190,6 +1190,38 @@ void RshareSettings::setPageAlreadyDisplayed(const QString& page_name,bool b) return setValueToGroup("PageAlreadyDisplayed",page_name,b); } +int RshareSettings::getFontSize() +{ +#if defined(Q_OS_DARWIN) + int defaultFontSize = 13; +#else + int defaultFontSize = 9; +#endif + + return value("FontSize", defaultFontSize).toInt(); +} + +void RshareSettings::setFontSize(int value) +{ + setValue("FontSize", value); +} + +int RshareSettings::getMessageFontSize() +{ +#if defined(Q_OS_DARWIN) + int defaultFontSize = 12; +#else + int defaultFontSize = 9; +#endif + + return valueFromGroup("Message", "FontSize", defaultFontSize).toInt(); +} + +void RshareSettings::setMessageFontSize(int value) +{ + setValueToGroup("Message", "FontSize", value); +} + #ifdef RS_JSONAPI bool RshareSettings::getJsonApiEnabled() { diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 362e52606..317dedb56 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -343,6 +343,12 @@ public: bool getPageAlreadyDisplayed(const QString& page_code) ; void setPageAlreadyDisplayed(const QString& page_code,bool b) ; + int getFontSize(); + void setFontSize(int value); + + int getMessageFontSize(); + void setMessageFontSize(int value); + #ifdef RS_JSONAPI bool getJsonApiEnabled(); void setJsonApiEnabled(bool enabled); From 93154fddc4b0a10fd29fde38824066dd64d6b5f5 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 26 Mar 2025 01:20:54 +0100 Subject: [PATCH 16/18] Added new class FontSizeHandler to set font size from settings --- retroshare-gui/src/retroshare-gui.pro | 2 + retroshare-gui/src/util/FontSizeHandler.cpp | 210 ++++++++++++++++++++ retroshare-gui/src/util/FontSizeHandler.h | 71 +++++++ 3 files changed, 283 insertions(+) create mode 100644 retroshare-gui/src/util/FontSizeHandler.cpp create mode 100644 retroshare-gui/src/util/FontSizeHandler.h diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index d73117b84..e88d931f6 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -451,6 +451,7 @@ HEADERS += rshare.h \ util/qtthreadsutils.h \ util/ClickableLabel.h \ util/AspectRatioPixmapLabel.h \ + util/FontSizeHandler.h \ gui/profile/ProfileWidget.h \ gui/profile/ProfileManager.h \ gui/profile/StatusMessage.h \ @@ -817,6 +818,7 @@ SOURCES += main.cpp \ util/RichTextEdit.cpp \ util/ClickableLabel.cpp \ util/AspectRatioPixmapLabel.cpp \ + util/FontSizeHandler.cpp \ gui/profile/ProfileWidget.cpp \ gui/profile/StatusMessage.cpp \ gui/profile/ProfileManager.cpp \ diff --git a/retroshare-gui/src/util/FontSizeHandler.cpp b/retroshare-gui/src/util/FontSizeHandler.cpp new file mode 100644 index 000000000..c184da0de --- /dev/null +++ b/retroshare-gui/src/util/FontSizeHandler.cpp @@ -0,0 +1,210 @@ +/******************************************************************************* + * util/FontSizeHandler.cpp * + * * + * Copyright (C) 2025, Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include + +#include "rshare.h" +#include "FontSizeHandler.h" +#include "gui/settings/rsharesettings.h" +#include "gui/notifyqt.h" + +// Data for QAbstractItemView +struct FontSizeHandlerWidgetData +{ + std::function callback; +}; + +// Data for QWidget +struct FontSizeHandlerViewData +{ + float iconHeightFactor; + std::function callback; +}; + +class FontSizeHandlerObject : public QObject +{ +public: + FontSizeHandlerObject(FontSizeHandlerBase *fontSizeHandler): QObject() + { + mFontSizeHandlerBase = fontSizeHandler; + } + + bool eventFilter(QObject* object, QEvent* event) + { + if (event->type() == QEvent::StyleChange) { + QMap::iterator itView = mView.find((QAbstractItemView*) object); + if (itView != mView.end()) { + mFontSizeHandlerBase->updateFontSize(itView.key(), itView.value().iconHeightFactor, itView.value().callback); + } + + QMap::iterator itWidget = mWidget.find((QWidget*) object); + if (itWidget != mWidget.end()) { + mFontSizeHandlerBase->updateFontSize(itWidget.key(), itWidget.value().callback); + } + } + + return false; + } + + void registerFontSize(QWidget *widget, std::function callback) + { + FontSizeHandlerWidgetData data; + data.callback = callback; + mWidget.insert(widget, data); + + QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, widget, [this, widget, callback]() { + mFontSizeHandlerBase->updateFontSize(widget, callback); + }); + + widget->installEventFilter(this); + QObject::connect(widget, &QObject::destroyed, this, [this, widget](QObject *object) { + if (widget == object) { + mWidget.remove(widget); + widget->removeEventFilter(this); + } + }); + + mFontSizeHandlerBase->updateFontSize(widget, callback, true); + } + + void registerFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback) + { + FontSizeHandlerViewData data; + data.iconHeightFactor = iconHeightFactor; + data.callback = callback; + mView.insert(view, data); + + QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, view, [this, view, iconHeightFactor, callback]() { + mFontSizeHandlerBase->updateFontSize(view, iconHeightFactor, callback); + }); + + view->installEventFilter(this); + QObject::connect(view, &QObject::destroyed, this, [this, view](QObject *object) { + if (view == object) { + mView.remove(view); + view->removeEventFilter(this); + } + }); + + mFontSizeHandlerBase->updateFontSize(view, iconHeightFactor, callback, true); + } + +private: + FontSizeHandlerBase *mFontSizeHandlerBase; + QMap mView; + QMap mWidget; +}; + +FontSizeHandlerBase::FontSizeHandlerBase(Type type) +{ + mType = type; + mObject = nullptr; +} + +FontSizeHandlerBase::~FontSizeHandlerBase() +{ + if (mObject) { + mObject->deleteLater(); + mObject = nullptr; + } +} + +int FontSizeHandlerBase::getFontSize() +{ + switch (mType) { + case FONT_SIZE: + return Settings->getFontSize(); + + case MESSAGE_FONT_SIZE: + return Settings->getMessageFontSize(); + } + + return 0; +} + +void FontSizeHandlerBase::registerFontSize(QWidget *widget, std::function callback) +{ + if (!widget) { + return; + } + + if (!mObject) { + mObject = new FontSizeHandlerObject(this); + } + + mObject->registerFontSize(widget, callback); +} + +void FontSizeHandlerBase::registerFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback) +{ + if (!view) { + return; + } + + if (!mObject) { + mObject = new FontSizeHandlerObject(this); + } + + mObject->registerFontSize(view, iconHeightFactor, callback); +} + +void FontSizeHandlerBase::updateFontSize(QWidget *widget, std::function callback, bool force) +{ + if (!widget) { + return; + } + + int fontSize = getFontSize(); + QFont font = widget->font(); + if (force || font.pointSize() != fontSize) { + font.setPointSize(fontSize); + widget->setFont(font); + + if (callback) { + callback(widget, fontSize); + } + } +} + +void FontSizeHandlerBase::updateFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback, bool force) +{ + if (!view) { + return; + } + + int fontSize = getFontSize(); + QFont font = view->font(); + if (force || font.pointSize() != fontSize) { + font.setPointSize(fontSize); + view->setFont(font); + + if (iconHeightFactor) { + QFontMetricsF fontMetrics(font); + int iconHeight = fontMetrics.height() * iconHeightFactor; + view->setIconSize(QSize(iconHeight, iconHeight)); + } + + if (callback) { + callback(view, fontSize); + } + } +} diff --git a/retroshare-gui/src/util/FontSizeHandler.h b/retroshare-gui/src/util/FontSizeHandler.h new file mode 100644 index 000000000..19859227d --- /dev/null +++ b/retroshare-gui/src/util/FontSizeHandler.h @@ -0,0 +1,71 @@ +/******************************************************************************* + * util/FontSizeHandler.h * + * * + * Copyright (C) 2025, Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef _FONTSIZEHANDLER_H +#define _FONTSIZEHANDLER_H + +class QWidget; +class QAbstractItemView; +class FontSizeHandlerObject; + +// Class to handle font size and message font size setting +class FontSizeHandlerBase +{ + friend class FontSizeHandlerObject; + +public: + virtual ~FontSizeHandlerBase(); + + int getFontSize(); + + void registerFontSize(QWidget *widget, std::function callback = nullptr); + void registerFontSize(QAbstractItemView *view, float iconHeightFactor = 0.0f, std::function callback = nullptr); + + void updateFontSize(QWidget *widget, std::function callback = nullptr, bool force = false); + void updateFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback, bool force = false); + +protected: + enum Type { + FONT_SIZE, + MESSAGE_FONT_SIZE + }; + + FontSizeHandlerBase(Type type); + +private: + Type mType; + FontSizeHandlerObject *mObject; +}; + +// Class to handle font size setting +class FontSizeHandler : public FontSizeHandlerBase +{ +public: + FontSizeHandler() : FontSizeHandlerBase(FONT_SIZE) {} +}; + +// Class to handle message font size setting +class MessageFontSizeHandler : public FontSizeHandlerBase +{ +public: + MessageFontSizeHandler() : FontSizeHandlerBase(MESSAGE_FONT_SIZE) {} +}; + +#endif // FONTSIZEHANDLER From 973246624f5032a0375163512e4250f87fe13523 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 26 Mar 2025 01:24:14 +0100 Subject: [PATCH 17/18] Replaced font handling by FontSizeHandler and reenabled deactivated item delegates --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 25 +------ retroshare-gui/src/gui/ChatLobbyWidget.h | 6 +- .../src/gui/FileTransfer/SearchDialog.cpp | 45 +++---------- .../src/gui/FileTransfer/SearchDialog.h | 8 +-- retroshare-gui/src/gui/Identity/IdDialog.cpp | 67 +++++++++++-------- retroshare-gui/src/gui/Identity/IdDialog.h | 5 +- retroshare-gui/src/gui/MainWindow.cpp | 22 +----- retroshare-gui/src/gui/MainWindow.h | 4 +- .../src/gui/RSHumanReadableDelegate.h | 15 ++++- .../src/gui/chat/ChatLobbyDialog.cpp | 24 +------ retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 6 +- .../src/gui/common/FriendSelectionWidget.cpp | 20 +----- .../src/gui/common/FriendSelectionWidget.h | 4 +- .../src/gui/common/GroupTreeWidget.cpp | 49 +++++--------- .../src/gui/common/GroupTreeWidget.h | 5 +- .../src/gui/common/NewFriendList.cpp | 27 +------- retroshare-gui/src/gui/common/NewFriendList.h | 5 +- .../src/gui/gxsforums/GxsForumModel.cpp | 18 +++-- .../src/gui/gxsforums/GxsForumModel.h | 3 + .../gui/gxsforums/GxsForumThreadWidget.cpp | 43 +++--------- .../src/gui/gxsforums/GxsForumThreadWidget.h | 6 +- .../src/gui/msgs/MessageComposer.cpp | 29 ++------ retroshare-gui/src/gui/msgs/MessageComposer.h | 5 +- retroshare-gui/src/gui/msgs/MessageModel.cpp | 14 +++- retroshare-gui/src/gui/msgs/MessageModel.h | 3 + .../src/gui/msgs/MessagesDialog.cpp | 52 ++++++-------- retroshare-gui/src/gui/msgs/MessagesDialog.h | 6 +- .../src/gui/settings/rsettingswin.cpp | 24 +------ .../src/gui/settings/rsettingswin.h | 5 +- retroshare-gui/src/util/RichTextEdit.cpp | 28 ++------ retroshare-gui/src/util/RichTextEdit.h | 6 +- 31 files changed, 196 insertions(+), 383 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 75894fea1..4caa97706 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -230,7 +230,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) int ltwH = misc::getFontSizeFactor("LobbyTreeWidget", 1.5).height(); ui.lobbyTreeWidget->setIconSize(QSize(ltwH,ltwH)); - updateFontSize(); + + mFontSizeHandler.registerFontSize(ui.lobbyTreeWidget); } ChatLobbyWidget::~ChatLobbyWidget() @@ -1369,25 +1370,3 @@ int ChatLobbyWidget::getNumColVisible() } return iNumColVis; } - -void ChatLobbyWidget::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void ChatLobbyWidget::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.lobbyTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.lobbyTreeWidget->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index ce451fe04..424780dac 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -25,6 +25,7 @@ #include "chat/ChatLobbyUserNotify.h" #include "gui/gxs/GxsIdChooser.h" +#include "util/FontSizeHandler.h" #include @@ -76,8 +77,6 @@ public: uint unreadCount(); - virtual void showEvent(QShowEvent *) ; - signals: void unreadCountChanged(uint unreadCount); @@ -114,7 +113,6 @@ private slots: void updateNotify(ChatLobbyId id, unsigned int count) ; void idChooserCurrentIndexChanged(int index); - void updateFontSize(); private: void autoSubscribeLobby(QTreeWidgetItem *item); @@ -149,6 +147,8 @@ private: QAbstractButton* myInviteYesButton; GxsIdChooser* myInviteIdChooser; + FontSizeHandler mFontSizeHandler; + /* UI - from Designer */ Ui::ChatLobbyWidget ui; }; diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index db11ab613..2d00b3e5b 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -168,8 +168,8 @@ SearchDialog::SearchDialog(QWidget *parent) // To allow a proper sorting, be careful to pad at right with spaces. This // is achieved by using QString("%1").arg(number,15,10). // - //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; - //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; + ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; + ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; /* make it extended selection */ ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -202,10 +202,6 @@ SearchDialog::SearchDialog(QWidget *parent) ui.searchResultWidget->sortItems(SR_NAME_COL, Qt::AscendingOrder); - QFontMetricsF fontMetrics(ui.searchResultWidget->font()); - int iconHeight = fontMetrics.height() * 1.4; - ui.searchResultWidget->setIconSize(QSize(iconHeight, iconHeight)); - /* Set initial size the splitter */ QList sizes; sizes << 250 << width(); // Qt calculates the right sizes @@ -240,6 +236,8 @@ SearchDialog::SearchDialog(QWidget *parent) RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); }, mEventHandlerId, RsEventType::FILE_TRANSFER ); + mFontSizeHandler.registerFontSize(ui.searchSummaryWidget); + mFontSizeHandler.registerFontSize(ui.searchResultWidget, 1.4f); } SearchDialog::~SearchDialog() @@ -256,8 +254,8 @@ SearchDialog::~SearchDialog() delete mSizeColumnDelegate; delete mAgeColumnDelegate; - //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); - //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); + ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); + ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); rsEvents->unregisterEventsHandler(mEventHandlerId); } @@ -1042,7 +1040,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons child->setText(SR_SOURCES_COL, QString::number(1)); child->setData(SR_SOURCES_COL, ROLE_SORT, 1); - child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); child->setText(SR_SEARCH_ID_COL, sid_hexa); setIconAndType(child, QString::fromUtf8(dir.name.c_str())); @@ -1067,7 +1065,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); child->setText(SR_SOURCES_COL, QString::number(1)); child->setData(SR_SOURCES_COL, ROLE_SORT, 1); - child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); child->setText(SR_SEARCH_ID_COL, sid_hexa); child->setText(SR_TYPE_COL, tr("Folder")); @@ -1136,7 +1134,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); child->setText(SR_SOURCES_COL, QString::number(1)); child->setData(SR_SOURCES_COL, ROLE_SORT, 1); - child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); child->setText(SR_SEARCH_ID_COL, sid_hexa); child->setText(SR_TYPE_COL, tr("Folder")); @@ -1351,7 +1349,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s item->setText(SR_SOURCES_COL,modifiedResult); item->setToolTip(SR_SOURCES_COL, tr("Obtained via ")+QString::fromStdString(rsPeers->getPeerName(file.id)) ); item->setData(SR_SOURCES_COL, ROLE_SORT, fltRes); - item->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + item->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); item->setText(SR_SEARCH_ID_COL, sid_hexa); QColor foreground; @@ -1630,26 +1628,3 @@ void SearchDialog::openFolderSearch() } } } - -void SearchDialog::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void SearchDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); -#endif - QFont newFont = ui.searchSummaryWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.searchSummaryWidget->setFont(newFont); - ui.searchResultWidget->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index aa5c4e2b4..0af53662b 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -25,6 +25,7 @@ #include "retroshare/rsevents.h" #include "ui_SearchDialog.h" #include "retroshare-gui/mainpage.h" +#include "util/FontSizeHandler.h" class AdvancedSearchDialog; class RSTreeWidgetItemCompareRole; @@ -66,9 +67,6 @@ public: void updateFiles(qulonglong request_id, const FileDetail& file) ; -protected: - virtual void showEvent(QShowEvent *) override; - private slots: /** Create the context popup menu and it's submenus */ @@ -119,8 +117,6 @@ private slots: void filterItems(); - void updateFontSize(); - private: /** render the results to the tree widget display */ void initSearchResult(const QString& txt,qulonglong searchId, int fileType, bool advanced) ; @@ -178,6 +174,8 @@ private: QAction *collViewAct; QAction *collOpenAct; + FontSizeHandler mFontSizeHandler; + /** Qt Designer generated object */ Ui::SearchDialog ui; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index c69b71647..834fbbbe0 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -170,17 +170,14 @@ IdDialog::IdDialog(QWidget *parent) ownItem = new QTreeWidgetItem(); ownItem->setText(RSID_COL_NICKNAME, tr("My own identities")); - ownItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); ownItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); // this is in order to prevent displaying a reputaiton icon next to these items. allItem = new QTreeWidgetItem(); allItem->setText(RSID_COL_NICKNAME, tr("All")); - allItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); allItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); contactsItem = new QTreeWidgetItem(); contactsItem->setText(RSID_COL_NICKNAME, tr("My contacts")); - contactsItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); contactsItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); @@ -415,6 +412,45 @@ IdDialog::IdDialog(QWidget *parent) updateIdTimer.setSingleShot(true); connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList())); + + mFontSizeHandler.registerFontSize(ui->idTreeWidget, 0, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QTreeWidgetItemIterator it(ui->idTreeWidget); + while (*it) { + QTreeWidgetItem *item = *it; + if (item->parent()) { + QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME); + font.setPointSize(fontSize); + + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPID, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, font); + } + ++it; + } + }); + mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QTreeWidgetItemIterator it(ui->treeWidget_membership); + while (*it) { + QTreeWidgetItem *item = *it; +#ifdef CIRCLE_MEMBERSHIP_CATEGORIES + if (item->parent()) + { +#endif + QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME); + font.setPointSize(fontSize); + + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPID, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, font); + +#ifdef CIRCLE_MEMBERSHIP_CATEGORIES + } +#endif + ++it; + } + }); } void IdDialog::handleEvent_main_thread(std::shared_ptr event) @@ -664,7 +700,6 @@ void IdDialog::loadCircles(const std::list& groupInfo) { mExternalOtherCircleItem = new QTreeWidgetItem(); mExternalOtherCircleItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Other circles")); - mExternalOtherCircleItem->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, ui->treeWidget_membership->font()); ui->treeWidget_membership->addTopLevelItem(mExternalOtherCircleItem); } @@ -672,7 +707,6 @@ void IdDialog::loadCircles(const std::list& groupInfo) { mExternalBelongingCircleItem = new QTreeWidgetItem(); mExternalBelongingCircleItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Circles I belong to")); - mExternalBelongingCircleItem->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, ui->treeWidget_membership->font()); ui->treeWidget_membership->addTopLevelItem(mExternalBelongingCircleItem); } #endif @@ -956,10 +990,6 @@ void IdDialog::showEvent(QShowEvent *s) needUpdateCirclesOnNextShow = false; MainPage::showEvent(s); - - if (!s->spontaneous()) { - updateFontSize(); - } } void IdDialog::createExternalCircle() @@ -2603,22 +2633,3 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mExternalOtherCircleItem,1); restoreTopLevel(mMyCircleItem,2); } - -void IdDialog::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->idTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->idTreeWidget->setFont(newFont); - ui->treeWidget_membership->setFont(newFont); - contactsItem->setFont(RSID_COL_NICKNAME, newFont); - allItem->setFont(RSID_COL_NICKNAME, newFont); - ownItem->setFont(RSID_COL_NICKNAME, newFont); - } -} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index ea6095d63..9b51cb933 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -22,6 +22,7 @@ #define IDENTITYDIALOG_H #include "gui/gxs/RsGxsUpdateBroadcastPage.h" +#include "util/FontSizeHandler.h" #include @@ -113,8 +114,6 @@ private slots: static QString inviteMessage(); void sendInvite(); - void updateFontSize(); - private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; @@ -159,6 +158,8 @@ private: bool needUpdateIdsOnNextShow; bool needUpdateCirclesOnNextShow; + FontSizeHandler mFontSizeHandler; + /* UI - Designer */ Ui::IdDialog *ui; }; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 69ba1494e..829050514 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -67,7 +67,6 @@ #include "notifyqt.h" #include "common/UserNotify.h" #include "gui/ServicePermissionDialog.h" -#include "gui/settings/rsharesettings.h" #ifdef UNFINISHED #include "unfinished/ApplicationWindow.h" @@ -361,6 +360,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); + + mFontSizeHandler.registerFontSize(ui->listWidget, 1.5f); } /** Destructor. */ @@ -1642,8 +1643,6 @@ void MainWindow::settingsChanged() ui->toolBarAction->setIconSize(QSize(toolSize,toolSize)); int itemSize = Settings->getListItemIconSize(); ui->listWidget->setIconSize(QSize(itemSize,itemSize)); - - updateFontSize(); } void MainWindow::externalLinkActivated(const QUrl &url) @@ -1823,23 +1822,6 @@ void MainWindow::setCompactStatusMode(bool compact) //opModeStatus: TODO Show only ??? } -void MainWindow::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->listWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - int iconHeight = fontMetrics.height()*1.5; - ui->listWidget->setFont(newFont); - ui->listWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} - Gui_InputDialogReturn MainWindow::guiInputDialog(const QString& windowTitle, const QString& labelText, QLineEdit::EchoMode textEchoMode, bool modal) { diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 56745d7d6..b435524f0 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -27,6 +27,7 @@ #include "gui/common/rwindow.h" #include "gui/common/RSComboBox.h" +#include "util/FontSizeHandler.h" namespace Ui { class MainWindow; @@ -307,7 +308,6 @@ private slots: void doQuit(); void updateTrayCombine(); - void updateFontSize(); private: void initStackedPage(); @@ -372,6 +372,8 @@ private: void setIdle(bool Idle); bool isIdle; + FontSizeHandler mFontSizeHandler; + Ui::MainWindow *ui ; }; diff --git a/retroshare-gui/src/gui/RSHumanReadableDelegate.h b/retroshare-gui/src/gui/RSHumanReadableDelegate.h index 18943c1dc..1b3995cd7 100644 --- a/retroshare-gui/src/gui/RSHumanReadableDelegate.h +++ b/retroshare-gui/src/gui/RSHumanReadableDelegate.h @@ -88,11 +88,16 @@ class RSHumanReadableAgeDelegate: public RSHumanReadableDelegate public: virtual void paint(QPainter *painter,const QStyleOptionViewItem & option, const QModelIndex & index) const { + painter->save(); QStyleOptionViewItem opt(option) ; setPainterOptions(painter,opt,index) ; - if(index.data().toLongLong() > 0) // no date is present. - painter->drawText(opt.rect, Qt::AlignCenter, misc::timeRelativeToNow(index.data().toLongLong())) ; + if(index.data().toLongLong() > 0) { // no date is present. + painter->setFont(opt.font); + painter->drawText(opt.rect, opt.displayAlignment, misc::timeRelativeToNow(index.data().toLongLong())) ; + } + + painter->restore(); } }; @@ -101,10 +106,14 @@ class RSHumanReadableSizeDelegate: public RSHumanReadableDelegate public: virtual void paint(QPainter *painter,const QStyleOptionViewItem & option, const QModelIndex & index) const { + painter->save(); QStyleOptionViewItem opt(option) ; setPainterOptions(painter,opt,index) ; - painter->drawText(opt.rect, Qt::AlignRight, misc::friendlyUnit(index.data().toULongLong())); + painter->setFont(opt.font); + painter->drawText(opt.rect, opt.displayAlignment, misc::friendlyUnit(index.data().toULongLong())); + + painter->restore(); } }; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 56feb5f2f..dd4a128a4 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -208,6 +208,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby())); getChatWidget()->addTitleBarWidget(unsubscribeButton) ; + + mFontSizeHandler.registerFontSize(ui.participantsList); } void ChatLobbyDialog::leaveLobby() @@ -1017,25 +1019,3 @@ void ChatLobbyDialog::setWindowed(bool windowed) if (chatLobbyPage)// If not defined, we are on autosubscribe loop of lobby widget constructor. So don't recall it. showDialog(RS_CHAT_FOCUS); } - -void ChatLobbyDialog::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void ChatLobbyDialog::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.participantsList->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.participantsList->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 7df0f01b9..c3572cc4b 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -26,6 +26,7 @@ #include "gui/common/RSTreeWidgetItem.h" #include "ChatDialog.h" #include "PopupChatWindow.h" +#include "util/FontSizeHandler.h" // Q_DECLARE_METATYPE(RsGxsId) // Q_DECLARE_METATYPE(QList) @@ -54,8 +55,6 @@ public: inline bool isWindowed() const { return dynamic_cast(this->window()) != nullptr; } - virtual void showEvent(QShowEvent *) ; - public slots: void leaveLobby() ; private slots: @@ -66,7 +65,6 @@ private slots: void showInPeopleTab(); void toggleWindowed(){setWindowed(!isWindowed());} void setWindowed(bool windowed); - void updateFontSize(); signals: void typingEventReceived(ChatLobbyId) ; @@ -118,6 +116,8 @@ private: bool mWindowedSetted; PopupChatWindow* mPCWindow; + FontSizeHandler mFontSizeHandler; + /** Qt Designer generated object */ Ui::ChatLobbyDialog ui; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 2d42726c8..d9fc4b8dc 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -28,7 +28,6 @@ #include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/StatusDefs.h" -#include "gui/settings/rsharesettings.h" #include "util/qtthreadsutils.h" #include "gui/common/PeerDefs.h" #include "gui/common/GroupDefs.h" @@ -136,6 +135,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) mEventHandlerId_peers = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::PEER_CONNECTION ); + + mFontSizeHandler.registerFontSize(ui->friendList); } void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr event) @@ -224,8 +225,6 @@ void FriendSelectionWidget::showEvent(QShowEvent */*e*/) { if(gxsIds.empty()) loadIdentities(); - - updateFontSize(); } void FriendSelectionWidget::start() { @@ -1274,18 +1273,3 @@ bool FriendSelectionWidget::isFilterConnected() { return mActionFilterConnected->isChecked(); } - -void FriendSelectionWidget::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->friendList->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->friendList->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index cde084ede..425e16774 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -26,6 +26,7 @@ #include "retroshare/rsevents.h" #include +#include "util/FontSizeHandler.h" namespace Ui { class FriendSelectionWidget; @@ -144,7 +145,6 @@ private slots: void itemChanged(QTreeWidgetItem *item, int column); void selectAll() ; void deselectAll() ; - void updateFontSize(); private: void fillList(); @@ -179,6 +179,8 @@ private: std::set mPreSelectedIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them. + FontSizeHandler mFontSizeHandler; + RsEventsHandlerId_t mEventHandlerId_identities; RsEventsHandlerId_t mEventHandlerId_peers; }; diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 3945037dd..43861c4c6 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -30,12 +30,10 @@ #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/DateTime.h" -#include "gui/notifyqt.h" #include #include #include -#include #include @@ -69,8 +67,6 @@ 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("_") ; @@ -152,7 +148,19 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) : connect(ui->distantSearchLineEdit,SIGNAL(returnPressed()),this,SLOT(distantSearch())) ; - ui->treeWidget->setIconSize(QSize(H*1.8,H*1.8)); + mFontSizeHandler.registerFontSize(ui->treeWidget, 1.8f, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QTreeWidgetItemIterator it(ui->treeWidget); + while (*it) { + QTreeWidgetItem *item = *it; + + QFont font = item->font(GTW_COLUMN_NAME); + font.setPointSize(fontSize); + item->setFont(GTW_COLUMN_NAME, font); + + ++it; + } + }); } GroupTreeWidget::~GroupTreeWidget() @@ -258,8 +266,8 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc RSTreeWidgetItem *item = new RSTreeWidgetItem(); ui->treeWidget->addTopLevelItem(item); // To get StyleSheet for Items - ui->treeWidget->style()->unpolish(ui->treeWidget); - ui->treeWidget->style()->polish(ui->treeWidget); +// ui->treeWidget->style()->unpolish(ui->treeWidget); +// ui->treeWidget->style()->polish(ui->treeWidget); item->setText(GTW_COLUMN_NAME, name); item->setData(GTW_COLUMN_DATA, ROLE_NAME, name); @@ -394,7 +402,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList< if (item == NULL) { item = new RSTreeWidgetItem(compareRole); item->setData(GTW_COLUMN_DATA, ROLE_ID, itemInfo.id); - item->setFont(GTW_COLUMN_DATA, ui->treeWidget->font()); + item->setFont(GTW_COLUMN_NAME, ui->treeWidget->font()); //static_cast(item)->setNoDataAsLast(true); //Uncomment this to sort data with QVariant() always at end. categoryItem->addChild(item); } @@ -671,28 +679,3 @@ 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); - int H = QFontMetricsF(ui->treeWidget->font()).height() ; - ui->treeWidget->setIconSize(QSize(H*1.8,H*1.8)); - } -} - diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index 7c95ec757..4aadb1c51 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -25,12 +25,12 @@ #include #include +#include "util/FontSizeHandler.h" class QToolButton; class RshareSettings; class RSTreeWidgetItemCompareRole; class RSTreeWidget; -class QShowEvent; #define GROUPTREEWIDGET_COLOR_STANDARD -1 #define GROUPTREEWIDGET_COLOR_CATEGORY 0 @@ -143,7 +143,6 @@ signals: protected: void changeEvent(QEvent *e); - virtual void showEvent(QShowEvent *) override; private slots: void customContextMenuRequested(const QPoint &pos); @@ -153,7 +152,6 @@ private slots: void distantSearch(); void sort(); - void updateFontSize(); private: void calculateScore(QTreeWidgetItem *item, const QString &filterText); @@ -166,6 +164,7 @@ private: // Compare role used for each column RSTreeWidgetItemCompareRole *compareRole; + FontSizeHandler mFontSizeHandler; Ui::GroupTreeWidget *ui; }; diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 9e5039f76..38e141e86 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -55,7 +55,6 @@ #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" #include "gui/notifyqt.h" -#include "gui/settings/rsharesettings.h" #include "NewFriendList.h" #include "ui_NewFriendList.h" @@ -274,6 +273,8 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)),Qt::QueuedConnection); connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); + mFontSizeHandler.registerFontSize(ui->peerTreeWidget,1.5f); + // #ifdef RS_DIRECT_CHAT // connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatNode())); // #endif @@ -1694,27 +1695,3 @@ void NewFriendList::expandGroup(const RsNodeGroupId& gid) QModelIndex index = mProxyModel->mapFromSource(mModel->getIndexOfGroup(gid)); ui->peerTreeWidget->setExpanded(index,true) ; } - -void NewFriendList::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void NewFriendList::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->peerTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - int iconHeight = fontMetrics.height()*1.5; - ui->peerTreeWidget->setFont(newFont); - ui->peerTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 4679b7804..cf4c68e6f 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -29,6 +29,7 @@ #include "FriendListModel.h" #include "retroshare/rsstatus.h" +#include "util/FontSizeHandler.h" namespace Ui { class NewFriendList; @@ -54,8 +55,6 @@ public: explicit NewFriendList(QWidget *parent = 0); ~NewFriendList(); - virtual void showEvent(QShowEvent *) ; - // Add a tool button to the tool area void addToolButton(QToolButton *toolButton); void processSettings(bool load); @@ -97,7 +96,6 @@ private slots: void sortColumn(int col,Qt::SortOrder so); void itemExpanded(const QModelIndex&); void itemCollapsed(const QModelIndex&); - void updateFontSize(); protected: void changeEvent(QEvent *e); @@ -107,6 +105,7 @@ private: Ui::NewFriendList *ui; RsFriendListModel *mModel; QAction *mActionSortByState; + FontSizeHandler mFontSizeHandler; void applyWhileKeepingTree(std::function predicate); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index b68a50173..18f518749 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -46,6 +46,7 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent) : QAbstractItemModel(parent), mUseChildTS(false),mFilteringEnabled(false),mTreeMode(TREE_MODE_TREE) { initEmptyHierarchy(mPosts); + mFont = QApplication::font(); } void RsGxsForumModel::preMods() @@ -399,7 +400,7 @@ QVariant RsGxsForumModel::data(const QModelIndex &index, int role) const if(role == Qt::FontRole) { - QFont font ; + QFont font = mFont; font.setBold( (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_HAS_UNREAD_CHILDREN) || IS_MSG_UNREAD(fmpe.mMsgStatus)); return QVariant(font); } @@ -533,6 +534,15 @@ void RsGxsForumModel::setFilter(int column,const QStringList& strings,uint32_t& postMods(); } +void RsGxsForumModel::setFont(const QFont &font) +{ + preMods(); + + mFont = font; + + postMods(); +} + QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_MISSING) @@ -562,7 +572,7 @@ QVariant RsGxsForumModel::toolTipRole(const ForumModelPostEntry& fmpe,int column if(!GxsIdDetails::MakeIdDesc(fmpe.mAuthorId, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR)) return QVariant(); - int S = QFontMetricsF(QApplication::font()).height(); + int S = QFontMetricsF(mFont).height(); QImage pix( (*icons.begin()).pixmap(QSize(5*S,5*S)).toImage()); QString embeddedImage; @@ -599,7 +609,7 @@ QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry& fmpe,int /*c QVariant RsGxsForumModel::sizeHintRole(int col) const { - float factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + float factor = QFontMetricsF(mFont).height()/14.0f ; switch(col) { @@ -650,7 +660,7 @@ QVariant RsGxsForumModel::displayRole(const ForumModelPostEntry& fmpe,int col) c case COLUMN_THREAD_TITLE: if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_REDACTED) return QVariant(tr("[ ... Redacted message ... ]")); // else if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED) -// return QVariant( QString("").arg(QFontMetricsF(QFont()).height()) +// return QVariant( QString("").arg(QFontMetricsF(mFont).height()) // + QString::fromUtf8(fmpe.mTitle.c_str())); else return QVariant(QString::fromUtf8(fmpe.mTitle.c_str())); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h index c69013c3e..10248101f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h @@ -22,6 +22,7 @@ #include "retroshare/rsgxsifacetypes.h" #include #include +#include struct ForumModelPostEntry: public ForumPostEntry { @@ -76,6 +77,7 @@ public: QModelIndex getIndexOfMessage(const RsGxsMessageId& mid) const; static const QString FilterString ; + void setFont(const QFont &font); std::vector > getPostVersions(const RsGxsMessageId& mid) const; @@ -185,6 +187,7 @@ private: QColor mBackgroundColorPinned; QColor mBackgroundColorFiltered; + QFont mFont; friend class const_iterator; }; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 8a0357303..fd293560f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -250,7 +250,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->setupUi(this); //setUpdateWhenInvisible(true); - updateFontSize(); //mUpdating = false; mUnreadCount = 0; @@ -308,10 +307,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool))); /* Set own item delegate */ - //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - //itemDelegate->setSpacing(QSize(0, 2)); - //itemDelegate->setOnlyPlainText(true); - //ui->threadTreeWidget->setItemDelegate(itemDelegate); + RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + itemDelegate->setSpacing(QSize(0, 2)); + itemDelegate->setOnlyPlainText(true); + ui->threadTreeWidget->setItemDelegate(itemDelegate); /* add filter actions */ ui->filterLineEdit->addFilter(QIcon(), tr("Title"), RsGxsForumModel::COLUMN_THREAD_TITLE, tr("Search Title")); @@ -322,10 +321,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget float f = QFontMetricsF(font()).height()/14.0f ; - QFontMetricsF fontMetrics(ui->threadTreeWidget->font()); - int iconHeight = fontMetrics.height() * 1.4; - ui->threadTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - /* Set header resize modes and initial section sizes */ QHeaderView * ttheader = ui->threadTreeWidget->header () ; @@ -368,8 +363,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget blankPost(); - - ui->subscribeToolButton->setToolTip(tr( "

Subscribing to the forum will gather \ available posts from your subscribed friends, and make the \ forum visible to all other friends.

Afterwards you can unsubscribe from the context menu of the forum list at left.

")); @@ -383,6 +376,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); }, mEventHandlerId, RsEventType::GXS_FORUMS ); + + mFontSizeHandler.registerFontSize(ui->threadTreeWidget, 1.4f, [this](QAbstractItemView *view, int) { + mThreadModel->setFont(view->font()); + }); } void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr event) @@ -2102,27 +2099,3 @@ void GxsForumThreadWidget::showAuthorInPeople(const RsGxsForumMsg& msg) MainWindow::showWindow(MainWindow::People); idDialog->navigate(RsGxsId(msg.mMeta.mAuthorId)); } - -void GxsForumThreadWidget::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void GxsForumThreadWidget::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); -#endif - QFont newFont = ui->threadTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->threadTreeWidget->setFont(newFont); - int iconHeight = fontMetrics.height() * 1.4; - ui->threadTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index b867c2399..8e6b1c01b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -26,6 +26,7 @@ #include "gui/gxs/GxsMessageFrameWidget.h" #include #include "gui/gxs/GxsIdDetails.h" +#include "util/FontSizeHandler.h" class QSortFilterProxyModel; class QTreeWidgetItem; @@ -97,7 +98,6 @@ public: protected: //bool eventFilter(QObject *obj, QEvent *ev); //void changeEvent(QEvent *e); - virtual void showEvent(QShowEvent *) override; /* RsGxsUpdateBroadcastWidget */ virtual void updateDisplay(bool complete); @@ -161,8 +161,6 @@ private slots: void filterColumnChanged(int column); void filterItems(const QString &text); - void updateFontSize(); - #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) void expandSubtree(); #endif @@ -237,6 +235,8 @@ private: QSortFilterProxyModel *mThreadProxyModel; QList mSavedExpandedMessages; + FontSizeHandler mFontSizeHandler; + Ui::GxsForumThreadWidget *ui; RsEventsHandlerId_t mEventHandlerId; }; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index bbca45bd3..0ee408685 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -299,7 +299,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) QFontDatabase db; foreach(int size, db.standardSizes()) - ui.comboSize->addItem(QString::number(size)); + ui.comboSize->addItem(QString::number(size), size); QStyleOptionComboBox opt; QSize sh; opt.initFrom(ui.comboSize); @@ -408,6 +408,10 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(true); + mMessageFontSizeHandler.registerFontSize(ui.msgText, [this, db] (QWidget*, int fontSize) { + ui.comboSize->setCurrentIndex(ui.comboSize->findData(fontSize)); + }); + #if QT_VERSION < 0x040700 // embedded images are not supported before QT 4.7.0 ui.imagebtn->setVisible(false); @@ -2933,26 +2937,3 @@ 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 d89aecda5..27bf28458 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -28,6 +28,7 @@ #include "ui_MessageComposer.h" #include "gui/msgs/MessageInterface.h" +#include "util/FontSizeHandler.h" class QAction; struct RsIdentityDetails; @@ -95,7 +96,6 @@ public slots: protected: void closeEvent (QCloseEvent * event); bool eventFilter(QObject *obj, QEvent *ev); - virtual void showEvent(QShowEvent *) ; private slots: /* toggle Contacts DockWidget */ @@ -170,7 +170,6 @@ private slots: static QString inviteMessage(); void checkLength(); - void updateFontSize(); private: static QString buildReplyHeader(const MessageInfo &msgInfo); @@ -269,6 +268,8 @@ private: bool has_gxs; bool mAlreadySent; // prevents a Qt bug that calls the same action twice. + MessageFontSizeHandler mMessageFontSizeHandler; + /** Qt Designer generated object */ Ui::MessageComposer ui; diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 14b15479c..dc2f16c7c 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -57,6 +57,7 @@ RsMessageModel::RsMessageModel(QObject *parent) mQuickViewFilter = QUICK_VIEW_ALL; mFilterType = FILTER_TYPE_NONE; mFilterStrings.clear(); + mFont = QApplication::font(); } void RsMessageModel::preMods() @@ -248,7 +249,7 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const if(role == Qt::FontRole) { - QFont font ; + QFont font = mFont; font.setBold(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER)); return QVariant(font); @@ -404,6 +405,15 @@ void RsMessageModel::setFilter(FilterType filter_type, const QStringList& string emit dataChanged(createIndex(0,0),createIndex(rowCount()-1,RsMessageModel::columnCount()-1)); } +void RsMessageModel::setFont(const QFont &font) +{ + mFont = font; + + if (rowCount() > 0) { + emit dataChanged(createIndex(0,0), createIndex(rowCount() - 1, RsMessageModel::columnCount() - 1)); + } +} + QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const { if(column == COLUMN_THREAD_AUTHOR || column == COLUMN_THREAD_TO) @@ -440,7 +450,7 @@ QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &/*fmpe*/ QVariant RsMessageModel::sizeHintRole(int col) const { - float factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + float factor = QFontMetricsF(mFont).height()/14.0f ; switch(col) { diff --git a/retroshare-gui/src/gui/msgs/MessageModel.h b/retroshare-gui/src/gui/msgs/MessageModel.h index d23b21f86..3bbd6ee31 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.h +++ b/retroshare-gui/src/gui/msgs/MessageModel.h @@ -22,6 +22,7 @@ #include #include +#include #include "retroshare/rsmsgs.h" @@ -104,6 +105,7 @@ public: void setQuickViewFilter(QuickViewFilter fn) ; void setFilter(FilterType filter_type, const QStringList& strings) ; + void setFont(const QFont &font); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; @@ -184,6 +186,7 @@ private: QuickViewFilter mQuickViewFilter ; QStringList mFilterStrings; FilterType mFilterType; + QFont mFont; std::vector mMessages; std::map mMessagesMap; diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 196012070..8f573c6b7 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -163,9 +163,9 @@ MessagesDialog::MessagesDialog(QWidget *parent) changeBox(0); // set to inbox - //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - //itemDelegate->setSpacing(QSize(0, 2)); - //ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); + RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + itemDelegate->setSpacing(QSize(0, 2)); + ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ; ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_TO,new GxsIdTreeItemDelegate()) ; @@ -306,6 +306,23 @@ MessagesDialog::MessagesDialog(QWidget *parent) mTagEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_TAG ); + + mFontSizeHandler.registerFontSize(ui.listWidget, 1.5f, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QList rows; + rows << ROW_INBOX << ROW_OUTBOX << ROW_DRAFTBOX; + + foreach (int row, rows) { + QListWidgetItem *item = ui.listWidget->item(row); + QFont font = item->font(); + font.setPointSize(fontSize); + item->setFont(font); + } + }); + mFontSizeHandler.registerFontSize(ui.quickViewWidget, 1.5f); + mFontSizeHandler.registerFontSize(ui.messageTreeWidget, 1.5f, [this] (QAbstractItemView *view, int) { + mMessageModel->setFont(view->font()); + }); } void MessagesDialog::handleEvent_main_thread(std::shared_ptr event) @@ -1660,32 +1677,3 @@ void MessagesDialog::updateInterface() ui.tabWidget->setTabIcon(0, FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); } } - -void MessagesDialog::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void MessagesDialog::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.listWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - int iconHeight = fontMetrics.height()*1.5; - ui.listWidget->setFont(newFont); - ui.quickViewWidget->setFont(newFont); - ui.messageTreeWidget->setFont(newFont); - ui.listWidget->setIconSize(QSize(iconHeight, iconHeight)); - ui.quickViewWidget->setIconSize(QSize(iconHeight, iconHeight)); - ui.messageTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} - diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 753f910dd..7f9573f81 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -25,6 +25,7 @@ #include #include +#include "util/FontSizeHandler.h" #include "ui_MessagesDialog.h" @@ -54,7 +55,6 @@ public: // replaced by shortcut // virtual void keyPressEvent(QKeyEvent *) ; - virtual void showEvent(QShowEvent *) ; QColor textColorInbox() const { return mTextColorInbox; } @@ -111,8 +111,6 @@ private slots: void tabChanged(int tab); void tabCloseRequested(int tab); - void updateFontSize(); - private: void handleEvent_main_thread(std::shared_ptr event); void handleTagEvent_main_thread(std::shared_ptr event); @@ -169,6 +167,8 @@ private: RsEventsHandlerId_t mEventHandlerId; RsEventsHandlerId_t mTagEventHandlerId; + + FontSizeHandler mFontSizeHandler; }; #endif diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 663cc7d03..a9fab8895 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -93,6 +93,8 @@ SettingsPage::SettingsPage(QWidget *parent) connect(ui.listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int))); connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int))); + + mFontSizeHandler.registerFontSize(ui.listWidget); } SettingsPage::~SettingsPage() @@ -239,25 +241,3 @@ void SettingsPage::notifySettingsChanged() if (NotifyQt::getInstance()) NotifyQt::getInstance()->notifySettingsChanged(); } - -void SettingsPage::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void SettingsPage::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.listWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.listWidget->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 64d8ebb52..47eb33e4b 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -27,6 +27,7 @@ #include #include "ui_settingsw.h" +#include "util/FontSizeHandler.h" class FloatingHelpBrowser; @@ -53,7 +54,6 @@ protected: ~SettingsPage(); void addPage(ConfigPage*) ; - virtual void showEvent(QShowEvent *) override; public slots: //! Go to a specific part of the control panel. @@ -68,12 +68,13 @@ private slots: private: void initStackedWidget(); - void updateFontSize(); private: FloatingHelpBrowser *mHelpBrowser; static int lastPage; + FontSizeHandler mFontSizeHandler; + /* UI - from Designer */ Ui::Settings ui; }; diff --git a/retroshare-gui/src/util/RichTextEdit.cpp b/retroshare-gui/src/util/RichTextEdit.cpp index 9d88d989f..020b13db9 100644 --- a/retroshare-gui/src/util/RichTextEdit.cpp +++ b/retroshare-gui/src/util/RichTextEdit.cpp @@ -167,7 +167,7 @@ RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { QFontDatabase db; foreach(int size, db.standardSizes()) - f_fontsize->addItem(QString::number(size)); + f_fontsize->addItem(QString::number(size), size); connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); @@ -195,6 +195,9 @@ RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { // check message length connect(f_textedit, SIGNAL(textChanged()), this, SLOT(checkLength())); + mMessageFontSizeHandler.registerFontSize(f_textedit, [this] (QWidget*, int fontSize) { + f_fontsize->setCurrentIndex(f_fontsize->findData(fontSize)); + }); } @@ -614,26 +617,3 @@ 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 a621a8514..6e4869838 100644 --- a/retroshare-gui/src/util/RichTextEdit.h +++ b/retroshare-gui/src/util/RichTextEdit.h @@ -23,6 +23,7 @@ #include #include "ui_RichTextEdit.h" +#include "util/FontSizeHandler.h" /** * @Brief A simple rich-text editor @@ -69,7 +70,6 @@ signals: void insertImage(); void textSource(); void checkLength(); - void updateFontSize(); protected: void mergeFormatOnWordOrSelection(const QTextCharFormat &format); @@ -79,7 +79,6 @@ 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; @@ -95,6 +94,9 @@ signals: ParagraphMonospace }; QPointer m_lastBlockList; + +private: + MessageFontSizeHandler mMessageFontSizeHandler; }; #endif From e87566ef92576b4e560b26580b6ccf08b7fac407 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 1 Apr 2025 21:26:54 +0200 Subject: [PATCH 18/18] set default font size to 11 --- retroshare-gui/src/gui/settings/rsharesettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 119ea9566..d878d6c99 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -1195,7 +1195,7 @@ int RshareSettings::getFontSize() #if defined(Q_OS_DARWIN) int defaultFontSize = 13; #else - int defaultFontSize = 9; + int defaultFontSize = 11; #endif return value("FontSize", defaultFontSize).toInt(); @@ -1211,7 +1211,7 @@ int RshareSettings::getMessageFontSize() #if defined(Q_OS_DARWIN) int defaultFontSize = 12; #else - int defaultFontSize = 9; + int defaultFontSize = 11; #endif return valueFromGroup("Message", "FontSize", defaultFontSize).toInt();