Skip to content
Permalink
Browse files

[gui] update icon sizing code to handle dock toolbars

  • Loading branch information
nirvn authored and nyalldawson committed Jun 2, 2015
1 parent cde749f commit d94cd881221c8c2844268017c06809dce9868b2e
Showing with 42 additions and 23 deletions.
  1. +27 −3 src/app/qgisapp.cpp
  2. +0 −17 src/app/qgisappstylesheet.cpp
  3. +15 −0 src/app/qgsidentifyresultsdialog.cpp
  4. +0 −3 src/app/qgsoptions.cpp
@@ -762,6 +762,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mActionShowPythonDialog = 0;
}

// Set icon size of toolbars
int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
setIconSizes( size );

mSplash->showMessage( tr( "Initializing file filters" ), Qt::AlignHCenter | Qt::AlignBottom );
qApp->processEvents();

@@ -1600,8 +1604,6 @@ void QgisApp::createMenus()
void QgisApp::createToolBars()
{
QSettings settings;
int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
setIconSize( QSize( size, size ) );
// QSize myIconSize ( 32,32 ); //large icons
// Note: we need to set each object name to ensure that
// qmainwindow::saveState and qmainwindow::restoreState
@@ -1927,14 +1929,36 @@ void QgisApp::createStatusBar()

void QgisApp::setIconSizes( int size )
{
int dockSize;
if ( size > 32 )
{
dockSize = size - 16;
}
else if ( size == 32 )
{
dockSize = 24;
}
else
{
dockSize = 16;
}

//Set the icon size of for all the toolbars created in the future.
setIconSize( QSize( size, size ) );

//Change all current icon sizes.
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
foreach ( QToolBar * toolbar, toolbars )
{
toolbar->setIconSize( QSize( size, size ) );
QString className = toolbar->parent()->metaObject()->className();
if ( className == "QgisApp" )
{
toolbar->setIconSize( QSize( size, size ) );
}
else
{
toolbar->setIconSize( QSize( dockSize, dockSize ) );
}
}

foreach ( QgsComposer *c, mPrintComposers )
@@ -176,23 +176,6 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )
.arg( palette.highlight().color().name() )
.arg( palette.highlightedText().color().name() );

int iconSize = opts.value( "iconSize" ).toInt();
if ( iconSize > 32 )
{
iconSize -= 16;
}
else if ( iconSize == 32 )
{
iconSize = 24;
}
else
{
iconSize = 16;
}

QgsDebugMsg( QString( "iconSize: %1" ).arg( iconSize ) );
ss += QString( "QDockWidget QToolButton { icon-size: %1px; }" ).arg( iconSize );

QgsDebugMsg( QString( "Stylesheet built: %1" ).arg( ss ) );

emit appStyleSheetChanged( ss );
@@ -267,6 +267,21 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
else
QgisApp::instance()->panelMenu()->addAction( mDock->toggleViewAction() );

int size = mySettings.value( "/IconSize", 16 ).toInt();
if ( size > 32 )
{
size -= 16;
}
else if ( size == 32 )
{
size = 24;
}
else
{
size = 16;
}
mIdentifyToolbar->setIconSize( QSize( size, size ) );

mExpandNewAction->setChecked( mySettings.value( "/Map/identifyExpand", false ).toBool() );
mActionCopy->setEnabled( false );
lstResults->setColumnCount( 2 );
@@ -925,9 +925,6 @@ void QgsOptions::on_pbnTemplateFolderReset_pressed()
void QgsOptions::iconSizeChanged( const QString &iconSize )
{
QgisApp::instance()->setIconSizes( iconSize.toInt() );

mStyleSheetNewOpts.insert( "iconSize", QVariant( iconSize.toInt() ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}

void QgsOptions::on_mProjectOnLaunchCmbBx_currentIndexChanged( int indx )

0 comments on commit d94cd88

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