30 QList < QPair<Qt::PenStyle, QString> > styles;
31 styles << qMakePair( Qt::SolidLine, tr(
"Solid Line" ) )
32 << qMakePair( Qt::NoPen, tr(
"No Pen" ) )
33 << qMakePair( Qt::DashLine, tr(
"Dash Line" ) )
34 << qMakePair( Qt::DotLine, tr(
"Dot Line" ) )
35 << qMakePair( Qt::DashDotLine, tr(
"Dash Dot Line" ) )
36 << qMakePair( Qt::DashDotDotLine, tr(
"Dash Dot Dot Line" ) );
39 setIconSize( QSize( iconSize * 2, iconSize ) );
41 for (
int i = 0; i < styles.count(); i++ )
43 Qt::PenStyle style = styles.at( i ).first;
44 QString name = styles.at( i ).second;
45 addItem(
iconForPen( style ), name, QVariant( (
int ) style ) );
51 return ( Qt::PenStyle ) currentData().toInt();
56 int idx = findData( QVariant( (
int ) style ) );
57 setCurrentIndex( idx == -1 ? 0 : idx );
62 QPixmap pix( iconSize() );
64 pix.fill( Qt::transparent );
70 double mid = iconSize().height() / 2.0;
71 p.drawLine( 0, mid, iconSize().width(), mid );
85 addItem( QIcon( path +
"/join_bevel.svg" ), tr(
"Bevel" ), QVariant( Qt::BevelJoin ) );
86 addItem( QIcon( path +
"/join_miter.svg" ), tr(
"Miter" ), QVariant( Qt::MiterJoin ) );
87 addItem( QIcon( path +
"/join_round.svg" ), tr(
"Round" ), QVariant( Qt::RoundJoin ) );
92 return ( Qt::PenJoinStyle ) currentData().toInt();
97 int idx = findData( QVariant( style ) );
98 setCurrentIndex( idx == -1 ? 0 : idx );
106 : QComboBox( parent )
109 addItem( QIcon( path +
"/cap_square.svg" ), tr(
"Square" ), QVariant( Qt::SquareCap ) );
110 addItem( QIcon( path +
"/cap_flat.svg" ), tr(
"Flat" ), QVariant( Qt::FlatCap ) );
111 addItem( QIcon( path +
"/cap_round.svg" ), tr(
"Round" ), QVariant( Qt::RoundCap ) );
116 return ( Qt::PenCapStyle ) currentData().toInt();
121 int idx = findData( QVariant( style ) );
122 setCurrentIndex( idx == -1 ? 0 : idx );
void setPenStyle(Qt::PenStyle style)
static QString defaultThemePath()
Returns the path to the default theme directory.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
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)