Skip to content

Commit 46139d6

Browse files
committed
Fix icon loading for themes
1 parent 0edcf6c commit 46139d6

File tree

6 files changed

+13
-38
lines changed

6 files changed

+13
-38
lines changed

python/core/qgsapplication.sip

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,6 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
104104

105105
static void setUITheme( const QString &themeName );
106106

107-
/**
108-
* @brief Return the active UI theme set in the settings.
109-
* @return The name of the current UI theme.
110-
*/
111-
static QString uiThemeName();
112-
113107
/**
114108
* @brief All themes found in the application resources folder
115109
* and ~/.qgis2/themes folder. The path is to the root folder for the theme

src/app/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ APP_EXPORT int main( int argc, char *argv[] )
889889
#endif
890890
#endif
891891

892-
QgsApplication::setUITheme( QgsApplication::uiThemeName() );
893892
/* Translation file for QGIS.
894893
*/
895894
QString i18nPath = QgsApplication::i18nPath();

src/app/qgisapp.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,9 +1146,8 @@ QgisAppStyleSheet* QgisApp::styleSheetBuilder()
11461146
void QgisApp::readSettings()
11471147
{
11481148
QSettings settings;
1149-
// get the users theme preference from the settings
1150-
// 'gis' theme is new /themes/default directory (2013-04-15)
1151-
setTheme( settings.value( "/Themes", "default" ).toString() );
1149+
QString themename = settings.value( "UI/UITheme", "default" ).toString();
1150+
setTheme( themename );
11521151

11531152
// Read legacy settings
11541153
mRecentProjects.clear();
@@ -2067,7 +2066,7 @@ void QgisApp::setTheme( QString theThemeName )
20672066
// for the user to choose from.
20682067
//
20692068
*/
2070-
QgsApplication::setThemeName( theThemeName );
2069+
QgsApplication::setUITheme( theThemeName );
20712070
//QgsDebugMsg("Setting theme to \n" + theThemeName);
20722071
mActionNewProject->setIcon( QgsApplication::getThemeIcon( "/mActionFileNew.svg" ) );
20732072
mActionOpenProject->setIcon( QgsApplication::getThemeIcon( "/mActionFileOpen.svg" ) );

src/app/qgsoptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
525525
QString name = QApplication::style()->objectName();
526526
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
527527

528-
QString theme = QgsApplication::uiThemeName();
528+
QString theme = QgsApplication::themeName();
529529
cmbUITheme->setCurrentIndex( cmbUITheme->findText( theme, Qt::MatchFixedString ) );
530530

531531
mNativeColorDialogsChkBx->setChecked( settings.value( "/qgis/native_color_dialogs", false ).toBool() );

src/core/qgsapplication.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ QString QgsApplication::defaultThemePath()
356356
}
357357
QString QgsApplication::activeThemePath()
358358
{
359-
return ":/images/themes/" + themeName() + "/";
359+
return userThemesFolder() + QDir::separator() + themeName() + QDir::separator() + "icons/";
360360
}
361361

362362

@@ -413,16 +413,7 @@ QPixmap QgsApplication::getThemePixmap( const QString &theName )
413413
*/
414414
void QgsApplication::setThemeName( const QString &theThemeName )
415415
{
416-
QString myPath = ":/images/themes/" + theThemeName + "/";
417-
//check it exists and if not roll back to default theme
418-
if ( QFile::exists( myPath ) )
419-
{
420-
ABISYM( mThemeName ) = theThemeName;
421-
}
422-
else
423-
{
424-
ABISYM( mThemeName ) = "default";
425-
}
416+
ABISYM( mThemeName ) = theThemeName;
426417
}
427418
/*!
428419
* Get the active theme name
@@ -436,7 +427,11 @@ void QgsApplication::setUITheme( const QString &themeName )
436427
{
437428
// Loop all style sheets, find matching name, load it.
438429
QHash<QString, QString> themes = QgsApplication::uiThemes();
439-
QString path = themes[themeName];
430+
QString themename = themeName;
431+
if (!themes.contains(themename))
432+
themename = "default";
433+
434+
QString path = themes[themename];
440435
QString stylesheetname = path + "/style.qss";
441436
QString autostylesheet = stylesheetname + ".auto";
442437

@@ -479,8 +474,7 @@ void QgsApplication::setUITheme( const QString &themeName )
479474
QString styleSheet = QLatin1String( "file:///" );
480475
styleSheet.append( stylesheetname );
481476
qApp->setStyleSheet( styleSheet );
482-
QSettings settings;
483-
return settings.setValue( "UI/UITheme", themeName );
477+
setThemeName( themename );
484478
}
485479

486480
QHash<QString, QString> QgsApplication::uiThemes()
@@ -506,12 +500,6 @@ QHash<QString, QString> QgsApplication::uiThemes()
506500
return mapping;
507501
}
508502

509-
QString QgsApplication::uiThemeName()
510-
{
511-
QSettings settings;
512-
return settings.value( "UI/UITheme", "default" ).toString();
513-
}
514-
515503
/*!
516504
Returns the path to the authors file.
517505
*/

src/core/qgsapplication.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,10 @@ class CORE_EXPORT QgsApplication : public QApplication
8181
* find valid themes to use. Variabels found in variables.qss will be added to the stylesheet
8282
* on load.
8383
* @param themeName The name of the theme.
84+
* @note using an invalid theme name will reset to default
8485
*/
8586
static void setUITheme( const QString &themeName );
8687

87-
/**
88-
* @brief Return the active UI theme set in the settings.
89-
* @return The name of the current UI theme.
90-
*/
91-
static QString uiThemeName();
92-
9388
/**
9489
* @brief All themes found in ~/.qgis2/themes folder.
9590
* The path is to the root folder for the theme

0 commit comments

Comments
 (0)