This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/resources/text.qml

59 lines
1.3 KiB
QML
Raw Normal View History

2021-02-25 19:04:14 +08:00
import QtQuick 2.12
import QtQuick.Controls 2.5
2021-03-18 11:27:26 +08:00
2021-03-16 15:20:46 +08:00
import "util.mjs" as Util
2021-03-18 11:27:26 +08:00
import "gravity.mjs" as Gravity
2021-02-25 19:04:14 +08:00
TextArea {
2021-04-06 16:14:43 +08:00
property var wrapper
2021-03-16 15:20:46 +08:00
property var uuid: Util.uuidv4()
2021-03-16 15:20:46 +08:00
property var tag: "Text"
readOnly: true
2021-03-16 15:20:46 +08:00
property int textAlignment: 0
background: Rectangle {
id: bg
color: 'transparent'
2021-03-16 15:20:46 +08:00
}
property var backgroundColor
2021-03-16 15:20:46 +08:00
onBackgroundColorChanged: {
bg.color = backgroundColor
2021-03-16 15:20:46 +08:00
}
onTextAlignmentChanged: {
let gravity = Gravity.enumerate()
let result = this.textAlignment | gravity.CENTER_Y
console.log(tag, uuid + " onTextAlignmentChanged: " + this.textAlignment)
switch(result) {
case gravity.CENTER:
this.horizontalAlignment = TextInput.AlignHCenter
this.verticalAlignment = TextInput.AlignVCenter
break
2021-03-18 11:27:26 +08:00
}
}
2021-03-18 11:49:52 +08:00
onWidthChanged: {
2021-04-13 21:14:17 +08:00
// bg.implicitWidth = width
console.log(tag, uuid + " onWidthChanged: " + this.width)
}
onHeightChanged: {
2021-04-13 21:14:17 +08:00
// bg.implicitHeight = height
console.log(tag, uuid + " onHeightChanged: " + this.height)
}
2021-03-18 11:49:52 +08:00
MouseArea {
anchors.fill: parent
onClicked: {
2021-04-07 10:41:34 +08:00
console.log(tag, uuid + " wrapper: " + wrapper)
mouseAreaBridge.onClick(wrapper)
2021-03-18 11:49:52 +08:00
}
}
2021-02-25 19:04:14 +08:00
}