Theme related fixes:

- implemented 'fall back' support so that if a theme is missing icons, the default theme icons will be used instead.
 - use a static function in qgisapp to get theme icons and pixmaps
 - updated all icon fetching code to use the new methods above
 - updated qgsapplication so that it differentiates between active and default themes
 - fixed a bug in qgsoptions that prevented themes being changed in some cases.
This is a part fix for #1054 - still need to do some work to make GRASS theming work properly


git-svn-id: http://svn.osgeo.org/qgis/trunk@8937 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2008-07-28 01:24:27 +00:00
parent 2e43667d73
commit ddd934fe0a
34 changed files with 2532 additions and 1543 deletions

View File

@ -82,8 +82,8 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
virtual ~QgsApplication();
//! Set the theme path to the specified theme.
static void selectTheme(const QString theThemeName);
//! Set the active theme path to the specified theme.
static void setTheme(const QString theThemeName);
//! Returns the path to the authors file.
static const QString authorsFilePath();
@ -130,8 +130,11 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//! Returns the common root path of all application data directories.
static const QString pkgDataPath();
//! Returns the path to the current theme directory.
static const QString themePath();
//! Returns the path to the currently active theme directory.
static const QString activeThemePath();
//! Returns the path to the default theme directory.
static const QString defaultThemePath();
//! Alters prefix path - used by 3rd party apps
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);

View File

@ -109,26 +109,22 @@ QgsComposer::~QgsComposer()
void QgsComposer::setupTheme()
{
//calculate the active theme path
QString myThemePath= QgsApplication::themePath();
//now set all the icons
mActionOpenTemplate->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileOpen.png")));
mActionSaveTemplateAs->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSaveAs.png")));
mActionExportAsImage->setIcon(QIcon(QPixmap(myThemePath + "/mActionExportMapServer.png")));
mActionExportAsSVG->setIcon(QIcon(QPixmap(myThemePath + "/mActionSaveAsSVG.png")));
mActionPrint->setIcon(QIcon(QPixmap(myThemePath + "/mActionFilePrint.png")));
mActionZoomAll->setIcon(QIcon(QPixmap(myThemePath + "/mActionZoomFullExtent.png")));
mActionZoomIn->setIcon(QIcon(QPixmap(myThemePath + "/mActionZoomIn.png")));
mActionZoomOut->setIcon(QIcon(QPixmap(myThemePath + "/mActionZoomOut.png")));
mActionRefreshView->setIcon(QIcon(QPixmap(myThemePath + "/mActionDraw.png")));
mActionAddImage->setIcon(QIcon(QPixmap(myThemePath + "/mActionSaveMapAsImage.png")));
mActionAddNewMap->setIcon(QIcon(QPixmap(myThemePath + "/mActionAddRasterLayer.png")));
mActionAddNewLabel->setIcon(QIcon(QPixmap(myThemePath + "/mActionLabel.png")));
mActionAddNewVectLegend->setIcon(QIcon(QPixmap(myThemePath + "/mActionAddLegend.png")));
mActionAddNewScalebar->setIcon(QIcon(QPixmap(myThemePath + "/mActionScaleBar.png")));
mActionSelectMoveItem->setIcon(QIcon(QPixmap(myThemePath + "/mActionPan.png")));
mActionOpenTemplate->setIcon(QgisApp::getThemeIcon("/mActionFileOpen.png"));
mActionSaveTemplateAs->setIcon(QgisApp::getThemeIcon("/mActionFileSaveAs.png"));
mActionExportAsImage->setIcon(QgisApp::getThemeIcon("/mActionExportMapServer.png"));
mActionExportAsSVG->setIcon(QgisApp::getThemeIcon("/mActionSaveAsSVG.png"));
mActionPrint->setIcon(QgisApp::getThemeIcon("/mActionFilePrint.png"));
mActionZoomAll->setIcon(QgisApp::getThemeIcon("/mActionZoomFullExtent.png"));
mActionZoomIn->setIcon(QgisApp::getThemeIcon("/mActionZoomIn.png"));
mActionZoomOut->setIcon(QgisApp::getThemeIcon("/mActionZoomOut.png"));
mActionRefreshView->setIcon(QgisApp::getThemeIcon("/mActionDraw.png"));
mActionAddImage->setIcon(QgisApp::getThemeIcon("/mActionSaveMapAsImage.png"));
mActionAddNewMap->setIcon(QgisApp::getThemeIcon("/mActionAddRasterLayer.png"));
mActionAddNewLabel->setIcon(QgisApp::getThemeIcon("/mActionLabel.png"));
mActionAddNewVectLegend->setIcon(QgisApp::getThemeIcon("/mActionAddLegend.png"));
mActionAddNewScalebar->setIcon(QgisApp::getThemeIcon("/mActionScaleBar.png"));
mActionSelectMoveItem->setIcon(QgisApp::getThemeIcon("/mActionPan.png"));
}
void QgsComposer::open ( void )

View File

@ -19,6 +19,7 @@
/* $Id$ */
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslogger.h"
#include "qgslegend.h"
#include "qgslegendgroup.h"
@ -87,8 +88,9 @@ QgsLegend::QgsLegend(QWidget * parent, const char *name)
setColumnCount(1);
header()->setHidden(1);
setRootIsDecorated(true);
initPixmaps();
}
@ -400,8 +402,6 @@ void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& posit
QMenu theMenu;
QString iconsPath = QgsApplication::themePath();
QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(item);
if (li)
{
@ -422,7 +422,7 @@ void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& posit
}
else if(li->type() == QgsLegendItem::LEGEND_GROUP)
{
theMenu.addAction(QPixmap(iconsPath+QString("/mActionRemove.png")),
theMenu.addAction(QgisApp::getThemeIcon("/mActionRemove.png"),
tr("&Remove"), this, SLOT(legendGroupRemove()));
}
@ -433,9 +433,9 @@ void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& posit
}
theMenu.addAction(QIcon(QPixmap(iconsPath+QString("/folder_new.png"))), tr("&Add group"), this, SLOT(addGroup()));
theMenu.addAction(QIcon(QPixmap(iconsPath+QString("/mActionExpandTree.png"))), tr("&Expand all"), this, SLOT(expandAll()));
theMenu.addAction(QIcon(QPixmap(iconsPath+QString("/mActionCollapseTree.png"))), tr("&Collapse all"), this, SLOT(collapseAll()));
theMenu.addAction(QgisApp::getThemeIcon("/folder_new.png"), tr("&Add group"), this, SLOT(addGroup()));
theMenu.addAction(QgisApp::getThemeIcon("/mActionExpandTree.png"), tr("&Expand all"), this, SLOT(expandAll()));
theMenu.addAction(QgisApp::getThemeIcon("/mActionCollapseTree.png"), tr("&Collapse all"), this, SLOT(collapseAll()));
QAction* showFileGroupsAction = theMenu.addAction(tr("Show file groups"), this, SLOT(showLegendLayerFileGroups()));
showFileGroupsAction->setCheckable(true);
@ -445,6 +445,14 @@ void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& posit
theMenu.exec(position);
}
void QgsLegend::initPixmaps()
{
mPixmaps.mOriginalPixmap = QgisApp::getThemePixmap("/mActionFileSmall.png");
mPixmaps.mInOverviewPixmap = QgisApp::getThemePixmap("/mActionInOverview.png");
mPixmaps.mEditablePixmap = QgisApp::getThemePixmap("/mIconEditable.png");
mPixmaps.mProjectionErrorPixmap = QgisApp::getThemePixmap("/mIconProjectionProblem.png");
}
int QgsLegend::getItemPos(QTreeWidgetItem* item)
{
int counter = 1;
@ -1828,15 +1836,6 @@ void QgsLegend::legendLayerAttributeTable()
tr("To open an attribute table, you must select a vector layer in the legend"));
}
void QgsLegend::initPixmaps()
{
QString myThemePath = QgsApplication::themePath();
mPixmaps.mOriginalPixmap.load(myThemePath + "/mActionFileSmall.png");
mPixmaps.mInOverviewPixmap.load(myThemePath + "/mActionInOverview.png");
mPixmaps.mEditablePixmap.load(myThemePath + "/mIconEditable.png");
mPixmaps.mProjectionErrorPixmap.load(myThemePath + "/mIconProjectionProblem.png");
}
void QgsLegend::readProject(const QDomDocument & doc)
{
QDomNodeList nodes = doc.elementsByTagName("legend");

View File

@ -177,7 +177,8 @@ class QgsLegend : public QTreeWidget
/**Returns structure with legend pixmaps*/
QgsLegendPixmaps& pixmaps() { return mPixmaps; }
void updateCheckStates(QTreeWidgetItem* item, Qt::CheckState state) {mStateOfCheckBoxes[item] = state;}
public slots:
@ -400,21 +401,23 @@ private:
/** structure which holds pixmap which are used in legend */
class QgsLegendPixmaps
{
public:
//! Pixmap which is shown by default
QPixmap mOriginalPixmap;
//! Pixmap to show a bogus vertex was encoutnered in this layer (applies to vector layers only)
QPixmap mProjectionErrorPixmap;
public:
//! Pixmap which is shown by default
QPixmap mOriginalPixmap;
//! Pixmap to show if this layer is represented in overview or now
QPixmap mInOverviewPixmap;
//! Pixmap to show a bogus vertex was encoutnered in this layer (applies to vector layers only)
QPixmap mProjectionErrorPixmap;
//! Pixmap to show it this layer has currently editing turned on
QPixmap mEditablePixmap;
//! Pixmap to show if this layer is represented in overview or now
QPixmap mInOverviewPixmap;
//! Pixmap to show it this layer has currently editing turned on
QPixmap mEditablePixmap;
} mPixmaps;
signals:
void zOrderChanged(QgsLegend * lv);

View File

@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslegendgroup.h"
#include "qgslegendlayer.h"
#include "qgslegendlayerfile.h"
@ -30,7 +31,7 @@ QgsLegendGroup::QgsLegendGroup(QTreeWidgetItem * theItem ,QString theName)
mType=LEGEND_GROUP;
setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
setCheckState (0, Qt::Checked);
QIcon myIcon(QgsApplication::themePath()+"/mActionFolder.png");
QIcon myIcon = QgisApp::getThemeIcon("/mActionFolder.png");
setIcon(0, myIcon);
}
QgsLegendGroup::QgsLegendGroup(QTreeWidget* theListView, QString theString)
@ -39,7 +40,7 @@ QgsLegendGroup::QgsLegendGroup(QTreeWidget* theListView, QString theString)
mType=LEGEND_GROUP;
setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
setCheckState (0, Qt::Checked);
QIcon myIcon(QgsApplication::themePath()+"/mActionFolder.png");
QIcon myIcon = QgisApp::getThemeIcon("/mActionFolder.png");
setIcon(0, myIcon);
}
@ -48,7 +49,7 @@ QgsLegendGroup::QgsLegendGroup(QString name): QgsLegendItem()
mType=LEGEND_GROUP;
setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
setCheckState (0, Qt::Checked);
QIcon myIcon(QgsApplication::themePath()+"/mActionFolder.png");
QIcon myIcon = QgisApp::getThemeIcon(+"/mActionFolder.png");
setText(0, name);
setIcon(0, myIcon);
}

View File

