|
| 1 | +import QtQuick.Layouts 1.4 |
| 2 | +import QtQuick 2.4 |
| 3 | +import QtQuick.Controls 2.0 |
| 4 | +import org.kde.kirigami 2.4 as Kirigami |
| 5 | + |
| 6 | +import Mycroft 1.0 as Mycroft |
| 7 | + |
| 8 | +Item { |
| 9 | + id: root |
| 10 | + |
| 11 | + property bool eyesOpen |
| 12 | + property string mouth |
| 13 | + property alias mouthItem: mouthItem |
| 14 | + |
| 15 | + Item { |
| 16 | + id: fixedProportionsContainer |
| 17 | + |
| 18 | + anchors.centerIn: parent |
| 19 | + readonly property real proportion: 1.6 |
| 20 | + |
| 21 | + width: parent.height / parent.width >= proportion ? parent.width : height / 1.6 |
| 22 | + height: parent.height / parent.width >= proportion ? width * 1.6 : parent.height |
| 23 | + |
| 24 | + Item { |
| 25 | + anchors { |
| 26 | + left: parent.left |
| 27 | + top: parent.top |
| 28 | + topMargin: parent.height * 0.28 |
| 29 | + leftMargin: parent.width * 0.02 |
| 30 | + } |
| 31 | + |
| 32 | + width: parent.width * 0.35 |
| 33 | + height: width |
| 34 | + Image { |
| 35 | + anchors.fill: parent |
| 36 | + visible: root.eyesOpen |
| 37 | + source: Qt.resolvedUrl("face/Eyeball.svg") |
| 38 | + fillMode: Image.PreserveAspectFit |
| 39 | + } |
| 40 | + Image { |
| 41 | + anchors { |
| 42 | + left: parent.left |
| 43 | + right: parent.right |
| 44 | + bottom: parent.bottom |
| 45 | + leftMargin: width * 0.001 |
| 46 | + rightMargin: width * 0.001 |
| 47 | + } |
| 48 | + height: width / (sourceSize.width/sourceSize.height) |
| 49 | + visible: !root.eyesOpen |
| 50 | + source: Qt.resolvedUrl("face/lid.svg") |
| 51 | + fillMode: Image.PreserveAspectFit |
| 52 | + } |
| 53 | + Image { |
| 54 | + anchors { |
| 55 | + left: parent.left |
| 56 | + right: parent.right |
| 57 | + top: parent.top |
| 58 | + leftMargin: width * 0.001 |
| 59 | + rightMargin: width * 0.001 |
| 60 | + } |
| 61 | + height: width / (sourceSize.width/sourceSize.height) |
| 62 | + visible: root.eyesOpen |
| 63 | + source: Qt.resolvedUrl("face/upper-lid.svg") |
| 64 | + fillMode: Image.PreserveAspectFit |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + Item { |
| 69 | + anchors { |
| 70 | + right: parent.right |
| 71 | + top: parent.top |
| 72 | + topMargin: parent.height * 0.28 |
| 73 | + rightMargin: parent.width * 0.02 |
| 74 | + } |
| 75 | + |
| 76 | + width: parent.width * 0.35 |
| 77 | + height: width |
| 78 | + Image { |
| 79 | + anchors.fill: parent |
| 80 | + visible: root.eyesOpen |
| 81 | + source: Qt.resolvedUrl("face/Eyeball.svg") |
| 82 | + fillMode: Image.PreserveAspectFit |
| 83 | + } |
| 84 | + Image { |
| 85 | + anchors { |
| 86 | + left: parent.left |
| 87 | + right: parent.right |
| 88 | + bottom: parent.bottom |
| 89 | + leftMargin: width * 0.001 |
| 90 | + rightMargin: width * 0.001 |
| 91 | + } |
| 92 | + height: width / (sourceSize.width/sourceSize.height) |
| 93 | + visible: !root.eyesOpen |
| 94 | + source: Qt.resolvedUrl("face/lid.svg") |
| 95 | + fillMode: Image.PreserveAspectFit |
| 96 | + } |
| 97 | + Image { |
| 98 | + anchors { |
| 99 | + left: parent.left |
| 100 | + right: parent.right |
| 101 | + top: parent.top |
| 102 | + leftMargin: width * 0.001 |
| 103 | + rightMargin: width * 0.001 |
| 104 | + } |
| 105 | + height: width / (sourceSize.width/sourceSize.height) |
| 106 | + visible: root.eyesOpen |
| 107 | + source: Qt.resolvedUrl("face/upper-lid.svg") |
| 108 | + fillMode: Image.PreserveAspectFit |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + Item { |
| 113 | + id: mouthItem |
| 114 | + anchors { |
| 115 | + horizontalCenter: parent.horizontalCenter |
| 116 | + bottom: parent.bottom |
| 117 | + bottomMargin: parent.height * 0.26 |
| 118 | + } |
| 119 | + width: parent.width / 2 |
| 120 | + height: smile.implicitHeight |
| 121 | + Image { |
| 122 | + id: smile |
| 123 | + anchors { |
| 124 | + left: parent.left |
| 125 | + right: parent.right |
| 126 | + verticalCenter: parent.verticalCenter |
| 127 | + } |
| 128 | + fillMode: Image.PreserveAspectFit |
| 129 | + source: Qt.resolvedUrl("face/" + root.mouth) |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | +} |
0 commit comments