Skip to content
Permalink
Browse files
Final fixes to default theme overlays and support for theme selection…
… in grass plugin. I have added setThemeName and themeName accessor and mutator to qgsapplication which return the theme name only sans path. Various other changes were made to support properly masking themes with missing icons so that the default icon is used instead.

git-svn-id: http://svn.osgeo.org/qgis/trunk@8941 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jul 28, 2008
1 parent cc5bba6 commit 6febbcaa36c0d0f91e6e79b409b4c262d016590c
Showing with 69 additions and 29 deletions.
  1. +18 −2 python/core/qgsapplication.sip
  2. +15 −14 src/app/qgisapp.cpp
  3. +17 −10 src/core/qgsapplication.cpp
  4. +19 −3 src/core/qgsapplication.h
@@ -82,8 +82,24 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)

virtual ~QgsApplication();

//! Set the active theme path to the specified theme.
static void setTheme(const QString theThemeName);
/** Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
* but plugin writers etc can use themeName() as a basis for searching
* for resources in their own datastores e.g. a Qt4 resource bundle.
* @Note A basic test will be carried out to ensure the theme search path
* based on the supplied theme name exists. If it does not the theme name will
* be reverted to 'default'.
*/
static void setThemeName(const QString theThemeName);

/** Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
* but plugin writers etc can use this method as a basis for searching
* for resources in their own datastores e.g. a Qt4 resource bundle.
*/
static const QString themeName();

//! Returns the path to the authors file.
static const QString authorsFilePath();
@@ -445,6 +445,8 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
mFullScreenMode = false;
show();
qApp->processEvents();
//finally show all the application settings as initialised above
QgsApplication::showSettings();
} // QgisApp ctor


