Add text alignment option to Flat Button
This commit is contained in:
parent
8f14fba5db
commit
7c608fad0f
|
@ -45,6 +45,7 @@ void QtMaterialFlatButtonPrivate::init()
|
|||
iconPlacement = Material::LeftIcon;
|
||||
overlayStyle = Material::GrayOverlay;
|
||||
bgMode = Qt::TransparentMode;
|
||||
textAlignment = Qt::AlignHCenter;
|
||||
fixedRippleRadius = 64;
|
||||
cornerRadius = 3;
|
||||
baseOpacity = 0.13;
|
||||
|
@ -440,6 +441,20 @@ void QtMaterialFlatButton::setFixedRippleRadius(qreal radius)
|
|||
setHasFixedRippleRadius(true);
|
||||
}
|
||||
|
||||
void QtMaterialFlatButton::setTextAlignment(Qt::Alignment alignment)
|
||||
{
|
||||
Q_D(QtMaterialFlatButton);
|
||||
|
||||
d->textAlignment = alignment;
|
||||
}
|
||||
|
||||
Qt::Alignment QtMaterialFlatButton::textAlignment() const
|
||||
{
|
||||
Q_D(const QtMaterialFlatButton);
|
||||
|
||||
return d->textAlignment;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
|
|
|
@ -78,6 +78,9 @@ public:
|
|||
|
||||
void setFixedRippleRadius(qreal radius);
|
||||
|
||||
void setTextAlignment(Qt::Alignment alignment);
|
||||
Qt::Alignment textAlignment() const;
|
||||
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
Material::ButtonIconPlacement iconPlacement;
|
||||
Material::OverlayStyle overlayStyle;
|
||||
Qt::BGMode bgMode;
|
||||
Qt::Alignment textAlignment;
|
||||
QColor backgroundColor;
|
||||
QColor foregroundColor;
|
||||
QColor overlayColor;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>549</width>
|
||||
<height>281</height>
|
||||
<height>314</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
|
@ -202,14 +202,14 @@
|
|||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="cornerRadiusSpinBox"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="overlayOpacityLabel">
|
||||
<property name="text">
|
||||
<string>Overlay opacity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="overlayOpacityDoubleSpinBox">
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
|
@ -219,36 +219,57 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="iconSizeLabel">
|
||||
<property name="text">
|
||||
<string>Icon size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QSpinBox" name="iconSizeSpinBox"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="fontSizeLabel">
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QDoubleSpinBox" name="fontSizeDoubleSpinBox"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="buttonTextLabel">
|
||||
<property name="text">
|
||||
<string>Button text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QLineEdit" name="buttonTextLineEdit"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="textAlignmentLabel">
|
||||
<property name="text">
|
||||
<string>Text alignment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="textAlignmentComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Center</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Reference in New Issue