Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layouts] add icons for items and use those in the items panel
  • Loading branch information
nirvn committed Dec 21, 2017
1 parent 1f6d1a6 commit 0a40a81
Show file tree
Hide file tree
Showing 52 changed files with 161 additions and 2 deletions.
13 changes: 13 additions & 0 deletions images/images.qrc
Expand Up @@ -434,6 +434,19 @@
<file>themes/default/mIconWms.svg</file>
<file>themes/default/mIconZip.png</file>
<file>themes/default/mIconZoom.svg</file>
<file>themes/default/mLayoutItem.svg</file>
<file>themes/default/mLayoutItemShapeEllipse.svg</file>
<file>themes/default/mLayoutItemShapeRectangle.svg</file>
<file>themes/default/mLayoutItemShapeTriangle.svg</file>
<file>themes/default/mLayoutItemHtml.svg</file>
<file>themes/default/mLayoutItemPicture.svg</file>
<file>themes/default/mLayoutItemLabel.svg</file>
<file>themes/default/mLayoutItemLegend.svg</file>
<file>themes/default/mLayoutItemMap.svg</file>
<file>themes/default/mLayoutItemPolygon.svg</file>
<file>themes/default/mLayoutItemPolyline.svg</file>
<file>themes/default/mLayoutItemScaleBar.svg</file>
<file>themes/default/mLayoutItemTable.svg</file>
<file>themes/default/mMessageLog.svg</file>
<file>themes/default/mMessageLogRead.svg</file>
<file>themes/default/north_arrow.png</file>
Expand Down
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItem.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemHtml.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemLabel.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemLegend.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemMap.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemPicture.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemPolygon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemPolyline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemScaleBar.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemShapeEllipse.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemShapeRectangle.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemShapeTriangle.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mLayoutItemTable.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutframe.sip
Expand Up @@ -35,6 +35,8 @@ Creates a new QgsLayoutFrame belonging to the specified ``layout``.

virtual int type() const;

virtual QIcon icon() const;

virtual QString uuid() const;


Expand Down
7 changes: 6 additions & 1 deletion python/core/layout/qgslayoutitem.sip
Expand Up @@ -262,9 +262,14 @@ tasks.
virtual int type() const;

%Docstring
Return unique graphics item type identifier.
Returns a unique graphics item type identifier.

Plugin based subclasses should return an identifier greater than QgsLayoutItemRegistry.PluginItem.
%End

virtual QIcon icon() const;
%Docstring
Returns the item's icon.
%End

virtual QString uuid() const;
Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemattributetable.sip
Expand Up @@ -39,6 +39,8 @@ Ownership is transferred to the layout.

virtual int type() const;

virtual QIcon icon() const;

virtual QString displayName() const;


Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemhtml.sip
Expand Up @@ -39,6 +39,8 @@ Ownership is transferred to the layout.

virtual int type() const;

virtual QIcon icon() const;


static QgsLayoutItemHtml *create( QgsLayout *layout ) /Factory/;
%Docstring
Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemlabel.sip
Expand Up @@ -42,6 +42,8 @@ The caller takes responsibility for deleting the returned object.

virtual int type() const;

virtual QIcon icon() const;

virtual QString displayName() const;


Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemlegend.sip
Expand Up @@ -65,6 +65,8 @@ The caller takes responsibility for deleting the returned object.

virtual int type() const;

virtual QIcon icon() const;

virtual QString displayName() const;


Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemmap.sip
Expand Up @@ -39,6 +39,8 @@ Constructor for QgsLayoutItemMap, with the specified parent ``layout``.

virtual int type() const;

virtual QIcon icon() const;


void assignFreeId();
%Docstring
Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitempicture.sip
Expand Up @@ -51,6 +51,8 @@ Constructor for QgsLayoutItemPicture, with the specified parent ``layout``.

virtual int type() const;

virtual QIcon icon() const;


static QgsLayoutItemPicture *create( QgsLayout *layout ) /Factory/;
%Docstring
Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitempolygon.sip
Expand Up @@ -43,6 +43,8 @@ The caller takes responsibility for deleting the returned object.

virtual int type() const;

virtual QIcon icon() const;

virtual QString displayName() const;


Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitempolyline.sip
Expand Up @@ -49,6 +49,8 @@ The caller takes responsibility for deleting the returned object.

virtual int type() const;

virtual QIcon icon() const;

virtual QString displayName() const;


Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemscalebar.sip
Expand Up @@ -28,6 +28,8 @@ Constructor for QgsLayoutItemScaleBar, with the specified parent ``layout``.

virtual int type() const;

virtual QIcon icon() const;


static QgsLayoutItemScaleBar *create( QgsLayout *layout ) /Factory/;
%Docstring
Expand Down
2 changes: 2 additions & 0 deletions python/core/layout/qgslayoutitemshape.sip
Expand Up @@ -36,6 +36,8 @@ Constructor for QgsLayoutItemShape, with the specified parent ``layout``.

virtual int type() const;

virtual QIcon icon() const;


virtual QString displayName() const;

