0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

Watermark has been fixed

This commit is contained in:
Arin Alexander 2019-04-06 00:28:02 +03:00
parent c7a3517f11
commit 602e8a82f6
4 changed files with 37 additions and 37 deletions

View File

@ -98,8 +98,8 @@ private:
class LIMEREPORT_EXPORT WatermarkSetting{ class LIMEREPORT_EXPORT WatermarkSetting{
public: public:
WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font) WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font)
: m_text(text), m_font(font), m_opacity(50), m_geomerty(geometry), m_color(QColor(Qt::black)){} : m_text(text), m_font(font), m_opacity(50), m_geometry(geometry), m_color(QColor(Qt::black)){}
WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geomerty(ItemGeometry()){} WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()){}
QString text() const; QString text() const;
void setText(const QString &text); void setText(const QString &text);
@ -109,8 +109,8 @@ public:
int opacity() const; int opacity() const;
void setOpacity(const int &opacity); void setOpacity(const int &opacity);
ItemGeometry geomerty() const; ItemGeometry geometry() const;
void setGeomerty(const ItemGeometry &geomerty); void setGeometry(const ItemGeometry &geometry);
QColor color() const; QColor color() const;
void setColor(const QColor &color); void setColor(const QColor &color);
@ -119,7 +119,7 @@ private:
QString m_text; QString m_text;
QFont m_font; QFont m_font;
int m_opacity; int m_opacity;
ItemGeometry m_geomerty; ItemGeometry m_geometry;
QColor m_color; QColor m_color;
}; };

View File

@ -1165,9 +1165,9 @@ void ReportEnginePrivate::paintByExternalPainter(const QString& objectName, QPai
BaseDesignIntf* ReportEnginePrivate::createWatermark(PageDesignIntf* page, WatermarkSetting watermarkSetting) BaseDesignIntf* ReportEnginePrivate::createWatermark(PageDesignIntf* page, WatermarkSetting watermarkSetting)
{ {
ItemGeometryHelper geometry(watermarkSetting.geomerty()); WatermarkHelper watermarkHelper(watermarkSetting);
BaseDesignIntf* watermark = page->addReportItem("TextItem", geometry.mapToPage(*page->pageItem()), geometry.sceneSize()); BaseDesignIntf* watermark = page->addReportItem("TextItem", watermarkHelper.mapToPage(*page->pageItem()), watermarkHelper.sceneSize());
if (watermark){ if (watermark){
watermark->setProperty("content", watermarkSetting.text()); watermark->setProperty("content", watermarkSetting.text());
watermark->setProperty("font",watermarkSetting.font()); watermark->setProperty("font",watermarkSetting.font());
@ -1794,14 +1794,14 @@ void WatermarkSetting::setOpacity(const int &opacity)
m_opacity = opacity; m_opacity = opacity;
} }
ItemGeometry WatermarkSetting::geomerty() const ItemGeometry WatermarkSetting::geometry() const
{ {
return m_geomerty; return m_geometry;
} }
void WatermarkSetting::setGeomerty(const ItemGeometry &geomerty) void WatermarkSetting::setGeometry(const ItemGeometry &geometry)
{ {
m_geomerty = geomerty; m_geometry = geometry;
} }
QColor WatermarkSetting::color() const QColor WatermarkSetting::color() const
@ -1814,52 +1814,52 @@ void WatermarkSetting::setColor(const QColor &color)
m_color = color; m_color = color;
} }
qreal ItemGeometryHelper::sceneX() qreal WatermarkHelper::sceneX()
{ {
return valueToPixels(m_geometry.x()); return valueToPixels(m_watermark.geometry().x());
} }
qreal ItemGeometryHelper::sceneY() qreal WatermarkHelper::sceneY()
{ {
return valueToPixels(m_geometry.y()); return valueToPixels(m_watermark.geometry().y());
} }
qreal ItemGeometryHelper::sceneWidth() qreal WatermarkHelper::sceneWidth()
{ {
return valueToPixels(m_geometry.width()); return valueToPixels(m_watermark.geometry().width());
} }
qreal ItemGeometryHelper::sceneHeight() qreal WatermarkHelper::sceneHeight()
{ {
return valueToPixels(m_geometry.height()); return valueToPixels(m_watermark.geometry().height());
} }
QPointF ItemGeometryHelper::scenePos() QPointF WatermarkHelper::scenePos()
{ {
return (QPointF(sceneX(), sceneY())); return (QPointF(sceneX(), sceneY()));
} }
QSizeF ItemGeometryHelper::sceneSize() QSizeF WatermarkHelper::sceneSize()
{ {
return (QSizeF(sceneWidth(), sceneHeight())); return (QSizeF(sceneWidth(), sceneHeight()));
} }
QPointF ItemGeometryHelper::mapToPage(const PageItemDesignIntf &page) QPointF WatermarkHelper::mapToPage(const PageItemDesignIntf &page)
{ {
qreal startX = 0; qreal startX = 0;
qreal startY = 0; qreal startY = 0;
if ( m_geometry.anchor() & Qt::AlignLeft){ if ( m_watermark.geometry().anchor() & Qt::AlignLeft){
startX = 0; startX = 0;
} else if (m_geometry.anchor() & Qt::AlignRight){ } else if ( m_watermark.geometry().anchor() & Qt::AlignRight){
startX = page.geometry().width(); startX = page.geometry().width();
} else { } else {
startX = page.geometry().width() / 2; startX = page.geometry().width() / 2;
} }
if ( m_geometry.anchor() & Qt::AlignTop){ if ( m_watermark.geometry().anchor() & Qt::AlignTop){
startY = 0; startY = 0;
} else if (m_geometry.anchor() & Qt::AlignBottom){ } else if (m_watermark.geometry().anchor() & Qt::AlignBottom){
startY = page.geometry().height(); startY = page.geometry().height();
} else { } else {
startY = page.geometry().height() / 2; startY = page.geometry().height() / 2;
@ -1868,9 +1868,9 @@ QPointF ItemGeometryHelper::mapToPage(const PageItemDesignIntf &page)
return QPointF(startX + sceneX(), startY + sceneY()); return QPointF(startX + sceneX(), startY + sceneY());
} }
qreal ItemGeometryHelper::valueToPixels(qreal value) qreal WatermarkHelper::valueToPixels(qreal value)
{ {
switch (m_geometry.type()) { switch (m_watermark.geometry().type()) {
case LimeReport::ItemGeometry::Milimeters: case LimeReport::ItemGeometry::Milimeters:
return value * Const::mmFACTOR; return value * Const::mmFACTOR;
case LimeReport::ItemGeometry::Pixels: case LimeReport::ItemGeometry::Pixels:

View File

@ -98,8 +98,8 @@ private:
class LIMEREPORT_EXPORT WatermarkSetting{ class LIMEREPORT_EXPORT WatermarkSetting{
public: public:
WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font) WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font)
: m_text(text), m_font(font), m_opacity(50), m_geomerty(geometry), m_color(QColor(Qt::black)){} : m_text(text), m_font(font), m_opacity(50), m_geometry(geometry), m_color(QColor(Qt::black)){}
WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geomerty(ItemGeometry()){} WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()){}
QString text() const; QString text() const;
void setText(const QString &text); void setText(const QString &text);
@ -109,8 +109,8 @@ public:
int opacity() const; int opacity() const;
void setOpacity(const int &opacity); void setOpacity(const int &opacity);
ItemGeometry geomerty() const; ItemGeometry geometry() const;
void setGeomerty(const ItemGeometry &geomerty); void setGeometry(const ItemGeometry &geometry);
QColor color() const; QColor color() const;
void setColor(const QColor &color); void setColor(const QColor &color);
@ -119,7 +119,7 @@ private:
QString m_text; QString m_text;
QFont m_font; QFont m_font;
int m_opacity; int m_opacity;
ItemGeometry m_geomerty; ItemGeometry m_geometry;
QColor m_color; QColor m_color;
}; };

View File

@ -57,10 +57,10 @@ class ReportDesignWindow;
class ReportExporterInterface; class ReportExporterInterface;
class ItemGeometryHelper{ class WatermarkHelper{
public: public:
ItemGeometryHelper(const ItemGeometry& geometry) WatermarkHelper(const WatermarkSetting& watermark)
: m_geometry(geometry){} : m_watermark(watermark){}
qreal sceneX(); qreal sceneX();
qreal sceneY(); qreal sceneY();
qreal sceneWidth(); qreal sceneWidth();
@ -71,7 +71,7 @@ public:
private: private:
qreal valueToPixels(qreal value); qreal valueToPixels(qreal value);
private: private:
const ItemGeometry& m_geometry; const WatermarkSetting& m_watermark;
}; };
class ReportEnginePrivateInterface { class ReportEnginePrivateInterface {