diff options
Diffstat (limited to 'src/ToastManager.qml')
-rw-r--r-- | src/ToastManager.qml | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ToastManager.qml b/src/ToastManager.qml index 1acf8d5..2f1600f 100644 --- a/src/ToastManager.qml +++ b/src/ToastManager.qml @@ -42,9 +42,12 @@ ListView { * * @param {string} text Text to show * @param {real} duration Duration to show in milliseconds, defaults to 3000 + * @param {enum} type Type of toast. Available is: + * ToastType.Standard, ToastType.Info, ToastType.Warning + * ToastType.Success, ToastType.Error */ - function show(text, duration) { - model.insert(0, {text: text, duration: duration}); + function show(text, duration, type) { + model.insert(0, {text: text, duration: duration, type: type}); } /** @@ -71,11 +74,13 @@ ListView { delegate: Toast { Component.onCompleted: { - if (typeof duration === "undefined") { - show(text); - } - else { - show(text, duration); + if (typeof duration === "undefined" && typeof type === "undefined") { + show(text, ToastType.ToastStandard); + } else if (typeof duration === "undefined" && + typeof type !== "undefined") { + show(text, type); + } else { + show(text, duration, type); } } } |