gui: reduce size of icons in chat for font.height lesser than 26

This commit is contained in:
chelovechishko 2018-07-04 22:46:01 +09:00
parent 77c3eae976
commit b3fb7abf99
2 changed files with 28 additions and 16 deletions

View File

@ -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 */

View File

@ -65,6 +65,8 @@
#include <time.h>
#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) ;
}