Skip to content
Snippets Groups Projects
Commit c7bae56d authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

qrcode: use a modal popup component

Change-Id: I8cd46f2f5bb404394513e1f93fe5bbab44cbddcf
parent 6e43a456
No related branches found
No related tags found
No related merge requests found
......@@ -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>
/*
* 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
}
}
}
......@@ -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 ""
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment