1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-11 10:15:40 +02:00
jami-client-qt/src/commoncomponents/ModalPopup.qml

87 lines
2.2 KiB
QML
Raw Normal View History

/*
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
*
* 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.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
Popup {
id: root
property int fadeDuration: 100
// convient access to closePolicy
property bool autoClose: true
onContentItemChanged: {
if(root.contentItem !== null)
root.contentItem.parent = container
}
parent: Overlay.overlay
// center in parent
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height - height) / 2)
modal: true
// A popup is invisible until opened.
visible: false
closePolicy: autoClose ?
(Popup.CloseOnEscape | Popup.CloseOnPressOutside) :
Popup.NoAutoClose
padding: 0
background: Rectangle {
id: container
// TODO: this is the MaterialButton radius and should be part of
// a theme.
radius: 4
width: root.width
height: root.height
}
DropShadow {
z: -1
width: root.width
height: root.height
horizontalOffset: 3.0
verticalOffset: 3.0
radius: container.radius * 2
samples: 16
color: "#80000000"
source: container
}
enter: Transition {
NumberAnimation {
properties: "opacity"; from: 0.0; to: 1.0
duration: fadeDuration
}
}
exit: Transition {
NumberAnimation {
properties: "opacity"; from: 1.0; to: 0.0
duration: fadeDuration
}
}
}