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

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

View File

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

View File

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

View File

@ -113,6 +113,8 @@ private slots:
static QString inviteMessage();
void sendInvite();
void updateFontSize();
private:
void processSettings(bool load);
QString createUsageString(const RsIdentityUsage& u) const;

View File

@ -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)
{

View File

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

View File

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

View File

@ -54,6 +54,8 @@ public:
inline bool isWindowed() const { return dynamic_cast<PopupChatWindow*>(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) ;

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

View File

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

View File

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

View File

@ -110,7 +110,8 @@ protected:
void updateGroupStatisticsReal(const RsGxsGroupId &groupId);
void updateMessageSummaryListReal(RsGxsGroupId groupId);
void updateFontSize();
private slots:
void todo();

View File

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

View File

@ -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<const RsEvent> event);
void handleTagEvent_main_thread(std::shared_ptr<const RsEvent> event);