diff options
| author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-08-09 12:34:48 +0000 |
|---|---|---|
| committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-08-09 12:34:48 +0000 |
| commit | 607edbcd8689ea71ec57340204ed3d908a7cadbb (patch) | |
| tree | 91961406adb5143e0c5072094d2d1a4846e6b6b0 /src/Toast.qml | |
| parent | 34abe223f7648929f0c6b9132fbdc83e0353b51a (diff) | |
| parent | fd5e881fdee35d21fd3e0728e5b927d04e64f459 (diff) | |
| download | RWA.Support.DesktopApp-607edbcd8689ea71ec57340204ed3d908a7cadbb.tar.gz RWA.Support.DesktopApp-607edbcd8689ea71ec57340204ed3d908a7cadbb.tar.bz2 RWA.Support.DesktopApp-607edbcd8689ea71ec57340204ed3d908a7cadbb.zip | |
Merge branch 'mr/feature/gitlab-ci' into 'master'
Add .gitlab-ci.yml
See merge request remotewebapp/rwa.support.desktopapp!2
Diffstat (limited to 'src/Toast.qml')
| -rw-r--r-- | src/Toast.qml | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/Toast.qml b/src/Toast.qml index eb65b20..7a18dc8 100644 --- a/src/Toast.qml +++ b/src/Toast.qml @@ -1,8 +1,8 @@ /* * This file is part of Remote Support Desktop * https://gitlab.das-netzwerkteam.de/RemoteWebApp/remote-support-desktop - * Copyright 2020-2021 Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> - * Copyright 2020-2021 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + * Copyright 2020, 2021 Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> + * Copyright 2020, 2021 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> * SPDX-License-Identifier: GPL-2.0-or-later * * This program is free software; you can redistribute it and/or modify @@ -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: @@ -36,7 +37,8 @@ import QtQuick.Controls.Material 2.3 */ /** - * @brief An Android-like timed message text in a box that self-destroys when finished if desired + * @brief An Android-like timed message text in + * a box that self-destroys when finished if desired */ Control { @@ -49,20 +51,41 @@ 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; - if (typeof duration !== "undefined") { // checks if parameter was passed + + // checks if parameter was passed + if (typeof duration !== "undefined") { time = Math.max(duration, 2 * fadeTime); - } - else { + } else { time = defaultTime; } - console.log("Showing a new toast with display time: " + time); + + 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(); } - property bool selfDestroying: false // whether this Toast will self-destroy when it is finished + // whether this Toast will self-destroy when it is finished + property bool selfDestroying: false /** * Private @@ -70,6 +93,7 @@ Control { id: root + property color selectedColor: "#dcdedc" readonly property real defaultTime: 3000 property real time: defaultTime readonly property real fadeTime: 300 @@ -86,6 +110,8 @@ Control { background: Rectangle { color: (Material.theme == Material.Dark) ? "#212121" : "#dcdedc" + border.color: selectedColor + border.width: 1.5 radius: margin } |
