mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
On first run, try to guess a good default icon size based on screen DPI
Otherwise icons are miniscule when loading QGIS on hidpi screens, and users must know that they need to manually change the icon size to make it usable...
This commit is contained in:
parent
dbd50b4bdd
commit
71b9ce25c6
@ -50,6 +50,7 @@
|
||||
#include <QProgressDialog>
|
||||
#include <QRegExp>
|
||||
#include <QRegExpValidator>
|
||||
#include <QScreen>
|
||||
#include <QShortcut>
|
||||
#include <QSpinBox>
|
||||
#include <QSplashScreen>
|
||||
@ -1033,8 +1034,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
|
||||
}
|
||||
|
||||
// Set icon size of toolbars
|
||||
int size = settings.value( QStringLiteral( "IconSize" ), QGIS_ICON_SIZE ).toInt();
|
||||
if ( settings.contains( QStringLiteral( "IconSize" ) ) )
|
||||
{
|
||||
int size = settings.value( QStringLiteral( "IconSize" ) ).toInt();
|
||||
if ( size < 16 )
|
||||
size = QGIS_ICON_SIZE;
|
||||
setIconSizes( size );
|
||||
}
|
||||
else
|
||||
{
|
||||
// first run, guess a good icon size
|
||||
int size = chooseReasonableDefaultIconSize();
|
||||
settings.setValue( QStringLiteral( "IconSize" ), size );
|
||||
setIconSizes( size );
|
||||
}
|
||||
|
||||
mSplash->showMessage( tr( "Initializing file filters" ), Qt::AlignHCenter | Qt::AlignBottom );
|
||||
qApp->processEvents();
|
||||
@ -1729,6 +1742,31 @@ QgsCoordinateReferenceSystem QgisApp::defaultCrsForNewLayers() const
|
||||
return defaultCrs;
|
||||
}
|
||||
|
||||
int QgisApp::chooseReasonableDefaultIconSize() const
|
||||
{
|
||||
QScreen *screen = QApplication::screens().at( 0 );
|
||||
if ( screen->physicalDotsPerInch() < 115 )
|
||||
{
|
||||
// no hidpi screen, use default size
|
||||
return QGIS_ICON_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
double size = fontMetrics().width( QStringLiteral( "XXX" ) );
|
||||
if ( size < 24 )
|
||||
return 16;
|
||||
else if ( size < 32 )
|
||||
return 24;
|
||||
else if ( size < 48 )
|
||||
return 32;
|
||||
else if ( size < 64 )
|
||||
return 48;
|
||||
else
|
||||
return 64;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QgisApp::readSettings()
|
||||
{
|
||||
QgsSettings settings;
|
||||
|
@ -1688,6 +1688,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
|
||||
QgsCoordinateReferenceSystem defaultCrsForNewLayers() const;
|
||||
|
||||
//! Attempts to choose a reasonable default icon size based on the window's screen DPI
|
||||
int chooseReasonableDefaultIconSize() const;
|
||||
|
||||
QgisAppStyleSheet *mStyleSheetBuilder = nullptr;
|
||||
|
||||
// actions for menus and toolbars -----------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user