Skip to content
Permalink
Browse files

[layouts] add icons for items and use those in the items panel

  • Loading branch information
nirvn committed Dec 21, 2017
1 parent 1f6d1a6 commit 0a40a81151fa04dec97a9cd4d80f23541c72af2f
Showing with 161 additions and 2 deletions.
  1. +13 −0 images/images.qrc
  2. +1 −0 images/themes/default/mLayoutItem.svg
  3. +1 −0 images/themes/default/mLayoutItemHtml.svg
  4. +1 −0 images/themes/default/mLayoutItemLabel.svg
  5. +1 −0 images/themes/default/mLayoutItemLegend.svg
  6. +1 −0 images/themes/default/mLayoutItemMap.svg
  7. +1 −0 images/themes/default/mLayoutItemPicture.svg
  8. +1 −0 images/themes/default/mLayoutItemPolygon.svg
  9. +1 −0 images/themes/default/mLayoutItemPolyline.svg
  10. +1 −0 images/themes/default/mLayoutItemScaleBar.svg
  11. +1 −0 images/themes/default/mLayoutItemShapeEllipse.svg
  12. +1 −0 images/themes/default/mLayoutItemShapeRectangle.svg
  13. +1 −0 images/themes/default/mLayoutItemShapeTriangle.svg
  14. +1 −0 images/themes/default/mLayoutItemTable.svg
  15. +2 −0 python/core/layout/qgslayoutframe.sip
  16. +6 −1 python/core/layout/qgslayoutitem.sip
  17. +2 −0 python/core/layout/qgslayoutitemattributetable.sip
  18. +2 −0 python/core/layout/qgslayoutitemhtml.sip
  19. +2 −0 python/core/layout/qgslayoutitemlabel.sip
  20. +2 −0 python/core/layout/qgslayoutitemlegend.sip
  21. +2 −0 python/core/layout/qgslayoutitemmap.sip
  22. +2 −0 python/core/layout/qgslayoutitempicture.sip
  23. +2 −0 python/core/layout/qgslayoutitempolygon.sip
  24. +2 −0 python/core/layout/qgslayoutitempolyline.sip
  25. +2 −0 python/core/layout/qgslayoutitemscalebar.sip
  26. +2 −0 python/core/layout/qgslayoutitemshape.sip
  27. +5 −0 python/core/layout/qgslayoutmultiframe.sip
  28. +8 −0 src/core/layout/qgslayoutframe.cpp
  29. +1 −0 src/core/layout/qgslayoutframe.h
  30. +7 −1 src/core/layout/qgslayoutitem.h
  31. +5 −0 src/core/layout/qgslayoutitemattributetable.cpp
  32. +1 −0 src/core/layout/qgslayoutitemattributetable.h
  33. +5 −0 src/core/layout/qgslayoutitemhtml.cpp
  34. +1 −0 src/core/layout/qgslayoutitemhtml.h
  35. +5 −0 src/core/layout/qgslayoutitemlabel.cpp
  36. +1 −0 src/core/layout/qgslayoutitemlabel.h
  37. +5 −0 src/core/layout/qgslayoutitemlegend.cpp
  38. +1 −0 src/core/layout/qgslayoutitemlegend.h
  39. +5 −0 src/core/layout/qgslayoutitemmap.cpp
  40. +1 −0 src/core/layout/qgslayoutitemmap.h
  41. +5 −0 src/core/layout/qgslayoutitempicture.cpp
  42. +1 −0 src/core/layout/qgslayoutitempicture.h
  43. +5 −0 src/core/layout/qgslayoutitempolygon.cpp
  44. +1 −0 src/core/layout/qgslayoutitempolygon.h
  45. +5 −0 src/core/layout/qgslayoutitempolyline.cpp
  46. +1 −0 src/core/layout/qgslayoutitempolyline.h
  47. +5 −0 src/core/layout/qgslayoutitemscalebar.cpp
  48. +1 −0 src/core/layout/qgslayoutitemscalebar.h
  49. +15 −0 src/core/layout/qgslayoutitemshape.cpp
  50. +1 −0 src/core/layout/qgslayoutitemshape.h
  51. +10 −0 src/core/layout/qgslayoutmodel.cpp
  52. +6 −0 src/core/layout/qgslayoutmultiframe.h
