Skip to content
Permalink
Browse files
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/qgis@8937 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jul 28, 2008
1 parent 91d5f39 commit 3a4648f92c5d9aaa01616c39947bcc8fcd2073ba
Showing with 2,532 additions and 1,543 deletions.
  1. +7 −4 python/core/qgsapplication.sip
  2. +15 −19 src/app/composer/qgscomposer.cpp
  3. +15 −16 src/app/legend/qgslegend.cpp
  4. +14 −11 src/app/legend/qgslegend.h
  5. +4 −3 src/app/legend/qgslegendgroup.cpp
  6. +27 −41 src/app/legend/qgslegendlayer.cpp
  7. +6 −6 src/app/legend/qgslegendlayerfile.cpp
  8. +2 −1 src/app/legend/qgslegendpropertygroup.cpp
  9. +2 −1 src/app/legend/qgslegendsymbologygroup.cpp
  10. +154 −134 src/app/qgisapp.cpp
  11. +8 −3 src/app/qgisapp.h
  12. +8 −9 src/app/qgsattributetabledisplay.cpp
  13. +10 −14 src/app/qgscustomprojectiondialog.cpp
  14. +9 −11 src/app/qgsdbtablemodel.cpp
  15. +2 −1 src/app/qgsdbtablemodel.h
  16. +3 −3 src/app/qgsgeomtypedialog.cpp
  17. +2 −2 src/app/qgsidentifyresults.cpp
  18. +13 −14 src/app/qgsrasterlayerproperties.cpp
  19. +16 −3 src/core/qgsapplication.cpp
  20. +7 −4 src/core/qgsapplication.h
  21. +1 −1 src/core/raster/qgsrasterlayer.cpp
  22. +22 −8 src/plugins/georeferencer/qgspointdialog.cpp
  23. +2 −0 src/plugins/georeferencer/qgspointdialog.h
  24. +1 −1 src/plugins/gps_importer/qgsgpsplugin.cpp
  25. +6 −7 src/plugins/grass/qgsgrassbrowser.cpp
  26. +2 −0 src/plugins/grass/qgsgrassbrowser.h
  27. +13 −13 src/plugins/grass/qgsgrassedit.cpp
  28. +10 −10 src/plugins/grass/qgsgrassmapcalc.cpp
  29. +6 −6 src/plugins/grass/qgsgrassmodel.cpp
  30. +2 −2 src/plugins/grass/qgsgrassmodule.cpp
  31. +2,121 −1,194 src/plugins/grass/qgsgrassnewmapsetbase.ui
  32. +18 −0 src/plugins/grass/qgsgrassplugin.cpp
  33. +3 −0 src/plugins/grass/qgsgrassplugin.h
  34. +1 −1 tests/src/core/testqgsapplication.cpp
@@ -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);
@@ -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 )
@@ -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");
@@ -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 @@ this item may be moved back to the original position with resetToInitialPosition
/** 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);

@@ -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);
}
@@ -19,6 +19,7 @@
***************************************************************************/

#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgslegend.h"
#include "qgslegendlayer.h"
#include "qgslegendlayerfile.h"
@@ -404,28 +405,27 @@ 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();

0 comments on commit 3a4648f

Please sign in to comment.