From 1720a94a80c9b67df8fc2bbace114912bd10738d Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 17 Apr 2025 20:49:30 +0200 Subject: [PATCH] added fontSizeHandler for Identity list --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 8 ++++- .../src/gui/Identity/IdentityListModel.cpp | 31 +++++++++++++------ .../src/gui/Identity/IdentityListModel.h | 2 ++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index e5f88541b..a2d588d3e 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -450,7 +450,13 @@ IdDialog::IdDialog(QWidget *parent) updateIdTimer.setSingleShot(true); connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList())); - mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { + mFontSizeHandler.registerFontSize(ui->idTreeWidget, 0, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + + mIdListModel->setFontSize(fontSize); + }); + + mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { // Set new font size on all items QTreeWidgetItemIterator it(ui->treeWidget_membership); while (*it) { diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 4768fe54d..b55d9c160 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -53,6 +53,8 @@ RsIdentityListModel::RsIdentityListModel(QObject *parent) : QAbstractItemModel(parent) , mLastInternalDataUpdate(0), mLastNodeUpdate(0) { + mFontSize = QApplication::font().pointSize(); + mFilterStrings.clear(); mIdentityUpdateTimer = new QTimer(); connect(mIdentityUpdateTimer,SIGNAL(timeout()),this,SLOT(timerUpdate())); @@ -565,19 +567,28 @@ QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) c } QVariant RsIdentityListModel::fontRole(const EntryIndex& e, int /*col*/) const { - auto it = getIdentityInfo(e); - if(!it) - return QVariant(); - RsGxsId id(it->id); + QFont f; + f.setPointSize(mFontSize); - if(rsIdentity->isOwnId(id)) + auto it = getIdentityInfo(e); + + if(it) { - QFont f; - f.setBold(true); - return QVariant(f); + RsGxsId id(it->id); + + if(rsIdentity->isOwnId(id)) + f.setBold(true); + } + + return QVariant(f); +} +void RsIdentityListModel::setFontSize(int s) +{ + if(s != mFontSize) + { + mFontSize = s; + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mCategories.size()-1,columnCount()-1,(void*)NULL)); } - else - return QVariant(); } #ifdef DEBUG_MODEL_INDEX diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index f92949f2c..4c3cb43e2 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -143,6 +143,7 @@ public: EntryType getType(const QModelIndex&) const; RsGxsId getIdentity(const QModelIndex&) const; int getCategory(const QModelIndex&) const; + void setFontSize(int s); void setFilter(uint8_t filter_type, const QStringList& strings) ; @@ -221,6 +222,7 @@ private: QStringList mFilterStrings; uint8_t mFilterType; + int mFontSize; rstime_t mLastInternalDataUpdate; rstime_t mLastNodeUpdate;;