22import QtQuick.Controls
26import Qt5Compat.GraphicalEffects
32import org.mauikit.controls as Maui
38 padding: Maui.Style.contentMargins
39 visible: _container.count > 0
43 property bool autoClose : Window.window.active
45 property Item previousItem : null
50 source: "qrc:/assets/notification_simple-01.wav"
56 source:
"qrc:/assets/notification_simple-02.wav"
69 control.previousItem =
Window.window.activeFocusItem
70 control.forceActiveFocus()
73 if(control.previousItem)
75 control.previousItem.forceActiveFocus()
76 control.previousItem = null
87 if(_container.count === 1)
94 start:
Qt.point(control.width/2, 0)
95 end:
Qt.point(control.width/2, control.height - _container.height)
97 GradientStop { position: 0.0; color:
"transparent" }
98 GradientStop { position: 1.0; color: Maui.Theme.backgroundColor }
112 Maui.Theme.colorSet: Maui.Theme.View
113 Maui.Theme.inherit:
false
115 readonly
property int mindex : ObjectModel.index
116 width: ListView.view.width
117 height: _layout.implicitHeight + topPadding +bottomPadding
121 padding: Maui.Style.contentMargins
123 property alias title : _template.label1.text
124 property alias iconSource: _template.iconSource
125 property alias imageSource: _template.imageSource
126 property alias body: _template.label2.text
127 property var callback : ({})
128 property alias buttonText: _button.text
129 property int timeout : 3500
131 onClicked: control.
remove(mindex)
133 background: Rectangle
135 radius: Maui.Style.radiusV
136 color: _toast.hovered? Maui.Theme.hoverColor : Maui.Theme.backgroundColor
141 anchors.bottom: parent.bottom
145 to : _toastTimer.interval
146 value: _progressTimer.progress
151 property int progress : 0
153 repeat: _toastTimer.running
154 onTriggered: progress += _progressTimer.interval
159 _progressTimer.progress = 0
160 _progressTimer.restart()
165 layer.effect: DropShadow
172 transparentBorder:
true
176 Component.onCompleted:
178 _progressTimer.start()
185 interval: _toast.timeout + (_toast.mindex * 500)
189 if(_toast.hovered || _container.hovered || !control.autoClose)
191 _toastTimer.restart()
192 _progressBar.restart()
195 _progressTimer.stop()
196 control.remove(_toast.mindex)
200 contentItem: ColumnLayout
203 spacing: Maui.Style.space.medium
205 Maui.ListItemTemplate
208 Layout.fillWidth:
true
209 Layout.fillHeight:
true
211 label2.text:
"Body of the message"
212 label2.wrapMode:
Text.Wrap
213 iconSource:
"dialog-warning"
214 iconSizeHint: Maui.Style.iconSizes.big
220 visible: _toast.callback instanceof Function
222 Layout.fillWidth: true
225 if(_toast.callback instanceof Function)
227 _toast.callback(_toast.mindex)
229 control.
remove(_toast.mindex)
243 if(_dragHandler.centroid.scenePressPosition.x.toFixed(1) - _dragHandler.centroid.scenePosition.x.toFixed(1) > 80)
245 control.
remove(_toast.mindex)
265 width: Math.min(400, parent.width)
266 height: Math.min( _listView.implicitHeight + topPadding + bottomPadding, 500)
268 anchors.bottom: parent.bottom
269 anchors.horizontalCenter: parent.horizontalCenter
271 contentItem: Maui.ListBrowser
275 property bool expanded :
true
277 orientation: ListView.Vertical
278 snapMode: ListView.SnapOneItem
280 spacing: Maui.Style.space.medium
282 model: _container.contentModel
286 width: ListView.view.
width
287 height: Maui.Style.toolBarHeight
292 visible: _container.count > 1
294 anchors.centerIn: parent
295 text:
i18n(
"Dismiss All")
296 onClicked: control.dismiss()
303 function add(icon, title, body, callback = ({}), buttonText =
"")
309 'callback': callback,
310 'buttonText': buttonText
312 const object = _toastComponent.createObject(_listView.flickable, properties);
313 _container.insertItem(0,
object)
320 let count = _container.count
322 for(var i = 0; i< count; i++)
324 items.push(_container.itemAt(i))
329 _container.removeItem(j)
337 _container.removeItem(_container.itemAt(index))
ItemDelegate is the base for the MauiKit delegate controls.
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18n(const char *text, const TYPE &arg...)
bool remove(const QString &column, const QVariant &value)
QAction * restart(const QObject *recvr, const char *slot, QObject *parent)
QAction * repeat(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & end()
QString & remove(QChar ch, Qt::CaseSensitivity cs)