fix button ui
This commit is contained in:
parent
c268171e48
commit
81b4d256b8
1 changed files with 10 additions and 15 deletions
|
|
@ -28,8 +28,6 @@ Control.Button {
|
||||||
// rightPadding: 20 * DefaultStyle.dp
|
// rightPadding: 20 * DefaultStyle.dp
|
||||||
// topPadding: 11 * DefaultStyle.dp
|
// topPadding: 11 * DefaultStyle.dp
|
||||||
// bottomPadding: 11 * DefaultStyle.dp
|
// bottomPadding: 11 * DefaultStyle.dp
|
||||||
implicitHeight: contentItem.implicitHeight + bottomPadding + topPadding
|
|
||||||
implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -58,12 +56,6 @@ Control.Button {
|
||||||
: mainItem.disabledColor
|
: mainItem.disabledColor
|
||||||
radius: mainItem.radius
|
radius: mainItem.radius
|
||||||
border.color: inversedColors ? mainItem.color : mainItem.borderColor
|
border.color: inversedColors ? mainItem.color : mainItem.borderColor
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MultiEffect {
|
MultiEffect {
|
||||||
enabled: mainItem.shadowEnabled
|
enabled: mainItem.shadowEnabled
|
||||||
|
|
@ -80,8 +72,10 @@ Control.Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
component ButtonText: Text {
|
component ButtonText: Text {
|
||||||
|
id: buttonText
|
||||||
horizontalAlignment: mainItem.textHAlignment
|
horizontalAlignment: mainItem.textHAlignment
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
width: textMetrics.advanceWidth
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
text: mainItem.text
|
text: mainItem.text
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
|
|
@ -94,6 +88,11 @@ Control.Button {
|
||||||
underline: mainItem.underline
|
underline: mainItem.underline
|
||||||
bold: mainItem.font.bold
|
bold: mainItem.font.bold
|
||||||
}
|
}
|
||||||
|
TextMetrics {
|
||||||
|
id: textMetrics
|
||||||
|
text: mainItem.text
|
||||||
|
font: buttonText.font
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component ButtonImage: EffectImage {
|
component ButtonImage: EffectImage {
|
||||||
|
|
@ -106,11 +105,6 @@ Control.Button {
|
||||||
|
|
||||||
contentItem: Control.StackView{
|
contentItem: Control.StackView{
|
||||||
id: stacklayout
|
id: stacklayout
|
||||||
width: mainItem.width
|
|
||||||
height: mainItem.height
|
|
||||||
// TODO Qt bug : contentItem is never changed....
|
|
||||||
implicitHeight: !!contentItem && contentItem.implicitHeight ? contentItem.implicitHeight : 0
|
|
||||||
implicitWidth: !!contentItem && contentItem.implicitWidth ? contentItem.implicitWidth: 0
|
|
||||||
function updateComponent(){
|
function updateComponent(){
|
||||||
var item
|
var item
|
||||||
var component = mainItem.text.length != 0 && mainItem.icon.source.toString().length != 0
|
var component = mainItem.text.length != 0 && mainItem.icon.source.toString().length != 0
|
||||||
|
|
@ -143,8 +137,6 @@ Control.Button {
|
||||||
Component{
|
Component{
|
||||||
id: imageTextComponent
|
id: imageTextComponent
|
||||||
RowLayout {
|
RowLayout {
|
||||||
width: stacklayout.width
|
|
||||||
height: stacklayout.height
|
|
||||||
spacing: mainItem.spacing
|
spacing: mainItem.spacing
|
||||||
ButtonImage{
|
ButtonImage{
|
||||||
Layout.preferredWidth: mainItem.icon.width
|
Layout.preferredWidth: mainItem.icon.width
|
||||||
|
|
@ -152,6 +144,9 @@ Control.Button {
|
||||||
}
|
}
|
||||||
ButtonText{
|
ButtonText{
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
}
|
||||||
|
Item{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue