Skip to content

Commit 92e18bf

Browse files
committedNov 1, 2018
Hidpi friendly message bar icon sizes
(cherry picked from commit e83aa5a)
1 parent 36b37eb commit 92e18bf

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎src/gui/qgsmessagebar.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ QgsMessageBar::QgsMessageBar( QWidget *parent )
4444
setFrameShadow( QFrame::Plain );
4545

4646
mLayout = new QGridLayout( this );
47-
mLayout->setContentsMargins( 9, 1, 9, 1 );
47+
const int xMargin = std::max( 9.0, Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 0.45 );
48+
const int yMargin = std::max( 1.0, Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 0.05 );
49+
mLayout->setContentsMargins( xMargin, yMargin, xMargin, yMargin );
4850
setLayout( mLayout );
4951

5052
mCountProgress = new QProgressBar( this );
@@ -55,7 +57,9 @@ QgsMessageBar::QgsMessageBar( QWidget *parent )
5557

5658
mCountProgress->setStyleSheet( mCountStyleSheet.arg( QStringLiteral( "mIconTimerPause.svg" ) ) );
5759
mCountProgress->setObjectName( QStringLiteral( "mCountdown" ) );
58-
mCountProgress->setFixedSize( 25, 14 );
60+
const int barWidth = std::max( 25.0, Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.25 );
61+
const int barHeight = std::max( 14.0, Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 0.7 );
62+
mCountProgress->setFixedSize( barWidth, barHeight );
5963
mCountProgress->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
6064
mCountProgress->setTextVisible( false );
6165
mCountProgress->setRange( 0, 5 );
@@ -83,7 +87,9 @@ QgsMessageBar::QgsMessageBar( QWidget *parent )
8387
"QToolButton::menu-button { background-color: rgba(0, 0, 0, 0); }" );
8488
mCloseBtn->setCursor( Qt::PointingHandCursor );
8589
mCloseBtn->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconClose.svg" ) ) );
86-
mCloseBtn->setIconSize( QSize( 18, 18 ) );
90+
91+
const int iconSize = std::max( 18.0, Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 0.9 );
92+
mCloseBtn->setIconSize( QSize( iconSize, iconSize ) );
8793
mCloseBtn->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
8894
mCloseBtn->setMenu( mCloseMenu );
8995
mCloseBtn->setPopupMode( QToolButton::MenuButtonPopup );

‎src/gui/qgsmessagebaritem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ void QgsMessageBarItem::writeContent()
109109
}
110110
icon = QgsApplication::getThemeIcon( msgIcon );
111111
}
112-
mLblIcon->setPixmap( icon.pixmap( 24 ) );
112+
const int iconSize = std::max( 24.0, fontMetrics().height() * 1.2 );
113+
mLblIcon->setPixmap( icon.pixmap( iconSize ) );
113114

114115

115116
// STYLESHEETS

0 commit comments

Comments
 (0)
Please sign in to comment.