@@ -1267,12 +1269,9 @@ void QgisApp::setTheme(QString theThemeName)
// the themes directory and builds a list of themes (ie subdirectories)
// for the user to choose from.
//
// TODO: Check as each icon is grabbed and if it doesn't exist, use the
// one from the default theme (which is installed with qgis and should
// always be good)
*/
QgsApplication::setTheme(theThemeName);
QgsDebugMsg("Setting theme to \n" + QgsApplication::activeThemePath());
QgsApplication::setThemeName(theThemeName);
QgsDebugMsg("Setting theme to \n" + theThemeName);
mActionFileNew->setIcon(getThemeIcon( "/mActionFileNew.png"));
mActionFileSave->setIcon(getThemeIcon( "/mActionFileSave.png"));
mActionFileSaveAs->setIcon(getThemeIcon( "/mActionFileSaveAs.png"));
@@ -1670,8 +1669,6 @@ void QgisApp::about()
void QgisApp::restoreSessionPlugins(QString thePluginDirString)
{
QSettings mySettings;

QgsApplication::showSettings();
QgsDebugMsg("\n\n*************************************************");
QgsDebugMsg("Restoring plugins from last session " + thePluginDirString);

@@ -5567,15 +5564,17 @@ void QgisApp::setupProxy()

QIcon QgisApp::getThemeIcon(const QString theName)
{
if (QFile::exists(QgsApplication::activeThemePath() + theName))
QString myPreferredPath = QgsApplication::activeThemePath() + theName;
QString myDefaultPath = QgsApplication::defaultThemePath() + theName;
if (QFile::exists(myPreferredPath))
{
return QIcon(QgsApplication::activeThemePath() + theName);
return QIcon(myPreferredPath);
}
else if (QFile::exists(QgsApplication::defaultThemePath() + theName))
else if (QFile::exists(myDefaultPath))
{
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QIcon(QgsApplication::defaultThemePath() + theName);
return QIcon(myDefaultPath);
}
else
{
@@ -5585,15 +5584,17 @@ QIcon QgisApp::getThemeIcon(const QString theName)

QPixmap QgisApp::getThemePixmap(const QString theName)
{
if (QFile::exists(QgsApplication::activeThemePath() + theName))
QString myPreferredPath = QgsApplication::activeThemePath() + theName;
QString myDefaultPath = QgsApplication::defaultThemePath() + theName;
if (QFile::exists(myPreferredPath))
{
return QPixmap(QgsApplication::activeThemePath() + theName);
return QPixmap(myPreferredPath);
}
else
{
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QPixmap(QgsApplication::defaultThemePath() + theName);
return QPixmap(myDefaultPath);
}
}

@@ -34,7 +34,7 @@
QString QgsApplication::mPrefixPath;
QString QgsApplication::mPluginPath;
QString QgsApplication::mPkgDataPath;
QString QgsApplication::mThemePath;
QString QgsApplication::mThemeName;

/*!
\class QgsApplication
@@ -91,7 +91,6 @@ void QgsApplication::setPluginPath(const QString thePluginPath)
void QgsApplication::setPkgDataPath(const QString thePkgDataPath)
{
mPkgDataPath = thePkgDataPath;
mThemePath = mPkgDataPath + QString("/themes/default/");
}

const QString QgsApplication::prefixPath()
@@ -108,30 +107,36 @@ const QString QgsApplication::pkgDataPath()
}
const QString QgsApplication::defaultThemePath()
{
return mPkgDataPath + QString("/themes/default/");
return mPkgDataPath + "/themes/default/";
}
const QString QgsApplication::activeThemePath()
{
return mThemePath;
return mPkgDataPath + "/themes/" + mThemeName + "/";
}

/*!
Set the theme path to the specified theme.
*/
void QgsApplication::setTheme(const QString theThemeName)
void QgsApplication::setThemeName(const QString theThemeName)
{
QString myPath = mPkgDataPath + QString("/themes/") + theThemeName + QString("/");
QString myPath = mPkgDataPath + "/themes/" + theThemeName + "/";
//check it exists and if not roll back to default theme
if (QFile::exists(myPath))
{
mThemePath = myPath;
mThemeName = theThemeName;
}
else
{
mThemePath = defaultThemePath();
mThemeName = "default";
}
}

/*!
* Get the active theme name
*/
const QString QgsApplication::themeName()
{
return mThemeName;
}
/*!
Returns the path to the authors file.
*/
@@ -269,7 +274,9 @@ void QgsApplication::showSettings()
qDebug("Prefix :" + mPrefixPath.toLocal8Bit());
qDebug("Plugin Path :" + mPluginPath.toLocal8Bit());
qDebug("PkgData Path :" + mPkgDataPath.toLocal8Bit());
qDebug("Theme Path :" + mThemePath.toLocal8Bit());
qDebug("Active Theme Name :" + themeName().toLocal8Bit());
qDebug("Active Theme Path :" + activeThemePath().toLocal8Bit());
qDebug("Default Theme Path :" + defaultThemePath().toLocal8Bit());
qDebug("User DB Path :" + qgisMasterDbFilePath().toLocal8Bit());
qDebug("**********************************\n");
}
@@ -24,8 +24,24 @@ class CORE_EXPORT QgsApplication: public QApplication
QgsApplication(int & argc, char ** argv, bool GUIenabled);
virtual ~QgsApplication();

//! Set the active theme path to the specified theme.
static void setTheme(const QString theThemeName);
/** Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
* but plugin writers etc can use themeName() as a basis for searching
* for resources in their own datastores e.g. a Qt4 resource bundle.
* @Note A basic test will be carried out to ensure the theme search path
* based on the supplied theme name exists. If it does not the theme name will
* be reverted to 'default'.
*/
static void setThemeName(const QString theThemeName);

/** Set the active theme to the specified theme.
* The theme name should be a single word e.g. 'default','classic'.
* The theme search path usually will be pkgDataPath + "/themes/" + themName + "/"
* but plugin writers etc can use this method as a basis for searching
* for resources in their own datastores e.g. a Qt4 resource bundle.
*/
static const QString themeName() ;

//! Returns the path to the authors file.
static const QString authorsFilePath();
@@ -123,7 +139,7 @@ class CORE_EXPORT QgsApplication: public QApplication
static QString mPrefixPath;
static QString mPluginPath;
static QString mPkgDataPath;
static QString mThemePath;
static QString mThemeName;
};

#endif

0 comments on commit 6febbca

Please sign in to comment.