1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-03-28 14:56:19 +01:00
jami-client-qt/src/app/commoncomponents/BaseModalDialog.qml
Sébastien Blin 84150e8977 misc: bump copyright to 2024
Change-Id: I8d5f968fbedbc884c91416246049a0ef4cd652eb
2024-01-03 09:54:49 -05:00

206 lines
6.1 KiB
QML

/*
* Copyright (C) 2020-2024 Savoir-faire Linux Inc.
* 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
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import net.jami.Constants 1.1
import "../mainview/components"
Popup {
id: root
// convient access to closePolicy
property bool autoClose: true
property alias backgroundColor: container.color
property alias backgroundOpacity: container.background.opacity
property alias title: titleText.text
property var popupcontainerSubContentLoader: containerSubContentLoader
property bool closeButtonVisible: true
property int button1Role
property int button2Role
property alias button1: action1
property alias button2: action2
property alias popupContentLoadStatus: containerSubContentLoader.status
property alias popupContent: containerSubContentLoader.sourceComponent
property int popupMargins: 30
property int buttonMargin: 20
property int maximumPopupWidth: 600
parent: Overlay.overlay
anchors.centerIn: parent
modal: true
focus: true
closePolicy: autoClose ? (Popup.CloseOnEscape | Popup.CloseOnPressOutside) : Popup.NoAutoClose
contentItem: Control {
id: container
property color color: JamiTheme.secondaryBackgroundColor
anchors.centerIn: parent
leftPadding: popupMargins
bottomPadding: action1.visible || action2.visible ? 10 :popupMargins
background: Rectangle {
id: bgRect
radius: 5
color: container.color
layer.enabled: true
layer.effect: DropShadow {
horizontalOffset: 3.0
verticalOffset: 3.0
radius: bgRect.radius * 4
color: JamiTheme.shadowColor
source: bgRect
transparentBorder: true
samples: radius + 1
}
}
contentItem: ColumnLayout {
id: contentLayout
JamiPushButton {
id: closeButton
visible: closeButtonVisible
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 20
Layout.preferredWidth: 20
Layout.topMargin: 5
Layout.rightMargin: 5
imageColor: hovered ? JamiTheme.textColor : JamiTheme.buttonTintedGreyHovered
normalColor: "transparent"
source: JamiResources.round_close_24dp_svg
onClicked: close()
}
Label {
id: titleText
Layout.rightMargin: popupMargins
Layout.bottomMargin: 20
Layout.topMargin: closeButtonVisible ? 0 : 30
Layout.alignment: Qt.AlignLeft
font.pointSize: JamiTheme.menuFontSize
color: JamiTheme.textColor
font.bold: true
visible: text.length > 0
}
JamiFlickable {
id: flickable
Layout.fillHeight: true
Layout.preferredHeight: Math.min(contentHeight, root.height)
Layout.preferredWidth: contentItem.childrenRect.width
Layout.rightMargin: popupMargins
Layout.alignment: Qt.AlignCenter
contentHeight: contentItem.childrenRect.height
contentItem.children: Loader {
id: containerSubContentLoader
}
ScrollBar.horizontal.visible: false
}
DialogButtonBox {
id: buttonBox
Layout.alignment: Qt.AlignRight
spacing: 1.5
background: Rectangle {
color: "transparent"
width: buttonBox.childrenRect.width
height: buttonBox.childrenRect.height
}
visible: action1.text.length > 0
contentHeight: childrenRect.height + 14
MaterialButton {
id: action1
visible: text.length > 0
rightPadding: buttonMargin
leftPadding: buttonMargin
tertiary: true
autoAccelerator: true
DialogButtonBox.buttonRole: root.button1Role
}
MaterialButton {
id: action2
visible: text.length > 0
rightPadding: buttonMargin
leftPadding: buttonMargin
tertiary: true
autoAccelerator: true
DialogButtonBox.buttonRole: root.button2Role
}
}
}
}
background: Rectangle {
color: JamiTheme.transparentColor
}
Overlay.modal: Rectangle {
color: JamiTheme.transparentColor
// Color animation for overlay when pop up is shown.
ColorAnimation on color {
to: JamiTheme.popupOverlayColor
duration: 500
}
}
enter: Transition {
NumberAnimation {
properties: "opacity"
from: 0.0
to: 1.0
duration: JamiTheme.shortFadeDuration
}
}
exit: Transition {
NumberAnimation {
properties: "opacity"
from: 1.0
to: 0.0
duration: JamiTheme.shortFadeDuration
}
}
}