Look for image files from substitution fields relative to project file.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeData>
|
||||
#include <QtDebug>
|
||||
@@ -280,6 +281,22 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get directory.
|
||||
///
|
||||
QString Model::dir() const
|
||||
{
|
||||
if ( mFileName.isEmpty() )
|
||||
{
|
||||
return QDir::currentPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QFileInfo( mFileName ).absolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get short name.
|
||||
///
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace glabels
|
||||
void setModified();
|
||||
void clearModified();
|
||||
|
||||
QString dir() const;
|
||||
QString shortName();
|
||||
const QString& fileName() const;
|
||||
void setFileName( const QString &fileName );
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
#include "ModelImageObject.h"
|
||||
|
||||
#include "Model.h"
|
||||
#include "Size.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QImage>
|
||||
#include <QPen>
|
||||
@@ -431,7 +433,12 @@ namespace glabels
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* image = new QImage( mFilenameNode.text( record, variables ) );
|
||||
// Look for image file relative to project file 1st then CWD 2nd
|
||||
auto* model = dynamic_cast<Model*>( parent() );
|
||||
QDir::setSearchPaths( "images", {model->dir(), QDir::currentPath()} );
|
||||
QString filename = QString("images:") + mFilenameNode.text( record, variables );
|
||||
|
||||
auto* image = new QImage( filename );
|
||||
if ( !image->isNull() && image->hasAlphaChannel() && (image->depth() == 32) )
|
||||
{
|
||||
QImage* shadowImage = createShadowImage( *image, shadowColor );
|
||||
@@ -528,7 +535,12 @@ namespace glabels
|
||||
}
|
||||
else if ( mFilenameNode.isField() )
|
||||
{
|
||||
auto* image = new QImage( mFilenameNode.text( record, variables ) );
|
||||
// Look for image file relative to project file 1st then CWD 2nd
|
||||
auto* model = dynamic_cast<Model*>( parent() );
|
||||
QDir::setSearchPaths( "images", {model->dir(), QDir::currentPath()} );
|
||||
QString filename = QString("images:") + mFilenameNode.text( record, variables );
|
||||
|
||||
auto* image = new QImage( filename );
|
||||
if ( !image->isNull() )
|
||||
{
|
||||
painter->drawImage( destRect, *image );
|
||||
|
||||
+1
-1
@@ -407,7 +407,7 @@ namespace glabels
|
||||
void draw( QPainter* painter,
|
||||
bool inEditor,
|
||||
merge::Record* record,
|
||||
Variables* variables ) const;
|
||||
Variables* variables ) const;
|
||||
|
||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||
|
||||
|
||||
@@ -496,8 +496,18 @@ namespace glabels
|
||||
XmlUtil::setStringAttr( node, "type", Variable::typeToIdString( v.type() ) );
|
||||
XmlUtil::setStringAttr( node, "name", v.name() );
|
||||
XmlUtil::setStringAttr( node, "initialValue", v.initialValue() );
|
||||
XmlUtil::setStringAttr( node, "increment", Variable::incrementToIdString( v.increment() ) );
|
||||
XmlUtil::setStringAttr( node, "stepSize", v.stepSize() );
|
||||
|
||||
if ( (v.type() == Variable::Type::INTEGER) ||
|
||||
(v.type() == Variable::Type::FLOATING_POINT) )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "increment",
|
||||
Variable::incrementToIdString( v.increment() ) );
|
||||
|
||||
if ( v.increment() != Variable::Increment::NEVER )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "stepSize", v.stepSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user