29 QList < QPair<Qt::PenStyle, QString> > styles;
30 styles << qMakePair( Qt::SolidLine, tr(
"Solid Line" ) )
31 << qMakePair( Qt::NoPen, tr(
"No Pen" ) )
32 << qMakePair( Qt::DashLine, tr(
"Dash Line" ) )
33 << qMakePair( Qt::DotLine, tr(
"Dot Line" ) )
34 << qMakePair( Qt::DashDotLine, tr(
"Dash Dot Line" ) )
35 << qMakePair( Qt::DashDotDotLine, tr(
"Dash Dot Dot Line" ) );
37 setIconSize( QSize( 32, 12 ) );
39 for (
int i = 0; i < styles.count(); i++ )
41 Qt::PenStyle style = styles.at( i ).first;
42 QString name = styles.at( i ).second;
43 addItem(
iconForPen( style ), name, QVariant( (
int ) style ) );
49 return ( Qt::PenStyle ) currentData().toInt();
54 int idx = findData( QVariant( (
int ) style ) );
55 setCurrentIndex( idx == -1 ? 0 : idx );
60 QPixmap pix( iconSize() );
62 pix.fill( Qt::transparent );
68 double mid = iconSize().height() / 2.0;
69 p.drawLine( 0, mid, iconSize().width(), mid );
83 addItem( QIcon( path +
"/join_bevel.svg" ), tr(
"Bevel" ), QVariant( Qt::BevelJoin ) );
84 addItem( QIcon( path +
"/join_miter.svg" ), tr(
"Miter" ), QVariant( Qt::MiterJoin ) );
85 addItem( QIcon( path +
"/join_round.svg" ), tr(
"Round" ), QVariant( Qt::RoundJoin ) );
90 return ( Qt::PenJoinStyle ) currentData().toInt();
95 int idx = findData( QVariant( style ) );
96 setCurrentIndex( idx == -1 ? 0 : idx );
104 : QComboBox( parent )
107 addItem( QIcon( path +
"/cap_square.svg" ), tr(
"Square" ), QVariant( Qt::SquareCap ) );
108 addItem( QIcon( path +
"/cap_flat.svg" ), tr(
"Flat" ), QVariant( Qt::FlatCap ) );
109 addItem( QIcon( path +
"/cap_round.svg" ), tr(
"Round" ), QVariant( Qt::RoundCap ) );
114 return ( Qt::PenCapStyle ) currentData().toInt();
119 int idx = findData( QVariant( style ) );
120 setCurrentIndex( idx == -1 ? 0 : idx );
void setPenStyle(Qt::PenStyle style)
static QString defaultThemePath()
Returns the path to the default theme directory.
void setPenCapStyle(Qt::PenCapStyle style)
QgsPenJoinStyleComboBox(QWidget *parent=nullptr)
Qt::PenJoinStyle penJoinStyle() const
void setPenJoinStyle(Qt::PenJoinStyle style)
QIcon iconForPen(Qt::PenStyle style)
Qt::PenCapStyle penCapStyle() const
QgsPenCapStyleComboBox(QWidget *parent=nullptr)
Qt::PenStyle penStyle() const
QgsPenStyleComboBox(QWidget *parent=nullptr)