mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-10-01 11:40:02 +03:00
SVGItem has been added
This commit is contained in:
48
limereport/objectinspector/editors/lrsvgeditor.cpp
Normal file
48
limereport/objectinspector/editors/lrsvgeditor.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "lrsvgeditor.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileDialog>
|
||||
#include "lrimageeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
SvgEditor::SvgEditor(QWidget* parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
m_button.setIcon(QIcon(":items/ImageItem"));
|
||||
m_clearButton.setIcon(QIcon(":items/clear.png"));
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(&m_button);
|
||||
layout->addWidget(&m_clearButton);
|
||||
layout->setSpacing(1);
|
||||
layout->setContentsMargins(1,0,1,1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(&m_button);
|
||||
setAutoFillBackground(true);
|
||||
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
connect(&m_clearButton,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
|
||||
}
|
||||
|
||||
QByteArray SvgEditor::image()
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
void SvgEditor::slotButtonClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "", "SVG| *.svg");
|
||||
if (!fileName.isEmpty()){
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly)){
|
||||
m_image = file.readAll();
|
||||
}
|
||||
}
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
void SvgEditor::slotClearButtonClicked()
|
||||
{
|
||||
m_image = QByteArray();
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
}
|
29
limereport/objectinspector/editors/lrsvgeditor.h
Normal file
29
limereport/objectinspector/editors/lrsvgeditor.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef SVGEDITOR_H
|
||||
#define SVGEDITOR_H
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class SvgEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SvgEditor(QWidget *parent=0);
|
||||
QByteArray image();
|
||||
void setImage(const QByteArray& image){m_image=image;}
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
void slotClearButtonClicked();
|
||||
private:
|
||||
QPushButton m_button;
|
||||
QPushButton m_clearButton;
|
||||
QByteArray m_image;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // SVGEDITOR_H
|
Reference in New Issue
Block a user