From b3fb7abf9925634b7f565668f0eeeef32625937a Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 4 Jul 2018 22:46:01 +0900 Subject: [PATCH] gui: reduce size of icons in chat for font.height lesser than 26 --- .../src/gui/chat/ChatLobbyDialog.cpp | 24 +++++++++++-------- retroshare-gui/src/gui/chat/ChatWidget.cpp | 20 +++++++++++----- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 1f7b20ac6..35a6f0f54 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -80,7 +80,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - int S = QFontMetricsF(font()).height() ; + int S = QFontMetricsF(font()).height() ; ui.participantsList->setIconSize(QSize(1.4*S,1.4*S)); ui.participantsList->setColumnCount(COLUMN_COUNT); @@ -128,23 +128,27 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi QString headerText = headerItem->text(COLUMN_NAME ); ui.filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerText)); + // just empiric values + double scaler_factor = S > 25 ? 2.4 : 1.8; + QSize icon_size(scaler_factor * S, scaler_factor * S); + // Add a button to invite friends. // inviteFriendsButton = new QToolButton ; - inviteFriendsButton->setMinimumSize(QSize(2.4*S,2.4*S)) ; - inviteFriendsButton->setMaximumSize(QSize(2.4*S,2.4*S)) ; + inviteFriendsButton->setMinimumSize(icon_size); + inviteFriendsButton->setMaximumSize(icon_size); inviteFriendsButton->setText(QString()) ; inviteFriendsButton->setAutoRaise(true) ; inviteFriendsButton->setToolTip(tr("Invite friends to this lobby")); - mParticipantCompareRole = new RSTreeWidgetItemCompareRole; - mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT); + mParticipantCompareRole = new RSTreeWidgetItemCompareRole; + mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT); { QIcon icon ; icon.addPixmap(QPixmap(":/icons/png/invite.png")) ; inviteFriendsButton->setIcon(icon) ; - inviteFriendsButton->setIconSize(QSize(2.4*S,2.4*S)) ; + inviteFriendsButton->setIconSize(icon_size); } connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends())); @@ -175,9 +179,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ; - unsubscribeButton = new QToolButton ; - unsubscribeButton->setMinimumSize(QSize(2.4*S,2.4*S)) ; - unsubscribeButton->setMaximumSize(QSize(2.4*S,2.4*S)) ; + unsubscribeButton = new QToolButton; + unsubscribeButton->setMinimumSize(icon_size); + unsubscribeButton->setMaximumSize(icon_size); unsubscribeButton->setText(QString()) ; unsubscribeButton->setAutoRaise(true) ; unsubscribeButton->setToolTip(tr("Leave this chat room (Unsubscribe)")); @@ -186,7 +190,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi QIcon icon ; icon.addPixmap(QPixmap(":/icons/png/leave.png")) ; unsubscribeButton->setIcon(icon) ; - unsubscribeButton->setIconSize(QSize(2.4*S,2.4*S)) ; + unsubscribeButton->setIconSize(icon_size); } /* Initialize splitter */ diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 674204d16..016d87d49 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -65,6 +65,8 @@ #include #define FMM 2.5//fontMetricsMultiplicator +#define FMM_SMALLER 1.8 +#define FMM_THRESHOLD 25 /***** * #define CHAT_DEBUG 1 @@ -75,9 +77,12 @@ ChatWidget::ChatWidget(QWidget *parent) : { ui->setupUi(this); - int iconHeight = FMM*QFontMetricsF(font()).height() ; - QSize iconSize = QSize(iconHeight,iconHeight); - QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM)); + int iconHeight = QFontMetricsF(font()).height(); + double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER; + iconHeight *= fmm; + QSize iconSize = QSize(iconHeight, iconHeight); + int butt_size(iconSize.height() + fmm); + QSize buttonSize = QSize(butt_size, butt_size); newMessages = false; typing = false; @@ -259,9 +264,12 @@ void ChatWidget::addChatHorizontalWidget(QWidget *w) void ChatWidget::addChatBarWidget(QWidget *w) { - int iconHeight = FMM*QFontMetricsF(font()).height() ; - QSize iconSize = QSize(iconHeight,iconHeight); - QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM)); + int iconHeight = QFontMetricsF(font()).height(); + double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER; + iconHeight *= fmm; + QSize iconSize = QSize(iconHeight, iconHeight); + int butt_size(iconSize.height() + fmm); + QSize buttonSize = QSize(butt_size, butt_size); w->setFixedSize(buttonSize); ui->pluginButtonFrame->layout()->addWidget(w) ; }