added shadow property for baseitem

This commit is contained in:
yanis60 2022-05-04 18:21:14 +01:00
parent 52f43f946b
commit db57157690
6 changed files with 174 additions and 102 deletions

View File

@ -80,7 +80,7 @@ void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter->save();
QPen pen(m_shapeColor);
pen.setWidthF(m_lineWidth+1);
pen.setWidthF(m_lineWidth);
pen.setStyle(m_penStyle);
pen.setJoinStyle(Qt::MiterJoin);
painter->setPen(pen);

View File

@ -87,7 +87,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_unitType(Millimeters),
m_itemGeometryLocked(false),
m_isChangingPos(false),
m_isMoveable(false)
m_isMoveable(false),
m_shadow(false)
{
@ -426,16 +427,17 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
Q_UNUSED(option);
Q_UNUSED(widget);
ppainter->save();
ppainter->setRenderHint(QPainter::HighQualityAntialiasing);
setupPainter(ppainter);
drawBorder(ppainter, rect());
// if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);}
// if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);}
if(m_shadow)
drawShadow(ppainter, rect());
// if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);}
// if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);}
drawResizeZone(ppainter);
ppainter->restore();
// if (m_hovered) ppainter->drawImage(
// QRectF(QPointF(rect().topRight().x()-24, rect().bottomLeft().y()-24),
// QSizeF(24, 24)),QImage(":/items/images/settings.png"));
// if (m_hovered) ppainter->drawImage(
// QRectF(QPointF(rect().topRight().x()-24, rect().bottomLeft().y()-24),
// QSizeF(24, 24)),QImage(":/items/images/settings.png"));
}
QColor calcColor(QColor color){
@ -772,6 +774,21 @@ bool BaseDesignIntf::isShapeItem() const
return QString(metaObject()->className()) == "LimeReport::ShapeItem";
}
bool BaseDesignIntf::hasShadow()
{
return m_shadow;
}
void BaseDesignIntf::setShadow(bool sh)
{
if (m_shadow != sh){
bool oldValue = m_shadow;
m_shadow = sh;
notify("shadow",oldValue,m_shadow);
update();
}
}
bool BaseDesignIntf::isGeometryLocked() const
{
return m_itemGeometryLocked;
@ -1110,6 +1127,32 @@ void BaseDesignIntf::drawBorder(QPainter *painter, QRectF rect) const
painter->restore();
}
void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect) const
{
qreal shWidth = rect.width()/100;
QRectF rshadow(rect.topRight() + QPointF(0, shWidth),
rect.bottomRight() + QPointF(shWidth, 0));
QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
rgrad.setColorAt(0.0, QColor(0,0,0,255));
rgrad.setColorAt(1.0, QColor(0,0,0,0));
painter->fillRect(rshadow, QBrush(rgrad));
QRectF bshadow(rect.bottomLeft() + QPointF(shWidth, 0),
rect.bottomRight() + QPointF(0, shWidth));
QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
bgrad.setColorAt(0.0, QColor(0,0,0,255));
bgrad.setColorAt(1.0, QColor(0,0,0,0));
painter->fillRect(bshadow, QBrush(bgrad));
QRectF cshadow(rect.bottomRight(),
rect.bottomRight() + QPointF(shWidth, shWidth));
QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
cgrad.setColorAt(0.0, QColor(0,0,0,255));
cgrad.setColorAt(1.0, QColor(0,0,0,0));
painter->fillRect(cshadow, QBrush(cgrad));
}
void BaseDesignIntf::setGeometry(QRectF rect)
{
if (m_rect == rect) return;
@ -1468,14 +1511,14 @@ void BaseDesignIntf::setMarginSize(int value)
void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/)
{
// if (m_resizeAreas.count() > 0) {
// painter->save();
// painter->setPen(QPen(Const::RESIZE_ZONE_COLOR));
// (isSelected()) ? painter->setOpacity(Const::SELECTED_RESIZE_ZONE_OPACITY) : painter->setOpacity(Const::RESIZE_ZONE_OPACITY);
// painter->setBrush(QBrush(Qt::green, Qt::SolidPattern));
// foreach(QRectF * resizeArea, m_resizeAreas) painter->drawRect(*resizeArea);
// painter->restore();
// }
// if (m_resizeAreas.count() > 0) {
// painter->save();
// painter->setPen(QPen(Const::RESIZE_ZONE_COLOR));
// (isSelected()) ? painter->setOpacity(Const::SELECTED_RESIZE_ZONE_OPACITY) : painter->setOpacity(Const::RESIZE_ZONE_OPACITY);
// painter->setBrush(QBrush(Qt::green, Qt::SolidPattern));
// foreach(QRectF * resizeArea, m_resizeAreas) painter->drawRect(*resizeArea);
// painter->restore();
// }
}

