Warning, /maui/mauikit/src/style.5/ComboBox.qml is written in an unsupported language. File is not indexed.
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2017 The Qt Company Ltd. 0004 ** Contact: http://www.qt.io/licensing/ 0005 ** 0006 ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. 0007 ** 0008 ** $QT_BEGIN_LICENSE:LGPL3$ 0009 ** Commercial License Usage 0010 ** Licensees holding valid commercial Qt licenses may use this file in 0011 ** accordance with the commercial license agreement provided with the 0012 ** Software or, alternatively, in accordance with the terms contained in 0013 ** a written agreement between you and The Qt Company. For licensing terms 0014 ** and conditions see http://www.qt.io/terms-conditions. For further 0015 ** information use the contact form at http://www.qt.io/contact-us. 0016 ** 0017 ** GNU Lesser General Public License Usage 0018 ** Alternatively, this file may be used under the terms of the GNU Lesser 0019 ** General Public License version 3 as published by the Free Software 0020 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the 0021 ** packaging of this file. Please review the following information to 0022 ** ensure the GNU Lesser General Public License version 3 requirements 0023 ** will be met: https://www.gnu.org/licenses/lgpl.html. 0024 ** 0025 ** GNU General Public License Usage 0026 ** Alternatively, this file may be used under the terms of the GNU 0027 ** General Public License version 2.0 or later as published by the Free 0028 ** Software Foundation and appearing in the file LICENSE.GPL included in 0029 ** the packaging of this file. Please review the following information to 0030 ** ensure the GNU General Public License version 2.0 requirements will be 0031 ** met: http://www.gnu.org/licenses/gpl-2.0.html. 0032 ** 0033 ** $QT_END_LICENSE$ 0034 ** 0035 ****************************************************************************/ 0036 0037 import QtQuick 2.15 0038 import QtQuick.Window 2.15 0039 import QtQuick.Templates 2.15 as T 0040 0041 import org.mauikit.controls 1.3 as Maui 0042 import QtGraphicalEffects 1.0 0043 0044 T.ComboBox 0045 { 0046 id: control 0047 0048 enabled: control.count > 0 0049 hoverEnabled: !Maui.Handy.isMobile 0050 0051 opacity: control.enabled ? 1 : 0.5 0052 0053 property alias popupContent: _popup.contentItem 0054 0055 //NOTE: typeof necessary to not have warnings on Qt 5.7 0056 Maui.Theme.colorSet: typeof(editable) != "undefined" && editable ? Maui.Theme.View : Maui.Theme.Button 0057 Maui.Theme.inherit: false 0058 0059 property alias icon : _icon 0060 0061 readonly property bool responsive: Maui.Handy.isMobile 0062 0063 readonly property size parentWindow : parent.Window.window ? Qt.size(parent.Window.window.width, parent.Window.window.height) : Qt.size(0,0) 0064 0065 readonly property int preferredWidth : 200 0066 0067 implicitWidth: Math.max(preferredWidth, implicitContentWidth + leftPadding + rightPadding) 0068 implicitHeight: Math.max(implicitContentHeight, Maui.Style.iconSize) + topPadding + bottomPadding 0069 0070 padding: Maui.Style.defaultPadding 0071 spacing: Maui.Style.space.small 0072 0073 font: Maui.Style.defaultFont 0074 0075 delegate: MenuItem 0076 { 0077 width: ListView.view.width 0078 text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData 0079 // Material.foreground: control.currentIndex === index ? parent.Material.accent : parent.Material.foreground 0080 highlighted: control.highlightedIndex === index 0081 hoverEnabled: control.hoverEnabled 0082 Maui.Theme.colorSet: control.Maui.Theme.inherit ? control.Maui.Theme.colorSet : Maui.Theme.View 0083 Maui.Theme.inherit: control.Maui.Theme.inherit 0084 } 0085 0086 indicator: Maui.Icon 0087 { 0088 x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding 0089 y: (control.topPadding + (control.availableHeight - height) / 2) - 2 0090 color: Maui.Theme.textColor 0091 source: "qrc:/assets/arrow-down.svg" 0092 height: 8 0093 width: 8 0094 0095 Behavior on color 0096 { 0097 Maui.ColorTransition{} 0098 } 0099 } 0100 0101 contentItem: T.TextField 0102 { 0103 padding: 0 0104 leftPadding : _icon.visible ? _icon.width + Maui.Style.space.medium : 0 0105 rightPadding: control.indicator ? control.indicator.width : 0 0106 text: control.editable ? control.editText : control.displayText 0107 0108 enabled: control.editable 0109 autoScroll: control.editable 0110 readOnly: control.down 0111 inputMethodHints: control.inputMethodHints 0112 validator: control.validator 0113 renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering 0114 selectByMouse: !Maui.Handy.isMobile 0115 0116 font: control.font 0117 color: Maui.Theme.textColor 0118 selectionColor: control.Maui.Theme.highlightColor 0119 selectedTextColor: control.Maui.Theme.highlightedTextColor 0120 verticalAlignment: Text.AlignVCenter 0121 // cursorDelegate: CursorDelegate { } 0122 0123 Maui.Icon 0124 { 0125 id: _icon 0126 visible: source ? true : false 0127 height: visible ? Maui.Style.iconSize : 0 0128 width: height 0129 color: Maui.Theme.textColor 0130 anchors.verticalCenter: parent.verticalCenter 0131 } 0132 } 0133 0134 background: Rectangle 0135 { 0136 radius: Maui.Style.radiusV 0137 0138 color: control.hovered ? Maui.Theme.hoverColor : Maui.Theme.backgroundColor 0139 0140 0141 MouseArea 0142 { 0143 property int wheelDelta: 0 0144 0145 anchors 0146 { 0147 fill: parent 0148 leftMargin: control.leftPadding 0149 rightMargin: control.rightPadding 0150 } 0151 0152 acceptedButtons: Qt.NoButton 0153 0154 onWheel: 0155 { 0156 var delta = wheel.angleDelta.y || wheel.angleDelta.x 0157 wheelDelta += delta; 0158 // magic number 120 for common "one click" 0159 // See: https://doc.qt.io/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop 0160 while (wheelDelta >= 120) { 0161 wheelDelta -= 120; 0162 control.decrementCurrentIndex(); 0163 } 0164 while (wheelDelta <= -120) { 0165 wheelDelta += 120; 0166 control.incrementCurrentIndex(); 0167 } 0168 } 0169 } 0170 0171 Behavior on color 0172 { 0173 Maui.ColorTransition{} 0174 } 0175 0176 } 0177 0178 0179 popup: T.Popup 0180 { 0181 id: _popup 0182 0183 Maui.Theme.colorSet: Maui.Theme.Window 0184 Maui.Theme.inherit: false 0185 0186 parent: control.responsive ? T.Overlay.overlay : control 0187 0188 readonly property int finalY : control.responsive ? control.parentWindow.height - height : ( control.editable ? control.height - 5 : 0) 0189 readonly property int preferredWidth: control.width 0190 0191 y: finalY 0192 x: control.responsive ? Math.round(control.parentWindow.width/2 - width/2) : 0 0193 0194 implicitWidth: Math.min(control.parentWindow.width, Math.max(preferredWidth, implicitContentWidth + leftPadding + rightPadding )) 0195 0196 implicitHeight: Math.min(implicitContentHeight + topPadding + bottomPadding, (control.responsive ? control.parentWindow.height *0.7 : control.parentWindow.height)) 0197 0198 transformOrigin: Item.Top 0199 0200 padding: 0 0201 spacing: Maui.Style.defaultSpacing 0202 0203 margins: Maui.Style.space.medium 0204 0205 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside 0206 0207 enter: Maui.Style.enableEffects ? (control.responsive ? _responsiveEnterTransition : _enterTransition) : null 0208 exit: Maui.Style.enableEffects ? (control.responsive ? _responsiveExitTransition : _exitTransition) : null 0209 0210 Transition 0211 { 0212 id: _enterTransition 0213 enabled: Maui.Style.enableEffects 0214 // grow_fade_in 0215 NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 } 0216 NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.OutCubic; duration: 150 } 0217 } 0218 0219 0220 Transition 0221 { 0222 id: _exitTransition 0223 enabled: Maui.Style.enableEffects 0224 0225 // shrink_fade_out 0226 NumberAnimation { property: "scale"; from: 1.0; to: 0.9; easing.type: Easing.OutQuint; duration: 220 } 0227 NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 } 0228 } 0229 0230 Transition 0231 { 0232 id: _responsiveEnterTransition 0233 enabled: Maui.Style.enableEffects 0234 0235 ParallelAnimation 0236 { 0237 //NumberAnimation { property: "y"; from: control.parentWindow.height; to: control.finalY; easing.type: Easing.OutQuint; duration: 220 } 0238 NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.OutCubic; duration: 150 } 0239 } 0240 } 0241 0242 Transition 0243 { 0244 id: _responsiveExitTransition 0245 enabled: Maui.Style.enableEffects 0246 0247 ParallelAnimation 0248 { 0249 //NumberAnimation { property: "y"; from: control.finalY; to: control.parentWindow.height; easing.type: Easing.OutQuint; duration: 220 } 0250 NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 } 0251 } 0252 } 0253 0254 contentItem: Maui.ListBrowser 0255 { 0256 clip: true 0257 0258 implicitWidth: { 0259 var maxWidth = 0; 0260 for (var i = 0; i < contentItem.children.length; ++i) { 0261 maxWidth = Math.max(maxWidth, contentItem.children[i].implicitWidth); 0262 } 0263 return Math.min(250, maxWidth); 0264 } 0265 0266 model: control.delegateModel 0267 spacing: control.spacing 0268 // padding: 0 0269 currentIndex: control.highlightedIndex 0270 } 0271 0272 background: Rectangle 0273 { 0274 color: _popup.Maui.Theme.backgroundColor 0275 radius: Maui.Style.radiusV 0276 0277 Behavior on color 0278 { 0279 Maui.ColorTransition{} 0280 0281 } 0282 MouseArea 0283 { 0284 property int wheelDelta: 0 0285 0286 anchors 0287 { 0288 fill: parent 0289 leftMargin: control.leftPadding 0290 rightMargin: control.rightPadding 0291 } 0292 0293 acceptedButtons: Qt.NoButton 0294 0295 onWheel: 0296 { 0297 var delta = wheel.angleDelta.y || wheel.angleDelta.x 0298 wheelDelta += delta; 0299 // magic number 120 for common "one click" 0300 // See: https://doc.qt.io/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop 0301 while (wheelDelta >= 120) { 0302 wheelDelta -= 120; 0303 control.decrementCurrentIndex(); 0304 } 0305 while (wheelDelta <= -120) { 0306 wheelDelta += 120; 0307 control.incrementCurrentIndex(); 0308 } 0309 } 0310 } 0311 0312 layer.enabled: true 0313 layer.effect: DropShadow 0314 { 0315 horizontalOffset: 0 0316 verticalOffset: 0 0317 radius: 8 0318 samples: 16 0319 color: "#80000000" 0320 transparentBorder: true 0321 } 0322 } 0323 } 0324 }