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