View File

@ -92,6 +92,7 @@ class BaseDesignIntf :
Q_PROPERTY(QString parentName READ parentReportItemName WRITE setParentReportItem DESIGNABLE false)
Q_PROPERTY(int borderLineSize READ borderLineSize WRITE setBorderLineSize)
Q_PROPERTY(bool isVisible READ isVisible WRITE setItemVisible DESIGNABLE false)
Q_PROPERTY(bool shadow READ hasShadow WRITE setShadow)
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
Q_PROPERTY(bool geometryLocked READ isGeometryLocked WRITE setGeometryLocked)
Q_PROPERTY(Qt::PenStyle borderStyle READ borderStyle WRITE setBorderStyle)
@ -335,7 +336,8 @@ public:
bool isChangingPos() const;
void setIsChangingPos(bool isChangingPos);
bool isShapeItem() const;
bool hasShadow();
void setShadow(bool sh);
Q_INVOKABLE QString setItemWidth(qreal width);
Q_INVOKABLE QString setItemHeight(qreal height);
Q_INVOKABLE qreal getItemWidth();
@ -384,6 +386,7 @@ protected:
void drawBorder(QPainter* painter, QRectF rect) const;
void drawShadow(QPainter* painter, QRectF rect) const;
void drawDesignModeBorder(QPainter* painter, QRectF rect) const;
void drawRenderModeBorder(QPainter *painter, QRectF rect) const;
void drawResizeZone(QPainter*);
@ -443,6 +446,7 @@ private:
bool m_fixedPos;
int m_borderLineSize;
QRectF m_rect;
mutable QRectF m_boundingRect;
@ -487,6 +491,7 @@ private:
bool m_itemGeometryLocked;
bool m_isChangingPos;
bool m_isMoveable;
bool m_shadow;
signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);

View File

@ -98,6 +98,26 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte
paintGrid(ppainter, rect);
ppainter->setPen(gridColor());
ppainter->drawRect(boundingRect());
//Draw shadow
qreal shWidth = boundingRect().width()/100;
QRectF rshadow(boundingRect().topRight() + QPointF(0, shWidth),
boundingRect().bottomRight() + QPointF(shWidth, 0));
QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
rgrad.setColorAt(0.0, QColor(0,0,0,255));
rgrad.setColorAt(1.0, QColor(0,0,0,0));
ppainter->fillRect(rshadow, QBrush(rgrad));
QRectF bshadow(boundingRect().bottomLeft() + QPointF(shWidth, 0),
boundingRect().bottomRight() + QPointF(0, shWidth));
QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
bgrad.setColorAt(0.0, QColor(0,0,0,255));
bgrad.setColorAt(1.0, QColor(0,0,0,0));
ppainter->fillRect(bshadow, QBrush(bgrad));
QRectF cshadow(boundingRect().bottomRight(),
boundingRect().bottomRight() + QPointF(shWidth, shWidth));
QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
cgrad.setColorAt(0.0, QColor(0,0,0,255));
cgrad.setColorAt(1.0, QColor(0,0,0,0));
ppainter->fillRect(cshadow, QBrush(cgrad));
if (m_isExtendedInDesignMode){
QPen pen;
pen.setColor(Qt::red);
@ -109,6 +129,7 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte
ppainter->restore();
}
if (itemMode() & PreviewMode) {
ppainter->save();
ppainter->fillRect(rect(), Qt::white);
@ -123,6 +144,9 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte
ppainter->restore();
BaseDesignIntf::paint(ppainter,option,widget);
}
}
BaseDesignIntf *PageItemDesignIntf::createSameTypeItem(QObject *owner, QGraphicsItem *parent)

View File

