Skip to content

Commit

Permalink
Fix icon loading for themes
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Aug 31, 2015
1 parent 0edcf6c commit 46139d6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 38 deletions.
6 changes: 0 additions & 6 deletions python/core/qgsapplication.sip
Expand Up @@ -104,12 +104,6 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)

static void setUITheme( const QString &themeName );

/**
* @brief Return the active UI theme set in the settings.
* @return The name of the current UI theme.
*/
static QString uiThemeName();

/**
* @brief All themes found in the application resources folder
* and ~/.qgis2/themes folder. The path is to the root folder for the theme
Expand Down
1 change: 0 additions & 1 deletion src/app/main.cpp
Expand Up @@ -889,7 +889,6 @@ APP_EXPORT int main( int argc, char *argv[] )
#endif
#endif

QgsApplication::setUITheme( QgsApplication::uiThemeName() );
/* Translation file for QGIS.
*/
QString i18nPath = QgsApplication::i18nPath();
Expand Down
7 changes: 3 additions & 4 deletions src/app/qgisapp.cpp
Expand Up @@ -1146,9 +1146,8 @@ QgisAppStyleSheet* QgisApp::styleSheetBuilder()
void QgisApp::readSettings()
{
QSettings settings;
// get the users theme preference from the settings
// 'gis' theme is new /themes/default directory (2013-04-15)
setTheme( settings.value( "/Themes", "default" ).toString() );
QString themename = settings.value( "UI/UITheme", "default" ).toString();
setTheme( themename );

// Read legacy settings
mRecentProjects.clear();
Expand Down Expand Up @@ -2067,7 +2066,7 @@ void QgisApp::setTheme( QString theThemeName )
// for the user to choose from.
//
*/
QgsApplication::setThemeName( theThemeName );
QgsApplication::setUITheme( theThemeName );
//QgsDebugMsg("Setting theme to \n" + theThemeName);
mActionNewProject->setIcon( QgsApplication::getThemeIcon( "/mActionFileNew.svg" ) );
mActionOpenProject->setIcon( QgsApplication::getThemeIcon( "/mActionFileOpen.svg" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.cpp
Expand Up @@ -525,7 +525,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
QString name = QApplication::style()->objectName();
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );

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

mNativeColorDialogsChkBx->setChecked( settings.value( "/qgis/native_color_dialogs", false ).toBool() );
Expand Down
28 changes: 8 additions & 20 deletions src/core/qgsapplication.cpp
Expand Up @@ -356,7 +356,7 @@ QString QgsApplication::defaultThemePath()
}
QString QgsApplication::activeThemePath()
{
return ":/images/themes/" + themeName() + "/";
return userThemesFolder() + QDir::separator() + themeName() + QDir::separator() + "icons/";
}


Expand Down Expand Up @@ -413,16 +413,7 @@ QPixmap QgsApplication::getThemePixmap( const QString &theName )
*/
void QgsApplication::setThemeName( const QString &theThemeName )
{
QString myPath = ":/images/themes/" + theThemeName + "/";
//check it exists and if not roll back to default theme
if ( QFile::exists( myPath ) )
{
ABISYM( mThemeName ) = theThemeName;
}
else
{
ABISYM( mThemeName ) = "default";
}
ABISYM( mThemeName ) = theThemeName;
}
/*!
* Get the active theme name
Expand All @@ -436,7 +427,11 @@ void QgsApplication::setUITheme( const QString &themeName )
{
// Loop all style sheets, find matching name, load it.
QHash<QString, QString> themes = QgsApplication::uiThemes();
QString path = themes[themeName];
QString themename = themeName;
if (!themes.contains(themename))
themename = "default";

QString path = themes[themename];
QString stylesheetname = path + "/style.qss";
QString autostylesheet = stylesheetname + ".auto";

Expand Down Expand Up @@ -479,8 +474,7 @@ void QgsApplication::setUITheme( const QString &themeName )
QString styleSheet = QLatin1String( "file:///" );
styleSheet.append( stylesheetname );
qApp->setStyleSheet( styleSheet );
QSettings settings;
return settings.setValue( "UI/UITheme", themeName );
setThemeName( themename );
}

QHash<QString, QString> QgsApplication::uiThemes()
Expand All @@ -506,12 +500,6 @@ QHash<QString, QString> QgsApplication::uiThemes()
return mapping;
}

QString QgsApplication::uiThemeName()
{
QSettings settings;
return settings.value( "UI/UITheme", "default" ).toString();
}

/*!
Returns the path to the authors file.
*/
Expand Down
7 changes: 1 addition & 6 deletions src/core/qgsapplication.h
Expand Up @@ -81,15 +81,10 @@ class CORE_EXPORT QgsApplication : public QApplication
* find valid themes to use. Variabels found in variables.qss will be added to the stylesheet
* on load.
* @param themeName The name of the theme.
* @note using an invalid theme name will reset to default
*/
static void setUITheme( const QString &themeName );

/**
* @brief Return the active UI theme set in the settings.
* @return The name of the current UI theme.
*/
static QString uiThemeName();

/**
* @brief All themes found in ~/.qgis2/themes folder.
* The path is to the root folder for the theme
Expand Down

0 comments on commit 46139d6

Please sign in to comment.