2019-12-06 18:06:19 +01:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.1
|
|
|
|
import QtQuick.Controls.Material 2.1
|
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
Loader {
|
|
|
|
id: control
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
property QIconSource icon: QIconSource {}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
property int fontPixelSize
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
property string text
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
signal clicked
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
Connections {
|
|
|
|
target: icon
|
|
|
|
onNameChanged: {
|
2019-12-06 18:06:19 +01:00
|
|
|
control.syncProperties()
|
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
onTextChanged: {
|
|
|
|
control.syncProperties()
|
|
|
|
}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
function syncProperties() {
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
if(control.status !== Loader.Ready) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(QtCompatiblityMode) {
|
|
|
|
control.item.text = control.text
|
|
|
|
control.item.font = control.font
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
if(control.fontPixelSize !== undefined) {
|
|
|
|
control.item.font.pixelSize = control.fontPixelSize
|
2019-12-06 18:06:19 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
else {
|
|
|
|
control.item.icon.name = control.icon.name
|
|
|
|
control.item.icon.color = control.icon.color
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
control.item.icon.width = control.icon.width
|
|
|
|
control.item.icon.height = control.icon.height
|
2019-12-06 18:06:19 +01:00
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
onLoaded: {
|
|
|
|
control.syncProperties()
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
if(QtCompatiblityMode) {
|
|
|
|
control.sourceComponent = ancientToolButtonCp
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
control.sourceComponent = modernToolButtonCp
|
2019-12-06 18:06:19 +01:00
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
Connections {
|
|
|
|
target: control.item
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
onClicked: {
|
|
|
|
control.clicked()
|
2019-12-06 18:06:19 +01:00
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
Component {
|
|
|
|
id: ancientToolButtonCp
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
ToolButton {
|
|
|
|
id: tb
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
opacity: enabled ? 1.0 : 0.3
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
contentItem: Text {
|
|
|
|
text: tb.text
|
|
|
|
font: tb.font
|
|
|
|
color: app.style.style.textColor
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
elide: Text.ElideRight
|
2019-12-06 18:06:19 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
}
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
Component {
|
|
|
|
id: modernToolButtonCp
|
2019-12-06 18:06:19 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
ToolButton {
|
|
|
|
height: implicitHeight
|
|
|
|
width: implicitWidth
|
2019-12-06 18:06:19 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-07 15:38:35 +01:00
|
|
|
|
|
|
|
}
|