@ -554,53 +554,53 @@ p, li { white-space: pre-wrap; }
<context>
<name>LimeReport::BaseDesignIntf</name>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1385"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1813"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1428"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1856"/>
<source>Lock item geometry</source>
<translation>Verrouiller la géométrie d&apos;un élément</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1391"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1434"/>
<source>Copy</source>
<translation>Copier</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1393"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1436"/>
<source>Cut</source>
<translation>Couper</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1395"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1438"/>
<source>Paste</source>
<translation>Coller</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1405"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1448"/>
<source>Bring to top</source>
<translation>Placer au premier-plan</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1406"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1449"/>
<source>Send to back</source>
<translation>Placer en arrière-plan</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1409"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1452"/>
<source>Create Horizontal Layout</source>
<translation>Créer une disposition horizontale</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1413"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1456"/>
<source>Create Vertical Layout</source>
<translation>Créer une disposition verticale</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1416"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1459"/>
<source>No borders</source>
<translation>Aucune bordure</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1417"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1460"/>
<source>All borders</source>
<translation>Toutes les bordures</translation>
</message>
@ -1697,37 +1697,37 @@ p, li { white-space: pre-wrap; }
<context>
<name>LimeReport::PageItemDesignIntf</name>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="750"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="774"/>
<source>Paste</source>
<translation>Coller</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="756"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="784"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="780"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="808"/>
<source>Page is TOC</source>
<translation>Table de contenus</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="760"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="787"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="784"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="811"/>
<source>Reset page number</source>
<translation>Réinitialiser le numéro de page</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="764"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="790"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="788"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="814"/>
<source>Full page</source>
<translation>Page entière</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="768"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="793"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="792"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="817"/>
<source>Set page size to printer</source>
<translation>Adapterr la taille de la page à l&apos;imprimante</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="772"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="797"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="796"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="821"/>
<source>Mix with prior page</source>
<translation type="unfinished"></translation>
</message>
@ -1745,7 +1745,7 @@ p, li { white-space: pre-wrap; }
<translation>%1 nom de fichier</translation>
</message>
<message>
<location filename="../limereport/lrpreviewreportwidget.cpp" line="289"/>
<location filename="../limereport/lrpreviewreportwidget.cpp" line="290"/>
<source>Report file name</source>
<translation>Nom du fichier du rapport</translation>
</message>

View File

@ -566,53 +566,53 @@ p, li { white-space: pre-wrap; }
<context>
<name>LimeReport::BaseDesignIntf</name>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1385"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1813"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1428"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1856"/>
<source>Lock item geometry</source>
<translation>Zablokuj geometrię pozycji</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1391"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1434"/>
<source>Copy</source>
<translation>Kopiuj</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1393"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1436"/>
<source>Cut</source>
<translation>Wytnij</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1395"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1438"/>
<source>Paste</source>
<translation>Wklej</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1405"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1448"/>
<source>Bring to top</source>
<translation>Przenieś na górę</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1406"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1449"/>
<source>Send to back</source>
<translation>Przenieś na dół</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1409"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1452"/>
<source>Create Horizontal Layout</source>
<translation>Utwórz układ poziomy</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1413"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1456"/>
<source>Create Vertical Layout</source>
<translation>Utwórz układ pionowy</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1416"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1459"/>
<source>No borders</source>
<translation>Bez obramowania</translation>
</message>
<message>
<location filename="../limereport/lrbasedesignintf.cpp" line="1417"/>
<location filename="../limereport/lrbasedesignintf.cpp" line="1460"/>
<source>All borders</source>
<translation>Pełne obramowanie</translation>
</message>
@ -1709,37 +1709,37 @@ p, li { white-space: pre-wrap; }
<context>
<name>LimeReport::PageItemDesignIntf</name>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="750"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="774"/>
<source>Paste</source>
<translation>Wklej</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="756"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="784"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="780"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="808"/>
<source>Page is TOC</source>
<translation>Strona to spis treści</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="760"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="787"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="784"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="811"/>
<source>Reset page number</source>
<translation>Zresetuj numer strony</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="764"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="790"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="788"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="814"/>
<source>Full page</source>
<translation>Cała strona</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="768"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="793"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="792"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="817"/>
<source>Set page size to printer</source>
<translation>Ustaw rozmiar strony na drukarkę</translation>
</message>
<message>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="772"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="797"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="796"/>
<location filename="../limereport/lrpageitemdesignintf.cpp" line="821"/>
<source>Mix with prior page</source>
<translation type="unfinished"></translation>
</message>
@ -1757,7 +1757,7 @@ p, li { white-space: pre-wrap; }
<translation>%1 nazwa pliku</translation>
</message>
<message>
<location filename="../limereport/lrpreviewreportwidget.cpp" line="289"/>
<location filename="../limereport/lrpreviewreportwidget.cpp" line="290"/>
<source>Report file name</source>
<translation>Nazwa pliku raportu</translation>
</message>