Settings for default tree & listwidget fonts

This commit is contained in:
defnax 2025-02-05 20:55:03 +01:00
parent 8fcc52b304
commit e14fc66ca3
14 changed files with 180 additions and 1 deletions

View file

@ -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));
}
}