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

0001 /*
0002     SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 import QtQuick
0007 import QtQuick.Window
0008 import QtQuick.Layouts
0009 import QtQuick.Controls
0010 
0011 /*
0012  * Small test application to test the difference between unmap and destroy.
0013  * The window has two buttons: one called "Unmap" which will hide() the QWindow,
0014  * one called "Destroy" which will close() the QWindow.
0015  *
0016  * The test application can be run with qmlscene:
0017  *
0018  * @code
0019  * qmlscene unmapdestroytest.qml
0020  * @endcode
0021  *
0022  * In order to test different modes, the test application understands some arguments:
0023  * --unmanaged    Creates an override redirect window
0024  * --frameless    Creates a frameless window (comparable Plasma Dialog)
0025  */
0026 
0027 Window {
0028     id: window
0029     visible: false
0030     x: 0
0031     y: 0
0032     width: layout.implicitWidth
0033     height: layout.implicitHeight
0034     color: "black"
0035 
0036     RowLayout {
0037         id: layout
0038         Button {
0039             Timer {
0040                 id: timer
0041                 interval: 2000
0042                 running: false
0043                 repeat: false
0044                 onTriggered: window.show()
0045             }
0046             text: "unmap"
0047             onClicked: {
0048                 timer.start();
0049                 window.hide();
0050             }
0051         }
0052         Button {
0053             text: "destroy"
0054             onClicked: window.close()
0055         }
0056     }
0057 
0058     Component.onCompleted: {
0059         var flags = Qt.Window;
0060         for (var i = 0; i < Qt.application.arguments.length; ++i) {
0061             var argument = Qt.application.arguments[i];
0062             if (argument == "--unmanaged") {
0063                 flags = flags | Qt.BypassWindowManagerHint;
0064             }
0065             if (argument == "--frameless") {
0066                 flags = flags | Qt.FramelessWindowHint
0067             }
0068         }
0069         window.flags = flags;
0070         window.visible = true;
0071     }
0072 }