72 lines
1.3 KiB
QML
Raw Normal View History

2018-12-06 22:49:35 +03:00
import QtQuick 2.11
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
2019-08-19 14:20:49 +03:00
import QtGraphicalEffects 1.12
2018-12-06 22:49:35 +03:00
2019-08-09 20:48:31 +03:00
Dialog {
2018-12-06 22:49:35 +03:00
id : basePopup
width: 200
height: 100
x: 0
y: 0
transformOrigin: Item.Center
property bool autoClose: true
2019-07-31 17:47:26 +03:00
property bool clickClose: true
2018-12-06 22:49:35 +03:00
property int closeInterval: 15000;
property int margin : 0
2019-07-31 23:15:01 +03:00
property color backgroundColor: Material.background
background: Item {
id: bacground
Rectangle{
anchors.fill: parent
id: backCorner
color: backgroundColor
radius: metrix.mm
}
DropShadow {
anchors.fill: parent
source: backCorner
color: "#80000000"
verticalOffset: 10
samples: 30
}
}
2018-12-06 22:49:35 +03:00
function _show() {
if (autoClose) {
2019-08-01 13:07:07 +03:00
timerAutoClose.start();
2018-12-06 22:49:35 +03:00
}
open();
}
Timer {
2019-08-01 13:07:07 +03:00
id: timerAutoClose;
2018-12-06 22:49:35 +03:00
running: false;
repeat: false;
2019-08-01 13:07:07 +03:00
interval: closeInterval;
2018-12-06 22:49:35 +03:00
onTriggered: {
2019-08-01 13:07:07 +03:00
close();
2018-12-06 22:49:35 +03:00
}
}
onClosed: {
if (autoClose)
opacity = 0;
}
2019-07-31 17:47:26 +03:00
closePolicy: (!clickClose || autoClose)? Popup.NoAutoClose: Popup.CloseOnReleaseOutside
2018-12-06 22:49:35 +03:00
2019-08-09 20:48:31 +03:00
onRejected: close()
2018-12-06 22:49:35 +03:00
}