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
146 anchors.bottom: parent.bottom
150 to : _toastTimer.interval
151 value: _progressTimer.progress
156 property int progress : 0
158 repeat: _toastTimer.running
159 onTriggered: progress += _progressTimer.interval
164 _progressTimer.progress = 0
165 _progressTimer.restart()
170 layer.effect: MultiEffect
172 autoPaddingEnabled:
true
174 shadowColor:
"#80000000"
178 Component.onCompleted:
180 _progressTimer.start()
187 interval: _toast.timeout + (_toast.mindex * 500)
191 if(_toast.hovered || _container.hovered || !control.autoClose)
193 _toastTimer.restart()
194 _progressBar.restart()
197 _progressTimer.stop()
198 control.remove(_toast.mindex)
202 contentItem: ColumnLayout
205 spacing: Maui.Style.space.medium
207 Maui.ListItemTemplate
210 Layout.fillWidth:
true
211 Layout.fillHeight:
true
212 label1.text: _toast.title
213 label2.wrapMode:
Text.Wrap
214 iconSizeHint: Maui.Style.iconSizes.big
219 Layout.preferredHeight: visible ? implicitHeight : -_layout.spacing
220 visible: _toast.actions.length > 0
221 Layout.fillWidth:
true
222 spacing: Maui.Style.defaultSpacing
226 model: _toast.actions
230 Maui.Controls.status: modelData.Maui.Controls.status
231 Layout.fillWidth:
true
235 control.remove(_toast.mindex)
251 if(_dragHandler.centroid.scenePressPosition.x.toFixed(1) - _dragHandler.centroid.scenePosition.x.toFixed(1) > 80)
253 control.remove(_toast.mindex)
272 width: Math.min(400, parent.width)
273 height: Math.min( _listView.implicitHeight + topPadding + bottomPadding, 500)
275 anchors.bottom: parent.bottom
276 anchors.horizontalCenter: parent.horizontalCenter
278 contentItem: Maui.ListBrowser
282 property bool expanded :
true
284 orientation: ListView.Vertical
285 snapMode: ListView.SnapOneItem
287 spacing: Maui.Style.space.medium
289 model: _container.contentModel
293 width: ListView.view.width
294 height: Maui.Style.toolBarHeight
299 visible: _container.count > 1
301 anchors.centerIn: parent
302 text:
i18n(
"Dismiss All")
303 onClicked: control.dismiss()
310 function add(icon, title, body, actions = [])
316 'actions': actions })
318 const object = _toastComponent.createObject(_listView.flickable, properties);
319 _container.insertItem(0,
object)
325 let count = _container.count
327 for(var i = 0; i< count; i++)
329 items.push(_container.itemAt(i))
334 _container.removeItem(j)
342 _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)