17#include "moc_qgsalignmentcombobox.cpp"
27 connect(
this,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ]
36 mAlignments = alignments;
42 return static_cast< Qt::Alignment
>( currentData().toInt() );
47 const int index = findData( QVariant( alignment ) );
49 setCurrentIndex( index );
54 const int index = findData( QVariant( alignment ) );
57 if ( !text.isEmpty() )
58 setItemText( index, text );
60 setItemIcon( index, icon );
64void QgsAlignmentComboBox::populate()
71 if ( mAlignments & Qt::AlignLeft )
73 if ( mAlignments & Qt::AlignHCenter )
75 if ( mAlignments & Qt::AlignRight )
77 if ( mAlignments & Qt::AlignJustify )
80 if ( mAlignments & Qt::AlignTop )
82 if ( mAlignments & Qt::AlignVCenter )
84 if ( mAlignments & Qt::AlignBottom )
87 const int index = findData( QVariant( prevAlign ) );
89 setCurrentIndex( index );
91 mBlockChanged =
false;
QgsAlignmentComboBox(QWidget *parent=nullptr)
Constructor for QgsAlignmentComboBox, with the specified parent widget.
void changed()
Emitted when the alignment is changed.
void setCurrentAlignment(Qt::Alignment alignment)
Sets the current alignment choice.
void customizeAlignmentDisplay(Qt::Alignment alignment, const QString &text=QString(), const QIcon &icon=QIcon())
Sets the text and icon to use for a particular alignment option, replacing the default text or icon.
Qt::Alignment currentAlignment() const
Returns the current alignment choice.
void setAvailableAlignments(Qt::Alignment alignments)
Sets the available alignment choices shown in the combo box.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.