SimpleQmlNotify/NotifyModule/NotificationForm.qml

113 lines
2.5 KiB
QML
Raw Normal View History

2020-05-23 02:30:51 +03:00
/*
2021-01-31 19:57:49 +03:00
* Copyright (C) 2018-2021 QuasarApp.
2020-05-23 02:30:51 +03:00
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
2021-01-18 23:20:03 +03:00
import QtQuick 2.15
import QtQuick.Controls 2.5
import QtQuick.Controls.Material 2.15
2019-11-19 15:20:38 +03:00
import QtQuick.Layouts 1.3
BasePopUp {
id : popup
property string text: qsTr("Message")
property string img: ""
property string titleText: qsTr("Message")
property int type: 0
2021-01-19 21:35:18 +03:00
readonly property string defImgI: "qrc:/icons/info"
readonly property string defImgW: "qrc:/icons/warning"
readonly property string defImgE: "qrc:/icons/error"
function getDefaultImage(type) {
2019-11-19 15:20:38 +03:00
switch(type) {
2021-01-19 21:35:18 +03:00
case 1: return defImgW
case 2: return defImgE
2019-11-19 15:20:38 +03:00
}
2021-01-19 21:35:18 +03:00
return defImgI
2019-11-19 15:20:38 +03:00
}
autoClose: true;
closeInterval: 5000
margins: 0
margin: 0
spacing: 0
2021-01-19 21:35:18 +03:00
backgroundColor: Material.background
2019-11-19 15:20:38 +03:00
2021-01-17 22:37:30 +03:00
contentItem:
2021-10-21 18:46:18 +03:00
Control {
id: control;
implicitHeight: rowLayout.implicitHeight
2019-11-19 15:20:38 +03:00
RowLayout {
id: rowLayout
spacing: 5
clip: true
2021-10-21 18:46:18 +03:00
width: control.width
Image {
id: image
Layout.preferredWidth: Math.max(message.height, 50);
Layout.preferredHeight: Math.max(message.height, 50);
2019-11-19 15:20:38 +03:00
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
2021-10-21 18:46:18 +03:00
fillMode: Image.PreserveAspectCrop
clip: true
source: img
2019-11-19 15:20:38 +03:00
}
Label {
id: message
text: popup.text
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.fillWidth: true;
clip: true
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
2021-10-21 18:46:18 +03:00
horizontalAlignment: Text.AlignLeft
2019-11-19 15:20:38 +03:00
}
2021-01-17 22:37:30 +03:00
}
MouseArea {
hoverEnabled: true
onEntered: {
autoclosePause();
}
onExited: {
autocloseResume();
}
onClicked: {
if (!autoClose) {
close();
}
if (autoClosePasused) {
autocloseResume()
} else {
autoclosePause();
}
}
anchors.fill: parent
2019-11-19 15:20:38 +03:00
}
}
2021-01-17 22:37:30 +03:00
2021-01-19 21:35:18 +03:00
title: titleText
2019-11-19 15:20:38 +03:00
}