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 | | |||
29 | Layout.fillWidth: true | 30 | Layout.fillWidth: true | ||
30 | height: childrenRect.height | 31 | height: childrenRect.height | ||
31 | 32 | | |||
32 | icon.name: "view-preview" | | |||
33 | checked: element.rotation === rot | 33 | checked: element.rotation === rot | ||
34 | 34 | | |||
35 | Controls.ToolTip { | 35 | Controls.ToolTip { | ||
36 | text: tooltip | 36 | text: tooltip | ||
37 | } | 37 | } | ||
38 | 38 | | |||
39 | contentItem: Kirigami.Icon { | ||||
40 | source: "view-preview" | ||||
41 | rotation: root.value | ||||
broulik: why not just use `rotation` property? | |||||
42 | } | ||||
43 | | ||||
39 | onClicked: { | 44 | onClicked: { | ||
40 | if (element.rotation === rot) { | 45 | if (element.rotation === rot) { | ||
41 | return; | 46 | return; | ||
42 | } | 47 | } | ||
43 | 48 | | |||
44 | element.rotation = rot; | 49 | element.rotation = rot; | ||
45 | screen.resetTotalSize(); | 50 | screen.resetTotalSize(); | ||
46 | } | 51 | } | ||
47 | 52 | | |||
48 | implicitWidth: 45 | 53 | implicitWidth: contentItem.implicitWidth + 2 * Kirigami.Units.smallSpacing | ||
49 | implicitHeight: 45 | 54 | implicitHeight: contentItem.implicitHeight + 2 * Kirigami.Units.smallSpacing | ||
ngraham: Kirigami.units.smallSpacing instead of hardcoded 2 | |||||
50 | 55 | | |||
51 | transform: Rotation { | | |||
52 | origin { | | |||
53 | x: root.width / 2 | | |||
54 | y: root.height / 2 | | |||
55 | } | | |||
56 | angle: root.value | | |||
57 | } | | |||
58 | Component.onCompleted: { | 56 | Component.onCompleted: { | ||
59 | switch(value) { | 57 | switch(value) { | ||
60 | case 90: | 58 | case 90: | ||
61 | rot = KScreen.Output.Left; | 59 | rot = KScreen.Output.Left; | ||
62 | tooltip = i18n("90° Clockwise"); | 60 | tooltip = i18n("90° Clockwise"); | ||
63 | break; | 61 | break; | ||
64 | case 180: | 62 | case 180: | ||
65 | rot = KScreen.Output.Inverted; | 63 | rot = KScreen.Output.Inverted; | ||
Show All 13 Lines |
why not just use rotation property?