Commit | Line | Data |
---|---|---|
321b1d72 TB |
1 | import QtQuick |
2 | import QtQuick.Layouts | |
3 | ||
4 | Rectangle { | |
5 | id: root | |
1605f832 | 6 | |
321b1d72 TB |
7 | property alias text: t.text |
8 | property alias wrapMode: t.wrapMode | |
9 | property alias isClickable: ma.enabled | |
10 | property var clickHandler: undefined | |
11 | property string name: "unnamed" | |
12 | property int buffer: 6 | |
13 | property int textMaxWidth | |
14 | property var isTotallyCentered: undefined | |
15 | ||
16 | height: t.height + buffer | |
17 | width: t.width + buffer | |
18 | ||
321b1d72 | 19 | border { |
1605f832 TB |
20 | width: 1 |
21 | color: "red" | |
321b1d72 TB |
22 | } |
23 | Text { | |
1605f832 | 24 | id: t |
321b1d72 | 25 | |
1605f832 TB |
26 | anchors { |
27 | left: { | |
28 | if (typeof isTotallyCentered !== "undefined") { | |
29 | if (isTotallyCentered) { | |
30 | return undefined | |
31 | } | |
32 | } | |
33 | return parent.left | |
34 | } | |
35 | leftMargin: { | |
36 | if (typeof isTotallyCentered !== "undefined") { | |
37 | if (isTotallyCentered) { | |
38 | return undefined | |
39 | } | |
40 | } | |
41 | return 5 | |
42 | } | |
43 | fill: { | |
44 | if (typeof isTotallyCentered !== "undefined") { | |
45 | if (isTotallyCentered) { | |
46 | return parent | |
321b1d72 TB |
47 | } |
48 | } | |
49 | return undefined | |
50 | } | |
1605f832 TB |
51 | } |
52 | ||
53 | horizontalAlignment: { | |
54 | if (typeof isTotallyCentered !== "undefined") { | |
55 | if (isTotallyCentered) { | |
56 | return Text.AlignHCenter | |
57 | } | |
58 | } | |
59 | return Text.AlignLeft | |
321b1d72 | 60 | } |
1605f832 TB |
61 | verticalAlignment: { |
62 | if (typeof isTotallyCentered !== "undefined") { | |
63 | if (isTotallyCentered) { | |
64 | return Text.AlignVCenter | |
65 | } | |
66 | } | |
67 | return Text.AlignTop | |
321b1d72 | 68 | } |
1605f832 TB |
69 | |
70 | text: "unset" | |
71 | wrapMode: Text.WordWrap | |
72 | width: parent.width | |
321b1d72 | 73 | } |
1605f832 TB |
74 | |
75 | function _l_on_clicked() { | |
76 | console.error("button '" + root.name + "' clicked") | |
77 | if (typeof clickHandler !== "undefined") { | |
78 | clickHandler() | |
79 | } | |
80 | } | |
81 | ||
321b1d72 | 82 | MouseArea { |
1605f832 TB |
83 | id: ma |
84 | ||
85 | anchors.fill: parent | |
321b1d72 | 86 | |
1605f832 TB |
87 | enabled: false |
88 | onClicked: _l_on_clicked() | |
321b1d72 TB |
89 | } |
90 | } |