Skip to content

Commit

Permalink
Fix some hidpi issues with tiny icons
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 23, 2020
1 parent ee9dadb commit 50b3f0c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
36 changes: 19 additions & 17 deletions src/app/qgisappstylesheet.cpp
Expand Up @@ -25,7 +25,7 @@
#include "qgsproxystyle.h"
#include "qgslogger.h"
#include "qgssettings.h"

#include "qgsguiutils.h"

QgisAppStyleSheet::QgisAppStyleSheet( QObject *parent )
: QObject( parent )
Expand Down Expand Up @@ -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() )
Expand Down
3 changes: 3 additions & 0 deletions src/gui/labeling/qgslabelingwidget.cpp
Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions src/gui/qgsoptionsdialogbase.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgstextformatwidget.cpp
Expand Up @@ -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 ) );
Expand Down
12 changes: 3 additions & 9 deletions src/ui/qgstextformatwidgetbase.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 50b3f0c

Please sign in to comment.