/** Copyright 2015 (C) Martin Klapetek <mklapetek@kde.org>* Copyright 2019 (C) Kai Uwe Broulik <kde@privat.broulik.de>** This program is free software; you can redistribute it and/or* modify it under the terms of the GNU General Public License as* published by the Free Software Foundation; either version 2 of* the License or (at your option) version 3 or any later version* accepted by the membership of KDE e.V. (or its successor approved* by the membership of KDE e.V.), which shall act as a proxy* defined in 14 of version 3 of the license.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>*/import QtQuick 2.0import QtQuick.Window 2.1import QtQuick.Controls 2.2 as QtControlsimport org.kde.kirigami 2.4 as Kirigamiimport org.kde.plasma.core 2.0 as PlasmaCoreimport org.kde.notificationmanager 1.0 as NotificationManagerItem {id: monitorPanelproperty int baseUnit: Kirigami.Units.gridUnitimplicitWidth: baseUnit * 13 + baseUnit * 2implicitHeight: (screenRatio * baseUnit * 13) + (baseUnit * 2) + basePart.heightproperty int selectedPositionproperty var disabledPositions: []property real screenRatio: Screen.height / Screen.widthonSelectedPositionChanged: {var buttons = positionRadios.buttons.length;for (var i = 0; i < buttons.length; ++i) {var button = buttons[i];if (button.position === selectedPosition) {button.checked = true;break;}}}PlasmaCore.Svg {id: monitorSvgimagePath: "widgets/monitor"}PlasmaCore.SvgItem {id: topleftPartanchors {left: parent.lefttop: parent.top}svg: monitorSvgelementId: "topleft"width: baseUnitheight: baseUnit}PlasmaCore.SvgItem {id: topPartanchors {top: parent.topleft: topleftPart.rightright: toprightPart.left}svg: monitorSvgelementId: "top"height: baseUnit}PlasmaCore.SvgItem {id: toprightPartanchors {right: parent.righttop: parent.top}svg: monitorSvgelementId: "topright"width: baseUnitheight: baseUnit}PlasmaCore.SvgItem {id: leftPartanchors {left: parent.lefttop: topleftPart.bottombottom: bottomleftPart.top}svg: monitorSvgelementId: "left"width: baseUnit}PlasmaCore.SvgItem {id: rightPartanchors {right: parent.righttop: toprightPart.bottombottom: bottomrightPart.top}svg: monitorSvgelementId: "right"width: baseUnit}PlasmaCore.SvgItem {id: bottomleftPartanchors {left: parent.leftbottom: basePart.top}svg: monitorSvgelementId: "bottomleft"width: baseUnitheight: baseUnit}PlasmaCore.SvgItem {id: bottomPartanchors {bottom: basePart.topleft: bottomleftPart.rightright: bottomrightPart.left}svg: monitorSvgelementId: "bottom"height: baseUnit}PlasmaCore.SvgItem {id: bottomrightPartanchors {right: parent.rightbottom: basePart.top}svg: monitorSvgelementId: "bottomright"width: baseUnitheight: baseUnit}PlasmaCore.SvgItem {id: basePartanchors {bottom: parent.bottomhorizontalCenter: parent.horizontalCenter}width: 120height: 60svg: monitorSvgelementId: "base"}QtControls.ButtonGroup {id: positionRadiosonCheckedButtonChanged: monitorPanel.selectedPosition = checkedButton.position}// TODO increase hit area for radio buttonsQtControls.RadioButton {anchors {top: topPart.bottomleft: leftPart.rightmargins: Kirigami.Units.smallSpacing}readonly property int position: NotificationManager.Settings.TopLeftchecked: monitorPanel.selectedPosition == positionvisible: monitorPanel.disabledPositions.indexOf(position) == -1QtControls.ButtonGroup.group: positionRadios}QtControls.RadioButton {anchors {top: topPart.bottomhorizontalCenter: topPart.horizontalCentermargins: Kirigami.Units.smallSpacing}readonly property int position: NotificationManager.Settings.TopCenterchecked: monitorPanel.selectedPosition == positionvisible: monitorPanel.disabledPositions.indexOf(position) == -1QtControls.ButtonGroup.group: positionRadios}QtControls.RadioButton {anchors {top: topPart.bottomright: rightPart.leftmargins: Kirigami.Units.smallSpacing}readonly property int position: NotificationManager.Settings.TopRightchecked: monitorPanel.selectedPosition == positionvisible: monitorPanel.disabledPositions.indexOf(position) == -1QtControls.ButtonGroup.group: positionRadios}QtControls.RadioButton {anchors {bottom: bottomPart.topleft: leftPart.rightmargins: Kirigami.Units.smallSpacing}readonly property int position: NotificationManager.Settings.BottomLeftchecked: monitorPanel.selectedPosition == positionvisible: monitorPanel.disabledPositions.indexOf(position) == -1QtControls.ButtonGroup.group: positionRadios}QtControls.RadioButton {anchors {bottom: bottomPart.tophorizontalCenter: bottomPart.horizontalCentermargins: Kirigami.Units.smallSpacing}readonly property int position: NotificationManager.Settings.BottomCenterchecked: monitorPanel.selectedPosition == positionvisible: monitorPanel.disabledPositions.indexOf(position) == -1QtControls.ButtonGroup.group: positionRadios}QtControls.RadioButton {anchors {bottom: bottomPart.topright: rightPart.leftmargins: Kirigami.Units.smallSpacing}readonly property int position: NotificationManager.Settings.BottomRightchecked: monitorPanel.selectedPosition == positionvisible: monitorPanel.disabledPositions.indexOf(position) == -1QtControls.ButtonGroup.group: positionRadios}}