Skip to content

Commit 50b3f0c

Browse files
committedMay 23, 2020
Fix some hidpi issues with tiny icons
1 parent ee9dadb commit 50b3f0c

File tree

5 files changed

+34
-29
lines changed

5 files changed

+34
-29
lines changed
 

‎src/app/qgisappstylesheet.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "qgsproxystyle.h"
2626
#include "qgslogger.h"
2727
#include "qgssettings.h"
28-
28+
#include "qgsguiutils.h"
2929

3030
QgisAppStyleSheet::QgisAppStyleSheet( QObject *parent )
3131
: QObject( parent )
@@ -133,22 +133,24 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
133133
if ( themeName == QStringLiteral( "default" ) || !QgsApplication::uiThemes().contains( themeName ) )
134134
{
135135
//sidebar style
136-
QString style = "QListWidget#mOptionsListWidget {"
137-
" background-color: rgba(69, 69, 69, 0);"
138-
" outline: 0;"
139-
"}"
140-
"QFrame#mOptionsListFrame {"
141-
" background-color: rgba(69, 69, 69, 220);"
142-
"}"
143-
"QListWidget#mOptionsListWidget::item {"
144-
" color: white;"
145-
" padding: 3px;"
146-
"}"
147-
"QListWidget#mOptionsListWidget::item::selected {"
148-
" color: black;"
149-
" background-color:palette(Window);"
150-
" padding-right: 0px;"
151-
"}";
136+
const int frameMargin = QgsGuiUtils::scaleIconSize( 3 );
137+
138+
QString style = QStringLiteral( "QListWidget#mOptionsListWidget {"
139+
" background-color: rgba(69, 69, 69, 0);"
140+
" outline: 0;"
141+
"}"
142+
"QFrame#mOptionsListFrame {"
143+
" background-color: rgba(69, 69, 69, 220);"
144+
"}"
145+
"QListWidget#mOptionsListWidget::item {"
146+
" color: white;"
147+
" padding: %1px;"
148+
"}"
149+
"QListWidget#mOptionsListWidget::item::selected {"
150+
" color: black;"
151+
" background-color:palette(Window);"
152+
" padding-right: 0px;"
153+
"}" ).arg( frameMargin );
152154

153155
QString toolbarSpacing = opts.value( QStringLiteral( "toolbarSpacing" ), QString() ).toString();
154156
if ( !toolbarSpacing.isEmpty() )

‎src/gui/labeling/qgslabelingwidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer *layer, QgsMapCanvas *canva
4646

4747
connect( mLabelModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLabelingWidget::labelModeChanged );
4848
setLayer( layer );
49+
50+
const int iconSize16 = QgsGuiUtils::scaleIconSize( 16 );
51+
mEngineSettingsButton->setIconSize( QSize( iconSize16, iconSize16 ) );
4952
}
5053

5154
QgsLabelingGui *QgsLabelingWidget::labelingGui()

‎src/gui/qgsoptionsdialogbase.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "qgslogger.h"
3434
#include "qgsoptionsdialoghighlightwidget.h"
3535
#include "qgsoptionswidgetfactory.h"
36+
#include "qgsguiutils.h"
3637

3738
QgsOptionsDialogBase::QgsOptionsDialogBase( const QString &settingsKey, QWidget *parent, Qt::WindowFlags fl, QgsSettings *settings )
3839
: QDialog( parent, fl )
@@ -101,14 +102,15 @@ void QgsOptionsDialogBase::initOptionsBase( bool restoreUi, const QString &title
101102
return;
102103
}
103104

104-
int size = mSettings->value( QStringLiteral( "/IconSize" ), 24 ).toInt();
105+
int size = QgsGuiUtils::scaleIconSize( mSettings->value( QStringLiteral( "/IconSize" ), 24 ).toInt() );
105106
// buffer size to match displayed icon size in toolbars, and expected geometry restore
106107
// newWidth (above) may need adjusted if you adjust iconBuffer here
107-
int iconBuffer = 4;
108+
const int iconBuffer = QgsGuiUtils::scaleIconSize( 4 );
108109
mOptListWidget->setIconSize( QSize( size + iconBuffer, size + iconBuffer ) );
109110
mOptListWidget->setFrameStyle( QFrame::NoFrame );
110111

111-
optionsFrame->layout()->setContentsMargins( 0, 3, 3, 3 );
112+
const int frameMargin = QgsGuiUtils::scaleIconSize( 3 );
113+
optionsFrame->layout()->setContentsMargins( 0, frameMargin, frameMargin, frameMargin );
112114
QVBoxLayout *layout = static_cast<QVBoxLayout *>( optionsFrame->layout() );
113115

114116
if ( buttonBoxFrame )

‎src/gui/qgstextformatwidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ void QgsTextFormatWidget::initWidget()
9696

9797
const int iconSize = QgsGuiUtils::scaleIconSize( 20 );
9898
mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
99+
mLabelingOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ) ;
99100
const int iconSize32 = QgsGuiUtils::scaleIconSize( 32 );
100101
const int iconSize24 = QgsGuiUtils::scaleIconSize( 24 );
101102
const int iconSize18 = QgsGuiUtils::scaleIconSize( 18 );
103+
const int iconSize16 = QgsGuiUtils::scaleIconSize( 16 );
104+
105+
mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
102106
mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
103107
mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
104108
mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );

‎src/ui/qgstextformatwidgetbase.ui

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,6 @@
268268
</item>
269269
<item>
270270
<widget class="QToolButton" name="mPreviewTextBtn">
271-
<property name="maximumSize">
272-
<size>
273-
<width>24</width>
274-
<height>22</height>
275-
</size>
276-
</property>
277271
<property name="toolTip">
278272
<string>Reset sample text</string>
279273
</property>
@@ -723,8 +717,8 @@
723717
<rect>
724718
<x>0</x>
725719
<y>0</y>
726-
<width>323</width>
727-
<height>292</height>
720+
<width>485</width>
721+
<height>429</height>
728722
</rect>
729723
</property>
730724
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
@@ -1313,7 +1307,7 @@ font-style: italic;</string>
13131307
<rect>
13141308
<x>0</x>
13151309
<y>0</y>
1316-
<width>373</width>
1310+
<width>370</width>
13171311
<height>708</height>
13181312
</rect>
13191313
</property>

0 commit comments

Comments
 (0)
Please sign in to comment.