diff --git a/qml.qrc b/qml.qrc index 0bb8fc3b02a583c0f37c67088a404a5e66a61f54..e6f7b8c6798cc32488b3968973212ed65f92c62a 100644 --- a/qml.qrc +++ b/qml.qrc @@ -139,5 +139,6 @@ <file>src/commoncomponents/UsernameLineEdit.qml</file> <file>src/mainview/components/UserInfoCallPage.qml</file> <file>src/commoncomponents/BaseDialog.qml</file> + <file>src/commoncomponents/ModalPopup.qml</file> </qresource> </RCC> diff --git a/src/commoncomponents/ModalPopup.qml b/src/commoncomponents/ModalPopup.qml new file mode 100644 index 0000000000000000000000000000000000000000..6ebd5ec94a8fab5ff03e4ef07b46a08b696e4a98 --- /dev/null +++ b/src/commoncomponents/ModalPopup.qml @@ -0,0 +1,86 @@ +/* + * 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 + } + } +} diff --git a/src/mainview/components/WelcomePageQrDialog.qml b/src/mainview/components/WelcomePageQrDialog.qml index a4a9e25153af31c11d094d8b3a8a6c3bbb105e0a..c296cf3b85caa6e41405c31982b47cf9e55563de 100644 --- a/src/mainview/components/WelcomePageQrDialog.qml +++ b/src/mainview/components/WelcomePageQrDialog.qml @@ -25,56 +25,34 @@ import net.jami.Adapters 1.0 import "../../constant" import "../../commoncomponents" -BaseDialog { +ModalPopup { id: root - title: JamiStrings.accountQr + modal: true - contentItem: Rectangle { - id: content + //Content height + margin. + property int size: userQrImage.height + 30 + width: size + height: size - implicitWidth: userQrImage.width + JamiTheme.preferredMarginSize * 2 - implicitHeight: 352 // Qr + btn + margins + Item { + anchors.fill: parent - ColumnLayout { + Image { + id: userQrImage anchors.centerIn: parent - anchors.fill: parent - Image { - id: userQrImage + width: 256 + height: 256 + smooth: false - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: 256 - Layout.preferredHeight: 256 - - smooth: false - - fillMode: Image.PreserveAspectFit - source: { - if (AccountAdapter.currentAccountId) - return "image://qrImage/account_" + AccountAdapter.currentAccountId - return "" - } - } - - MaterialButton { - id: btnClose - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.bottomMargin: JamiTheme.preferredMarginSize - - text: JamiStrings.close - color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - - onClicked: { - close() - } + fillMode: Image.PreserveAspectFit + source: { + if (AccountAdapter.currentAccountId && + AccountAdapter.currentAccountType === Profile.Type.RING) + return "image://qrImage/account_" + AccountAdapter.currentAccountId + return "" } } }