Skip to content
Permalink
Browse files

Fix some hidpi issues with tiny icons

  • Loading branch information
nyalldawson committed May 22, 2020
1 parent ee9dadb commit 50b3f0c20f997ca5769f526158f67cb0f7dcfb4c
@@ -25,7 +25,7 @@
#include "qgsproxystyle.h"
#include "qgslogger.h"
#include "qgssettings.h"

#include "qgsguiutils.h"

QgisAppStyleSheet::QgisAppStyleSheet( QObject *parent )
: QObject( parent )
@@ -133,22 +133,24 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
if ( themeName == QStringLiteral( "default" ) || !QgsApplication::uiThemes().contains( themeName ) )
{
//sidebar style
QString style = "QListWidget#mOptionsListWidget {"
" background-color: rgba(69, 69, 69, 0);"
" outline: 0;"
"}"
"QFrame#mOptionsListFrame {"
" background-color: rgba(69, 69, 69, 220);"
"}"
"QListWidget#mOptionsListWidget::item {"
" color: white;"
" padding: 3px;"
"}"
"QListWidget#mOptionsListWidget::item::selected {"
" color: black;"
" background-color:palette(Window);"
" padding-right: 0px;"
"}";
const int frameMargin = QgsGuiUtils::scaleIconSize( 3 );

QString style = QStringLiteral( "QListWidget#mOptionsListWidget {"
" background-color: rgba(69, 69, 69, 0);"
" outline: 0;"
"}"
"QFrame#mOptionsListFrame {"
" background-color: rgba(69, 69, 69, 220);"
"}"
"QListWidget#mOptionsListWidget::item {"
" color: white;"
" padding: %1px;"
"}"
"QListWidget#mOptionsListWidget::item::selected {"
" color: black;"
" background-color:palette(Window);"
" padding-right: 0px;"
"}" ).arg( frameMargin );

QString toolbarSpacing = opts.value( QStringLiteral( "toolbarSpacing" ), QString() ).toString();
if ( !toolbarSpacing.isEmpty() )
@@ -46,6 +46,9 @@ QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer *layer, QgsMapCanvas *canva

connect( mLabelModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLabelingWidget::labelModeChanged );
setLayer( layer );

const int iconSize16 = QgsGuiUtils::scaleIconSize( 16 );
mEngineSettingsButton->setIconSize( QSize( iconSize16, iconSize16 ) );
}

QgsLabelingGui *QgsLabelingWidget::labelingGui()
@@ -33,6 +33,7 @@
#include "qgslogger.h"
#include "qgsoptionsdialoghighlightwidget.h"
#include "qgsoptionswidgetfactory.h"
#include "qgsguiutils.h"

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

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

optionsFrame->layout()->setContentsMargins( 0, 3, 3, 3 );
const int frameMargin = QgsGuiUtils::scaleIconSize( 3 );
optionsFrame->layout()->setContentsMargins( 0, frameMargin, frameMargin, frameMargin );
QVBoxLayout *layout = static_cast<QVBoxLayout *>( optionsFrame->layout() );

if ( buttonBoxFrame )
@@ -96,9 +96,13 @@ void QgsTextFormatWidget::initWidget()

const int iconSize = QgsGuiUtils::scaleIconSize( 20 );
mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
mLabelingOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ) ;
const int iconSize32 = QgsGuiUtils::scaleIconSize( 32 );
const int iconSize24 = QgsGuiUtils::scaleIconSize( 24 );
const int iconSize18 = QgsGuiUtils::scaleIconSize( 18 );
const int iconSize16 = QgsGuiUtils::scaleIconSize( 16 );

mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
@@ -268,12 +268,6 @@
</item>
<item>
<widget class="QToolButton" name="mPreviewTextBtn">
<property name="maximumSize">
<size>
<width>24</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Reset sample text</string>
</property>
@@ -723,8 +717,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>323</width>
<height>292</height>
<width>485</width>
<height>429</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
@@ -1313,7 +1307,7 @@ font-style: italic;</string>
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<width>370</width>
<height>708</height>
</rect>
</property>

0 comments on commit 50b3f0c

Please sign in to comment.
You can’t perform that action at this time.