[QGIS Commit] r8941 - in trunk/qgis: python/core src/app src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Jul 28 14:08:44 EDT 2008
Author: timlinux
Date: 2008-07-28 14:08:44 -0400 (Mon, 28 Jul 2008)
New Revision: 8941
Modified:
trunk/qgis/python/core/qgsapplication.sip
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/core/qgsapplication.cpp
trunk/qgis/src/core/qgsapplication.h
Log:
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.
Modified: trunk/qgis/python/core/qgsapplication.sip
===================================================================
--- trunk/qgis/python/core/qgsapplication.sip 2008-07-28 17:29:31 UTC (rev 8940)
+++ trunk/qgis/python/core/qgsapplication.sip 2008-07-28 18:08:44 UTC (rev 8941)
@@ -82,9 +82,25 @@
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();
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2008-07-28 17:29:31 UTC (rev 8940)
+++ trunk/qgis/src/app/qgisapp.cpp 2008-07-28 18:08:44 UTC (rev 8941)
@@ -445,6 +445,8 @@
mFullScreenMode = false;
show();
qApp->processEvents();
+ //finally show all the application settings as initialised above
+ QgsApplication::showSettings();
} // QgisApp ctor
@@ -1267,12 +1269,9 @@
// 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::restoreSessionPlugins(QString thePluginDirString)
{
QSettings mySettings;
-
- QgsApplication::showSettings();
QgsDebugMsg("\n\n*************************************************");
QgsDebugMsg("Restoring plugins from last session " + thePluginDirString);
@@ -5567,15 +5564,17 @@
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 @@
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);
}
}
Modified: trunk/qgis/src/core/qgsapplication.cpp
===================================================================
--- trunk/qgis/src/core/qgsapplication.cpp 2008-07-28 17:29:31 UTC (rev 8940)
+++ trunk/qgis/src/core/qgsapplication.cpp 2008-07-28 18:08:44 UTC (rev 8941)
@@ -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::setPkgDataPath(const QString thePkgDataPath)
{
mPkgDataPath = thePkgDataPath;
- mThemePath = mPkgDataPath + QString("/themes/default/");
}
const QString QgsApplication::prefixPath()
@@ -108,31 +107,37 @@
}
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.
*/
const QString QgsApplication::authorsFilePath()
@@ -269,7 +274,9 @@
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");
}
Modified: trunk/qgis/src/core/qgsapplication.h
===================================================================
--- trunk/qgis/src/core/qgsapplication.h 2008-07-28 17:29:31 UTC (rev 8940)
+++ trunk/qgis/src/core/qgsapplication.h 2008-07-28 18:08:44 UTC (rev 8941)
@@ -24,9 +24,25 @@
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 @@
static QString mPrefixPath;
static QString mPluginPath;
static QString mPkgDataPath;
- static QString mThemePath;
+ static QString mThemeName;
};
#endif
More information about the QGIS-commit
mailing list