Skip to content

Commit

Permalink
Merge pull request #5921 from nirvn/layout_item_icon
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored Dec 21, 2017
2 parents 1f6d1a6 + 3dc5211 commit 909a0fc
Show file tree
Hide file tree
Showing 54 changed files with 166 additions and 11 deletions.
14 changes: 14 additions & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
<file>themes/default/mActionSharingExport.svg</file>
<file>themes/default/mActionSharingImport.svg</file>
<file>themes/default/mActionShowAllLayers.svg</file>
<file>themes/default/mActionShowAllLayersGray.svg</file>
<file>themes/default/mActionShowBookmarks.svg</file>
<file>themes/default/mActionShowHideLabels.svg</file>
<file>themes/default/mActionShowPinnedLabels.svg</file>
Expand Down Expand Up @@ -434,6 +435,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
8 changes: 1 addition & 7 deletions images/themes/default/lockedGray.svg
Loading
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/mActionShowAllLayersGray.svg
Loading
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/mLayoutItem.svg
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Loading
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ int QgsLayoutItemLegend::type() const
return QgsLayoutItemRegistry::LayoutLegend;
}