4
0
mirror of https://github.com/QuasarApp/SimpleQmlNotify.git synced 2025-05-09 19:59:34 +00:00

added support of the progres bar

This commit is contained in:
Andrei Yankovich 2021-01-17 22:37:30 +03:00
parent d9b5ee82f5
commit 6cc502f101
3 changed files with 75 additions and 30 deletions

@ -5,11 +5,11 @@
* of this license document, but changing it is not allowed.
*/
import QtQuick 2.11
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.12
import QtGraphicalEffects 1.15
Dialog {
id : basePopup
@ -27,6 +27,8 @@ Dialog {
property int margin : 0
property color backgroundColor: Material.background
property alias autoClosePasused: progressAnimation.paused
background: Item {
id: bacground
@ -47,23 +49,20 @@ Dialog {
}
function _show() {
open();
if (autoClose) {
timerAutoClose.start();
progressAnimation.from = 0;
progressAnimation.start();
}
open();
}
Timer {
id: timerAutoClose;
running: false;
repeat: false;
interval: closeInterval;
function autoclosePause() {
progressAnimation.pause();
}
onTriggered: {
close();
}
function autocloseResume() {
progressAnimation.resume();
}
onClosed: {
@ -75,4 +74,26 @@ Dialog {
onRejected: close()
footer: ProgressBar {
id: progress;
from: 0
to: 100
visible: autoClose
value: 0;
NumberAnimation on value {
id: progressAnimation
duration: closeInterval
easing.type: Easing.Linear
running: false
to: 100
from: progress.value
onFinished: {
close();
}
}
}
}

@ -39,21 +39,9 @@ BasePopUp {
backgroundColor: _getBackGraundColor(type);
Page {
id: page
anchors.fill: parent
spacing: 0
contentItem:
Item {
background: Rectangle {
color: "#00000000"
}
header: Label {
text: titleText
horizontalAlignment: Text.AlignHCenter
}
contentItem:
RowLayout {
id: rowLayout
spacing: 5
@ -86,6 +74,42 @@ BasePopUp {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
anchors.fill: parent
}
MouseArea {
hoverEnabled: true
onEntered: {
autoclosePause();
}
onExited: {
autocloseResume();
}
onClicked: {
if (!autoClose) {
close();
}
if (autoClosePasused) {
autocloseResume()
} else {
autoclosePause();
}
}
anchors.fill: parent
}
}
header: Label {
text: titleText
horizontalAlignment: Text.AlignHCenter
}
}

@ -30,7 +30,7 @@ Item {
x: parent.width - width - margin;
y: margin;
width: 6 * metrix.controlPtMaterial;
width: 5 * metrix.pt;
height: width * 0.5
}