2021-07-22 21:52:01 +00:00
|
|
|
/**
|
2022-01-20 17:19:36 +00:00
|
|
|
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and repartition functions.
|
2022-01-12 13:39:23 +00:00
|
|
|
* Copyright (C) 2022 Ad5001
|
2021-07-22 21:52:01 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
2022-01-29 17:17:19 +00:00
|
|
|
/*!
|
|
|
|
\qmltype Alert
|
|
|
|
\inqmlmodule eu.ad5001.LogarithmPlotter.Popup
|
|
|
|
\brief Alert used to show status messages to the user.
|
|
|
|
|
|
|
|
This class (only one instance) allows messages to be displayed to the user that will fade in time.
|
|
|
|
|
|
|
|
\sa LogarithmPlotter
|
|
|
|
*/
|
2021-07-22 21:52:01 +00:00
|
|
|
Rectangle {
|
|
|
|
id: alert
|
|
|
|
color: "black"
|
|
|
|
radius: 5
|
|
|
|
x: fadingAnimation.running ? fadingX : parent.width - width - 10
|
|
|
|
visible: false;
|
|
|
|
width: textItem.width + 10
|
|
|
|
height: textItem.height + 10
|
|
|
|
|
2022-01-29 17:17:19 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty int Alert::fadingX
|
|
|
|
X of the object that is being animated.
|
|
|
|
*/
|
2021-07-22 21:52:01 +00:00
|
|
|
property int fadingX: parent.width - width - 10
|
2022-01-29 17:17:19 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty int Alert::fadeTime
|
|
|
|
Length in millisecond of the animation.
|
|
|
|
*/
|
2021-07-22 21:52:01 +00:00
|
|
|
property int fadeTime: 200
|
2022-01-29 17:17:19 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty string Alert::text
|
|
|
|
Text of the alert.
|
|
|
|
*/
|
2021-07-22 21:52:01 +00:00
|
|
|
property alias text: textItem.text
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: textItem
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
color: "white"
|
|
|
|
font.pixelSize: 18
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
id: fadingAnimation
|
|
|
|
running: false
|
|
|
|
NumberAnimation { target: alert; property: "fadingX"; to: alert.parent.width; duration: alert.fadeTime }
|
|
|
|
NumberAnimation { target: alert; property: "opacity"; to: 0; duration: alert.fadeTime }
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: fadeTimer
|
2021-07-23 17:37:03 +00:00
|
|
|
interval: 1000 + text.length * 45
|
2021-07-22 21:52:01 +00:00
|
|
|
onTriggered: {
|
|
|
|
hideTimer.start()
|
|
|
|
fadingAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: hideTimer
|
|
|
|
interval: alert.fadeTime
|
|
|
|
onTriggered: {
|
|
|
|
alert.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-29 17:17:19 +00:00
|
|
|
/*!
|
|
|
|
\qmlmethod void Alert::show(string alertText)
|
|
|
|
Show an alert with a certain \c alertText.
|
|
|
|
*/
|
2021-07-22 21:52:01 +00:00
|
|
|
function show(alertText) {
|
|
|
|
visible = true
|
2021-07-23 17:37:03 +00:00
|
|
|
fadeTimer.restart()
|
2021-07-22 21:52:01 +00:00
|
|
|
text = alertText
|
|
|
|
opacity = 0.75
|
|
|
|
fadingX = parent.width - width - 10
|
|
|
|
}
|
|
|
|
}
|