Plasma

MenuStyle.qml
1 /*
2  * Copyright 2014 Marco Martin <[email protected]>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Library General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
18  */
19 
20 import QtQuick 2.2
21 import QtQuick.Window 2.1
22 import QtQuick.Controls 1.2
23 import QtQuick.Controls.Private 1.0
24 import QtQuick.Controls.Styles 1.2 as QtQuickControlStyle
25 import org.kde.plasma.components 2.0 as PlasmaComponents
26 
27 QtQuickControlStyle.MenuStyle {
28  id: styleRoot
29 
30  __menuItemType: "menuitem"
31 
32  submenuOverlap: 0
33  submenuPopupDelay: 0
34  __maxPopupHeight: 0
35  __leftLabelMargin: theme.mSize(theme.defaultFont).height * 2 //see RadioButtonStyle size
36 
37  frame: StyleItem {
38  elementType: "menu"
39 
40  Rectangle {
41  visible: anchors.margins > 0
42  anchors {
43  fill: parent
44  margins: pixelMetric("menupanelwidth")
45  }
46  color: theme.backgroundColor
47  }
48 
49  Accessible.role: Accessible.PopupMenu
50 
51  Component.onCompleted: {
52  var menuHMargin = pixelMetric("menuhmargin")
53  var menuVMargin = pixelMetric("menuvmargin")
54  var menuPanelWidth = pixelMetric("menupanelwidth")
55  styleRoot.padding.left = menuHMargin + menuPanelWidth
56  styleRoot.padding.right = menuHMargin + menuPanelWidth
57  styleRoot.padding.top = menuVMargin + menuPanelWidth
58  styleRoot.padding.bottom = menuVMargin + menuPanelWidth
59  styleRoot.submenuOverlap = 2 * menuPanelWidth
60  styleRoot.submenuPopupDelay = styleHint("submenupopupdelay")
61  }
62 
63  readonly property int desktopAvailableHeight: Screen.desktopAvailableHeight
64  Binding {
65  target: styleRoot
66  property: "__maxPopupHeight"
67  value: desktopAvailableHeight * 0.99
68  }
69  }
70 
71  __scrollerStyle: null
72 
73  itemDelegate.background: PlasmaComponents.Highlight {
74  visible: styleData.selected && styleData.enabled
75  }
76  itemDelegate.label: PlasmaComponents.Label {
77  text: formatMnemonic(styleData.text, styleData.underlineMnemonic)
78  }
79  itemDelegate.submenuIndicator: PlasmaComponents.Label {
80  text: __mirrored ? "\u25c2" : "\u25b8" // BLACK LEFT/RIGHT-POINTING SMALL TRIANGLE
81  style: styleData.selected ? Text.Normal : Text.Raised
82  styleColor: Qt.lighter(color, 4)
83  }
84 
85  itemDelegate.shortcut: PlasmaComponents.Label {
86  text: styleData.shortcut
87  }
88 
89  itemDelegate.checkmarkIndicator: Loader {
90  sourceComponent: styleData.exclusive ? exclusiveCheckMark : nonExclusiveCheckMark
91  Component {
92  id: exclusiveCheckMark
93  PlasmaComponents.RadioButton {
94  width: parent.height
95  height: parent.height
96  checked: styleData.checked
97  }
98  }
99 
100  Component {
101  id: nonExclusiveCheckMark
102  PlasmaComponents.CheckBox {
103  width: parent.height
104  height: parent.height
105  checked: styleData.checked
106  }
107  }
108  }
109 }
Used to highlight an item of a list.
Definition: Highlight.qml:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jun 6 2020 22:52:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.