Control orientation of labels in NewLabelDialog.
This commit is contained in:
@@ -55,6 +55,9 @@ namespace gLabels
|
|||||||
connect( pageSizeOtherRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
|
connect( pageSizeOtherRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
|
||||||
|
|
||||||
connect( templatePicker, SIGNAL(itemSelectionChanged()), this, SLOT(templatePickerSelectionChanged()) );
|
connect( templatePicker, SIGNAL(itemSelectionChanged()), this, SLOT(templatePickerSelectionChanged()) );
|
||||||
|
|
||||||
|
connect( orientationNormalRadio, SIGNAL(toggled(bool)), this, SLOT(orientationRadioToggled(bool)) );
|
||||||
|
connect( orientationRotatedRadio, SIGNAL(toggled(bool)), this, SLOT(orientationRadioToggled(bool)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,6 +84,8 @@ namespace gLabels
|
|||||||
|
|
||||||
void NewLabelDialog::templatePickerSelectionChanged()
|
void NewLabelDialog::templatePickerSelectionChanged()
|
||||||
{
|
{
|
||||||
|
orientationNormalRadio->setChecked( true );
|
||||||
|
|
||||||
QList<QListWidgetItem *> selectedItems = templatePicker->selectedItems();
|
QList<QListWidgetItem *> selectedItems = templatePicker->selectedItems();
|
||||||
|
|
||||||
if ( selectedItems.isEmpty() )
|
if ( selectedItems.isEmpty() )
|
||||||
@@ -97,6 +102,7 @@ namespace gLabels
|
|||||||
const libglabels::Frame *frame = tmplate->frames().first();
|
const libglabels::Frame *frame = tmplate->frames().first();
|
||||||
|
|
||||||
simplePreview->setTemplate( tmplate );
|
simplePreview->setTemplate( tmplate );
|
||||||
|
simplePreview->setRotate( false );
|
||||||
|
|
||||||
const libglabels::Vendor *vendor = libglabels::Db::lookupVendorFromName( tmplate->brand() );
|
const libglabels::Vendor *vendor = libglabels::Db::lookupVendorFromName( tmplate->brand() );
|
||||||
if ( (vendor != NULL) && (vendor->url() != NULL) )
|
if ( (vendor != NULL) && (vendor->url() != NULL) )
|
||||||
@@ -148,7 +154,19 @@ namespace gLabels
|
|||||||
}
|
}
|
||||||
similarBrowser->setText( similarListString );
|
similarBrowser->setText( similarListString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orientationGroupBox->setEnabled( frame->w() != frame->h() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NewLabelDialog::orientationRadioToggled( bool checked )
|
||||||
|
{
|
||||||
|
if ( checked )
|
||||||
|
{
|
||||||
|
simplePreview->setRotate( orientationRotatedRadio->isChecked() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace gLabels
|
|||||||
void searchEntryTextChanged( const QString &text );
|
void searchEntryTextChanged( const QString &text );
|
||||||
void pageSizeRadioToggled( bool checked );
|
void pageSizeRadioToggled( bool checked );
|
||||||
void templatePickerSelectionChanged();
|
void templatePickerSelectionChanged();
|
||||||
|
void orientationRadioToggled( bool checked );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+46
-42
@@ -39,11 +39,11 @@ namespace
|
|||||||
const QColor labelOutlineColor( 128, 128, 255 );
|
const QColor labelOutlineColor( 128, 128, 255 );
|
||||||
const double labelOutlineWidthPixels = 2;
|
const double labelOutlineWidthPixels = 2;
|
||||||
|
|
||||||
const QColor arrowColor( 224, 224, 255 );
|
const QColor arrowColor( 192, 192, 255, 128 );
|
||||||
const double arrowScale = 0.35;
|
const double arrowScale = 0.35;
|
||||||
|
|
||||||
const QColor upColor( 224, 224, 255 );
|
const QColor upColor( 192, 192, 255, 128 );
|
||||||
const double upScale = 0.15;
|
const double upScale = 0.15;
|
||||||
const QString upFontFamily( "Sans" );
|
const QString upFontFamily( "Sans" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,47 +166,51 @@ namespace gLabels
|
|||||||
double w = frame->w();
|
double w = frame->w();
|
||||||
double h = frame->h();
|
double h = frame->h();
|
||||||
|
|
||||||
if ( w != h )
|
double min = ( w < h ) ? w : h;
|
||||||
|
|
||||||
|
QPen pen( arrowColor );
|
||||||
|
pen.setWidthF( 0.25*min*arrowScale );
|
||||||
|
pen.setCapStyle( Qt::FlatCap );
|
||||||
|
pen.setJoinStyle( Qt::MiterJoin );
|
||||||
|
|
||||||
|
QBrush brush( upColor );
|
||||||
|
|
||||||
|
libglabels::Point origin = frame->getOrigins().first();
|
||||||
|
double x0 = origin.x();
|
||||||
|
double y0 = origin.y();
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
path.moveTo( 0, min*arrowScale/3 );
|
||||||
|
path.lineTo( 0, -min*arrowScale );
|
||||||
|
path.moveTo( -min*arrowScale/2, -min*arrowScale/2 );
|
||||||
|
path.lineTo( 0, -min*arrowScale );
|
||||||
|
path.lineTo( min*arrowScale/2, -min*arrowScale/2 );
|
||||||
|
|
||||||
|
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
|
||||||
|
arrowItem->setPen( pen );
|
||||||
|
arrowItem->setPos( x0+w/2, y0+h/2 );
|
||||||
|
if ( mRotateFlag )
|
||||||
{
|
{
|
||||||
double min = ( w < h ) ? w : h;
|
arrowItem->setRotation( 90 );
|
||||||
|
|
||||||
QPen pen( arrowColor );
|
|
||||||
pen.setWidthF( 0.25*min*arrowScale );
|
|
||||||
pen.setCapStyle( Qt::FlatCap );
|
|
||||||
pen.setJoinStyle( Qt::MiterJoin );
|
|
||||||
|
|
||||||
QBrush brush( upColor );
|
|
||||||
|
|
||||||
libglabels::Point origin = frame->getOrigins().first();
|
|
||||||
double x0 = origin.x();
|
|
||||||
double y0 = origin.y();
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
path.moveTo( 0, min*arrowScale/3 );
|
|
||||||
path.lineTo( 0, -min*arrowScale );
|
|
||||||
path.moveTo( -min*arrowScale/2, -min*arrowScale/2 );
|
|
||||||
path.lineTo( 0, -min*arrowScale );
|
|
||||||
path.lineTo( min*arrowScale/2, -min*arrowScale/2 );
|
|
||||||
|
|
||||||
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
|
|
||||||
arrowItem->setPen( pen );
|
|
||||||
arrowItem->setPos( x0+w/2, y0+h/2 );
|
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
|
|
||||||
upItem->setBrush( brush );
|
|
||||||
upItem->setFont( QFont( upFontFamily, min*upScale, QFont::Bold ) );
|
|
||||||
QRectF rect = upItem->boundingRect();
|
|
||||||
upItem->setPos( x0+w/2-rect.width()/2, y0+h/2+min/8 );
|
|
||||||
|
|
||||||
if ( mRotateFlag )
|
|
||||||
{
|
|
||||||
arrowItem->setRotation( -90 );
|
|
||||||
upItem->setRotation( -90 );
|
|
||||||
}
|
|
||||||
|
|
||||||
mScene->addItem( arrowItem );
|
|
||||||
mScene->addItem( upItem );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
|
||||||
|
upItem->setBrush( brush );
|
||||||
|
upItem->setFont( QFont( upFontFamily, min*upScale, QFont::Bold ) );
|
||||||
|
upItem->setPos( x0+w/2, y0+h/2 );
|
||||||
|
QRectF rect = upItem->boundingRect();
|
||||||
|
if ( mRotateFlag )
|
||||||
|
{
|
||||||
|
upItem->setPos( upItem->x()-min/8, upItem->y()-rect.width()/2 );
|
||||||
|
upItem->setRotation( 90 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
upItem->setPos( upItem->x()-rect.width()/2, upItem->y()+min/8 );
|
||||||
|
}
|
||||||
|
|
||||||
|
mScene->addItem( arrowItem );
|
||||||
|
mScene->addItem( upItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">TextLabel</string>
|
<string notr="true">TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
@@ -327,7 +330,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="orientationGroupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
|||||||
Reference in New Issue
Block a user