MauiKit Controls

linux/WindowControls.qml
1import QtQuick
2import QtQuick.Window
3
4import org.mauikit.controls as Maui
5
6/**
7 @since org.mauikit.controls.labs 1.0
8 @brief The window control buttons for windows using client side decorations.
9
10 @note Although this control name has the "Linux" suffix, the right name for usage is WindowControls.
11 @code
12QQC2.Pane
13{
14 WindowControls
15 {
16 anchors.top: parent.top
17 anchors.left: parent.left
18 anchors.margins: Style.space.medium
19 }
20}
21 @endcode
22
23 This control takes care of drawing the window buttons, and when triggered it performs the associated actions such as close, minimize and maximize.
24
25 It is loaded asynchronous, and only active if the client side decorations have been enabled and the form factor of the device is on desktop mode.
26 Consider only using it in cases where the main application window container does not support the attached property Controls.showCSD.
27
28 Some of the containers and items that support the formerly mentioned attached property are:
29 - TabView
30 - Page
31 - AppViews
32 - ToolBar
33 - TabBar
34
35 For more details on the implementation of this control and how to customize it you can refer to CSDControls.
36
37 @image html WindowControls/themes.png
38 @note There are different window control buttons themes, and new ones can be created.
39
40
41*/
42Loader
43{
44 id: control
45 asynchronous: true
46 active: Maui.CSD.enabled && Maui.Handy.formFactor === Maui.Handy.Desktop && control.Window.window.visibility !== Window.FullScreen
47
48 visible: active
49 width: visible ? implicitWidth: 0
50
51 sourceComponent: Maui.CSDControls
52 {
53 onButtonClicked: (type) => performActiveWindowAction(type)
54
55 function performActiveWindowAction(type)
56 {
57 switch(type)
58 {
59 case Maui.CSDButton.Close: Window.window.close(); break;
60 case Maui.CSDButton.Maximize :
61 case Maui.CSDButton.Restore : Window.window.toggleMaximized(); break;
62 case Maui.CSDButton.Minimize: Window.window.showMinimized(); break;
63 default: console.error("CSD Button clicked type not recognized.")
64 }
65 }
66 }
67}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.