aboutsummaryrefslogtreecommitdiff
path: root/src/Toast.qml
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-08-01 02:22:57 +0200
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-08-01 02:25:13 +0200
commit35343e5158ca441f8001c0a91685f4e93b53cb03 (patch)
treed3bf2c6b4396644b2e33a675217d9f1a002bf85c /src/Toast.qml
parent766a90125df68f065495354c20412faf9e1df77a (diff)
downloadRWA.Support.DesktopApp-35343e5158ca441f8001c0a91685f4e93b53cb03.tar.gz
RWA.Support.DesktopApp-35343e5158ca441f8001c0a91685f4e93b53cb03.tar.bz2
RWA.Support.DesktopApp-35343e5158ca441f8001c0a91685f4e93b53cb03.zip
Toast: Add a variety of new toast colors; Session complete rewrite; A lot of bugfixing;
New available toast colors/types: ToastType.Standard, ToastType.Info, ToastType.Warning ToastType.Success, ToastType.Error
Diffstat (limited to 'src/Toast.qml')
-rw-r--r--src/Toast.qml26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/Toast.qml b/src/Toast.qml
index 0de53a9..7a18dc8 100644
--- a/src/Toast.qml
+++ b/src/Toast.qml
@@ -27,6 +27,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.3
+import rwa.toast.type 1.0
/**
* adapted from StackOverflow:
@@ -50,8 +51,11 @@ Control {
*
* @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) {
+ function show(text, duration, type) {
message.text = text;
// checks if parameter was passed
@@ -60,6 +64,23 @@ Control {
} else {
time = defaultTime;
}
+
+ if (typeof type !== "undefined" ) {
+ if (type === ToastType.ToastStandard) {
+ selectedColor = "#dcdedc";
+ } else if (type === ToastType.ToastInfo) {
+ selectedColor = "#0d5eaf";
+ } else if (type === ToastType.ToastSuccess) {
+ selectedColor = "#0daf36";
+ } else if (type === ToastType.ToastWarning) {
+ selectedColor = "#efef2a";
+ } else if (type === ToastType.ToastError) {
+ selectedColor = "#ed1212";
+ }
+ } else {
+ selectedColor = "#dcdedc";
+ }
+
animation.start();
}
@@ -72,6 +93,7 @@ Control {
id: root
+ property color selectedColor: "#dcdedc"
readonly property real defaultTime: 3000
property real time: defaultTime
readonly property real fadeTime: 300
@@ -88,6 +110,8 @@ Control {
background: Rectangle {
color: (Material.theme == Material.Dark) ? "#212121" : "#dcdedc"
+ border.color: selectedColor
+ border.width: 1.5
radius: margin
}