22import QtQuick.Controls
31import org.mauikit.controls as Maui
37 padding: Maui.Style.contentMargins
38 visible: _container.count > 0
42 property bool autoClose : Window.window.active
44 property Item previousItem : null
49 source: "qrc:/assets/notification_simple-01.wav"
55 source:
"qrc:/assets/notification_simple-02.wav"
68 control.previousItem = Window.window.activeFocusItem
69 control.forceActiveFocus()
72 if(control.previousItem)
74 control.previousItem.forceActiveFocus()
75 control.previousItem = null
86 if(_container.count === 1)
95 GradientStop { position: 0.0; color:
"transparent" }
96 GradientStop { position: 1.0; color: Maui.Theme.backgroundColor }
110 Maui.Theme.colorSet: Maui.Theme.View
111 Maui.Theme.inherit:
false
113 readonly
property int mindex : ObjectModel.index
115 width: ListView.view.width
116 height: _layout.implicitHeight + topPadding +bottomPadding
120 padding: Maui.Style.contentMargins
122 property string title :
""
123 property alias iconSource: _template.iconSource
124 property alias imageSource: _template.imageSource
125 property alias body: _template.label2.text
126 property list<Action> actions
128 property int timeout : 3500
132 if( _toast.actions.length > 0)
135 control.remove(mindex)
138 background: Rectangle
140 radius: Maui.Style.radiusV
141 color: _toast.hovered && _toast.actions.length === 0? Maui.Theme.hoverColor : Maui.Theme.backgroundColor
156 visible: (!_toast.hovered && !_container.hovered ) && control.autoClose
157 anchors.bottom: parent.bottom
161 to : _toastTimer.interval
162 value: _progressTimer.progress
168 running: _toastTimer.running
169 property int progress : 0
171 repeat: _toastTimer.running
172 onTriggered: progress += _progressTimer.interval
177 _progressTimer.progress = 0
178 _progressTimer.restart()
181 layer.enabled: GraphicsInfo.api !== GraphicsInfo.Software
182 layer.effect: MultiEffect
185 maskThresholdMin: 0.5
188 maskThresholdMax: 1.0
189 maskSource: ShaderEffectSource
191 sourceItem: Rectangle
196 height: _bglay.height
197 radius: Maui.Style.radiusV
203 layer.enabled: GraphicsInfo.api !== GraphicsInfo.Software
204 layer.effect: MultiEffect
206 autoPaddingEnabled:
true
208 shadowColor:
"#80000000"
212 Component.onCompleted:
215 _toastTimer.interval = _toast.timeout + (_listView.count * 1500)
226 if(_toast.hovered || _container.hovered || !control.autoClose)
228 _toastTimer.restart()
229 _progressBar.restart()
232 _progressTimer.stop()
233 control.remove(_toast.mindex)
237 contentItem: ColumnLayout
240 spacing: Maui.Style.space.medium
242 Maui.ListItemTemplate
245 Layout.fillWidth:
true
246 Layout.fillHeight:
true
247 label1.text: _toast.title
248 label2.wrapMode:
Text.Wrap
249 iconSizeHint: Maui.Style.iconSizes.big
254 Layout.preferredHeight: visible ? implicitHeight : -_layout.spacing
255 visible: _toast.actions.length > 0
256 Layout.fillWidth:
true
257 spacing: Maui.Style.defaultSpacing
261 model: _toast.actions
265 Maui.Controls.status: modelData.Maui.Controls.status
266 Layout.fillWidth:
true
270 control.remove(_toast.mindex)
286 if(_dragHandler.centroid.scenePressPosition.x.toFixed(1) - _dragHandler.centroid.scenePosition.x.toFixed(1) > 80)
288 control.remove(_toast.mindex)
307 width: Math.min(400, parent.width)
308 height: Math.min( _listView.implicitHeight + topPadding + bottomPadding, 500)
310 anchors.bottom: parent.bottom
311 anchors.horizontalCenter: parent.horizontalCenter
313 contentItem: Maui.ListBrowser
317 property bool expanded :
true
319 orientation: ListView.Vertical
320 snapMode: ListView.SnapOneItem
322 spacing: Maui.Style.space.medium
324 model: _container.contentModel
328 width: ListView.view.width
329 height: Maui.Style.toolBarHeight
334 visible: _container.count > 1
336 anchors.centerIn: parent
337 text:
i18n(
"Dismiss All")
338 onClicked: control.dismiss()
345 function add(icon, title, body, actions = [])
351 'actions': actions })
353 const object = _toastComponent.createObject(_listView.flickable, properties);
354 _container.insertItem(0,
object)
360 let count = _container.count
362 for(var i = 0; i< count; i++)
364 items.push(_container.itemAt(i))
369 _container.removeItem(j)
377 _container.removeItem(_container.itemAt(index))
ItemDelegate is the base for the MauiKit delegate controls.
QString i18n(const char *text, const TYPE &arg...)
QAction * restart(const QObject *recvr, const char *slot, QObject *parent)
QAction * repeat(const QObject *recvr, const char *slot, QObject *parent)