Warning, /plasma/kscreen/kcm/ui/RotationButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 import QtQuick 2.15
0007 import QtQuick.Layouts 1.15
0008 import QtQuick.Controls 2.15 as QQC2
0009 import org.kde.kirigami 2.20 as Kirigami
0010 
0011 import org.kde.private.kcm.kscreen 1.0 as KScreen
0012 
0013 QQC2.ToolButton {
0014     id: root
0015 
0016     property int value
0017     property /*KScreen::Output::Rotation*/int outputRotation
0018     property string tooltip
0019 
0020     Layout.fillWidth: true
0021     height: childrenRect.height
0022 
0023     checkable: true
0024     checked: element.rotation === outputRotation
0025 
0026     QQC2.ToolTip {
0027         text: tooltip
0028     }
0029 
0030     contentItem: Kirigami.Icon {
0031         source: "tv"
0032         rotation: root.value
0033     }
0034 
0035     onClicked: {
0036         if (element.rotation === outputRotation) {
0037             return;
0038         }
0039 
0040         element.rotation = outputRotation;
0041         screen.resetTotalSize();
0042     }
0043 
0044     implicitWidth: contentItem.implicitWidth + 2 * Kirigami.Units.smallSpacing
0045     implicitHeight: contentItem.implicitHeight + 2 * Kirigami.Units.smallSpacing
0046 
0047     Component.onCompleted: {
0048         switch (value) {
0049         case 90:
0050             outputRotation = KScreen.Output.Left;
0051             tooltip = i18n("90° Clockwise");
0052             break;
0053         case 180:
0054             outputRotation = KScreen.Output.Inverted;
0055             tooltip = i18n("Upside Down");
0056             break;
0057         case 270:
0058             outputRotation = KScreen.Output.Right;
0059             tooltip = i18n("90° Counterclockwise")
0060             break;
0061         case 0:
0062         default:
0063             outputRotation = KScreen.Output.None;
0064             tooltip = i18n("No Rotation");
0065         }
0066     }
0067 }