Warning, /plasma/plasma-workspace/kcms/wallpaper/ui/Output.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
0003 SPDX-FileCopyrightText: 2012 Dan Vratil <dvratil@redhat.com>
0004 SPDX-FileCopyrightText: 2022 Kai Uwe Broulik <kde@broulik.de>
0005 SPDX-FileCopyrightText: 2023 Méven Car <meven@kde.org>
0006
0007 SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 import QtQuick
0010 import QtQuick.Layouts
0011 import QtQuick.Controls as QQC2
0012 import org.kde.kirigami as Kirigami
0013
0014 Item {
0015 id: output
0016
0017 // readonly property bool isSelected: root.selectedOutput === model.index
0018 property real relativeFactor
0019 property var screen
0020 property int xOffset
0021 property int yOffset
0022 property bool isSelected
0023
0024 readonly property size outputSize: Qt.size(screen.geometry.width, screen.geometry.height)
0025 readonly property point position: Qt.point(screen.geometry.x, screen.geometry.y)
0026
0027 signal screenSelected(string screenName)
0028
0029 x: position.x / relativeFactor + xOffset
0030 y: position.y / relativeFactor + yOffset
0031
0032 width: outputSize.width / relativeFactor
0033 height: outputSize.height / relativeFactor
0034
0035 Rectangle {
0036 id: outline
0037
0038 readonly property int orientationPanelWidth: 10
0039 readonly property real orientationPanelPosition: 1 - (orientationPanelWidth / outline.height)
0040
0041 anchors.centerIn: parent
0042 width: parent.width
0043 height: parent.height
0044 radius: Kirigami.Units.smallSpacing
0045
0046 gradient: Gradient {
0047 GradientStop {
0048 position: 0.0
0049 color: Kirigami.Theme.alternateBackgroundColor
0050 }
0051 GradientStop {
0052 // Create a hard cut. Can't use the same number otherwise it gets confused.
0053 position: outline.orientationPanelPosition - Number.EPSILON
0054 color: Kirigami.Theme.alternateBackgroundColor
0055 }
0056 GradientStop {
0057 position: outline.orientationPanelPosition
0058 color: outline.border.color
0059 }
0060 GradientStop {
0061 position: 1.0
0062 color: outline.border.color
0063 }
0064 }
0065
0066 border {
0067 color: isSelected ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0068 width: 1
0069
0070 Behavior on color {
0071 PropertyAnimation {
0072 duration: Kirigami.Units.longDuration
0073 }
0074 }
0075 }
0076 }
0077
0078 Item {
0079 id: labelContainer
0080 anchors {
0081 fill: parent
0082 margins: outline.border.width
0083 }
0084
0085 // so the text is drawn above orientationPanelContainer
0086 z: 1
0087 ColumnLayout {
0088 anchors.centerIn: parent
0089 spacing: 0
0090 width: parent.width
0091 Layout.maximumHeight: parent.height
0092
0093 QQC2.Label {
0094 Layout.fillWidth: true
0095 Layout.maximumHeight: labelContainer.height - resolutionLabel.implicitHeight
0096
0097 text: screen.name
0098 textFormat: Text.PlainText
0099 wrapMode: Text.Wrap
0100 horizontalAlignment: Text.AlignHCenter
0101 elide: Text.ElideRight
0102 }
0103
0104 QQC2.Label {
0105 id: resolutionLabel
0106 Layout.fillWidth: true
0107
0108 text: "(" + outputSize.width + "x" + outputSize.height + ")"
0109 textFormat: Text.PlainText
0110 wrapMode: Text.Wrap
0111 horizontalAlignment: Text.AlignHCenter
0112 elide: Text.ElideRight
0113 }
0114 }
0115 }
0116
0117 states: [
0118 State {
0119 name: "transposed"
0120 PropertyChanges {
0121 target: outline
0122 width: output.height
0123 height: output.width
0124 }
0125 },
0126
0127 State {
0128 name: "rot90"
0129 extend: "transposed"
0130 when: screen.orientation === 1 // Qt::PortraitOrientation
0131 PropertyChanges {
0132 target: outline
0133 rotation: 90
0134 }
0135 PropertyChanges {
0136 target: labelContainer
0137 anchors.leftMargin: outline.orientationPanelWidth + outline.border.width
0138 }
0139 },
0140 State {
0141 name: "rot0"
0142 when: screen.orientation === 2 // Qt::LandscapeOrientation
0143 PropertyChanges {
0144 target: labelContainer
0145 anchors.bottomMargin: outline.orientationPanelWidth + outline.border.width
0146 }
0147 },
0148 State {
0149 name: "rot270"
0150 extend: "transposed"
0151 when: screen.orientation === 4 // Qt::InvertedPortraitOrientation
0152 PropertyChanges {
0153 target: outline
0154 rotation: 270
0155 }
0156 PropertyChanges {
0157 target: labelContainer
0158 anchors.rightMargin: outline.orientationPanelWidth + outline.border.width
0159 }
0160 },
0161 State {
0162 name: "rot180"
0163 when: screen.orientation === 8 // Qt::InvertedLandscapeOrientation
0164 PropertyChanges {
0165 target: outline
0166 rotation: 180
0167 }
0168 PropertyChanges {
0169 target: labelContainer
0170 anchors.topMargin: outline.orientationPanelWidth + outline.border.width
0171 }
0172 }
0173 ]
0174
0175 HoverHandler {
0176 cursorShape: Qt.PointingHandCursor
0177 }
0178
0179 TapHandler {
0180 id: tapHandler
0181 gesturePolicy: TapHandler.WithinBounds
0182
0183 onPressedChanged: {
0184 if (pressed) {
0185 output.screenSelected(screen.name)
0186 }
0187 }
0188 }
0189 }
0190