Warning, /plasma/libplasma/tests/dialog_positioning.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2014 David Edmundson <davidedmundson@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.0
0008 
0009 import QtQuick.Controls 2.15 as Controls
0010 import QtQuick.Layouts 1.1
0011 
0012 import org.kde.plasma.core 2.0 as PlasmaCore
0013 
0014 
0015 /*This test is for checking PlasmaDialog visualParent and related function work
0016 *To test move the window towards various edges and press the button.
0017 The Red rectangle should always be on screen and on the right screen
0018 
0019 */
0020 
0021 PlasmaCore.Dialog {
0022 
0023     type: windowIsDockControl.checked ? PlasmaCore.Dialog.Dock : PlasmaCore.Dialog.Normal
0024     visible: true
0025 
0026     Rectangle {
0027         color: "#ffffff"
0028         width: 300
0029         height: 300
0030 
0031         Rectangle {
0032             id: innerRect
0033             color: "#ddffdd"
0034             width: 200
0035             height: layout.height
0036             anchors.centerIn: parent
0037 
0038             ColumnLayout {
0039                 id: layout
0040                 anchors.margins: 5
0041                 anchors.top: parent.top
0042                 anchors.left:parent.left
0043                 anchors.right:parent.right
0044 
0045                 Controls.Label {
0046                     Layout.fillWidth: true
0047                     text: "alt + left click and move the window to various edges to test popup position"
0048                     wrapMode: Text.WordWrap
0049                 }
0050 
0051                 Controls.ComboBox {
0052                     id: alignmentControl
0053                     //order must match Location in plasma.h
0054                     model: ["Left", "Right", "Top", "Bottom"]
0055                     currentIndex: 0
0056                 }
0057 
0058                 Controls.CheckBox {
0059                     id: windowIsDockControl
0060                     text: "Window is a dock"
0061                 }
0062 
0063                 Controls.Button {
0064                     text: "Show Popup"
0065                     onClicked: {
0066                         dialog.visible = !dialog.visible
0067                         console.log(alignmentControl.currentIndex);
0068                     }
0069                 }
0070             }
0071 
0072             PlasmaCore.Dialog
0073             {
0074                 id: dialog
0075                 visualParent: innerRect
0076                 location: {
0077                     switch (alignmentControl.currentIndex) {
0078                         case 0:
0079                             return PlasmaCore.Types.LeftEdge
0080                         case 1:
0081                             return PlasmaCore.Types.RightEdge
0082                         case 2:
0083                             return PlasmaCore.Types.TopEdge
0084                         default:
0085                             return PlasmaCore.Types.BottomEdge
0086                     }
0087                 }
0088 
0089 
0090                 Rectangle {
0091                     color: "#FF0000"
0092                     width: 150
0093                     height: 150
0094                 }
0095 
0096                 Component.onCompleted: {
0097                     console.log(alignmentControl.currentIndex);
0098                     console.log(dialog.location);
0099 
0100                 }
0101             }
0102         }
0103     }
0104 }