| 1 |
/* |
| 2 |
* Copyright 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.3 |
| 19 |
import Lomiri.Components.Private 1.3 |
| 20 |
|
| 21 |
Item { |
| 22 |
id: root |
| 23 |
width: 600 |
| 24 |
height: 600 |
| 25 |
focus: true |
| 26 |
|
| 27 |
property string textOverlayString: |
| 28 |
"thickness (t/T): " + frame.thickness.toFixed(1) + "\n" + |
| 29 |
"radius (r/R): " + frame.radius.toFixed(1) + "\n" + |
| 30 |
"color (c): " + frame.color + "\n" + |
| 31 |
"opacity (o/O): " + frame.opacity.toFixed(2) + "\n" |
| 32 |
|
| 33 |
Item { |
| 34 |
id: scene |
| 35 |
anchors.fill: parent |
| 36 |
|
| 37 |
Frame { |
| 38 |
id: frame |
| 39 |
anchors.fill: parent |
| 40 |
anchors.margins: 100.0 |
| 41 |
color: "blue" |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
Text { |
| 46 |
id: textOverlay |
| 47 |
width: 200 |
| 48 |
anchors.top: parent.top |
| 49 |
anchors.topMargin: 10 |
| 50 |
anchors.left: parent.left |
| 51 |
anchors.leftMargin: 10 |
| 52 |
font.family: "Ubuntu Mono" |
| 53 |
font.pixelSize: 14 |
| 54 |
font.weight: Font.Bold |
| 55 |
color: "black" |
| 56 |
text: textOverlayString |
| 57 |
} |
| 58 |
|
| 59 |
Keys.onPressed: { |
| 60 |
var shift = event.modifiers & Qt.ShiftModifier; |
| 61 |
if (event.key == Qt.Key_T) { |
| 62 |
frame.thickness = frame.thickness + (shift ? 1.0 : -1.0); |
| 63 |
} else if (event.key == Qt.Key_R) { |
| 64 |
frame.radius = frame.radius + (shift ? 1.0 : -1.0); |
| 65 |
} else if (event.key == Qt.Key_C) { |
| 66 |
frame.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1.0); |
| 67 |
} else if (event.key == Qt.Key_O) { |
| 68 |
frame.opacity = frame.opacity + (shift ? 0.02 : -0.02); |
| 69 |
} |
| 70 |
} |
| 71 |
} |