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

Merge tag '1.5.43' into develop

Finish 1.5.43
This commit is contained in:
Arin Alexander 2020-03-19 20:29:37 +03:00
commit e4c5c46e44
16 changed files with 190 additions and 36 deletions

View File

@ -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}\\\"

View File

@ -0,0 +1,20 @@
#ifndef LREDITABLEIMAGEITEMINTF_H
#define LREDITABLEIMAGEITEMINTF_H
#include <QByteArray>
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

View File

@ -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)
{

View File

@ -30,11 +30,12 @@
#ifndef LRIMAGEITEM_H
#define LRIMAGEITEM_H
#include "lritemdesignintf.h"
#include "lreditableimageitemintf.h"
#include <QtGlobal>
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;
};
}

View File

@ -5,12 +5,12 @@
#include <QFileInfo>
#include <QFileDialog>
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();
}

View File

@ -2,6 +2,7 @@
#define LRIMAGEITEMEDITOR_H
#include <QWidget>
#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();

View File

@ -1,5 +1,7 @@
#include "lrsvgitem.h"
#include "lrdesignelementsfactory.h"
#include "lrimageitemeditor.h"
#include "lrpagedesignintf.h"
#include <QtSvg>
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){

View File

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

View File

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

View File

@ -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<BandDesignIntf*>(patternItem());
arrangeSubItems(pass, dataManager);
if (autoHeight()){

View File

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

View File

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

View File

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

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>378</height>
<width>521</width>
<height>445</height>
</rect>
</property>
<property name="sizePolicy">
@ -30,8 +30,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>250</height>
<width>503</width>
<height>301</height>
</rect>
</property>
<attribute name="label">
@ -215,8 +215,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>250</height>
<width>503</width>
<height>301</height>
</rect>
</property>
<attribute name="label">
@ -304,8 +304,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>250</height>
<width>503</width>
<height>301</height>
</rect>
</property>
<attribute name="label">

View File

@ -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)){

View File

@ -1161,6 +1161,10 @@ p, li { white-space: pre-wrap; }
<source>Edit</source>
<translation>Правка</translation>
</message>
<message>
<source>Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*)</source>
<translation>Изображения (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;Все файлы(*.*)</translation>
</message>
</context>
<context>
<name>LimeReport::ItemLocationPropItem</name>
@ -2548,6 +2552,25 @@ This preview is no longer valid.</source>
<translation>Использовать первую строку в качестве заголовка</translation>
</message>
</context>
<context>
<name>LimeReport::SVGItem</name>
<message>
<source>SVG Image</source>
<translation>Изображение в формате SVG</translation>
</message>
<message>
<source>Edit</source>
<translation>Правка</translation>
</message>
<message>
<source>Watermark</source>
<translation>Водный знак</translation>
</message>
<message>
<source>SVG (*.svg)</source>
<translation>SVG (*.svg)</translation>
</message>
</context>
<context>
<name>LimeReport::ScriptBrowser</name>
<message>
@ -2797,6 +2820,13 @@ This preview is no longer valid.</source>
<translation>Заголовок подчиненных данных</translation>
</message>
</context>
<context>
<name>LimeReport::SvgEditor</name>
<message>
<source>Select image file</source>
<translation>Выбрать файл изображения</translation>
</message>
</context>
<context>
<name>LimeReport::TearOffBand</name>
<message>
@ -3237,5 +3267,9 @@ This preview is no longer valid.</source>
<source>Series</source>
<translation>Ряды данных</translation>
</message>
<message>
<source>SVG Item</source>
<translation>Элемент SVG избражение</translation>
</message>
</context>
</TS>