forked from qt-creator/qt-creator
Adds classes to merge a template qml file and a qml stylesheet that have been exported from other design tools into a resulting qml file that can be used for further processing in Qt Design Studio. Current issues: * Sometimes it makes sense to define width and height if an anchor is present, but most of the time not. * Actually if the hierachy was defined (e.g. Text item not child of background) most likely the anchors should be ignored. But this would be just a "dirty" heuristic. I suggest to let the template decide. If the template has anchors those have "precedence". It is always possible to define templates without anchors. Task-number: QDS-2071 Change-Id: I9159514a8e884b7ffc31897aef4551b5efbbcb87 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
101 lines
2.8 KiB
QML
101 lines
2.8 KiB
QML
import QtQuick 2.10
|
|
import QtQuick.Templates 2.1 as T
|
|
|
|
T.Button {
|
|
id: control
|
|
|
|
implicitWidth: Math.max(
|
|
background ? background.implicitWidth : 0,
|
|
contentItem.implicitWidth + leftPadding + rightPadding)
|
|
implicitHeight: Math.max(
|
|
background ? background.implicitHeight : 0,
|
|
contentItem.implicitHeight + topPadding + bottomPadding)
|
|
leftPadding: 4
|
|
rightPadding: 4
|
|
|
|
text: "My Button"
|
|
|
|
background: Item {
|
|
implicitWidth: buttonNormal.width
|
|
implicitHeight: buttonNormal.height
|
|
opacity: enabled ? 1 : 0.3
|
|
|
|
Rectangle {
|
|
|
|
id: buttonNormal
|
|
color: "#d4d4d4"
|
|
width: 100 //Bit of black magic to define the default size
|
|
height: 40
|
|
|
|
border.color: "gray"
|
|
border.width: 1
|
|
radius: 2
|
|
anchors.fill: parent //binding has to be preserved
|
|
|
|
Text {
|
|
id: normalText //id only required to preserve binding
|
|
text: control.text //binding has to be preserved
|
|
anchors.fill: parent
|
|
color: "gray"
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
verticalAlignment: Text.AlignVCenter
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
id: buttonPressed
|
|
color: "#d4d4d4"
|
|
width: 100 //Bit of black magic to define the default size
|
|
height: 40
|
|
|
|
border.color: "gray"
|
|
border.width: 1
|
|
radius: 2
|
|
anchors.fill: parent //binding has to be preserved
|
|
|
|
Text {
|
|
id: pressedText //id only required to preserve binding
|
|
text: control.text //binding has to be preserved
|
|
anchors.fill: parent
|
|
color: "black"
|
|
|
|
horizontalAlignment: Text.AlignHCenter // should not be preserved
|
|
verticalAlignment: Text.AlignVCenter // should not be preserved
|
|
elide: Text.ElideRight // should not be preserved
|
|
}
|
|
}
|
|
}
|
|
|
|
contentItem: Item {}
|
|
|
|
states: [
|
|
State {
|
|
name: "normal"
|
|
when: !control.down
|
|
PropertyChanges {
|
|
target: buttonPressed
|
|
visible: false
|
|
}
|
|
PropertyChanges {
|
|
target: buttonNormal
|
|
visible: true
|
|
}
|
|
},
|
|
State {
|
|
name: "down"
|
|
when: control.down
|
|
PropertyChanges {
|
|
target: buttonPressed
|
|
visible: true
|
|
}
|
|
PropertyChanges {
|
|
target: buttonNormal
|
|
visible: false
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|