diff --git a/common.pri b/common.pri index e1bd053..4080819 100644 --- a/common.pri +++ b/common.pri @@ -134,7 +134,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 42 +LIMEREPORT_VERSION_RELEASE = 43 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/items/lreditableimageitemintf.h b/limereport/items/lreditableimageitemintf.h new file mode 100644 index 0000000..d470b64 --- /dev/null +++ b/limereport/items/lreditableimageitemintf.h @@ -0,0 +1,20 @@ +#ifndef LREDITABLEIMAGEITEMINTF_H +#define LREDITABLEIMAGEITEMINTF_H + +#include + +namespace LimeReport { + +class IEditableImageItem{ +public: + virtual QByteArray imageAsByteArray() const = 0; + virtual void setImageAsByteArray(QByteArray image) = 0; + virtual QString resourcePath() const = 0; + virtual void setResourcePath(const QString &value) = 0; + virtual QString fileFilter() const = 0; +}; + +} + + +#endif // LREDITABLEIMAGEITEMINTF_H diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 0ded44b..0baaac1 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -141,6 +141,37 @@ QWidget *ImageItem::defaultEditor() return editor; } +QByteArray ImageItem::imageAsByteArray() const +{ + QByteArray result; + QBuffer buffer(&result); + buffer.open(QIODevice::WriteOnly); + m_picture.save(&buffer,"PNG"); + + return result; +} + +void ImageItem::setImageAsByteArray(QByteArray image) +{ + QImage value; + value.loadFromData(image); + if (m_picture != value){ + QImage oldValue = m_picture; + m_picture = value; + if (m_autoSize){ + setWidth(m_picture.width()); + setHeight(m_picture.height()); + } + update(); + notify("image",oldValue,value); + } +} + +QString ImageItem::fileFilter() const +{ + return tr("Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*)"); +} + void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index a8bc51a..bf36257 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -30,11 +30,12 @@ #ifndef LRIMAGEITEM_H #define LRIMAGEITEM_H #include "lritemdesignintf.h" +#include "lreditableimageitemintf.h" #include namespace LimeReport{ -class ImageItem : public ItemDesignIntf, public IPainterProxy +class ImageItem : public ItemDesignIntf, public IPainterProxy, public IEditableImageItem { Q_OBJECT Q_PROPERTY(QImage image READ image WRITE setImage) @@ -95,6 +96,10 @@ public: void setUseExternalPainter(bool value); QWidget* defaultEditor(); + + QByteArray imageAsByteArray() const; + void setImageAsByteArray(QByteArray image); + QString fileFilter() const; protected: BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight); @@ -117,6 +122,7 @@ private: bool m_center; Format m_format; QString m_variable; + }; } diff --git a/limereport/items/lrimageitemeditor.cpp b/limereport/items/lrimageitemeditor.cpp index 9e34df9..8cba803 100644 --- a/limereport/items/lrimageitemeditor.cpp +++ b/limereport/items/lrimageitemeditor.cpp @@ -5,12 +5,12 @@ #include #include -ImageItemEditor::ImageItemEditor(LimeReport::ImageItem *item, QWidget *parent) : +ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *parent) : QWidget(parent), ui(new Ui::ImageItemEditor), m_item(item) { ui->setupUi(this); - m_image = QPixmap::fromImage(m_item->image()); + m_image = item->imageAsByteArray(); ui->resourcePath->setText(m_item->resourcePath()); updateImage(); } @@ -22,30 +22,35 @@ ImageItemEditor::~ImageItemEditor() void ImageItemEditor::updateImage() { - ui->imageViewer->setPixmap(m_image); - if (m_image.isNull() && !ui->resourcePath->text().isEmpty()){ - if (m_resourcePathImage.isNull()) - m_resourcePathImage = QPixmap(ui->resourcePath->text()); - ui->imageViewer->setPixmap(m_resourcePathImage); + QPixmap image; + if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()){ + image.load(ui->resourcePath->text()); + } else { + image.loadFromData(m_image); } + ui->imageViewer->setPixmap(image); } void ImageItemEditor::on_tbLoadImage_clicked() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file")); - m_image = QPixmap(fileName); + QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", m_item->fileFilter()); + QFile file(fileName); + if (file.open(QIODevice::ReadOnly)){ + m_image = file.readAll(); + } updateImage(); } void ImageItemEditor::on_tbClearImage_clicked() { - m_image = QPixmap(); + m_image.clear(); updateImage(); } void ImageItemEditor::on_buttonBox_accepted() { - m_item->setImage(m_image.toImage()); + QImage image; + m_item->setImageAsByteArray(m_image); m_item->setResourcePath(ui->resourcePath->text()); this->close(); } diff --git a/limereport/items/lrimageitemeditor.h b/limereport/items/lrimageitemeditor.h index 551baae..80bc9c3 100644 --- a/limereport/items/lrimageitemeditor.h +++ b/limereport/items/lrimageitemeditor.h @@ -2,6 +2,7 @@ #define LRIMAGEITEMEDITOR_H #include +#include "lreditableimageitemintf.h" namespace Ui { class ImageItemEditor; @@ -16,15 +17,17 @@ class ImageItemEditor : public QWidget Q_OBJECT public: - explicit ImageItemEditor(LimeReport::ImageItem* item, QWidget *parent = NULL); + explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget *parent = NULL); ~ImageItemEditor(); private: void updateImage(); private: Ui::ImageItemEditor *ui; - LimeReport::ImageItem* m_item; - QPixmap m_image; + LimeReport::IEditableImageItem* m_item; + + QByteArray m_image; QPixmap m_resourcePathImage; + private slots: void on_tbLoadImage_clicked(); void on_tbClearImage_clicked(); diff --git a/limereport/items/lrsvgitem.cpp b/limereport/items/lrsvgitem.cpp index 4a50af9..7595b13 100644 --- a/limereport/items/lrsvgitem.cpp +++ b/limereport/items/lrsvgitem.cpp @@ -1,5 +1,7 @@ #include "lrsvgitem.h" #include "lrdesignelementsfactory.h" +#include "lrimageitemeditor.h" +#include "lrpagedesignintf.h" #include namespace{ @@ -39,6 +41,51 @@ void SVGItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q } ItemDesignIntf::paint(painter,option,widget); painter->restore(); +} + +QByteArray SVGItem::imageAsByteArray() const +{ + return m_image; +} + +void SVGItem::setImageAsByteArray(QByteArray image) +{ + setImage(image); +} + +QString SVGItem::fileFilter() const +{ + return tr("SVG (*.svg)"); +} + +void SVGItem::preparePopUpMenu(QMenu &menu) +{ + QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit")); + menu.insertAction(menu.actions().at(0),editAction); + menu.insertSeparator(menu.actions().at(1)); + + menu.addSeparator(); + QAction* action = menu.addAction(tr("Watermark")); + action->setCheckable(true); + action->setChecked(isWatermark()); +} + +void SVGItem::processPopUpAction(QAction *action) +{ + if (action->text().compare(tr("Watermark")) == 0){ + page()->setPropertyToSelectedItems("watermark",action->isChecked()); + } + if (action->text().compare(tr("Edit")) == 0){ + this->showEditorDialog(); + } + ItemDesignIntf::processPopUpAction(action); +} + +QWidget *SVGItem::defaultEditor() +{ + ImageItemEditor* editor = new ImageItemEditor(this); + editor->setAttribute(Qt::WA_DeleteOnClose); + return editor; }; BaseDesignIntf* SVGItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent){ diff --git a/limereport/items/lrsvgitem.h b/limereport/items/lrsvgitem.h index cae58e0..36aea98 100644 --- a/limereport/items/lrsvgitem.h +++ b/limereport/items/lrsvgitem.h @@ -2,9 +2,10 @@ #define SVGITEM_H #include "lritemdesignintf.h" +#include "lreditableimageitemintf.h" namespace LimeReport{ -class SVGItem: public ItemDesignIntf +class SVGItem: public ItemDesignIntf, public IEditableImageItem { Q_OBJECT Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath) @@ -18,6 +19,14 @@ public: SVGItem(QObject *owner, QGraphicsItem *parent); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + QByteArray imageAsByteArray() const; + void setImageAsByteArray(QByteArray image); + QString fileFilter() const; + + void preparePopUpMenu(QMenu &menu); + void processPopUpAction(QAction *action); + QWidget* defaultEditor(); + QString resourcePath() const; void setResourcePath(const QString &resourcePath); QByteArray image() const; @@ -39,6 +48,8 @@ private: QString m_datasource; QString m_field; QString m_variable; +public: + }; } // namespace LimeReport #endif // SVGITEM_H diff --git a/limereport/limereport.pri b/limereport/limereport.pri index cecf5b4..68ad8e7 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -105,6 +105,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { } HEADERS += \ + $$PWD/items/lreditableimageitemintf.h \ $$REPORT_PATH/base/lrsingleton.h \ $$REPORT_PATH/base/lrsimpleabstractfactory.h \ $$REPORT_PATH/base/lrattribsabstractfactory.h \ diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 474a842..008e9a6 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -137,6 +137,7 @@ void BandMarker::mouseMoveEvent(QGraphicsSceneMouseEvent* event) void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { + Q_UNUSED(event) m_band->posChanged(m_band, m_band->pos(), m_oldBandPos); } @@ -1129,7 +1130,6 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p spaceBorder += m_bottomSpace; restoreLinks(); snapshotItemsLayout(); - BandDesignIntf* patternBand = dynamic_cast(patternItem()); arrangeSubItems(pass, dataManager); if (autoHeight()){ diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 5f8f7e1..52aba2c 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -492,6 +492,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer) { + Q_UNUSED(printer) if (pages.count()>0){ Q_Q(ReportEngine); PreviewReportWindow* w = new PreviewReportWindow(q, 0, settings()); @@ -2054,6 +2055,7 @@ qreal WatermarkHelper::valueToPixels(qreal value) case LimeReport::ItemGeometry::Pixels: return value; } + return -1; } diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index a022f41..d62d667 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -190,6 +190,7 @@ void ReportRender::initDatasource(const QString& name){ } void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){ + Q_UNUSED(band) if (contentItem){ QString content = contentItem->content(); QVector functions; diff --git a/limereport/lrsettingdialog.cpp b/limereport/lrsettingdialog.cpp index bff304c..05374a3 100644 --- a/limereport/lrsettingdialog.cpp +++ b/limereport/lrsettingdialog.cpp @@ -7,18 +7,11 @@ namespace LimeReport{ SettingDialog::SettingDialog(QWidget *parent) : - QDialog(parent), m_settings(0), - ui(new Ui::SettingDialog) + QDialog(parent), + ui(new Ui::SettingDialog), m_settings(0) { ui->setupUi(this); ui->toolBox->setCurrentIndex(0); -// ui->cbTheme->addItem(QObject::tr("Default")); -// if (isFileExists(":/qdarkstyle/style.qss")){ -// ui->cbTheme->addItem(QObject::tr("Dark")); -// } -// if (isFileExists(":/qlightstyle/lightstyle.qss")){ -// ui->cbTheme->addItem(QObject::tr("Light")); -// } ui->indentSize->setRange(0,10); } diff --git a/limereport/lrsettingdialog.ui b/limereport/lrsettingdialog.ui index 3c197bf..6664f63 100644 --- a/limereport/lrsettingdialog.ui +++ b/limereport/lrsettingdialog.ui @@ -6,8 +6,8 @@ 0 0 - 419 - 378 + 521 + 445 @@ -30,8 +30,8 @@ 0 0 - 401 - 250 + 503 + 301 @@ -215,8 +215,8 @@ 0 0 - 401 - 250 + 503 + 301 @@ -304,8 +304,8 @@ 0 0 - 401 - 250 + 503 + 301 diff --git a/limereport/objectinspector/editors/lrsvgeditor.cpp b/limereport/objectinspector/editors/lrsvgeditor.cpp index 37952e7..f394f8f 100644 --- a/limereport/objectinspector/editors/lrsvgeditor.cpp +++ b/limereport/objectinspector/editors/lrsvgeditor.cpp @@ -29,7 +29,7 @@ QByteArray SvgEditor::image() void SvgEditor::slotButtonClicked() { - QString fileName = QFileDialog::getOpenFileName(this, "", "SVG| *.svg"); + QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", "SVG (*.svg)"); if (!fileName.isEmpty()){ QFile file(fileName); if (file.open(QIODevice::ReadOnly)){ diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index e6211ba..47156ee 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -1161,6 +1161,10 @@ p, li { white-space: pre-wrap; } Edit Правка + + Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*) + Изображения (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;Все файлы(*.*) + LimeReport::ItemLocationPropItem @@ -2548,6 +2552,25 @@ This preview is no longer valid. Использовать первую строку в качестве заголовка + + LimeReport::SVGItem + + SVG Image + Изображение в формате SVG + + + Edit + Правка + + + Watermark + Водный знак + + + SVG (*.svg) + SVG (*.svg) + + LimeReport::ScriptBrowser @@ -2797,6 +2820,13 @@ This preview is no longer valid. Заголовок подчиненных данных + + LimeReport::SvgEditor + + Select image file + Выбрать файл изображения + + LimeReport::TearOffBand @@ -3237,5 +3267,9 @@ This preview is no longer valid. Series Ряды данных + + SVG Item + Элемент SVG избражение +