Merge pull request #417 from rangemastersystems/master

Add ImageItem::isEmpty, Fix: ImageItem::paint
This commit is contained in:
Alexander Arin 2022-11-01 11:45:20 +03:00 committed by GitHub
commit 33dce7ef27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

@ -111,14 +111,14 @@ void ImageItem::processPopUpAction(QAction *action)
ItemDesignIntf::processPopUpAction(action);
}
QImage getFileByResourcePath(QString resourcePath){
QImage getFileByResourcePath(QString resourcePath) {
QFileInfo resourceFile(resourcePath);
if (resourceFile.exists())
return QImage(resourcePath);
return QImage();
}
QImage ImageItem::drawImage()
QImage ImageItem::drawImage() const
{
if (image().isNull())
return getFileByResourcePath(m_resourcePath);
@ -364,7 +364,7 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
}
if (shiftHeight > 0){
point.setY(point.x()+shiftHeight/2);
point.setY(point.y()+shiftHeight/2);
} else {
cutY = fabs(shiftHeight/2);
cutHeigth += shiftHeight;
@ -410,7 +410,7 @@ void ImageItem::setImage(QImage value)
}
}
QImage ImageItem::image(){
QImage ImageItem::image() const{
return m_picture;
}
@ -439,3 +439,8 @@ void ImageItem::setFormat(Format format)
}
}
bool LimeReport::ImageItem::isEmpty() const
{
return drawImage().isNull();
}

View File

@ -67,7 +67,7 @@ public:
ImageItem(QObject *owner, QGraphicsItem *parent);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setImage(QImage value);
QImage image();
QImage image() const;
void setResourcePath(const QString &value);
QString resourcePath() const;
QString datasource() const;
@ -108,7 +108,7 @@ protected:
void loadPictureFromVariant(QVariant& data);
void preparePopUpMenu(QMenu &menu);
void processPopUpAction(QAction *action);
QImage drawImage();
QImage drawImage() const;
private:
QImage m_picture;
bool m_useExternalPainter;
@ -121,8 +121,12 @@ private:
bool m_keepAspectRatio;
bool m_center;
Format m_format;
QString m_variable;
QString m_variable;
// BaseDesignIntf interface
public:
bool isEmpty() const override;
};
}

View File

@ -389,6 +389,7 @@ void TextItem::setTextFont(TextPtr text, const QFont& value) const {
void TextItem::adaptFontSize(TextPtr text) const{
QFont _font = transformToSceneFont(font());
do{
// qApp->processEvents();
setTextFont(text,_font);
if (_font.pixelSize()>2)
_font.setPixelSize(_font.pixelSize()-1);