Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/RotationButton.qml
Show All 11 Lines | |||||
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | *********************************************************************/ | 16 | *********************************************************************/ | ||
17 | import QtQuick 2.9 | 17 | import QtQuick 2.9 | ||
18 | import QtQuick.Layouts 1.1 | 18 | import QtQuick.Layouts 1.1 | ||
19 | import QtQuick.Controls 2.4 as Controls | 19 | import QtQuick.Controls 2.4 as Controls | ||
20 | import org.kde.kirigami 2.4 as Kirigami | ||||
20 | import org.kde.private.kcm.kscreen 1.0 as KScreen | 21 | import org.kde.private.kcm.kscreen 1.0 as KScreen | ||
21 | 22 | | |||
22 | Controls.ToolButton { | 23 | Controls.ToolButton { | ||
23 | id: root | 24 | id: root | ||
24 | 25 | | |||
25 | property int value | 26 | property int value | ||
26 | property var rot | 27 | property var rot | ||
27 | property var tooltip | 28 | property var tooltip | ||
28 | 29 | | |||
30 | property int iconSize: 64 | ||||
31 | | ||||
29 | Layout.fillWidth: true | 32 | Layout.fillWidth: true | ||
30 | height: childrenRect.height | 33 | height: childrenRect.height | ||
31 | 34 | | |||
32 | icon.name: "view-preview" | | |||
33 | checked: element.rotation === rot | 35 | checked: element.rotation === rot | ||
34 | 36 | | |||
35 | Controls.ToolTip { | 37 | Controls.ToolTip { | ||
36 | text: tooltip | 38 | text: tooltip | ||
37 | } | 39 | } | ||
38 | 40 | | |||
41 | contentItem: Kirigami.Icon { | ||||
42 | source: "view-preview" | ||||
43 | transform: Rotation { | ||||
broulik: why not just use `rotation` property? | |||||
44 | origin { | ||||
45 | x: width / 2 | ||||
46 | y: height / 2 | ||||
47 | } | ||||
48 | angle: root.value | ||||
49 | } | ||||
50 | } | ||||
51 | | ||||
39 | onClicked: { | 52 | onClicked: { | ||
40 | if (element.rotation === rot) { | 53 | if (element.rotation === rot) { | ||
41 | return; | 54 | return; | ||
42 | } | 55 | } | ||
43 | 56 | | |||
44 | element.rotation = rot; | 57 | element.rotation = rot; | ||
45 | screen.resetTotalSize(); | 58 | screen.resetTotalSize(); | ||
46 | } | 59 | } | ||
47 | 60 | | |||
48 | implicitWidth: 45 | 61 | implicitWidth: contentItem.implicitWidth + 2 * 4 | ||
49 | implicitHeight: 45 | 62 | implicitHeight: contentItem.implicitHeight + 2 * 4 | ||
ngraham: Kirigami.units.smallSpacing instead of hardcoded 2 | |||||
50 | 63 | | |||
51 | transform: Rotation { | | |||
52 | origin { | | |||
53 | x: root.width / 2 | | |||
54 | y: root.height / 2 | | |||
55 | } | | |||
56 | angle: root.value | | |||
57 | } | | |||
58 | Component.onCompleted: { | 64 | Component.onCompleted: { | ||
59 | switch(value) { | 65 | switch(value) { | ||
60 | case 90: | 66 | case 90: | ||
61 | rot = KScreen.Output.Left; | 67 | rot = KScreen.Output.Left; | ||
62 | tooltip = i18n("90° Clockwise"); | 68 | tooltip = i18n("90° Clockwise"); | ||
63 | break; | 69 | break; | ||
64 | case 180: | 70 | case 180: | ||
65 | rot = KScreen.Output.Inverted; | 71 | rot = KScreen.Output.Inverted; | ||
Show All 13 Lines |
why not just use rotation property?