Skip to content
Permalink
Browse files

Fix icon loading for themes

  • Loading branch information
NathanW2 committed Aug 31, 2015
1 parent 0edcf6c commit 46139d6591a53e7c04451e0557ee80b6ca3bd9c4
Showing with 13 additions and 38 deletions.
  1. +0 −6 python/core/qgsapplication.sip
  2. +0 −1 src/app/main.cpp
  3. +3 −4 src/app/qgisapp.cpp
  4. +1 −1 src/app/qgsoptions.cpp
  5. +8 −20 src/core/qgsapplication.cpp
  6. +1 −6 src/core/qgsapplication.h
@@ -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
@@ -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();
@@ -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();
@@ -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" ) );
@@ -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() );
@@ -356,7 +356,7 @@ QString QgsApplication::defaultThemePath()
}
QString QgsApplication::activeThemePath()
{
return ":/images/themes/" + themeName() + "/";
return userThemesFolder() + QDir::separator() + themeName() + QDir::separator() + "icons/";
}


@@ -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
@@ -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";

@@ -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()
@@ -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.
*/
@@ -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

0 comments on commit 46139d6

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