Draw label layer in view.
This commit is contained in:
@@ -75,6 +75,7 @@ namespace glabels
|
||||
inline void setCompressionLevel( int compressionLevel );
|
||||
|
||||
inline const libglabels::Template* tmplate() const;
|
||||
inline const libglabels::Frame* frame() const;
|
||||
inline void setTmplate( const libglabels::Template* tmplate );
|
||||
|
||||
inline bool rotate() const;
|
||||
@@ -234,6 +235,12 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
inline const libglabels::Frame* LabelModel::frame() const
|
||||
{
|
||||
return mFrame;
|
||||
}
|
||||
|
||||
|
||||
inline void LabelModel::setTmplate( const libglabels::Template* tmplate )
|
||||
{
|
||||
if (mTmplate != tmplate)
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ namespace glabels
|
||||
setCentralWidget( tmp );
|
||||
#else
|
||||
LabelModel* model = new LabelModel();
|
||||
const libglabels::Template* tmplate = libglabels::Db::lookupTemplateFromName( "Avery 3612" );
|
||||
const libglabels::Template* tmplate = libglabels::Db::lookupTemplateFromName( "Avery 5163" );
|
||||
model->setTmplate( tmplate );
|
||||
LabelModelBoxObject* object = new LabelModelBoxObject();
|
||||
object->setW( 36 );
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "View.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
@@ -31,6 +32,14 @@ namespace
|
||||
const double zoomLevels[nZoomLevels] = { 8, 6, 4, 3, 2, 1.5, 1, 0.75, 0.67, 0.50, 0.33, 0.25, 0.15, 0.10 };
|
||||
|
||||
const double ZOOM_TO_FIT_PAD = 16;
|
||||
|
||||
const QColor shadowColor( 64, 64, 64 );
|
||||
const double shadowOffsetPixels = 3;
|
||||
const double shadowRadiusPixels = 12;
|
||||
|
||||
const QColor labelColor( 255, 255, 255 );
|
||||
const QColor labelOutlineColor( 0, 0, 0 );
|
||||
const double labelOutlineWidthPixels = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +53,9 @@ namespace glabels
|
||||
|
||||
setMouseTracking( true );
|
||||
|
||||
setAttribute( Qt::WA_TranslucentBackground );
|
||||
viewport()->setAutoFillBackground( false );
|
||||
|
||||
mScene = new QGraphicsScene();
|
||||
setScene( mScene );
|
||||
}
|
||||
@@ -53,6 +65,8 @@ namespace glabels
|
||||
{
|
||||
mModel = model;
|
||||
|
||||
createLabelLayer();
|
||||
|
||||
foreach (LabelModelObject* object, model->objectList() )
|
||||
{
|
||||
QGraphicsItem* item = object->createGraphicsItem();
|
||||
@@ -170,4 +184,27 @@ namespace glabels
|
||||
emit pointerExited();
|
||||
}
|
||||
|
||||
|
||||
void View::createLabelLayer()
|
||||
{
|
||||
QGraphicsPathItem *labelItem = new QGraphicsPathItem( mModel->frame()->path() );
|
||||
|
||||
QBrush brush( labelColor );
|
||||
labelItem->setBrush( brush );
|
||||
|
||||
QPen pen( labelOutlineColor );
|
||||
pen.setJoinStyle( Qt::MiterJoin );
|
||||
pen.setCosmetic( true );
|
||||
pen.setWidthF( labelOutlineWidthPixels );
|
||||
labelItem->setPen( pen );
|
||||
|
||||
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
|
||||
shadowEffect->setColor( shadowColor );
|
||||
shadowEffect->setOffset( shadowOffsetPixels );
|
||||
shadowEffect->setBlurRadius( shadowRadiusPixels );
|
||||
labelItem->setGraphicsEffect( shadowEffect );
|
||||
|
||||
mScene->addItem( labelItem );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,6 +87,13 @@ namespace glabels
|
||||
void leaveEvent( QEvent* event );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Private methods
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
void createLabelLayer();
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user