Expand Down
5 changes: 5 additions & 0 deletions python/core/layout/qgslayoutmultiframe.sip
Expand Up @@ -73,6 +73,11 @@ Returns the total size of the multiframe's content, in layout units.
virtual int type() const = 0;
%Docstring
Returns unique multiframe type id.
%End

virtual QIcon icon() const;
%Docstring
Returns the item's icon.
%End

virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const;
Expand Down
8 changes: 8 additions & 0 deletions src/core/layout/qgslayoutframe.cpp
Expand Up @@ -110,6 +110,14 @@ int QgsLayoutFrame::type() const
return QgsLayoutItemRegistry::LayoutFrame;
}

QIcon QgsLayoutFrame::icon() const
{
if ( mMultiFrame )
return mMultiFrame->icon();
else
return QIcon();
}

QString QgsLayoutFrame::uuid() const
{
if ( mMultiFrame )
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutframe.h
Expand Up @@ -46,6 +46,7 @@ class CORE_EXPORT QgsLayoutFrame: public QgsLayoutItem
static QgsLayoutFrame *create( QgsLayout *layout ) SIP_FACTORY;

int type() const override;
QIcon icon() const override;
QString uuid() const override;

//Overridden to allow multiframe to set display name
Expand Down
8 changes: 7 additions & 1 deletion src/core/layout/qgslayoutitem.h
Expand Up @@ -25,6 +25,7 @@
#include "qgslayoutundocommand.h"
#include "qgslayoutmeasurement.h"
#include <QGraphicsRectItem>
#include <QIcon>
#include <QPainter>

class QgsLayout;
Expand Down Expand Up @@ -292,12 +293,17 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
virtual void cleanup();

/**
* Return unique graphics item type identifier.
* Returns a unique graphics item type identifier.
*
* Plugin based subclasses should return an identifier greater than QgsLayoutItemRegistry::PluginItem.
*/
int type() const override;

/**
* Returns the item's icon.
*/
virtual QIcon icon() const { return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItem.svg" ) ); }

/**
* Returns the item identification string. This is a unique random string set for the item
* upon creation.
Expand Down
5 changes: 5 additions & 0 deletions src/core/layout/qgslayoutitemattributetable.cpp
Expand Up @@ -95,6 +95,11 @@ int QgsLayoutItemAttributeTable::type() const
return QgsLayoutItemRegistry::LayoutAttributeTable;
}

QIcon QgsLayoutItemAttributeTable::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemTable.svg" ) );
}

QgsLayoutItemAttributeTable *QgsLayoutItemAttributeTable::create( QgsLayout *layout )
{
return new QgsLayoutItemAttributeTable( layout );
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitemattributetable.h
Expand Up @@ -56,6 +56,7 @@ class CORE_EXPORT QgsLayoutItemAttributeTable: public QgsLayoutTable
QgsLayoutItemAttributeTable( QgsLayout *layout SIP_TRANSFERTHIS );

int type() const override;
QIcon icon() const override;
QString displayName() const override;

/**
Expand Down
5 changes: 5 additions & 0 deletions src/core/layout/qgslayoutitemhtml.cpp
Expand Up @@ -81,6 +81,11 @@ int QgsLayoutItemHtml::type() const
return QgsLayoutItemRegistry::LayoutHtml;
}

QIcon QgsLayoutItemHtml::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemHtml.svg" ) );
}

QgsLayoutItemHtml *QgsLayoutItemHtml::create( QgsLayout *layout )
{
return new QgsLayoutItemHtml( layout );
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitemhtml.h
Expand Up @@ -56,6 +56,7 @@ class CORE_EXPORT QgsLayoutItemHtml: public QgsLayoutMultiFrame
~QgsLayoutItemHtml() override;

int type() const override;
QIcon icon() const override;

/**
* Returns a new QgsLayoutItemHtml for the specified parent \a layout.
Expand Down
5 changes: 5 additions & 0 deletions src/core/layout/qgslayoutitemlabel.cpp
Expand Up @@ -102,6 +102,11 @@ int QgsLayoutItemLabel::type() const
return QgsLayoutItemRegistry::LayoutLabel;
}

QIcon QgsLayoutItemLabel::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLabel.svg" ) );
}

void QgsLayoutItemLabel::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
{
QPainter *painter = context.painter();
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitemlabel.h
Expand Up @@ -57,6 +57,7 @@ class CORE_EXPORT QgsLayoutItemLabel: public QgsLayoutItem
static QgsLayoutItemLabel *create( QgsLayout *layout ) SIP_FACTORY;

int type() const override;
QIcon icon() const override;
//Overridden to contain part of label's text
QString displayName() const override;

Expand Down
5 changes: 5 additions & 0 deletions src/core/layout/qgslayoutitemlegend.cpp
Expand Up @@ -58,6 +58,11 @@ int QgsLayoutItemLegend::type() const
return QgsLayoutItemRegistry::LayoutLegend;
}

QIcon QgsLayoutItemLegend::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLegend.svg" ) );
}

void QgsLayoutItemLegend::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
{
if ( !painter )
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitemlegend.h