Warning, /frameworks/kirigami/src/controls/OverlayDrawer.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.1 0008 import QtQuick.Templates 2.0 as T2 0009 import org.kde.kirigami 2.15 as Kirigami 0010 import "private" as P 0011 import "templates" as T 0012 0013 /** 0014 * @brief Overlay drawers are used to expose additional UI elements needed for 0015 * small secondary tasks for which the main UI elements are not needed. 0016 * 0017 * Overlay drawers can be used to create two kinds of components, a modal drawer 0018 * and an inline drawer. A modal drawer darkens the rest of the application and 0019 * grabs focus until confirmed, whereas an inline drawer does not. 0020 * 0021 * Unlike an OverlaySheet that appears in the center of the application, an OverlayDrawer 0022 * can be attached to an edge of the application, usually the top or the bottom edges. 0023 * 0024 * @see Visit https://develop.kde.org/docs/getting-started/kirigami/components-drawers to read more 0025 * about modal and non-modal drawers. 0026 * 0027 * Example usage: 0028 * @include overlaydrawer.qml 0029 * 0030 * @inherit kirigami::templates::OverlayDrawer 0031 */ 0032 T.OverlayDrawer { 0033 id: root 0034 0035 //BEGIN Properties 0036 focus: false 0037 modal: true 0038 drawerOpen: !modal 0039 closePolicy: modal ? T2.Popup.CloseOnEscape | T2.Popup.CloseOnReleaseOutside : T2.Popup.NoAutoClose 0040 handleVisible: interactive && (modal || !drawerOpen) && (typeof(applicationWindow)===typeof(Function) && applicationWindow() ? applicationWindow().controlsVisible : true) 0041 0042 // FIXME: set to false when it does not lead to blocking closePolicy. 0043 // See Kirigami bug: 454119 0044 interactive: true 0045 0046 onPositionChanged: { 0047 if (!modal && !root.peeking && !root.animating) { 0048 position = 1; 0049 } 0050 } 0051 0052 background: Rectangle { 0053 color: Kirigami.Theme.backgroundColor 0054 0055 Item { 0056 parent: root.handle 0057 anchors.fill: parent 0058 0059 Kirigami.ShadowedRectangle { 0060 id: handleGraphics 0061 anchors.centerIn: parent 0062 0063 Kirigami.Theme.colorSet: parent.parent.handleAnchor && parent.parent.handleAnchor.visible ? parent.parent.handleAnchor.Kirigami.Theme.colorSet : Kirigami.Theme.Button 0064 0065 Kirigami.Theme.backgroundColor: parent.parent.handleAnchor && parent.parent.handleAnchor.visible ? parent.parent.handleAnchor.Kirigami.Theme.backgroundColor : undefined 0066 0067 Kirigami.Theme.textColor: parent.parent.handleAnchor && parent.parent.handleAnchor.visible ? parent.parent.handleAnchor.Kirigami.Theme.textColor : undefined 0068 0069 Kirigami.Theme.inherit: false 0070 color: root.handle.pressed ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor 0071 0072 visible: !parent.parent.handleAnchor || !parent.parent.handleAnchor.visible || root.handle.pressed || (root.modal && root.position > 0) 0073 0074 shadow.color: Qt.rgba(0, 0, 0, root.handle.pressed ? 0.6 : 0.4) 0075 shadow.yOffset: 1 0076 shadow.size: Kirigami.Units.gridUnit / 2 0077 0078 width: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2 0079 height: width 0080 radius: 2 0081 Behavior on color { 0082 ColorAnimation { 0083 duration: Kirigami.Units.longDuration 0084 easing.type: Easing.InOutQuad 0085 } 0086 } 0087 } 0088 Loader { 0089 anchors.centerIn: handleGraphics 0090 width: height 0091 height: Kirigami.Units.iconSizes.smallMedium 0092 0093 Kirigami.Theme.colorSet: handleGraphics.Kirigami.Theme.colorSet 0094 Kirigami.Theme.backgroundColor: handleGraphics.Kirigami.Theme.backgroundColor 0095 Kirigami.Theme.textColor: handleGraphics.Kirigami.Theme.textColor 0096 0097 asynchronous: true 0098 0099 source: { 0100 let edge = root.edge; 0101 if (Qt.application.layoutDirection === Qt.RightToLeft) { 0102 if (edge === Qt.LeftEdge) { 0103 edge = Qt.RightEdge; 0104 } else { 0105 edge = Qt.LeftEdge; 0106 } 0107 } 0108 0109 if ((root.handleClosedIcon.source || root.handleClosedIcon.name) 0110 && (root.handleOpenIcon.source || root.handleOpenIcon.name)) { 0111 return Qt.resolvedUrl("templates/private/GenericDrawerIcon.qml"); 0112 } else if (edge === Qt.LeftEdge ) { 0113 return Qt.resolvedUrl("templates/private/MenuIcon.qml"); 0114 } else if(edge === Qt.RightEdge && root.hasOwnProperty("actions")) { 0115 return Qt.resolvedUrl("templates/private/ContextIcon.qml"); 0116 } else { 0117 return ""; 0118 } 0119 } 0120 onItemChanged: { 0121 if (item) { 0122 item.drawer = Qt.binding(function(){return root}); 0123 item.color = Qt.binding(function(){return root.handle.pressed ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor}); 0124 } 0125 } 0126 } 0127 } 0128 0129 Kirigami.Separator { 0130 LayoutMirroring.enabled: false 0131 // LayoutMirroring.childrenInherit: true 0132 anchors { 0133 right: root.edge === Qt.RightEdge ? parent.left : (root.edge === Qt.LeftEdge ? undefined : parent.right) 0134 left: root.edge === Qt.LeftEdge ? parent.right : (root.edge === Qt.RightEdge ? undefined : parent.left) 0135 top: root.edge === Qt.TopEdge ? parent.bottom : (root.edge === Qt.BottomEdge ? undefined : parent.top) 0136 bottom: root.edge === Qt.BottomEdge ? parent.top : (root.edge === Qt.TopEdge ? undefined : parent.bottom) 0137 } 0138 visible: !root.modal 0139 } 0140 P.EdgeShadow { 0141 z: -2 0142 visible: root.modal 0143 edge: root.edge 0144 anchors { 0145 right: root.edge === Qt.RightEdge ? parent.left : (root.edge === Qt.LeftEdge ? undefined : parent.right) 0146 left: root.edge === Qt.LeftEdge ? parent.right : (root.edge === Qt.RightEdge ? undefined : parent.left) 0147 top: root.edge === Qt.TopEdge ? parent.bottom : (root.edge === Qt.BottomEdge ? undefined : parent.top) 0148 bottom: root.edge === Qt.BottomEdge ? parent.top : (root.edge === Qt.TopEdge ? undefined : parent.bottom) 0149 } 0150 0151 opacity: root.position === 0 ? 0 : 1 0152 0153 Behavior on opacity { 0154 NumberAnimation { 0155 duration: Kirigami.Units.longDuration 0156 easing.type: Easing.InOutQuad 0157 } 0158 } 0159 } 0160 } 0161 }