@@ -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>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M2.5 2.5h11v11h-11z" fill="#f0f0f0" stroke="#9a9a9a"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M1.5 1.5h13v13h-13z" fill="#f0f0f0" stroke="#9a9a9a"/><path d="M3 12h9M3 9h7M3 6h10" fill="#b3b3b3" stroke="#b3b3b3" stroke-width="2"/><path d="M5.955 3.52L3.5 6l2.455 2.48m4.09 0L12.5 6l-2.455-2.48M7.182 8.48l1.636-4.96" fill="none" stroke="#f0f0f0" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/><path d="M5.955 3.52L3.5 6l2.455 2.48m4.09 0L12.5 6l-2.455-2.48M7.182 8.48l1.636-4.96" fill="none" stroke="#424242" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M1.5 2.5h13v11h-13z" fill="#f0f0f0" stroke="#9a9a9a"/><path d="M8 11.5v-7M10.5 6V4.5h-5V6M7 11.5h2" fill="none" stroke="#424242"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M1.5 1.5h3v3h-3zM1.5 6.5h3v3h-3zM1.5 11.5h3v3h-3z" fill="#b3b3b3" stroke="#424242"/><path d="M6 13h4M6 8h9M6 3h6" fill="#b3b3b3" stroke="#b3b3b3" stroke-width="2"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="3.5" x2="11.5" y1="19.5" y2="19.5" gradientTransform="translate(0 -8)"><stop offset="0" stop-color="#b7b7b7"/><stop offset="1" stop-color="#e6e6e6"/></linearGradient><path d="M14.5 13.5H2.658c-.58 0-1.145-.824-1.158-1.45V2.5h13z" fill="url(#a)" fill-rule="evenodd" stroke="#9a9a9a"/><path d="M3.816 2.185c-.58-.58-1.737-.58-2.316 0v8.897c.579-.58 1.737-.58 2.316 0z" fill="#e6e6e6" fill-rule="evenodd" stroke="#9a9a9a"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M1.5 3.5h13v9h-13z" fill="#424242" stroke="#9a9a9a"/><path d="M2 8l3.263-2.077L14 9.385v2.769H2z" fill="#f0f0f0" fill-rule="evenodd"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><ellipse cy="2.975" cx="2.974" rx="1.522" ry="1.523" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><ellipse cy="2.67" cx="12.409" rx="1.522" ry="1.523" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><ellipse cy="10.589" cx="2.669" rx="1.522" ry="1.523" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><ellipse cy="13.33" cx="7.235" rx="1.522" ry="1.523" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><path d="M2.73 9.067l.183-4.57m1.582-1.571l6.393-.207m.856 1.321L7.9 11.96m-1.97.586l-1.956-1.174" fill="#b3b3b3" stroke="#424242"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><ellipse cy="7.976" cx="2.642" rx="1.494" ry="1.495" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><path d="M3.962 4.012l-.848 2.545" fill="none" stroke="#424242"/><ellipse cy="2.642" cx="4.435" rx="1.494" ry="1.495" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><ellipse cy="3.24" cx="12.804" rx="1.494" ry="1.495" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><ellipse cy="13.358" cx="6.228" rx="1.494" ry="1.495" fill="#b3b3b3" stroke="#424242" stroke-width=".295" stroke-linejoin="round" stroke-miterlimit=".4"/><path d="M5.926 2.7l5.387.385M3.47 9.22l1.93 2.894" fill="none" stroke="#424242"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M6 6h4v4H6z" fill="#fff"/><path d="M2 6h4v4H2z" fill="#424242"/><path d="M11 7h2v2h-2z" fill="#424242" stroke="#424242" stroke-width="2"/><path d="M1.5 6.5h13v3h-13z" fill="none" stroke="#9a9a9a"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><circle cy="8" cx="8" r="5.5" fill="#f0f0f0" stroke="#9a9a9a" stroke-linejoin="round" stroke-miterlimit=".4"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M2.5 2.5h11v11h-11z" fill="#f0f0f0" stroke="#9a9a9a"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M2.5 13.5L8 2.5l5.5 11z" fill="#f0f0f0" fill-rule="evenodd" stroke="#9a9a9a" stroke-linejoin="round" stroke-miterlimit=".4"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M1.5 1.5h13v13h-13z" fill="#e6e6e6" stroke="#9a9a9a"/><path d="M1.5 1.5h13v5h-13z" fill="#b3b3b3" stroke="#9a9a9a"/><path overflow="visible" d="M3 4h4" fill="none" stroke="#424242" stroke-width="2"/><path d="M8 4h5" fill="none" stroke="#424242" stroke-width="2"/><path overflow="visible" d="M3 8.5h4" fill="none" stroke="#b3b3b3"/><path d="M8 8.5h5" fill="none" stroke="#b3b3b3"/><path overflow="visible" d="M3 12.5h4" fill="none" stroke="#b3b3b3"/><path d="M8 12.5h5" fill="none" stroke="#b3b3b3"/><path overflow="visible" d="M3 10.5h4" fill="none" stroke="#b3b3b3"/><path d="M8 10.5h5" fill="none" stroke="#b3b3b3"/></svg>
@@ -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;


