From 785b6cec67e865c10b09ac90bc25cbdd9645d1a6 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Thu, 22 Mar 2018 20:26:07 +0300 Subject: [PATCH] Watermark property can be changed by context menu --- limereport/items/lrimageitem.cpp | 15 +++++++++++++++ limereport/items/lrimageitem.h | 2 ++ limereport/items/lrtextitem.cpp | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 72f5a62..a271cda 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -31,6 +31,7 @@ #include "lrdesignelementsfactory.h" #include "lrglobal.h" #include "lrdatasourcemanager.h" +#include "lrpagedesignintf.h" namespace{ @@ -76,6 +77,20 @@ void ImageItem::loadPictureFromVariant(QVariant& data){ } } +void ImageItem::preparePopUpMenu(QMenu &menu) +{ + QAction* action = menu.addAction(tr("Watermark")); + action->setCheckable(true); + action->setChecked(isWatermark()); +} + +void ImageItem::processPopUpAction(QAction *action) +{ + if (action->text().compare(tr("Watermark")) == 0){ + page()->setPropertyToSelectedItems("watermark",action->isChecked()); + } +} + void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index 4c16699..f6713df 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -87,6 +87,8 @@ protected: bool isNeedUpdateSize(RenderPass) const; bool drawDesignBorders() const {return m_picture.isNull();} void loadPictureFromVariant(QVariant& data); + void preparePopUpMenu(QMenu &menu); + void processPopUpAction(QAction *action); private: QImage m_picture; QString m_resourcePath; diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 772f084..47318dc 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -111,6 +111,9 @@ void TextItem::preparePopUpMenu(QMenu &menu) action->setCheckable(true); action->setChecked(backgroundMode() == TransparentMode); + action = menu.addAction(tr("Watermark")); + action->setCheckable(true); + action->setChecked(isWatermark()); } void TextItem::processPopUpAction(QAction *action) @@ -137,6 +140,9 @@ void TextItem::processPopUpAction(QAction *action) setProperty("backgroundMode",OpaqueMode); } } + if (action->text().compare(tr("Watermark")) == 0){ + page()->setPropertyToSelectedItems("watermark",action->isChecked()); + } } void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, QWidget* widget) {