mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-11 18:29:16 -04:00
Merge pull request #2918 from defnax/fontssettings
Fonts settings for Tree & list Views & Composer Fonts
This commit is contained in:
commit
42bbf785ea
@ -230,6 +230,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
|
||||
|
||||
int ltwH = misc::getFontSizeFactor("LobbyTreeWidget", 1.5).height();
|
||||
ui.lobbyTreeWidget->setIconSize(QSize(ltwH,ltwH));
|
||||
|
||||
mFontSizeHandler.registerFontSize(ui.lobbyTreeWidget);
|
||||
}
|
||||
|
||||
ChatLobbyWidget::~ChatLobbyWidget()
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "chat/ChatLobbyUserNotify.h"
|
||||
#include "gui/gxs/GxsIdChooser.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
@ -146,6 +147,8 @@ private:
|
||||
QAbstractButton* myInviteYesButton;
|
||||
GxsIdChooser* myInviteIdChooser;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::ChatLobbyWidget ui;
|
||||
};
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsturtle.h>
|
||||
@ -201,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<int> sizes;
|
||||
sizes << 250 << width(); // Qt calculates the right sizes
|
||||
@ -239,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()
|
||||
@ -1041,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()));
|
||||
@ -1066,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"));
|
||||
|
||||
@ -1135,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"));
|
||||
|
||||
@ -1325,11 +1324,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)
|
||||
@ -1348,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;
|
||||
|
@ -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;
|
||||
@ -173,6 +174,8 @@ private:
|
||||
QAction *collViewAct;
|
||||
QAction *collOpenAct;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::SearchDialog ui;
|
||||
|
||||
|
@ -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<const RsEvent> event)
|
||||
@ -664,7 +700,6 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& 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<RsGroupMetaData>& 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
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define IDENTITYDIALOG_H
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
@ -157,6 +158,8 @@ private:
|
||||
bool needUpdateIdsOnNextShow;
|
||||
bool needUpdateCirclesOnNextShow;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
/* UI - Designer */
|
||||
Ui::IdDialog *ui;
|
||||
};
|
||||
|
@ -360,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. */
|
||||
@ -1027,6 +1029,7 @@ void SetForegroundWindowInternal(HWND hWnd)
|
||||
|
||||
/* Show the dialog. */
|
||||
raiseWindow();
|
||||
|
||||
/* Set the focus to the specified page. */
|
||||
_instance->ui->stackPages->setCurrentPage(page);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "gui/common/rwindow.h"
|
||||
#include "gui/common/RSComboBox.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -371,6 +372,8 @@ private:
|
||||
void setIdle(bool Idle);
|
||||
bool isIdle;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
Ui::MainWindow *ui ;
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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<RsGxsId>)
|
||||
@ -115,6 +116,8 @@ private:
|
||||
bool mWindowedSetted;
|
||||
PopupChatWindow* mPCWindow;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ChatLobbyDialog ui;
|
||||
|
||||
|
@ -135,6 +135,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
||||
mEventHandlerId_peers = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> 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<const RsEvent> event)
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "retroshare/rsevents.h"
|
||||
#include <gui/gxs/RsGxsUpdateBroadcastPage.h>
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
namespace Ui {
|
||||
class FriendSelectionWidget;
|
||||
@ -178,6 +179,8 @@ private:
|
||||
|
||||
std::set<std::string> 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;
|
||||
};
|
||||
|
@ -148,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()
|
||||
@ -254,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);
|
||||
@ -390,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<RSTreeWidgetItem*>(item)->setNoDataAsLast(true); //Uncomment this to sort data with QVariant() always at end.
|
||||
categoryItem->addChild(item);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QDateTime>
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
class QToolButton;
|
||||
class RshareSettings;
|
||||
@ -163,6 +164,7 @@ private:
|
||||
|
||||
// Compare role used for each column
|
||||
RSTreeWidgetItemCompareRole *compareRole;
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
Ui::GroupTreeWidget *ui;
|
||||
};
|
||||
|
@ -273,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
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "FriendListModel.h"
|
||||
#include "retroshare/rsstatus.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
namespace Ui {
|
||||
class NewFriendList;
|
||||
@ -104,6 +105,7 @@ private:
|
||||
Ui::NewFriendList *ui;
|
||||
RsFriendListModel *mModel;
|
||||
QAction *mActionSortByState;
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
void applyWhileKeepingTree(std::function<void()> predicate);
|
||||
|
||||
|
@ -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("<img src=\":/icons/pinned_64.png\" height=%1/>").arg(QFontMetricsF(QFont()).height())
|
||||
// return QVariant( QString("<img src=\":/icons/pinned_64.png\" height=%1/>").arg(QFontMetricsF(mFont).height())
|
||||
// + QString::fromUtf8(fmpe.mTitle.c_str()));
|
||||
else
|
||||
return QVariant(QString::fromUtf8(fmpe.mTitle.c_str()));
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
#include <QModelIndex>
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
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<std::pair<rstime_t,RsGxsMessageId> > getPostVersions(const RsGxsMessageId& mid) const;
|
||||
|
||||
@ -185,6 +187,7 @@ private:
|
||||
|
||||
QColor mBackgroundColorPinned;
|
||||
QColor mBackgroundColorFiltered;
|
||||
QFont mFont;
|
||||
|
||||
friend class const_iterator;
|
||||
};
|
||||
|
@ -321,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 () ;
|
||||
@ -380,6 +376,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
[this](std::shared_ptr<const RsEvent> 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<const RsEvent> event)
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "gui/gxs/GxsMessageFrameWidget.h"
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
class QTreeWidgetItem;
|
||||
@ -234,6 +235,8 @@ private:
|
||||
QSortFilterProxyModel *mThreadProxyModel;
|
||||
QList<RsGxsMessageId> mSavedExpandedMessages;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
Ui::GxsForumThreadWidget *ui;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "ui_MessageComposer.h"
|
||||
|
||||
#include "gui/msgs/MessageInterface.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
class QAction;
|
||||
struct RsIdentityDetails;
|
||||
@ -267,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;
|
||||
|
||||
|
@ -57,6 +57,7 @@ RsMessageModel::RsMessageModel(QObject *parent)
|
||||
mQuickViewFilter = QUICK_VIEW_ALL;
|
||||
mFilterType = FILTER_TYPE_NONE;
|
||||
mFilterStrings.clear();
|
||||
mFont = QApplication::font();
|
||||
}
|
||||
|
||||
void RsMessageModel::preMods()
|
||||
@ -209,6 +210,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();
|
||||
|
||||
@ -246,11 +249,19 @@ 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);
|
||||
}
|
||||
|
||||
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;
|
||||
@ -394,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)
|
||||
@ -430,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)
|
||||
{
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
#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<Rs::Msgs::MsgInfoSummary> mMessages;
|
||||
std::map<std::string,uint32_t> mMessagesMap;
|
||||
|
@ -306,6 +306,23 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
|
||||
mTagEventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> 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<int> 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<const RsEvent> event)
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <retroshare/rsevents.h>
|
||||
#include <retroshare-gui/mainpage.h>
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
#include "ui_MessagesDialog.h"
|
||||
|
||||
@ -166,6 +167,8 @@ private:
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
RsEventsHandlerId_t mTagEventHandlerId;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -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) ; }
|
||||
@ -359,4 +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());
|
||||
|
||||
whileBlocking(ui.minimumFontSize_SB)->setValue(Settings->getFontSize());
|
||||
}
|
||||
|
||||
void AppearancePage::updateFontSize()
|
||||
{
|
||||
Settings->setFontSize(ui.minimumFontSize_SB->value());
|
||||
|
||||
NotifyQt::getInstance()->notifySettingsChanged();
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ private slots:
|
||||
// void updateCmboListItemSize();
|
||||
|
||||
void updateStyle() ;
|
||||
void updateFontSize();
|
||||
|
||||
private:
|
||||
void switch_status(MainWindow::StatusElement s,const QString& key,bool b);
|
||||
|
||||
|
@ -14,22 +14,7 @@
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="AppearancePageGLayout">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="grpLanguage">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -86,110 +71,12 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="grpStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="grpStyleGLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="RSComboBox" name="cmboStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Choose RetroShare's interface style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="grpStyleHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="grpStyleSheet">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Style Sheet</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="grpStyleSheetGLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="RSComboBox" name="cmboStyleSheet">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="grpStyleSheetHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="AppearancePageVSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>361</width>
|
||||
<height>61</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="grpToolBar">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>228</height>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
@ -198,8 +85,8 @@
|
||||
<property name="title">
|
||||
<string>Tool Bar</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelPageToolBar">
|
||||
@ -237,7 +124,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frameToolListStyle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -289,19 +176,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="RSComboBox" name="cmboTollButtonsSize">
|
||||
<item>
|
||||
@ -352,10 +226,79 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="3" column="1">
|
||||
<widget class="QGroupBox" name="grpFonts">
|
||||
<property name="title">
|
||||
<string>Fonts</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="minimumFontSizeHLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="minimumFontSizeLabel">
|
||||
<property name="text">
|
||||
<string>Minimum font size </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="minimumFontSize_SB">
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>64</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="minimumFontSizeHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>188</width>
|
||||
<height>96</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="grpStatus">
|
||||
<property name="title">
|
||||
<string>Status Bar</string>
|
||||
@ -464,6 +407,104 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="AppearancePageVSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>361</width>
|
||||
<height>61</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="grpStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="grpStyleGLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="RSComboBox" name="cmboStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Choose RetroShare's interface style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="grpStyleHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="grpStyleSheet">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Style Sheet</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="grpStyleSheetGLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="RSComboBox" name="cmboStyleSheet">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="grpStyleSheetHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -18,6 +18,8 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <QFontDatabase>
|
||||
|
||||
#include "rshare.h"
|
||||
#include "rsharesettings.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
@ -28,6 +30,7 @@
|
||||
#include <algorithm>
|
||||
#include "NewTag.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
|
||||
: ConfigPage(parent, flags)
|
||||
@ -48,13 +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, SIGNAL(activated(QString)), this, SLOT(updateFontSize())) ;
|
||||
|
||||
mTagEventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG );
|
||||
@ -116,12 +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());
|
||||
Settings->endGroup();
|
||||
whileBlocking(ui.minimumFontSize)->setCurrentIndex(ui.minimumFontSize->findData(Settings->getMessageFontSize()));
|
||||
|
||||
// state of filter combobox
|
||||
|
||||
@ -298,3 +307,9 @@ void MessagePage::currentRowChangedTag(int row)
|
||||
ui.deletepushButton->setEnabled(bDeleteEnable);
|
||||
}
|
||||
|
||||
void MessagePage::updateFontSize()
|
||||
{
|
||||
Settings->setMessageFontSize(ui.minimumFontSize->currentData().toInt());
|
||||
|
||||
NotifyQt::getInstance()->notifySettingsChanged();
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ private slots:
|
||||
void updateDistantMsgs() ;
|
||||
void updateMsgTags() ;
|
||||
void updateLoadEmoticons();
|
||||
void updateFontSize();
|
||||
|
||||
private:
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
@ -16,44 +16,15 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Distant messages:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="2">
|
||||
<widget class="RSComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Everyone</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Contacts</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Nobody</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Accept encrypted distant messages from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Reading</string>
|
||||
</property>
|
||||
@ -65,20 +36,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="openLabel">
|
||||
<property name="text">
|
||||
<string>Open messages in</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="RSComboBox" name="openComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="loadEmbeddedImages">
|
||||
<property name="text">
|
||||
@ -93,10 +50,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="openLabel">
|
||||
<property name="text">
|
||||
<string>Open messages in</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="RSComboBox" name="openComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Tags</string>
|
||||
@ -172,6 +143,102 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Distant messages:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="2">
|
||||
<widget class="RSComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Everyone</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Contacts</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Nobody</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Accept encrypted distant messages from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Fonts</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="minimumFontSizeHLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="minimumFontSizeLabel">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Minimum font size </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="RSComboBox" name="minimumFontSize">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>MS Sans Serif</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
|
@ -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()
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <retroshare-gui/mainpage.h>
|
||||
|
||||
#include "ui_settingsw.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
class FloatingHelpBrowser;
|
||||
|
||||
@ -72,6 +73,8 @@ private:
|
||||
FloatingHelpBrowser *mHelpBrowser;
|
||||
static int lastPage;
|
||||
|
||||
FontSizeHandler mFontSizeHandler;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::Settings ui;
|
||||
};
|
||||
|
@ -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 = 11;
|
||||
#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 = 11;
|
||||
#endif
|
||||
|
||||
return valueFromGroup("Message", "FontSize", defaultFontSize).toInt();
|
||||
}
|
||||
|
||||
void RshareSettings::setMessageFontSize(int value)
|
||||
{
|
||||
setValueToGroup("Message", "FontSize", value);
|
||||
}
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
bool RshareSettings::getJsonApiEnabled()
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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 \
|
||||
|
210
retroshare-gui/src/util/FontSizeHandler.cpp
Normal file
210
retroshare-gui/src/util/FontSizeHandler.cpp
Normal file
@ -0,0 +1,210 @@
|
||||
/*******************************************************************************
|
||||
* util/FontSizeHandler.cpp *
|
||||
* *
|
||||
* Copyright (C) 2025, Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* 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 <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
#include <QAbstractItemView>
|
||||
|
||||
#include "rshare.h"
|
||||
#include "FontSizeHandler.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
// Data for QAbstractItemView
|
||||
struct FontSizeHandlerWidgetData
|
||||
{
|
||||
std::function<void(QWidget*, int)> callback;
|
||||
};
|
||||
|
||||
// Data for QWidget
|
||||
struct FontSizeHandlerViewData
|
||||
{
|
||||
float iconHeightFactor;
|
||||
std::function<void(QAbstractItemView*, int)> callback;
|
||||
};
|
||||
|
||||
class FontSizeHandlerObject : public QObject
|
||||
{
|
||||
public:
|
||||
FontSizeHandlerObject(FontSizeHandlerBase *fontSizeHandler): QObject()
|
||||
{
|
||||
mFontSizeHandlerBase = fontSizeHandler;
|
||||
}
|
||||
|
||||
bool eventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::StyleChange) {
|
||||
QMap<QAbstractItemView*, FontSizeHandlerViewData>::iterator itView = mView.find((QAbstractItemView*) object);
|
||||
if (itView != mView.end()) {
|
||||
mFontSizeHandlerBase->updateFontSize(itView.key(), itView.value().iconHeightFactor, itView.value().callback);
|
||||
}
|
||||
|
||||
QMap<QWidget*, FontSizeHandlerWidgetData>::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<void(QWidget*, int)> 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<void(QAbstractItemView*, int)> 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<QAbstractItemView*, FontSizeHandlerViewData> mView;
|
||||
QMap<QWidget*, FontSizeHandlerWidgetData> 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<void(QWidget*, int)> callback)
|
||||
{
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mObject) {
|
||||
mObject = new FontSizeHandlerObject(this);
|
||||
}
|
||||
|
||||
mObject->registerFontSize(widget, callback);
|
||||
}
|
||||
|
||||
void FontSizeHandlerBase::registerFontSize(QAbstractItemView *view, float iconHeightFactor, std::function<void(QAbstractItemView*, int)> callback)
|
||||
{
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mObject) {
|
||||
mObject = new FontSizeHandlerObject(this);
|
||||
}
|
||||
|
||||
mObject->registerFontSize(view, iconHeightFactor, callback);
|
||||
}
|
||||
|
||||
void FontSizeHandlerBase::updateFontSize(QWidget *widget, std::function<void (QWidget *, int)> 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<void (QAbstractItemView *, int)> 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);
|
||||
}
|
||||
}
|
||||
}
|
71
retroshare-gui/src/util/FontSizeHandler.h
Normal file
71
retroshare-gui/src/util/FontSizeHandler.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
* util/FontSizeHandler.h *
|
||||
* *
|
||||
* Copyright (C) 2025, Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* 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 <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#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<void(QWidget*, int)> callback = nullptr);
|
||||
void registerFontSize(QAbstractItemView *view, float iconHeightFactor = 0.0f, std::function<void(QAbstractItemView*, int)> callback = nullptr);
|
||||
|
||||
void updateFontSize(QWidget *widget, std::function<void(QWidget*, int)> callback = nullptr, bool force = false);
|
||||
void updateFontSize(QAbstractItemView *view, float iconHeightFactor, std::function<void (QAbstractItemView *, int)> 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
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <QPointer>
|
||||
#include "ui_RichTextEdit.h"
|
||||
#include "util/FontSizeHandler.h"
|
||||
|
||||
/**
|
||||
* @Brief A simple rich-text editor
|
||||
@ -93,6 +94,9 @@ signals:
|
||||
ParagraphMonospace };
|
||||
|
||||
QPointer<QTextList> m_lastBlockList;
|
||||
|
||||
private:
|
||||
MessageFontSizeHandler mMessageFontSizeHandler;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user