@@ -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;
@@ -39,6 +39,8 @@ Ownership is transferred to the layout.

virtual int type() const;

virtual QIcon icon() const;

virtual QString displayName() const;


@@ -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
@@ -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;


@@ -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;


@@ -39,6 +39,8 @@ Constructor for QgsLayoutItemMap, with the specified parent ``layout``.

virtual int type() const;

virtual QIcon icon() const;


void assignFreeId();
%Docstring
@@ -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
@@ -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;


@@ -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;


@@ -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
@@ -36,6 +36,8 @@ Constructor for QgsLayoutItemShape, with the specified parent ``layout``.

virtual int type() const;

virtual QIcon icon() const;


virtual QString displayName() const;

@@ -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;
@@ -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 )
@@ -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
@@ -25,6 +25,7 @@
#include "qgslayoutundocommand.h"
#include "qgslayoutmeasurement.h"
#include <QGraphicsRectItem>
#include <QIcon>
#include <QPainter>

class QgsLayout;
@@ -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.
@@ -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 );
@@ -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;

/**
@@ -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 );
@@ -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.
@@ -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();
@@ -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;

@@ -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 )
@@ -77,6 +77,7 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem
static QgsLayoutItemLegend *create( QgsLayout *layout ) SIP_FACTORY;

int type() const override;
QIcon icon() const override;
//Overridden to show legend title
QString displayName() const override;

@@ -75,6 +75,11 @@ int QgsLayoutItemMap::type() const
return QgsLayoutItemRegistry::LayoutMap;
}

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

void QgsLayoutItemMap::assignFreeId()
{
if ( !mLayout )
@@ -70,6 +70,7 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem
~QgsLayoutItemMap() override;

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

/**
* Sets the map id() to a number not yet used in the layout. The existing id() is kept if it is not in use.
@@ -71,6 +71,11 @@ int QgsLayoutItemPicture::type() const
return QgsLayoutItemRegistry::LayoutPicture;
}

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

QgsLayoutItemPicture *QgsLayoutItemPicture::create( QgsLayout *layout )
{
return new QgsLayoutItemPicture( layout );
@@ -71,6 +71,7 @@ class CORE_EXPORT QgsLayoutItemPicture: public QgsLayoutItem
QgsLayoutItemPicture( QgsLayout *layout );

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

/**
* Returns a new picture item for the specified \a layout.
@@ -47,6 +47,11 @@ int QgsLayoutItemPolygon::type() const
return QgsLayoutItemRegistry::LayoutPolygon;
}

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

bool QgsLayoutItemPolygon::_addNode( const int indexPoint,
QPointF newPoint,
const double radius )
@@ -52,6 +52,7 @@ class CORE_EXPORT QgsLayoutItemPolygon: public QgsLayoutNodesItem
static QgsLayoutItemPolygon *create( QgsLayout *layout ) SIP_FACTORY;

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

/**
@@ -48,6 +48,11 @@ int QgsLayoutItemPolyline::type() const
return QgsLayoutItemRegistry::LayoutPolyline;
}

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

bool QgsLayoutItemPolyline::_addNode( const int indexPoint,
QPointF newPoint,
const double radius )
@@ -59,6 +59,7 @@ class CORE_EXPORT QgsLayoutItemPolyline: public QgsLayoutNodesItem
static QgsLayoutItemPolyline *create( QgsLayout *layout ) SIP_FACTORY;

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

/**
@@ -52,6 +52,11 @@ int QgsLayoutItemScaleBar::type() const
return QgsLayoutItemRegistry::LayoutScaleBar;
}

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

QgsLayoutItemScaleBar *QgsLayoutItemScaleBar::create( QgsLayout *layout )
{
return new QgsLayoutItemScaleBar( layout );

0 comments on commit 0a40a81

Please sign in to comment.
You can’t perform that action at this time.