@ -19,6 +19,7 @@
***************************************************************************/
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslegend.h"
#include "qgslegendlayer.h"
#include "qgslegendlayerfile.h"
@ -404,29 +405,28 @@ void QgsLegendLayer::updateIcon()
QgsLegendLayerFile* theFile = firstLayerFile();
if(mapLayers().size() == 1)
{
//overview
if(theFile->isInOverview())
{
//overview
if(theFile->isInOverview())
{
// Overlay the overview icon on the default icon
QPixmap myPixmap(QgsApplication::themePath()+"mIconOverview.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
}
//editable
if(theLayer->isEditable())
{
// Overlay the editable icon on the default icon
QPixmap myPixmap(QgsApplication::themePath()+"mIconEditable.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
}
// Overlay the overview icon on the default icon
QPixmap myPixmap = QgisApp::getThemePixmap(+"mIconOverview.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
}
//editable
if(theLayer->isEditable())
{
// Overlay the editable icon on the default icon
QPixmap myPixmap = QgisApp::getThemePixmap(+"mIconEditable.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
}
}
QIcon theIcon(newIcon);
setIcon(0, theIcon);
}
@ -436,48 +436,34 @@ QPixmap QgsLegendLayer::getOriginalPixmap() const
QgsMapLayer* firstLayer = firstMapLayer();
if(firstLayer)
{
QString myThemePath = QgsApplication::themePath();
QString myPath;
if (firstLayer->type() == QgsMapLayer::VECTOR)
{
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(firstLayer);
switch(vlayer->vectorType())
{
case QGis::Point:
myPath = myThemePath+"/mIconPointLayer.png";
return QgisApp::getThemePixmap("/mIconPointLayer.png");
break;
case QGis::Line:
myPath = myThemePath+"/mIconLineLayer.png";
return QgisApp::getThemePixmap("/mIconLineLayer.png");
break;
case QGis::Polygon:
myPath = myThemePath+"/mIconPolygonLayer.png";
return QgisApp::getThemePixmap("/mIconPolygonLayer.png");
break;
default:
myPath = myThemePath+"/mIconLayer.png";
return QgisApp::getThemePixmap("/mIconLayer.png");
}
}
else // RASTER
{
myPath = myThemePath+"/mIconLayer.png";
}
QFileInfo file(myPath);
if(file.exists())
{
return QPixmap(file.absoluteFilePath());
return QgisApp::getThemePixmap("/mIconLayer.png");
}
}
QPixmap emptyPixmap;
return emptyPixmap;
}
void QgsLegendLayer::addToPopupMenu(QMenu& theMenu, QAction* toggleEditingAction)
{
QString iconsPath = QgsApplication::themePath();
std::list<QgsLegendLayerFile*> files = legendLayerFiles();
QgsMapLayer* firstLayer = NULL;
if (files.size() > 0)
@ -486,7 +472,7 @@ void QgsLegendLayer::addToPopupMenu(QMenu& theMenu, QAction* toggleEditingAction
}
// zoom to layer extent
theMenu.addAction(QIcon(iconsPath+QString("/mActionZoomToLayer.png")),
theMenu.addAction(QgisApp::getThemeIcon("/mActionZoomToLayer.png"),
tr("&Zoom to layer extent"), legend(), SLOT(legendLayerZoom()));
if (firstLayer && firstLayer->type() == QgsMapLayer::RASTER)
{
@ -499,7 +485,7 @@ void QgsLegendLayer::addToPopupMenu(QMenu& theMenu, QAction* toggleEditingAction
showInOverviewAction->setChecked(isInOverview());
// remove from canvas
theMenu.addAction(QIcon(QPixmap(iconsPath+QString("/mActionRemove.png"))),
theMenu.addAction(QgisApp::getThemeIcon("/mActionRemove.png"),
tr("&Remove"), legend(), SLOT(legendLayerRemove()));
theMenu.addSeparator();

View File

@ -19,6 +19,7 @@
***************************************************************************/
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslegend.h"
#include "qgslegendlayer.h"
#include "qgslegendlayerfile.h"
@ -104,7 +105,7 @@ QgsLegendItem::DRAG_ACTION QgsLegendLayerFile::accept(const QgsLegendItem* li) c
QPixmap QgsLegendLayerFile::getOriginalPixmap() const
{
QPixmap myPixmap(QgsApplication::themePath()+"mActionFileSmall.png");
QPixmap myPixmap = QgisApp::getThemePixmap("mActionFileSmall.png");
return myPixmap;
}
@ -148,7 +149,7 @@ void QgsLegendLayerFile::setIconAppearance(bool inOverview,
if (inOverview)
{
// Overlay the overview icon on the default icon
QPixmap myPixmap(QgsApplication::themePath()+"mIconOverview.png");
QPixmap myPixmap = QgisApp::getThemePixmap("mIconOverview.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
@ -157,7 +158,7 @@ void QgsLegendLayerFile::setIconAppearance(bool inOverview,
if (editable)
{
// Overlay the editable icon on the default icon
QPixmap myPixmap(QgsApplication::themePath()+"mIconEditable.png");
QPixmap myPixmap = QgisApp::getThemePixmap("mIconEditable.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
@ -494,10 +495,9 @@ void QgsLegendLayerFile::layerNameChanged()
void QgsLegendLayerFile::addToPopupMenu(QMenu& theMenu, QAction* toggleEditingAction)
{
QgsMapLayer* lyr = layer();
QString iconsPath = QgsApplication::themePath();
// zoom to layer extent
theMenu.addAction(QIcon(iconsPath+QString("/mActionZoomToLayer.png")),
theMenu.addAction(QgisApp::getThemeIcon("/mActionZoomToLayer.png"),
tr("&Zoom to layer extent"), legend(), SLOT(legendLayerZoom()));
// show in overview
@ -508,7 +508,7 @@ void QgsLegendLayerFile::addToPopupMenu(QMenu& theMenu, QAction* toggleEditingAc
showInOverviewAction->blockSignals(false);
// remove from canvas
theMenu.addAction(QIcon(iconsPath+QString("/mActionRemove.png")),
theMenu.addAction(QgisApp::getThemeIcon("/mActionRemove.png"),
tr("&Remove"), legend(), SLOT(legendLayerRemove()));
theMenu.addSeparator();

View File

@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslegendpropertygroup.h"
#include <QCoreApplication>
#include <QIcon>
@ -26,7 +27,7 @@ QgsLegendPropertyGroup::QgsLegendPropertyGroup(QTreeWidgetItem* theLegendItem, Q
: QgsLegendItem(theLegendItem,theString )
{
mType=LEGEND_PROPERTY_GROUP;
QIcon myIcon(QgsApplication::themePath()+"/mIconProperties.png");
QIcon myIcon = QgisApp::getThemeIcon("/mIconProperties.png");
setText(0, theString);
setIcon(0,myIcon);
}

View File

@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslegendlayerfile.h"
#include "qgslegendlayerfilegroup.h"
#include "qgslegendsymbologygroup.h"
@ -29,7 +30,7 @@ QgsLegendSymbologyGroup::QgsLegendSymbologyGroup(QTreeWidgetItem * theItem, QStr
: QgsLegendItem( theItem, theString)
{
mType = LEGEND_SYMBOL_GROUP;
QIcon myIcon(QgsApplication::themePath()+"/mIconSymbology.png");
QIcon myIcon = QgisApp::getThemeIcon("/mIconSymbology.png");
setText(0, theString);
setIcon(0,myIcon);
}

View File

@ -318,7 +318,6 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
mSplash->showMessage(tr("Reading settings"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
readSettings();
mSplash->showMessage(tr("Setting up the GUI"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
@ -327,13 +326,13 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
createMenus();
createToolBars();
createStatusBar();
setTheme(mThemeName);
updateRecentProjectPaths();
createCanvas();
createLegend();
createOverview();
createMapTips();
setupProxy();
readSettings();
mComposer = new QgsComposer(this); // Map composer
mInternalClipboard = new QgsClipboard; // create clipboard
@ -520,11 +519,9 @@ void QgisApp::dropEvent(QDropEvent *event)
// restore any application settings stored in QSettings
void QgisApp::readSettings()
{
QSettings settings;
// get the users theme preference from the settings
mThemeName = settings.value("/Themes","default").toString();
setTheme(settings.value("/Themes","default").toString());
// Add the recently accessed project file paths to the File menu
mRecentProjectPaths = settings.value("/UI/recentProjectsList").toStringList();
@ -533,7 +530,8 @@ void QgisApp::readSettings()
bool splitterRedraw = settings.value("/qgis/splitterRedraw", true).toBool();
canvasLegendSplit->setOpaqueResize(splitterRedraw);
legendOverviewSplit->setOpaqueResize(splitterRedraw);
*/}
*/
}
//////////////////////////////////////////////////////////////////////
@ -542,66 +540,65 @@ void QgisApp::readSettings()
void QgisApp::createActions()
{
QString myIconPath = QgsApplication::themePath();
//
// File Menu Related Items
//
mActionFileNew= new QAction(QIcon(myIconPath+"/mActionFileNew.png"), tr("&New Project"), this);
mActionFileNew= new QAction(getThemeIcon("/mActionFileNew.png"), tr("&New Project"), this);
mActionFileNew->setShortcut(tr("Ctrl+N","New Project"));
mActionFileNew->setStatusTip(tr("New Project"));
connect(mActionFileNew, SIGNAL(triggered()), this, SLOT(fileNew()));
//
mActionFileOpen= new QAction(QIcon(myIconPath+"/mActionFileOpen.png"), tr("&Open Project..."), this);
mActionFileOpen= new QAction(getThemeIcon("/mActionFileOpen.png"), tr("&Open Project..."), this);
mActionFileOpen->setShortcut(tr("Ctrl+O","Open a Project"));
mActionFileOpen->setStatusTip(tr("Open a Project"));
connect(mActionFileOpen, SIGNAL(triggered()), this, SLOT(fileOpen()));
//
mActionFileSave= new QAction(QIcon(myIconPath+"/mActionFileSave.png"), tr("&Save Project"), this);
mActionFileSave= new QAction(getThemeIcon("/mActionFileSave.png"), tr("&Save Project"), this);
mActionFileSave->setShortcut(tr("Ctrl+S","Save Project"));
mActionFileSave->setStatusTip(tr("Save Project"));
connect(mActionFileSave, SIGNAL(triggered()), this, SLOT(fileSave()));
//
mActionFileSaveAs= new QAction(QIcon(myIconPath+"/mActionFileSaveAs.png"), tr("Save Project &As..."), this);
mActionFileSaveAs= new QAction(getThemeIcon("/mActionFileSaveAs.png"), tr("Save Project &As..."), this);
mActionFileSaveAs->setShortcut(tr("Ctrl+A","Save Project under a new name"));
mActionFileSaveAs->setStatusTip(tr("Save Project under a new name"));
connect(mActionFileSaveAs, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
//
mActionFilePrint= new QAction(QIcon(myIconPath+"/mActionFilePrint.png"), tr("&Print..."), this);
mActionFilePrint= new QAction(getThemeIcon("/mActionFilePrint.png"), tr("&Print..."), this);
mActionFilePrint->setShortcut(tr("Ctrl+P","Print"));
mActionFilePrint->setStatusTip(tr("Print"));
connect(mActionFilePrint, SIGNAL(triggered()), this, SLOT(filePrint()));
//
mActionSaveMapAsImage= new QAction(QIcon(myIconPath+"/mActionSaveMapAsImage.png"), tr("Save as Image..."), this);
mActionSaveMapAsImage= new QAction(getThemeIcon("/mActionSaveMapAsImage.png"), tr("Save as Image..."), this);
mActionSaveMapAsImage->setShortcut(tr("Ctrl+I","Save map as image"));
mActionSaveMapAsImage->setStatusTip(tr("Save map as image"));
connect(mActionSaveMapAsImage, SIGNAL(triggered()), this, SLOT(saveMapAsImage()));
//
// TODO: Remove the mActionExportMapServer related code once the mapserver export plugin
// is complete and tested.
/* mActionExportMapServer= new QAction(QIcon(myIconPath+"/mActionExportMapServer.png"), tr("Export to MapServer Map..."), this);
/* mActionExportMapServer= new QAction(getThemeIcon("/mActionExportMapServer.png"), tr("Export to MapServer Map..."), this);
mActionExportMapServer->setShortcut(tr("M","Export as MapServer .map file"));
mActionExportMapServer->setStatusTip(tr("Export as MapServer .map file"));
connect(mActionExportMapServer, SIGNAL(triggered()), this, SLOT(exportMapServer()));
*/
//
mActionFileExit= new QAction(QIcon(myIconPath+"/mActionFileExit.png"), tr("Exit"), this);
mActionFileExit= new QAction(getThemeIcon("/mActionFileExit.png"), tr("Exit"), this);
mActionFileExit->setShortcut(tr("Ctrl+Q","Exit QGIS"));
mActionFileExit->setStatusTip(tr("Exit QGIS"));
connect(mActionFileExit, SIGNAL(triggered()), this, SLOT(fileExit()));
//
// Layer Menu Related Items
//
mActionAddOgrLayer= new QAction(QIcon(myIconPath+"/mActionAddOgrLayer.png"), tr("Add a Vector Layer..."), this);
mActionAddOgrLayer= new QAction(getThemeIcon("/mActionAddOgrLayer.png"), tr("Add a Vector Layer..."), this);
mActionAddOgrLayer->setShortcut(tr("V","Add a Vector Layer"));
mActionAddOgrLayer->setStatusTip(tr("Add a Vector Layer"));
connect(mActionAddOgrLayer, SIGNAL(triggered()), this, SLOT(addVectorLayer()));
//
mActionAddRasterLayer= new QAction(QIcon(myIconPath+"/mActionAddRasterLayer.png"), tr("Add a Raster Layer..."), this);
mActionAddRasterLayer= new QAction(getThemeIcon("/mActionAddRasterLayer.png"), tr("Add a Raster Layer..."), this);
mActionAddRasterLayer->setShortcut(tr("R","Add a Raster Layer"));
mActionAddRasterLayer->setStatusTip(tr("Add a Raster Layer"));
connect(mActionAddRasterLayer, SIGNAL(triggered()), this, SLOT(addRasterLayer()));
//
mActionAddLayer= new QAction(QIcon(myIconPath+"/mActionAddLayer.png"), tr("Add a PostGIS Layer..."), this);
mActionAddLayer= new QAction(getThemeIcon("/mActionAddLayer.png"), tr("Add a PostGIS Layer..."), this);
mActionAddLayer->setShortcut(tr("D","Add a PostGIS Layer"));
mActionAddLayer->setStatusTip(tr("Add a PostGIS Layer"));
//#ifdef HAVE_POSTGRESQL
@ -613,63 +610,63 @@ void QgisApp::createActions()
//#endif
connect(mActionAddLayer, SIGNAL(triggered()), this, SLOT(addDatabaseLayer()));
//
mActionNewVectorLayer= new QAction(QIcon(myIconPath+"/mActionNewVectorLayer.png"), tr("New Vector Layer..."), this);
mActionNewVectorLayer= new QAction(getThemeIcon("/mActionNewVectorLayer.png"), tr("New Vector Layer..."), this);
mActionNewVectorLayer->setShortcut(tr("N","Create a New Vector Layer"));
mActionNewVectorLayer->setStatusTip(tr("Create a New Vector Layer"));
connect(mActionNewVectorLayer, SIGNAL(triggered()), this, SLOT(newVectorLayer()));
//
mActionRemoveLayer= new QAction(QIcon(myIconPath+"/mActionRemoveLayer.png"), tr("Remove Layer"), this);
mActionRemoveLayer= new QAction(getThemeIcon("/mActionRemoveLayer.png"), tr("Remove Layer"), this);
mActionRemoveLayer->setShortcut(tr("Ctrl+D","Remove a Layer"));
mActionRemoveLayer->setStatusTip(tr("Remove a Layer"));
connect(mActionRemoveLayer, SIGNAL(triggered()), this, SLOT(removeLayer()));
mActionRemoveLayer->setEnabled(false);
//
mActionAddAllToOverview= new QAction(QIcon(myIconPath+"/mActionAddAllToOverview.png"), tr("Add All To Overview"), this);
mActionAddAllToOverview= new QAction(getThemeIcon("/mActionAddAllToOverview.png"), tr("Add All To Overview"), this);
mActionAddAllToOverview->setShortcut(tr("+","Show all layers in the overview map"));
mActionAddAllToOverview->setStatusTip(tr("Show all layers in the overview map"));
connect(mActionAddAllToOverview, SIGNAL(triggered()), this, SLOT(addAllToOverview()));
//
mActionRemoveAllFromOverview= new QAction(QIcon(myIconPath+"/mActionRemoveAllFromOverview.png"), tr("Remove All From Overview"), this);
mActionRemoveAllFromOverview= new QAction(getThemeIcon("/mActionRemoveAllFromOverview.png"), tr("Remove All From Overview"), this);
mActionRemoveAllFromOverview->setShortcut(tr("-","Remove all layers from overview map"));
mActionRemoveAllFromOverview->setStatusTip(tr("Remove all layers from overview map"));
connect(mActionRemoveAllFromOverview, SIGNAL(triggered()), this, SLOT(removeAllFromOverview()));
//
mActionToggleFullScreen = new QAction(QIcon(myIconPath+"/mActionToggleFullScreen.png"), tr("Toggle full screen mode"), this);
mActionToggleFullScreen = new QAction(getThemeIcon("/mActionToggleFullScreen.png"), tr("Toggle full screen mode"), this);
mActionToggleFullScreen->setShortcut(tr("Ctrl-F","Toggle fullscreen mode"));
mActionToggleFullScreen->setStatusTip(tr("Toggle fullscreen mode"));
connect(mActionToggleFullScreen, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
//
mActionShowAllLayers= new QAction(QIcon(myIconPath+"/mActionShowAllLayers.png"), tr("Show All Layers"), this);
mActionShowAllLayers= new QAction(getThemeIcon("/mActionShowAllLayers.png"), tr("Show All Layers"), this);
mActionShowAllLayers->setShortcut(tr("S","Show all layers"));
mActionShowAllLayers->setStatusTip(tr("Show all layers"));
connect(mActionShowAllLayers, SIGNAL(triggered()), this, SLOT(showAllLayers()));
//
mActionHideAllLayers= new QAction(QIcon(myIconPath+"/mActionHideAllLayers.png"), tr("Hide All Layers"), this);
mActionHideAllLayers= new QAction(getThemeIcon("/mActionHideAllLayers.png"), tr("Hide All Layers"), this);
mActionHideAllLayers->setShortcut(tr("H","Hide all layers"));
mActionHideAllLayers->setStatusTip(tr("Hide all layers"));
connect(mActionHideAllLayers, SIGNAL(triggered()), this, SLOT(hideAllLayers()));
//
// Settings Menu Related Items
//
mActionProjectProperties= new QAction(QIcon(myIconPath+"/mActionProjectProperties.png"), tr("Project Properties..."), this);
mActionProjectProperties= new QAction(getThemeIcon("/mActionProjectProperties.png"), tr("Project Properties..."), this);
mActionProjectProperties->setShortcut(tr("P","Set project properties"));
mActionProjectProperties->setStatusTip(tr("Set project properties"));
connect(mActionProjectProperties, SIGNAL(triggered()), this, SLOT(projectProperties()));
//
mActionOptions= new QAction(QIcon(myIconPath+"/mActionOptions.png"), tr("Options..."), this);
mActionOptions= new QAction(getThemeIcon("/mActionOptions.png"), tr("Options..."), this);
// mActionOptions->setShortcut(tr("Alt+O","Change various QGIS options"));
mActionOptions->setStatusTip(tr("Change various QGIS options"));
connect(mActionOptions, SIGNAL(triggered()), this, SLOT(options()));
//
mActionCustomProjection= new QAction(QIcon(myIconPath+"/mActionCustomProjection.png"), tr("Custom Projection..."), this);
mActionCustomProjection= new QAction(getThemeIcon("/mActionCustomProjection.png"), tr("Custom Projection..."), this);
// mActionCustomProjection->setShortcut(tr("Alt+I","Manage custom projections"));
mActionCustomProjection->setStatusTip(tr("Manage custom projections"));
connect(mActionCustomProjection, SIGNAL(triggered()), this, SLOT(customProjection()));
//
// Help Menu Related items
//
mActionHelpContents= new QAction(QIcon(myIconPath+"/mActionHelpContents.png"), tr("Help Contents"), this);
mActionHelpContents= new QAction(getThemeIcon("/mActionHelpContents.png"), tr("Help Contents"), this);
#ifdef Q_WS_MAC
mActionHelpContents->setShortcut(tr("Ctrl+?","Help Documentation (Mac)"));
#else
@ -678,89 +675,89 @@ void QgisApp::createActions()
mActionHelpContents->setStatusTip(tr("Help Documentation"));
connect(mActionHelpContents, SIGNAL(triggered()), this, SLOT(helpContents()));
//
mActionQgisHomePage= new QAction(QIcon(myIconPath+"/mActionQgisHomePage.png"), tr("Qgis Home Page"), this);
mActionQgisHomePage= new QAction(getThemeIcon("/mActionQgisHomePage.png"), tr("Qgis Home Page"), this);
#ifndef Q_WS_MAC
mActionQgisHomePage->setShortcut(tr("Ctrl+H","QGIS Home Page"));
#endif
mActionQgisHomePage->setStatusTip(tr("QGIS Home Page"));
connect(mActionQgisHomePage, SIGNAL(triggered()), this, SLOT(helpQgisHomePage()));
//
mActionHelpAbout= new QAction(QIcon(myIconPath+"/mActionHelpAbout.png"), tr("About"), this);
mActionHelpAbout= new QAction(getThemeIcon("/mActionHelpAbout.png"), tr("About"), this);
mActionHelpAbout->setStatusTip(tr("About QGIS"));
connect(mActionHelpAbout, SIGNAL(triggered()), this, SLOT(about()));
//
mActionCheckQgisVersion= new QAction(QIcon(myIconPath+"/mActionCheckQgisVersion.png"), tr("Check Qgis Version"), this);
mActionCheckQgisVersion= new QAction(getThemeIcon("/mActionCheckQgisVersion.png"), tr("Check Qgis Version"), this);
mActionCheckQgisVersion->setStatusTip(tr("Check if your QGIS version is up to date (requires internet access)"));
connect(mActionCheckQgisVersion, SIGNAL(triggered()), this, SLOT(checkQgisVersion()));
//
// View Menu Items
//
mActionDraw= new QAction(QIcon(myIconPath+"/mActionDraw.png"), tr("Refresh"), this);
mActionDraw= new QAction(getThemeIcon("/mActionDraw.png"), tr("Refresh"), this);
mActionDraw->setShortcut(tr("Ctrl+R","Refresh Map"));
mActionDraw->setStatusTip(tr("Refresh Map"));
connect(mActionDraw, SIGNAL(triggered()), this, SLOT(refreshMapCanvas()));
//
mActionZoomIn= new QAction(QIcon(myIconPath+"/mActionZoomIn.png"), tr("Zoom In"), this);
mActionZoomIn= new QAction(getThemeIcon("/mActionZoomIn.png"), tr("Zoom In"), this);
mActionZoomIn->setShortcut(tr("Ctrl++","Zoom In"));
mActionZoomIn->setStatusTip(tr("Zoom In"));
connect(mActionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
//
mActionZoomOut= new QAction(QIcon(myIconPath+"/mActionZoomOut.png"), tr("Zoom Out"), this);
mActionZoomOut= new QAction(getThemeIcon("/mActionZoomOut.png"), tr("Zoom Out"), this);
mActionZoomOut->setShortcut(tr("Ctrl+-","Zoom Out"));
mActionZoomOut->setStatusTip(tr("Zoom Out"));
connect(mActionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));
//
mActionZoomFullExtent= new QAction(QIcon(myIconPath+"/mActionZoomFullExtent.png"), tr("Zoom Full"), this);
mActionZoomFullExtent= new QAction(getThemeIcon("/mActionZoomFullExtent.png"), tr("Zoom Full"), this);
mActionZoomFullExtent->setShortcut(tr("F","Zoom to Full Extents"));
mActionZoomFullExtent->setStatusTip(tr("Zoom to Full Extents"));
connect(mActionZoomFullExtent, SIGNAL(triggered()), this, SLOT(zoomFull()));
//
mActionZoomToSelected= new QAction(QIcon(myIconPath+"/mActionZoomToSelected.png"), tr("Zoom To Selection"), this);
mActionZoomToSelected= new QAction(getThemeIcon("/mActionZoomToSelected.png"), tr("Zoom To Selection"), this);
mActionZoomToSelected->setShortcut(tr("Ctrl+F","Zoom to selection"));
mActionZoomToSelected->setStatusTip(tr("Zoom to selection"));
connect(mActionZoomToSelected, SIGNAL(triggered()), this, SLOT(zoomToSelected()));
//
mActionPan= new QAction(QIcon(myIconPath+"/mActionPan.png"), tr("Pan Map"), this);
mActionPan= new QAction(getThemeIcon("/mActionPan.png"), tr("Pan Map"), this);
mActionPan->setStatusTip(tr("Pan the map"));
connect(mActionPan, SIGNAL(triggered()), this, SLOT(pan()));
//
mActionZoomLast= new QAction(QIcon(myIconPath+"/mActionZoomLast.png"), tr("Zoom Last"), this);
mActionZoomLast= new QAction(getThemeIcon("/mActionZoomLast.png"), tr("Zoom Last"), this);
//mActionZoomLast->setShortcut(tr("Ctrl+O","Zoom to Last Extent"));
mActionZoomLast->setStatusTip(tr("Zoom to Last Extent"));
connect(mActionZoomLast, SIGNAL(triggered()), this, SLOT(zoomPrevious()));
//
mActionZoomToLayer= new QAction(QIcon(myIconPath+"/mActionZoomToLayer.png"), tr("Zoom To Layer"), this);
mActionZoomToLayer= new QAction(getThemeIcon("/mActionZoomToLayer.png"), tr("Zoom To Layer"), this);
//mActionZoomToLayer->setShortcut(tr("Ctrl+O","Zoom to Layer"));
mActionZoomToLayer->setStatusTip(tr("Zoom to Layer"));
connect(mActionZoomToLayer, SIGNAL(triggered()), this, SLOT(zoomToLayerExtent()));
//
mActionIdentify= new QAction(QIcon(myIconPath+"/mActionIdentify.png"), tr("Identify Features"), this);
mActionIdentify= new QAction(getThemeIcon("/mActionIdentify.png"), tr("Identify Features"), this);
mActionIdentify->setShortcut(tr("I","Click on features to identify them"));
mActionIdentify->setStatusTip(tr("Click on features to identify them"));
connect(mActionIdentify, SIGNAL(triggered()), this, SLOT(identify()));
//
mActionSelect= new QAction(QIcon(myIconPath+"/mActionSelect.png"), tr("Select Features"), this);
mActionSelect= new QAction(getThemeIcon("/mActionSelect.png"), tr("Select Features"), this);
mActionSelect->setStatusTip(tr("Select Features"));
connect(mActionSelect, SIGNAL(triggered()), this, SLOT(select()));
mActionSelect->setEnabled(false);
//
mActionOpenTable= new QAction(QIcon(myIconPath+"/mActionOpenTable.png"), tr("Open Table"), this);
mActionOpenTable= new QAction(getThemeIcon("/mActionOpenTable.png"), tr("Open Table"), this);
//mActionOpenTable->setShortcut(tr("Ctrl+O","Open Table"));
mActionOpenTable->setStatusTip(tr("Open Table"));
connect(mActionOpenTable, SIGNAL(triggered()), this, SLOT(attributeTable()));
mActionOpenTable->setEnabled(false);
//
mActionMeasure= new QAction(QIcon(myIconPath+"/mActionMeasure.png"), tr("Measure Line "), this);
mActionMeasure= new QAction(getThemeIcon("/mActionMeasure.png"), tr("Measure Line "), this);
mActionMeasure->setShortcut(tr("Ctrl+M","Measure a Line"));
mActionMeasure->setStatusTip(tr("Measure a Line"));
connect(mActionMeasure, SIGNAL(triggered()), this, SLOT(measure()));
//
mActionMeasureArea= new QAction(QIcon(myIconPath+"/mActionMeasureArea.png"), tr("Measure Area"), this);
mActionMeasureArea= new QAction(getThemeIcon("/mActionMeasureArea.png"), tr("Measure Area"), this);
mActionMeasureArea->setShortcut(tr("Ctrl+J","Measure an Area"));
mActionMeasureArea->setStatusTip(tr("Measure an Area"));
connect(mActionMeasureArea, SIGNAL(triggered()), this, SLOT(measureArea()));
//
mActionShowBookmarks= new QAction(QIcon(myIconPath+"/mActionShowBookmarks.png"), tr("Show Bookmarks"), this);
mActionShowBookmarks= new QAction(getThemeIcon("/mActionShowBookmarks.png"), tr("Show Bookmarks"), this);
mActionShowBookmarks->setShortcut(tr("B","Show Bookmarks"));
mActionShowBookmarks->setStatusTip(tr("Show Bookmarks"));
connect(mActionShowBookmarks, SIGNAL(triggered()), this, SLOT(showBookmarks()));
@ -777,17 +774,17 @@ void QgisApp::createActions()
connect(mActionHideAllToolbars, SIGNAL(triggered()), this,
SLOT(hideAllToolbars()));
//
mActionNewBookmark= new QAction(QIcon(myIconPath+"/mActionNewBookmark.png"), tr("New Bookmark..."), this);
mActionNewBookmark= new QAction(getThemeIcon("/mActionNewBookmark.png"), tr("New Bookmark..."), this);
mActionNewBookmark->setShortcut(tr("Ctrl+B","New Bookmark"));
mActionNewBookmark->setStatusTip(tr("New Bookmark"));
connect(mActionNewBookmark, SIGNAL(triggered()), this, SLOT(newBookmark()));
//
mActionAddWmsLayer= new QAction(QIcon(myIconPath+"/mActionAddWmsLayer.png"), tr("Add WMS Layer..."), this);
mActionAddWmsLayer= new QAction(getThemeIcon("/mActionAddWmsLayer.png"), tr("Add WMS Layer..."), this);
mActionAddWmsLayer->setShortcut(tr("W","Add Web Mapping Server Layer"));
mActionAddWmsLayer->setStatusTip(tr("Add Web Mapping Server Layer"));
connect(mActionAddWmsLayer, SIGNAL(triggered()), this, SLOT(addWmsLayer()));
//
mActionInOverview= new QAction(QIcon(myIconPath+"/mActionInOverview.png"), tr("In Overview"), this);
mActionInOverview= new QAction(getThemeIcon("/mActionInOverview.png"), tr("In Overview"), this);
mActionInOverview->setShortcut(tr("O","Add current layer to overview map"));
mActionInOverview->setStatusTip(tr("Add current layer to overview map"));
connect(mActionInOverview, SIGNAL(triggered()), this, SLOT(inOverview()));
@ -795,7 +792,7 @@ void QgisApp::createActions()
//
// Plugin Menu Related Items
//
mActionShowPluginManager= new QAction(QIcon(myIconPath+"/mActionShowPluginManager.png"), tr("Plugin Manager..."), this);
mActionShowPluginManager= new QAction(getThemeIcon("/mActionShowPluginManager.png"), tr("Plugin Manager..."), this);
// mActionShowPluginManager->setShortcut(tr("Ctrl+P","Open the plugin manager"));
mActionShowPluginManager->setStatusTip(tr("Open the plugin manager"));
connect(mActionShowPluginManager, SIGNAL(triggered()), this, SLOT(showPluginManager()));
@ -807,7 +804,7 @@ void QgisApp::createActions()
// Digitising Toolbar Items
//
mActionToggleEditing = new QAction(QIcon(myIconPath+"/mActionToggleEditing.png"),
mActionToggleEditing = new QAction(getThemeIcon("/mActionToggleEditing.png"),
tr("Toggle editing"), this);
mActionToggleEditing->setStatusTip(tr("Toggles the editing state of the current layer"));
mActionToggleEditing->setCheckable(true);
@ -815,81 +812,81 @@ void QgisApp::createActions()
mActionToggleEditing->setEnabled(false);
//
mActionCapturePoint= new QAction(QIcon(myIconPath+"/mActionCapturePoint.png"), tr("Capture Point"), this);
mActionCapturePoint= new QAction(getThemeIcon("/mActionCapturePoint.png"), tr("Capture Point"), this);
mActionCapturePoint->setShortcut(tr(".","Capture Points"));
mActionCapturePoint->setStatusTip(tr("Capture Points"));
connect(mActionCapturePoint, SIGNAL(triggered()), this, SLOT(capturePoint()));
mActionCapturePoint->setEnabled(false);
//
mActionCaptureLine= new QAction(QIcon(myIconPath+"/mActionCaptureLine.png"), tr("Capture Line"), this);
mActionCaptureLine= new QAction(getThemeIcon("/mActionCaptureLine.png"), tr("Capture Line"), this);
mActionCaptureLine->setShortcut(tr("/","Capture Lines"));
mActionCaptureLine->setStatusTip(tr("Capture Lines"));
connect(mActionCaptureLine, SIGNAL(triggered()), this, SLOT(captureLine()));
mActionCaptureLine->setEnabled(false);
//
mActionCapturePolygon= new QAction(QIcon(myIconPath+"/mActionCapturePolygon.png"), tr("Capture Polygon"), this);
mActionCapturePolygon= new QAction(getThemeIcon("/mActionCapturePolygon.png"), tr("Capture Polygon"), this);
mActionCapturePolygon->setShortcut(tr("Ctrl+/","Capture Polygons"));
mActionCapturePolygon->setStatusTip(tr("Capture Polygons"));
connect(mActionCapturePolygon, SIGNAL(triggered()), this, SLOT(capturePolygon()));
mActionCapturePolygon->setEnabled(false);
//
mActionDeleteSelected = new QAction(QIcon(myIconPath+"/mActionDeleteSelected.png"), tr("Delete Selected"), this);
mActionDeleteSelected = new QAction(getThemeIcon("/mActionDeleteSelected.png"), tr("Delete Selected"), this);
mActionDeleteSelected->setStatusTip(tr("Delete Selected"));
connect(mActionDeleteSelected, SIGNAL(triggered()), this, SLOT(deleteSelected()));
mActionDeleteSelected->setEnabled(false);
//
mActionMoveFeature = new QAction(QIcon(myIconPath+"/mActionMoveFeature.png"), tr("Move Feature"), this);
mActionMoveFeature = new QAction(getThemeIcon("/mActionMoveFeature.png"), tr("Move Feature"), this);
mActionMoveFeature->setStatusTip(tr("Move Feature"));
connect(mActionMoveFeature, SIGNAL(triggered()), this, SLOT(moveFeature()));
mActionMoveFeature->setEnabled(false);
//
mActionSplitFeatures = new QAction(QIcon(myIconPath+"/mActionSplitFeatures.png"), tr("Split Features"), this);
mActionSplitFeatures = new QAction(getThemeIcon("/mActionSplitFeatures.png"), tr("Split Features"), this);
mActionSplitFeatures->setStatusTip(tr("Split Features"));
connect(mActionSplitFeatures, SIGNAL(triggered()), this, SLOT(splitFeatures()));
mActionSplitFeatures->setEnabled(false);
//
mActionAddVertex = new QAction(QIcon(myIconPath+"/mActionAddVertex.png"), tr("Add Vertex"), this);
mActionAddVertex = new QAction(getThemeIcon("/mActionAddVertex.png"), tr("Add Vertex"), this);
mActionAddVertex->setStatusTip(tr("Add Vertex"));
connect(mActionAddVertex, SIGNAL(triggered()), this, SLOT(addVertex()));
mActionAddVertex->setEnabled(false);
//
mActionDeleteVertex = new QAction(QIcon(myIconPath+"/mActionDeleteVertex.png"), tr("Delete Vertex"), this);
mActionDeleteVertex = new QAction(getThemeIcon("/mActionDeleteVertex.png"), tr("Delete Vertex"), this);
mActionDeleteVertex->setStatusTip(tr("Delete Vertex"));
connect(mActionDeleteVertex, SIGNAL(triggered()), this, SLOT(deleteVertex()));
mActionDeleteVertex->setEnabled(false);
//
mActionMoveVertex = new QAction(QIcon(myIconPath+"/mActionMoveVertex.png"), tr("Move Vertex"), this);
mActionMoveVertex = new QAction(getThemeIcon("/mActionMoveVertex.png"), tr("Move Vertex"), this);
mActionMoveVertex->setStatusTip(tr("Move Vertex"));
connect(mActionMoveVertex, SIGNAL(triggered()), this, SLOT(moveVertex()));
mActionMoveVertex->setEnabled(false);
mActionAddRing = new QAction(QIcon(myIconPath+"/mActionAddRing.png"), tr("Add Ring"), this);
mActionAddRing = new QAction(getThemeIcon("/mActionAddRing.png"), tr("Add Ring"), this);
mActionAddRing->setStatusTip(tr("Add Ring"));
connect(mActionAddRing, SIGNAL(triggered()), this, SLOT(addRing()));
mActionAddRing->setEnabled(false);
mActionAddIsland = new QAction(QIcon(myIconPath+"/mActionAddIsland.png"), tr("Add Island"), this);
mActionAddIsland = new QAction(getThemeIcon("/mActionAddIsland.png"), tr("Add Island"), this);
mActionAddIsland->setStatusTip(tr("Add Island to multipolygon"));
connect(mActionAddIsland, SIGNAL(triggered()), this, SLOT(addIsland()));
mActionAddIsland->setEnabled(false);
mActionEditCut = new QAction(QIcon(myIconPath+"/mActionEditCut.png"), tr("Cut Features"), this);
mActionEditCut = new QAction(getThemeIcon("/mActionEditCut.png"), tr("Cut Features"), this);
mActionEditCut->setStatusTip(tr("Cut selected features"));
connect(mActionEditCut, SIGNAL(triggered()), this, SLOT(editCut()));
mActionEditCut->setEnabled(false);
mActionEditCopy = new QAction(QIcon(myIconPath+"/mActionEditCopy.png"), tr("Copy Features"), this);
mActionEditCopy = new QAction(getThemeIcon("/mActionEditCopy.png"), tr("Copy Features"), this);
mActionEditCopy->setStatusTip(tr("Copy selected features"));
connect(mActionEditCopy, SIGNAL(triggered()), this, SLOT(editCopy()));
mActionEditCopy->setEnabled(false);
mActionEditPaste = new QAction(QIcon(myIconPath+"/mActionEditPaste.png"), tr("Paste Features"), this);
mActionEditPaste = new QAction(getThemeIcon("/mActionEditPaste.png"), tr("Paste Features"), this);
mActionEditPaste->setStatusTip(tr("Paste selected features"));
connect(mActionEditPaste, SIGNAL(triggered()), this, SLOT(editPaste()));
mActionEditPaste->setEnabled(false);
// maptips
mActionMapTips = new QAction(QIcon(myIconPath+"/mActionMapTips.png"), tr("Map Tips"), this);
mActionMapTips = new QAction(getThemeIcon("/mActionMapTips.png"), tr("Map Tips"), this);
mActionMapTips->setStatusTip(tr("Show information about a feature when the mouse is hovered over it"));
connect ( mActionMapTips, SIGNAL ( triggered() ), this, SLOT ( toggleMapTips() ) );
mActionMapTips->setCheckable(true);
@ -949,7 +946,6 @@ void QgisApp::createActionGroups()
void QgisApp::createMenus()
{
QString myIconPath = QgsApplication::themePath();
//
// File Menu
mFileMenu = menuBar()->addMenu(tr("&File"));
@ -1204,14 +1200,11 @@ void QgisApp::createStatusBar()
"as the mouse is moved."));
mCoordsLabel->setToolTip(tr("Map coordinates at mouse cursor position"));
statusBar()->addPermanentWidget(mCoordsLabel, 0);
QString myIconPath = QgsApplication::themePath();
//stop rendering status bar widget
mStopRenderButton = new QToolButton( statusBar() );
mStopRenderButton->setMaximumWidth(20);
mStopRenderButton->setMaximumHeight(20);
QPixmap myStopPixmap;
myStopPixmap.load(myIconPath+"/mIconDelete.png");
mStopRenderButton->setIcon(myStopPixmap);
mStopRenderButton->setIcon(getThemeIcon("/mIconDelete.png"));
mStopRenderButton->setToolTip(tr("Stop map rendering") );
statusBar()->addPermanentWidget(mStopRenderButton, 0);
// render suppression status bar widget
@ -1232,14 +1225,13 @@ void QgisApp::createStatusBar()
// Maintain uniform widget height in status bar by setting button height same as labels
// For Qt/Mac 3.3, the default toolbutton height is 30 and labels were expanding to match
mOnTheFlyProjectionStatusButton->setMaximumHeight(mScaleLabel->height());
QPixmap myProjPixmap;
myProjPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
mOnTheFlyProjectionStatusButton->setIcon(myProjPixmap);
QgsDebugMsg("Icon Path: " + myIconPath.toLocal8Bit());
if (myProjPixmap.isNull())
mOnTheFlyProjectionStatusButton->setIcon(getThemeIcon("/mIconProjectionDisabled.png"));
if (!QFile::exists(QgsApplication::defaultThemePath() + "/mIconProjectionDisabled.png"))
{
QMessageBox::critical(this, tr("Resource Location Error"),
tr("Error reading icon resources from: \n %1\n Quitting...").arg(myIconPath));
tr("Error reading icon resources from: \n %1\n Quitting...").arg(
QgsApplication::defaultThemePath() + "/mIconProjectionDisabled.png"
));
exit(0);
}
mOnTheFlyProjectionStatusButton->setWhatsThis(tr("This icon shows whether "
@ -1268,7 +1260,7 @@ void QgisApp::setTheme(QString theThemeName)
// default theme is installed in <prefix>/share/qgis/themes/default.
//
// New core themes can be added by creating a subdirectory under src/themes
// and modifying the appropriate Makefile.am files. User contributed themes
// and modifying the appropriate CMakeLists.txt files. User contributed themes
// will be installed directly into <prefix>/share/qgis/themes/<themedir>.
//
// Themes can be selected from the preferences dialog. The dialog parses
@ -1279,56 +1271,56 @@ void QgisApp::setTheme(QString theThemeName)
// one from the default theme (which is installed with qgis and should
// always be good)
*/
QgsApplication::selectTheme(theThemeName);
QString myIconPath = QgsApplication::themePath();
mActionFileNew->setIcon(QIcon(QPixmap(myIconPath + "/mActionFileNew.png")));
mActionFileSave->setIcon(QIcon(QPixmap(myIconPath + "/mActionFileSave.png")));
mActionFileSaveAs->setIcon(QIcon(QPixmap(myIconPath + "/mActionFileSaveAs.png")));
mActionFileOpen->setIcon(QIcon(QPixmap(myIconPath + "/mActionFileOpen.png")));
mActionFilePrint->setIcon(QIcon(QPixmap(myIconPath + "/mActionFilePrint.png")));
mActionSaveMapAsImage->setIcon(QIcon(QPixmap(myIconPath + "/mActionSaveMapAsImage.png")));
QgsApplication::setTheme(theThemeName);
QgsDebugMsg("Setting theme to \n" + QgsApplication::activeThemePath());
mActionFileNew->setIcon(getThemeIcon( "/mActionFileNew.png"));
mActionFileSave->setIcon(getThemeIcon( "/mActionFileSave.png"));
mActionFileSaveAs->setIcon(getThemeIcon( "/mActionFileSaveAs.png"));
mActionFileOpen->setIcon(getThemeIcon( "/mActionFileOpen.png"));
mActionFilePrint->setIcon(getThemeIcon( "/mActionFilePrint.png"));
mActionSaveMapAsImage->setIcon(getThemeIcon( "/mActionSaveMapAsImage.png"));
// TODO: Remove the mActionExportMapServer related code once the mapserver export plugin
/*
mActionExportMapServer->setIcon(QIcon(QPixmap(myIconPath + "/mActionExportMapServer.png")));
mActionExportMapServer->setIcon(getThemeIcon( "/mActionExportMapServer.png"));
*/
mActionFileExit->setIcon(QIcon(QPixmap(myIconPath + "/mActionFileExit.png")));
mActionAddOgrLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionAddOgrLayer.png")));
mActionAddRasterLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionAddRasterLayer.png")));
mActionAddLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionAddLayer.png")));
mActionRemoveLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionRemoveLayer.png")));
mActionNewVectorLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionNewVectorLayer.png")));
mActionAddAllToOverview->setIcon(QIcon(QPixmap(myIconPath + "/mActionAddAllToOverview.png")));
mActionHideAllLayers->setIcon(QIcon(QPixmap(myIconPath + "/mActionHideAllLayers.png")));
mActionShowAllLayers->setIcon(QIcon(QPixmap(myIconPath + "/mActionShowAllLayers.png")));
mActionRemoveAllFromOverview->setIcon(QIcon(QPixmap(myIconPath + "/mActionRemoveAllFromOverview.png")));
mActionProjectProperties->setIcon(QIcon(QPixmap(myIconPath + "/mActionProjectProperties.png")));
mActionShowPluginManager->setIcon(QIcon(QPixmap(myIconPath + "/mActionShowPluginManager.png")));
mActionCheckQgisVersion->setIcon(QIcon(QPixmap(myIconPath + "/mActionCheckQgisVersion.png")));
mActionOptions->setIcon(QIcon(QPixmap(myIconPath + "/mActionOptions.png")));
mActionHelpContents->setIcon(QIcon(QPixmap(myIconPath + "/mActionHelpContents.png")));
mActionQgisHomePage->setIcon(QIcon(QPixmap(myIconPath + "/mActionQgisHomePage.png")));
mActionHelpAbout->setIcon(QIcon(QPixmap(myIconPath + "/mActionHelpAbout.png")));
mActionDraw->setIcon(QIcon(QPixmap(myIconPath + "/mActionDraw.png")));
mActionCapturePoint->setIcon(QIcon(QPixmap(myIconPath + "/mActionCapturePoint.png")));
mActionCaptureLine->setIcon(QIcon(QPixmap(myIconPath + "/mActionCaptureLine.png")));
mActionCapturePolygon->setIcon(QIcon(QPixmap(myIconPath + "/mActionCapturePolygon.png")));
mActionZoomIn->setIcon(QIcon(QPixmap(myIconPath + "/mActionZoomIn.png")));
mActionZoomOut->setIcon(QIcon(QPixmap(myIconPath + "/mActionZoomOut.png")));
mActionZoomFullExtent->setIcon(QIcon(QPixmap(myIconPath + "/mActionZoomFullExtent.png")));
mActionZoomToSelected->setIcon(QIcon(QPixmap(myIconPath + "/mActionZoomToSelected.png")));
mActionPan->setIcon(QIcon(QPixmap(myIconPath + "/mActionPan.png")));
mActionZoomLast->setIcon(QIcon(QPixmap(myIconPath + "/mActionZoomLast.png")));
mActionZoomToLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionZoomToLayer.png")));
mActionIdentify->setIcon(QIcon(QPixmap(myIconPath + "/mActionIdentify.png")));
mActionSelect->setIcon(QIcon(QPixmap(myIconPath + "/mActionSelect.png")));
mActionOpenTable->setIcon(QIcon(QPixmap(myIconPath + "/mActionOpenTable.png")));
mActionMeasure->setIcon(QIcon(QPixmap(myIconPath + "/mActionMeasure.png")));
mActionMeasureArea->setIcon(QIcon(QPixmap(myIconPath + "/mActionMeasureArea.png")));
mActionShowBookmarks->setIcon(QIcon(QPixmap(myIconPath + "/mActionShowBookmarks.png")));
mActionNewBookmark->setIcon(QIcon(QPixmap(myIconPath + "/mActionNewBookmark.png")));
mActionCustomProjection->setIcon(QIcon(QPixmap(myIconPath + "/mActionCustomProjection.png")));
mActionAddWmsLayer->setIcon(QIcon(QPixmap(myIconPath + "/mActionAddWmsLayer.png")));
mActionInOverview->setIcon(QIcon(QPixmap(myIconPath + "/mActionInOverview.png")));
mActionFileExit->setIcon(getThemeIcon( "/mActionFileExit.png"));
mActionAddOgrLayer->setIcon(getThemeIcon( "/mActionAddOgrLayer.png"));
mActionAddRasterLayer->setIcon(getThemeIcon( "/mActionAddRasterLayer.png"));
mActionAddLayer->setIcon(getThemeIcon( "/mActionAddLayer.png"));
mActionRemoveLayer->setIcon(getThemeIcon( "/mActionRemoveLayer.png"));
mActionNewVectorLayer->setIcon(getThemeIcon( "/mActionNewVectorLayer.png"));
mActionAddAllToOverview->setIcon(getThemeIcon( "/mActionAddAllToOverview.png"));
mActionHideAllLayers->setIcon(getThemeIcon( "/mActionHideAllLayers.png"));
mActionShowAllLayers->setIcon(getThemeIcon( "/mActionShowAllLayers.png"));
mActionRemoveAllFromOverview->setIcon(getThemeIcon( "/mActionRemoveAllFromOverview.png"));
mActionProjectProperties->setIcon(getThemeIcon( "/mActionProjectProperties.png"));
mActionShowPluginManager->setIcon(getThemeIcon( "/mActionShowPluginManager.png"));
mActionCheckQgisVersion->setIcon(getThemeIcon( "/mActionCheckQgisVersion.png"));
mActionOptions->setIcon(getThemeIcon( "/mActionOptions.png"));
mActionHelpContents->setIcon(getThemeIcon( "/mActionHelpContents.png"));
mActionQgisHomePage->setIcon(getThemeIcon( "/mActionQgisHomePage.png"));
mActionHelpAbout->setIcon(getThemeIcon( "/mActionHelpAbout.png"));
mActionDraw->setIcon(getThemeIcon( "/mActionDraw.png"));
mActionCapturePoint->setIcon(getThemeIcon( "/mActionCapturePoint.png"));
mActionCaptureLine->setIcon(getThemeIcon( "/mActionCaptureLine.png"));
mActionCapturePolygon->setIcon(getThemeIcon( "/mActionCapturePolygon.png"));
mActionZoomIn->setIcon(getThemeIcon( "/mActionZoomIn.png"));
mActionZoomOut->setIcon(getThemeIcon( "/mActionZoomOut.png"));
mActionZoomFullExtent->setIcon(getThemeIcon( "/mActionZoomFullExtent.png"));
mActionZoomToSelected->setIcon(getThemeIcon( "/mActionZoomToSelected.png"));
mActionPan->setIcon(getThemeIcon( "/mActionPan.png"));
mActionZoomLast->setIcon(getThemeIcon( "/mActionZoomLast.png"));
mActionZoomToLayer->setIcon(getThemeIcon( "/mActionZoomToLayer.png"));
mActionIdentify->setIcon(getThemeIcon( "/mActionIdentify.png"));
mActionSelect->setIcon(getThemeIcon( "/mActionSelect.png"));
mActionOpenTable->setIcon(getThemeIcon( "/mActionOpenTable.png"));
mActionMeasure->setIcon(getThemeIcon( "/mActionMeasure.png"));
mActionMeasureArea->setIcon(getThemeIcon( "/mActionMeasureArea.png"));
mActionShowBookmarks->setIcon(getThemeIcon( "/mActionShowBookmarks.png"));
mActionNewBookmark->setIcon(getThemeIcon( "/mActionNewBookmark.png"));
mActionCustomProjection->setIcon(getThemeIcon( "/mActionCustomProjection.png"));
mActionAddWmsLayer->setIcon(getThemeIcon( "/mActionAddWmsLayer.png"));
mActionInOverview->setIcon(getThemeIcon( "/mActionInOverview.png"));
}
void QgisApp::setupConnections()
@ -4661,20 +4653,15 @@ void QgisApp::projectionsEnabled(bool theFlag)
QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled", (theFlag?1:0));
// update icon
QString myIconPath = QgsApplication::themePath();
if (theFlag)
{
QPixmap myProjPixmap;
myProjPixmap.load(myIconPath+"/mIconProjectionEnabled.png");
//assert(!myProjPixmap.isNull());
mOnTheFlyProjectionStatusButton->setIcon(myProjPixmap);
mOnTheFlyProjectionStatusButton->setIcon(
getThemeIcon("/mIconProjectionEnabled.png"));
}
else
{
QPixmap myProjPixmap;
myProjPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
//assert(!myProjPixmap.isNull());
mOnTheFlyProjectionStatusButton->setIcon(myProjPixmap);
mOnTheFlyProjectionStatusButton->setIcon(
getThemeIcon("/mIconProjectionDisabled.png"));
}
}
// slot to update the progress bar in the status bar
@ -5577,3 +5564,36 @@ void QgisApp::setupProxy()
}
QNetworkProxy::setApplicationProxy(myProxy);
}
QIcon QgisApp::getThemeIcon(const QString theName)
{
if (QFile::exists(QgsApplication::activeThemePath() + theName))
{
return QIcon(QgsApplication::activeThemePath() + theName);
}
else if (QFile::exists(QgsApplication::defaultThemePath() + theName))
{
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QIcon(QgsApplication::defaultThemePath() + theName);
}
else
{
return QIcon();
}
}
QPixmap QgisApp::getThemePixmap(const QString theName)
{
if (QFile::exists(QgsApplication::activeThemePath() + theName))
{
return QPixmap(QgsApplication::activeThemePath() + theName);
}
else
{
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QPixmap(QgsApplication::defaultThemePath() + theName);
}
}

View File

@ -162,6 +162,14 @@ class QgisApp : public QMainWindow
* (as documented in Qt documentation.
*/
void setupProxy();
//! Helper to get a theme icon. It will fall back to the
//default theme if the active theme does not have the required
//icon.
static QIcon getThemeIcon(const QString theName);
//! Helper to get a theme icon as a pixmap. It will fall back to the
//default theme if the active theme does not have the required
//icon.
static QPixmap getThemePixmap(const QString theName);
//private slots:
public slots:
//! About QGis
@ -589,9 +597,6 @@ class Tools
QgsMapTool *mNonEditMapTool;
//!The name of the active theme
QString mThemeName;
//! Widget that will live on the statusbar to display "scale 1:"
QLabel * mScaleLabel;
//! Widget that will live on the statusbar to display scale value

View File

@ -109,15 +109,14 @@ QgsAttributeTable *QgsAttributeTableDisplay::table()
}
void QgsAttributeTableDisplay::setTheme()
{
QString myIconPath = QgsApplication::themePath();
mAddAttributeButton->setIcon(QPixmap(myIconPath+"/mActionNewAttribute.png"));
mRemoveSelectionButton->setIcon(QPixmap(myIconPath+"/mActionUnselectAttributes.png"));
mSelectedToTopButton->setIcon(QPixmap(myIconPath+"/mActionSelectedToTop.png"));
mInvertSelectionButton->setIcon(QPixmap(myIconPath+"/mActionInvertSelection.png"));
mCopySelectedRowsButton->setIcon(QPixmap(myIconPath+"/mActionCopySelected.png"));
mZoomMapToSelectedRowsButton->setIcon(QPixmap(myIconPath+"/mActionZoomToSelected.png"));
mAddAttributeButton->setIcon(QPixmap(myIconPath+"/mActionNewAttribute.png"));
mDeleteAttributeButton->setIcon(QPixmap(myIconPath+"/mActionDeleteAttribute.png"));
mAddAttributeButton->setIcon(QgisApp::getThemeIcon("/mActionNewAttribute.png"));
mRemoveSelectionButton->setIcon(QgisApp::getThemeIcon("/mActionUnselectAttributes.png"));
mSelectedToTopButton->setIcon(QgisApp::getThemeIcon("/mActionSelectedToTop.png"));
mInvertSelectionButton->setIcon(QgisApp::getThemeIcon("/mActionInvertSelection.png"));
mCopySelectedRowsButton->setIcon(QgisApp::getThemeIcon("/mActionCopySelected.png"));
mZoomMapToSelectedRowsButton->setIcon(QgisApp::getThemeIcon("/mActionZoomToSelected.png"));
mAddAttributeButton->setIcon(QgisApp::getThemeIcon("/mActionNewAttribute.png"));
mDeleteAttributeButton->setIcon(QgisApp::getThemeIcon("/mActionDeleteAttribute.png"));
}
void QgsAttributeTableDisplay::setTitle(QString title)

View File

@ -20,6 +20,7 @@
//qgis includes
#include "qgis.h" //<--magick numbers
#include "qgisapp.h" //<--theme icons
#include "qgsapplication.h"
#include "qgslogger.h"
@ -44,16 +45,13 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog(QWidget *parent, Qt::WFlags
{
setupUi(this);
QString myThemePath = QgsApplication::themePath();
pbnFirst->setIcon(QPixmap(myThemePath+"mIconFirst.png"));
QString myString = "Setting first button to : " + myThemePath+"mIconFirst.png";
qDebug(myString.toLocal8Bit());
pbnPrevious->setIcon(QPixmap(myThemePath+"mIconPrevious.png"));
pbnNext->setIcon(QPixmap(myThemePath+"mIconNext.png"));
pbnLast->setIcon(QPixmap(myThemePath+"mIconLast.png"));
pbnNew->setIcon(QPixmap(myThemePath+"mIconNew.png"));
pbnSave->setIcon(QPixmap(myThemePath+"mActionFileSave.png"));
pbnDelete->setIcon(QPixmap(myThemePath+"mIconDelete.png"));
pbnFirst->setIcon(QgisApp::getThemeIcon("mIconFirst.png"));
pbnPrevious->setIcon(QgisApp::getThemeIcon("mIconPrevious.png"));
pbnNext->setIcon(QgisApp::getThemeIcon("mIconNext.png"));
pbnLast->setIcon(QgisApp::getThemeIcon("mIconLast.png"));
pbnNew->setIcon(QgisApp::getThemeIcon("mIconNew.png"));
pbnSave->setIcon(QgisApp::getThemeIcon("mActionFileSave.png"));
pbnDelete->setIcon(QgisApp::getThemeIcon("mIconDelete.png"));
// user database is created at QGIS startup in QgisApp::createDB
// we just check whether there is our database [MD]
QFileInfo myFileInfo;
@ -701,8 +699,7 @@ void QgsCustomProjectionDialog::on_pbnNew_clicked()
if (pbnNew->text()==tr("Abort"))
{
//if we get here, user has aborted add record
QString myThemePath = QgsApplication::themePath();
pbnNew->setIcon(QPixmap(myThemePath+"mIconNew.png"));
pbnNew->setIcon(QgisApp::getThemeIcon("mIconNew.png"));
//next line needed for new/abort logic
pbnNew->setText(tr("New"));
//get back to the last used record before insert was pressed
@ -724,8 +721,7 @@ void QgsCustomProjectionDialog::on_pbnNew_clicked()
pbnNext->setEnabled(false);
pbnLast->setEnabled(false);
pbnDelete->setEnabled(false);
QString myThemePath = QgsApplication::themePath();
pbnNew->setIcon(QPixmap(myThemePath+"mIconNew.png"));
pbnNew->setIcon(QgisApp::getThemeIcon("mIconNew.png"));
//next line needed for new/abort logic
pbnNew->setText(tr("Abort"));
//clear the controls

View File

@ -17,6 +17,7 @@
#include "qgsdbtablemodel.h"
#include "qgsapplication.h"
#include "qgisapp.h"
QgsDbTableModel::QgsDbTableModel(): QStandardItemModel(), mTableCount(0)
{
@ -53,12 +54,10 @@ void QgsDbTableModel::addTableEntry(QString type, QString schemaName, QString ta
}
//path to icon for specified type
QString myThemePath = QgsApplication::themePath();
QString typeName;
QString iconFile;
QGis::WKBTYPE wkbType = qgisTypeFromDbType(type);
iconFile = iconFilePathForType(wkbType);
QIcon iconFile = iconForType(wkbType);
QList<QStandardItem*> childItemList;
QStandardItem* schemaNameItem = new QStandardItem(schemaName);
@ -197,9 +196,9 @@ void QgsDbTableModel::setGeometryTypesForTable(const QString& schema, const QStr
}
QGis::WKBTYPE wkbType = qgisTypeFromDbType(typeList.at(0));
QString iconPath = iconFilePathForType(wkbType);
QIcon myIcon = iconForType(wkbType);
itemFromIndex(currentTypeIndex)->setText(typeList.at(0)); //todo: add other rows
itemFromIndex(currentTypeIndex)->setIcon(QIcon(iconPath));
itemFromIndex(currentTypeIndex)->setIcon(myIcon);
if(!geomColText.contains(" AS "))
{
itemFromIndex(currentGeomColumnIndex)->setText(geomColText + " AS " + typeList.at(0));
@ -214,22 +213,21 @@ void QgsDbTableModel::setGeometryTypesForTable(const QString& schema, const QStr
}
}
QString QgsDbTableModel::iconFilePathForType(QGis::WKBTYPE type) const
QIcon QgsDbTableModel::iconForType(QGis::WKBTYPE type) const
{
QString myThemePath = QgsApplication::themePath();
if(type == QGis::WKBPoint || type == QGis::WKBPoint25D || type == QGis::WKBMultiPoint || type == QGis::WKBMultiPoint25D)
{
return myThemePath+"/mIconPointLayer.png";
return QgisApp::getThemeIcon("/mIconPointLayer.png");
}
else if(type == QGis::WKBLineString || type == QGis::WKBLineString25D || type == QGis::WKBMultiLineString || type == QGis::WKBMultiLineString25D)
{
return myThemePath+"/mIconLineLayer.png";
return QgisApp::getThemeIcon("/mIconLineLayer.png");
}
else if(type == QGis::WKBPolygon || type == QGis::WKBPolygon25D || type == QGis::WKBMultiPolygon || type == QGis::WKBMultiPolygon25D)
{
return myThemePath+"/mIconPolygonLayer.png";
return QgisApp::getThemeIcon("/mIconPolygonLayer.png");
}
else return "";
else return QIcon();
}
QString QgsDbTableModel::displayStringForType(QGis::WKBTYPE type) const

View File

@ -16,6 +16,7 @@
***************************************************************************/
#include <QStandardItemModel>
class QIcon;
#include "qgis.h"
/**A model that holds the tables of a database in a hierarchy where the
@ -41,7 +42,7 @@ class QgsDbTableModel: public QStandardItemModel
/**Number of tables in the model*/
int mTableCount;
QString iconFilePathForType(QGis::WKBTYPE type) const;
QIcon iconForType(QGis::WKBTYPE type) const;
QString displayStringForType(QGis::WKBTYPE type) const;
/**Returns qgis wkbtype from database typename*/
QGis::WKBTYPE qgisTypeFromDbType(const QString& dbType) const;

View File

@ -18,15 +18,15 @@
#include "qgsgeomtypedialog.h"
#include "qgsapplication.h"
#include "qgisapp.h" // <- for theme icons
#include <QPushButton>
QgsGeomTypeDialog::QgsGeomTypeDialog(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
QString myThemePath = QgsApplication::themePath();
mAddAttributeButton->setIcon(QIcon(QPixmap(myThemePath + "/mActionNewAttribute.png")));
mRemoveAttributeButton->setIcon(QIcon(QPixmap(myThemePath + "/mActionDeleteAttribute.png")));
mAddAttributeButton->setIcon(QgisApp::getThemeIcon("/mActionNewAttribute.png"));
mRemoveAttributeButton->setIcon(QgisApp::getThemeIcon("/mActionDeleteAttribute.png"));
mTypeBox->addItem(tr("Real"),"Real");
mTypeBox->addItem(tr("Integer"),"Integer");;
mTypeBox->addItem(tr("String"),"String");

View File

@ -20,6 +20,7 @@
#include "qgsidentifyresults.h"
#include "qgscontexthelp.h"
#include "qgsapplication.h"
#include "qgisapp.h"
#include <QCloseEvent>
#include <QLabel>
@ -210,8 +211,7 @@ void QgsIdentifyResults::addAction(QTreeWidgetItem * fnode, int id, QString fiel
labels << field << value << "action" << QString::number(id);
QTreeWidgetItem *item = new QTreeWidgetItem(fnode, labels );
QPixmap pm ( QgsApplication::themePath() + "/mAction.png" );
item->setIcon ( 0, QIcon(pm) );
item->setIcon ( 0, QgisApp::getThemeIcon("/mAction.png") );
}
/** Add a feature node to the list */

View File

@ -17,6 +17,7 @@
#include "qgslogger.h"
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgscoordinatetransform.h"
#include "qgsrasterlayerproperties.h"
#include "qgslayerprojectionselector.h"
@ -280,18 +281,17 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
cboxTransparencyBand->addItem(TRSTRING_NOT_SET);
QString myThemePath = QgsApplication::themePath();
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");
QIcon myPyramidPixmap(QgisApp::getThemeIcon("/mIconPyramid.png"));
QIcon myNoPyramidPixmap(QgisApp::getThemeIcon("/mIconNoPyramid.png"));
pbnAddValuesManually->setIcon(QIcon(myThemePath + "/mActionNewAttribute.png"));
pbnAddValuesFromDisplay->setIcon(QIcon(myThemePath + "/mActionContextHelp.png"));
pbnRemoveSelectedRow->setIcon(QIcon(myThemePath + "/mActionDeleteAttribute.png"));
pbnDefaultValues->setIcon(QIcon(myThemePath + "/mActionCopySelected.png"));
pbnImportTransparentPixelValues->setIcon(QIcon(myThemePath + "/mActionFileOpen.png"));
pbnExportTransparentPixelValues->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));
pbtnMakeBandCombinationDefault->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));
pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));
pbnAddValuesManually->setIcon(QgisApp::getThemeIcon("/mActionNewAttribute.png"));
pbnAddValuesFromDisplay->setIcon(QgisApp::getThemeIcon("/mActionContextHelp.png"));
pbnRemoveSelectedRow->setIcon(QgisApp::getThemeIcon("/mActionDeleteAttribute.png"));
pbnDefaultValues->setIcon(QgisApp::getThemeIcon("/mActionCopySelected.png"));
pbnImportTransparentPixelValues->setIcon(QgisApp::getThemeIcon("/mActionFileOpen.png"));
pbnExportTransparentPixelValues->setIcon(QgisApp::getThemeIcon("/mActionFileSave.png"));
pbtnMakeBandCombinationDefault->setIcon(QgisApp::getThemeIcon("/mActionFileSave.png"));
pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QgisApp::getThemeIcon("/mActionFileSave.png"));
// Only do pyramids if dealing directly with GDAL.
if (mRasterLayerIsGdal)
@ -1616,9 +1616,8 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
// repopulate the pyramids list
//
lbxPyramidResolutions->clear();
QString myThemePath = QgsApplication::themePath();
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");
QIcon myPyramidPixmap(QgisApp::getThemeIcon("/mIconPyramid.png"));
QIcon myNoPyramidPixmap(QgisApp::getThemeIcon("/mIconNoPyramid.png"));
QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
for ( myRasterPyramidIterator=myPyramidList.begin();

View File

@ -106,7 +106,11 @@ const QString QgsApplication::pkgDataPath()
{
return mPkgDataPath;
}
const QString QgsApplication::themePath()
const QString QgsApplication::defaultThemePath()
{
return mPkgDataPath + QString("/themes/default/");
}
const QString QgsApplication::activeThemePath()
{
return mThemePath;
}
@ -114,9 +118,18 @@ const QString QgsApplication::themePath()
/*!
Set the theme path to the specified theme.
*/
void QgsApplication::selectTheme(const QString theThemeName)
void QgsApplication::setTheme(const QString theThemeName)
{
mThemePath = mPkgDataPath + QString("/themes/") + theThemeName + QString("/");
QString myPath = mPkgDataPath + QString("/themes/") + theThemeName + QString("/");
//check it exists and if not roll back to default theme
if (QFile::exists(myPath))
{
mThemePath = myPath;
}
else
{
mThemePath = defaultThemePath();
}
}
/*!

View File

@ -24,8 +24,8 @@ class CORE_EXPORT QgsApplication: public QApplication
QgsApplication(int & argc, char ** argv, bool GUIenabled);
virtual ~QgsApplication();
//! Set the theme path to the specified theme.
static void selectTheme(const QString theThemeName);
//! Set the active theme path to the specified theme.
static void setTheme(const QString theThemeName);
//! Returns the path to the authors file.
static const QString authorsFilePath();
@ -75,8 +75,11 @@ class CORE_EXPORT QgsApplication: public QApplication
//! Returns the common root path of all application data directories.
static const QString pkgDataPath();
//! Returns the path to the current theme directory.
static const QString themePath();
//! Returns the path to the currently active theme directory.
static const QString activeThemePath();
//! Returns the path to the default theme directory.
static const QString defaultThemePath();
//! Alters prefix path - used by 3rd party apps
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);

View File

@ -2954,7 +2954,7 @@ QPixmap QgsRasterLayer::getLegendQPixmap(bool theWithNameFlag)
QPainter myQPainter(&myQPixmap2);
//load up the pyramid icons
QString myThemePath = QgsApplication::themePath();
QString myThemePath = QgsApplication::activeThemePath();
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");

View File

@ -479,35 +479,33 @@ void QgsPointDialog::initialize()
{
setupUi(this);
QString myIconPath = QgsApplication::themePath();
// setup actions
//
mActionZoomIn= new QAction(QIcon(myIconPath+"/mActionZoomIn.png"), tr("Zoom In"), this);
mActionZoomIn= new QAction(getThemeIcon("/mActionZoomIn.png"), tr("Zoom In"), this);
mActionZoomIn->setShortcut(tr("z"));
mActionZoomIn->setStatusTip(tr("Zoom In"));
connect(mActionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
//
mActionZoomOut= new QAction(QIcon(myIconPath+"/mActionZoomOut.png"), tr("Zoom Out"), this);
mActionZoomOut= new QAction(getThemeIcon("/mActionZoomOut.png"), tr("Zoom Out"), this);
mActionZoomOut->setShortcut(tr("Z"));
mActionZoomOut->setStatusTip(tr("Zoom Out"));
connect(mActionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));
//
mActionZoomToLayer= new QAction(QIcon(myIconPath+"/mActionZoomToLayer.png"), tr("Zoom To Layer"), this);
mActionZoomToLayer= new QAction(getThemeIcon("/mActionZoomToLayer.png"), tr("Zoom To Layer"), this);
//mActionZoomToLayer->setShortcut(tr("Ctrl+O"));
mActionZoomToLayer->setStatusTip(tr("Zoom to Layer"));
connect(mActionZoomToLayer, SIGNAL(triggered()), this, SLOT(zoomToLayer()));
//
mActionPan= new QAction(QIcon(myIconPath+"/mActionPan.png"), tr("Pan Map"), this);
mActionPan= new QAction(getThemeIcon("/mActionPan.png"), tr("Pan Map"), this);
mActionPan->setStatusTip(tr("Pan the map"));
connect(mActionPan, SIGNAL(triggered()), this, SLOT(pan()));
//
mActionAddPoint= new QAction(QIcon(myIconPath+"/mActionCapturePoint.png"), tr("Add Point"), this);
mActionAddPoint= new QAction(getThemeIcon("/mActionCapturePoint.png"), tr("Add Point"), this);
mActionAddPoint->setShortcut(tr("."));
mActionAddPoint->setStatusTip(tr("Capture Points"));
connect(mActionAddPoint, SIGNAL(triggered()), this, SLOT(addPoint()));
//
mActionDeletePoint = new QAction(QIcon(myIconPath+"/mActionDeleteSelected.png"), tr("Delete Point"), this);
mActionDeletePoint = new QAction(getThemeIcon("/mActionDeleteSelected.png"), tr("Delete Point"), this);
mActionDeletePoint->setStatusTip(tr("Delete Selected"));
connect(mActionDeletePoint, SIGNAL(triggered()), this, SLOT(deletePoint()));
@ -565,3 +563,19 @@ void QgsPointDialog::initialize()
pbnGenerateWorldFile->setEnabled(false);
pbnGenerateAndLoad->setEnabled(false);
}
// Note this code is duplicated from qgisapp.cpp because
// I didnt want to make plugins on qgsapplication [TS]
QIcon QgsPointDialog::getThemeIcon(const QString theName)
{
if (QFile::exists(QgsApplication::activeThemePath() + theName))
{
return QIcon(QgsApplication::activeThemePath() + theName);
}
else
{
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QIcon(QgsApplication::defaultThemePath() + theName);
}
}

View File

@ -24,6 +24,7 @@
class QAction;
class QActionGroup;
class QIcon;
class QgsGeorefDataPoint;
class QgsMapTool;
class QgisInterface;
@ -66,6 +67,7 @@ private:
QString guessWorldFileName(const QString& raster);
void enableModifiedRasterControls(bool state);
QIcon getThemeIcon(const QString theName);
QActionGroup* mMapToolGroup;
QAction* mActionZoomIn;

View File

@ -109,7 +109,7 @@ void QgsGPSPlugin::help()
//implement me!
}
// Slot called when the buffer menu item is activated
// Slot called when the menu item is activated
void QgsGPSPlugin::run()
{
// find all GPX layers

View File

@ -65,9 +65,8 @@ QgsGrassBrowser::QgsGrassBrowser ( QgisInterface *iface,
QActionGroup *ag = new QActionGroup ( this );
QToolBar *tb = addToolBar(tr("Tools"));
QString myIconPath = QgsApplication::themePath() + "/grass/";
mActionAddMap = new QAction(
QIcon(myIconPath+"grass_add_map.png"),
getThemeIcon("grass_add_map.png"),
tr("Add selected map to canvas"), this);
mActionAddMap->setEnabled(false);
ag->addAction ( mActionAddMap );
@ -75,7 +74,7 @@ QgsGrassBrowser::QgsGrassBrowser ( QgisInterface *iface,
connect ( mActionAddMap, SIGNAL(triggered()), this, SLOT(addMap()) );
mActionCopyMap = new QAction(
QIcon(myIconPath+"grass_copy_map.png"),
getThemeIcon("grass_copy_map.png"),
tr("Copy selected map"), this);
mActionCopyMap->setEnabled(false);
ag->addAction ( mActionCopyMap );
@ -83,7 +82,7 @@ QgsGrassBrowser::QgsGrassBrowser ( QgisInterface *iface,
connect ( mActionCopyMap, SIGNAL(triggered()), this, SLOT(copyMap()) );
mActionRenameMap = new QAction(
QIcon(myIconPath+"grass_rename_map.png"),
getThemeIcon("grass_rename_map.png"),
tr("Rename selected map"), this);
mActionRenameMap->setEnabled(false);
ag->addAction ( mActionRenameMap );
@ -91,7 +90,7 @@ QgsGrassBrowser::QgsGrassBrowser ( QgisInterface *iface,
connect ( mActionRenameMap, SIGNAL(triggered()), this, SLOT(renameMap()) );
mActionDeleteMap = new QAction(
QIcon(myIconPath+"grass_delete_map.png"),
getThemeIcon("grass_delete_map.png"),
tr("Delete selected map"), this);
mActionDeleteMap->setEnabled(false);
ag->addAction ( mActionDeleteMap );
@ -99,7 +98,7 @@ QgsGrassBrowser::QgsGrassBrowser ( QgisInterface *iface,
connect ( mActionDeleteMap, SIGNAL(triggered()), this, SLOT(deleteMap()) );
mActionSetRegion = new QAction(
QIcon(myIconPath+"grass_set_region.png"),
getThemeIcon("grass_set_region.png"),
tr("Set current region to selected map"), this);
mActionSetRegion->setEnabled(false);
ag->addAction ( mActionSetRegion );
@ -107,7 +106,7 @@ QgsGrassBrowser::QgsGrassBrowser ( QgisInterface *iface,
connect ( mActionSetRegion, SIGNAL(triggered()), this, SLOT(setRegion()) );
mActionRefresh = new QAction(
QIcon(myIconPath+"grass_refresh.png"),
getThemeIcon("grass_refresh.png"),
tr("Refresh"), this);
ag->addAction ( mActionRefresh );
tb->addAction ( mActionRefresh );

View File

@ -22,6 +22,7 @@ class QAction;
class QTreeView;
class QTextBrowser;
class QDirModel;
class QIcon;
class QgisInterface;
#include "qgsgrassmodel.h"
@ -80,6 +81,7 @@ signals:
void regionChanged();
private:
QIcon getThemeIcon(const QString theName);
QgisInterface *mIface;
//! Current GISBASE

View File

@ -72,6 +72,7 @@ extern "C" {
#include "qgsgrassedit.h"
#include "qgsgrassedittools.h"
#include "qgsgrassutils.h"
#include "qgsgrassplugin.h"
#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
@ -216,77 +217,76 @@ void QgsGrassEdit::init()
connect ( mCanvas, SIGNAL(keyPressed(QKeyEvent *)), this, SLOT(keyPress(QKeyEvent *)) );
QString myIconPath = QgsApplication::themePath() + "/grass/";
mToolBar = addToolBar(tr("Edit tools"));
mNewPointAction = new QAction(
QIcon(myIconPath+"grass_new_point.png"), tr("New point"), this);
QgsGrassPlugin::getThemeIcon("grass_new_point.png"), tr("New point"), this);
mNewPointAction->setShortcut ( QKeySequence(Qt::Key_F1) );
mToolBar->addAction ( mNewPointAction );
connect ( mNewPointAction, SIGNAL(triggered()), this, SLOT(newPoint()) );
mNewLineAction = new QAction(
QIcon(myIconPath+"grass_new_line.png"), tr("New line"), this);
QgsGrassPlugin::getThemeIcon("grass_new_line.png"), tr("New line"), this);
mNewLineAction->setShortcut ( QKeySequence(Qt::Key_F2) );
mToolBar->addAction ( mNewLineAction );
connect ( mNewLineAction, SIGNAL(triggered()), this, SLOT(newLine()) );
mNewBoundaryAction = new QAction(
QIcon(myIconPath+"grass_new_boundary.png"), tr("New boundary"), this);
QgsGrassPlugin::getThemeIcon("grass_new_boundary.png"), tr("New boundary"), this);
mNewBoundaryAction->setShortcut ( QKeySequence(Qt::Key_F3) );
mToolBar->addAction ( mNewBoundaryAction );
connect ( mNewBoundaryAction, SIGNAL(triggered()), this, SLOT(newBoundary()) );
mNewCentroidAction = new QAction(
QIcon(myIconPath+"grass_new_centroid.png"), tr("New centroid"), this);
QgsGrassPlugin::getThemeIcon("grass_new_centroid.png"), tr("New centroid"), this);
mNewCentroidAction->setShortcut ( QKeySequence(Qt::Key_F4) );
mToolBar->addAction ( mNewCentroidAction );
connect ( mNewCentroidAction, SIGNAL(triggered()), this, SLOT(newCentroid()) );
mMoveVertexAction = new QAction(
QIcon(myIconPath+"grass_move_vertex.png"), tr("Move vertex"), this);
QgsGrassPlugin::getThemeIcon("grass_move_vertex.png"), tr("Move vertex"), this);
mMoveVertexAction->setShortcut ( QKeySequence(Qt::Key_F5) );
mToolBar->addAction ( mMoveVertexAction );
connect ( mMoveVertexAction, SIGNAL(triggered()), this, SLOT(moveVertex()) );
mAddVertexAction = new QAction(
QIcon(myIconPath+"grass_add_vertex.png"), tr("Add vertex"), this);
QgsGrassPlugin::getThemeIcon("grass_add_vertex.png"), tr("Add vertex"), this);
mAddVertexAction->setShortcut ( QKeySequence(Qt::Key_F6) );
mToolBar->addAction ( mAddVertexAction );
connect ( mAddVertexAction, SIGNAL(triggered()), this, SLOT(addVertex()) );
mDeleteVertexAction = new QAction(
QIcon(myIconPath+"grass_delete_vertex.png"), tr("Delete vertex"), this);
QgsGrassPlugin::getThemeIcon("grass_delete_vertex.png"), tr("Delete vertex"), this);
mDeleteVertexAction->setShortcut ( QKeySequence(Qt::Key_F7) );
mToolBar->addAction ( mDeleteVertexAction );
connect ( mDeleteVertexAction, SIGNAL(triggered()), this, SLOT(deleteVertex()) );
mMoveLineAction = new QAction(
QIcon(myIconPath+"grass_move_line.png"), tr("Move element"), this);
QgsGrassPlugin::getThemeIcon("grass_move_line.png"), tr("Move element"), this);
mMoveLineAction->setShortcut ( QKeySequence(Qt::Key_F9) );
mToolBar->addAction ( mMoveLineAction );
connect ( mMoveLineAction, SIGNAL(triggered()), this, SLOT(moveLine()) );
mSplitLineAction = new QAction(
QIcon(myIconPath+"grass_split_line.png"), tr("Split line"), this);
QgsGrassPlugin::getThemeIcon("grass_split_line.png"), tr("Split line"), this);
mSplitLineAction->setShortcut ( QKeySequence(Qt::Key_F10) );
mToolBar->addAction ( mSplitLineAction );
connect ( mSplitLineAction, SIGNAL(triggered()), this, SLOT(splitLine()) );
mDeleteLineAction = new QAction(
QIcon(myIconPath+"grass_delete_line.png"), tr("Delete element"), this);
QgsGrassPlugin::getThemeIcon("grass_delete_line.png"), tr("Delete element"), this);
mDeleteLineAction->setShortcut ( QKeySequence(Qt::Key_F11) );
mToolBar->addAction ( mDeleteLineAction );
connect ( mDeleteLineAction, SIGNAL(triggered()), this, SLOT(deleteLine()) );
mEditAttributesAction = new QAction(
QIcon(myIconPath+"grass_edit_attributes.png"), tr("Edit attributes"), this);
QgsGrassPlugin::getThemeIcon("grass_edit_attributes.png"), tr("Edit attributes"), this);
mToolBar->addAction ( mEditAttributesAction );
connect ( mEditAttributesAction, SIGNAL(triggered()), this, SLOT(editAttributes()) );
mCloseEditAction = new QAction(
QIcon(myIconPath+"grass_close_edit.png"), tr("Close"), this);
QgsGrassPlugin::getThemeIcon("grass_close_edit.png"), tr("Close"), this);
mToolBar->addAction ( mCloseEditAction );
connect ( mCloseEditAction, SIGNAL(triggered()), this, SLOT(closeEdit()) );

View File

@ -53,6 +53,7 @@
#include "qgsvectorlayer.h"
#include "qgsdataprovider.h"
#include "qgsfield.h"
#include "qgsgrassplugin.h"
extern "C" {
#include <grass/gis.h>
@ -105,47 +106,46 @@ QgsGrassMapcalc::QgsGrassMapcalc (
mView->setCanvas ( mCanvas );
QString myIconPath = QgsApplication::themePath() + "/grass/";
QActionGroup *ag = new QActionGroup ( this );
QToolBar *tb = addToolBar(tr("Mapcalc tools"));
mActionAddMap = new QAction( QIcon(myIconPath+"mapcalc_add_map.png"),
mActionAddMap = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_add_map.png"),
tr("Add map"), this);
mActionAddMap->setCheckable ( true );
ag->addAction ( mActionAddMap );
tb->addAction ( mActionAddMap );
connect ( mActionAddMap, SIGNAL(triggered()), this, SLOT(addMap()) );
mActionAddConstant = new QAction( QIcon(myIconPath+"mapcalc_add_constant.png"),
mActionAddConstant = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_add_constant.png"),
tr("Add constant value"), this);
mActionAddConstant->setCheckable ( true );
ag->addAction ( mActionAddConstant );
tb->addAction ( mActionAddConstant );
connect ( mActionAddConstant, SIGNAL(triggered()), this, SLOT(addConstant()) );
mActionAddFunction = new QAction( QIcon(myIconPath+"mapcalc_add_function.png"),
mActionAddFunction = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_add_function.png"),
tr("Add operator or function"), this);
mActionAddFunction->setCheckable ( true );
ag->addAction ( mActionAddFunction );
tb->addAction ( mActionAddFunction );
connect ( mActionAddFunction, SIGNAL(triggered()), this, SLOT(addFunction()) );
mActionAddConnection = new QAction( QIcon(myIconPath+"mapcalc_add_connection.png"),
mActionAddConnection = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_add_connection.png"),
tr("Add connection"), this);
mActionAddConnection->setCheckable ( true );
ag->addAction ( mActionAddConnection );
tb->addAction ( mActionAddConnection );
connect ( mActionAddConnection, SIGNAL(triggered()), this, SLOT(addConnection()) );
mActionSelectItem = new QAction( QIcon(myIconPath+"mapcalc_select.png"),
mActionSelectItem = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_select.png"),
tr("Select item"), this);
mActionSelectItem->setCheckable ( true );
ag->addAction ( mActionSelectItem );
tb->addAction ( mActionSelectItem );
connect ( mActionSelectItem, SIGNAL(triggered()), this, SLOT(selectItem()) );
mActionDeleteItem = new QAction( QIcon(myIconPath+"mapcalc_delete.png"),
mActionDeleteItem = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_delete.png"),
tr("Delete selected item"), this);
mActionDeleteItem->setCheckable ( true );
mActionDeleteItem->setEnabled ( false );
@ -155,18 +155,18 @@ QgsGrassMapcalc::QgsGrassMapcalc (
mActionAddMap->setOn(true);
mActionLoad = new QAction( QIcon(myIconPath+"mapcalc_open.png"),
mActionLoad = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_open.png"),
tr("Open"), this);
tb->addAction ( mActionLoad );
connect ( mActionLoad, SIGNAL(triggered()), this, SLOT(load()) );
mActionSave = new QAction( QIcon(myIconPath+"mapcalc_save.png"),
mActionSave = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_save.png"),
tr("Save"), this);
tb->addAction ( mActionSave );
connect ( mActionSave, SIGNAL(triggered()), this, SLOT(save()) );
mActionSave->setEnabled(false);
mActionSaveAs = new QAction( QIcon(myIconPath+"mapcalc_save_as.png"),
mActionSaveAs = new QAction( QgsGrassPlugin::getThemeIcon("mapcalc_save_as.png"),
tr("Save as"), this);
tb->addAction ( mActionSaveAs );
connect ( mActionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()) );

View File

@ -36,6 +36,7 @@
#include "qgis.h"
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsgrassplugin.h"
extern "C" {
#include <grass/gis.h>
@ -488,12 +489,11 @@ QgsGrassModel::QgsGrassModel ( QObject * parent )
mIconFile = QIcon(style->standardPixmap(QStyle::SP_FileIcon));
QString iconPath = QgsApplication::themePath();
mIconPointLayer = QIcon ( iconPath+"/mIconPointLayer.png" );
mIconLineLayer = QIcon ( iconPath+"/mIconLineLayer.png" );
mIconPolygonLayer = QIcon ( iconPath+"/mIconPolygonLayer.png" );
mIconVectorLayer = QIcon ( iconPath+"/grass/grass_browser_vector_layer.png" );
mIconRasterLayer = QIcon ( iconPath+"/grass/grass_browser_raster_layer.png" );
mIconPointLayer = QgsGrassPlugin::getThemeIcon("/mIconPointLayer.png" );
mIconLineLayer = QgsGrassPlugin::getThemeIcon("/mIconLineLayer.png" );
mIconPolygonLayer = QgsGrassPlugin::getThemeIcon("/mIconPolygonLayer.png" );
mIconVectorLayer = QgsGrassPlugin::getThemeIcon("/grass/grass_browser_vector_layer.png" );
mIconRasterLayer = QgsGrassPlugin::getThemeIcon("/grass/grass_browser_raster_layer.png" );
mRoot = new QgsGrassModelItem();
mRoot->mType = QgsGrassModel::Location;

View File

@ -90,6 +90,7 @@ extern "C" {
#include "qgsgrassmapcalc.h"
#include "qgsgrasstools.h"
#include "qgsgrassselect.h"
#include "qgsgrassplugin.h"
#include <gdal.h> // to collect version information
@ -2102,10 +2103,9 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
&& region != "no"
)
{
QString iconPath = QgsApplication::themePath() + "/grass/";
mRegionButton = new QPushButton(
QIcon(iconPath+"grass_set_region.png"), "" );
QgsGrassPlugin::getThemeIcon("grass_set_region.png"), "" );
mRegionButton->setToolTip ( tr("Use region of this map") );
mRegionButton->setCheckable ( true );

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
/* $Id$ */
// includes
#include "qgsapplication.h"
#include "qgsmaplayer.h"
#include "qgisinterface.h"
#include "qgsmapcanvas.h"
@ -39,6 +40,7 @@
#include <qregexp.h>
#include <qglobal.h>
#include <qinputdialog.h>
#include <QIcon>
//Added by qt3to4:
#include <QPixmap>
#include <Q3PointArray>
@ -810,6 +812,22 @@ void QgsGrassPlugin::unload()
disconnect( qgis, SIGNAL( projectRead() ), this, SLOT( projectRead()));
disconnect( qgis, SIGNAL( newProject() ), this, SLOT(newProject()));
}
// Note this code is duplicated from qgisapp.cpp because
// I didnt want to make plugins dependent on qgsapplication
// and because it needs grass specific path [TS]
QIcon QgsGrassPlugin::getThemeIcon(const QString theName)
{
if (QFile::exists(QgsApplication::activeThemePath() + "/grass/" + theName))
{
return QIcon(QgsApplication::activeThemePath() + theName);
}
else
{
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QIcon(QgsApplication::defaultThemePath() + "/grass/" + theName);
}
}
/**
* Required extern functions needed for every plugin

View File

@ -31,6 +31,7 @@ class QgsGrassTools;
class QgsGrassNewMapset;
class QgsGrassRegion;
class QToolBar;
class QIcon;
/**
* \class QgsGrassPlugin
* \brief OpenModeller plugin for QGIS
@ -69,6 +70,8 @@ Q_OBJECT public:
QPen & regionPen(void);
//! Set Region Pen
void setRegionPen(QPen &);
//! Get a plugin icon resource using the active theme
static QIcon getThemeIcon(const QString theName);
public slots:
//! init the gui

View File

@ -46,7 +46,7 @@ void TestQgsApplication::initTestCase()
void TestQgsApplication::checkTheme()
{
QString myIconPath = QgsApplication::themePath();
QString myIconPath = QgsApplication::defaultThemePath();
QPixmap myPixmap;
myPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
qDebug("Checking if a theme icon exists:");