mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 14:33:06 +02:00
186 lines
6.2 KiB
QML
186 lines
6.2 KiB
QML
//
|
|
// CommerceLightbox.qml
|
|
// qml/hifi/commerce/common
|
|
//
|
|
// CommerceLightbox
|
|
//
|
|
// Created by Zach Fox on 2017-09-19
|
|
// Copyright 2017 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
import Hifi 1.0 as Hifi
|
|
import QtQuick 2.5
|
|
import QtGraphicalEffects 1.0
|
|
import "../../../styles-uit"
|
|
import "../../../controls-uit" as HifiControlsUit
|
|
import "../../../controls" as HifiControls
|
|
|
|
// references XXX from root context
|
|
|
|
Rectangle {
|
|
property string titleText;
|
|
property string bodyImageSource;
|
|
property string bodyText;
|
|
property string button1color: hifi.buttons.noneBorderlessGray;
|
|
property string button1text;
|
|
property string button1method;
|
|
property string button2color: hifi.buttons.noneBorderless;
|
|
property string button2text;
|
|
property string button2method;
|
|
property string buttonLayout: "leftright";
|
|
|
|
readonly property string securityPicBodyText: "When you see your Security Pic, your actions and data are securely making use of your " +
|
|
"Wallet's private keys.<br><br>You can change your Security Pic in your Wallet.";
|
|
|
|
id: root;
|
|
visible: false;
|
|
anchors.fill: parent;
|
|
color: Qt.rgba(0, 0, 0, 0.5);
|
|
z: 999;
|
|
|
|
onVisibleChanged: {
|
|
if (!visible) {
|
|
resetLightbox();
|
|
}
|
|
}
|
|
|
|
// This object is always used in a popup.
|
|
// This MouseArea is used to prevent a user from being
|
|
// able to click on a button/mouseArea underneath the popup.
|
|
MouseArea {
|
|
anchors.fill: parent;
|
|
propagateComposedEvents: false;
|
|
hoverEnabled: true;
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.centerIn: parent;
|
|
width: parent.width - 100;
|
|
height: childrenRect.height + 30;
|
|
color: "white";
|
|
|
|
RalewaySemiBold {
|
|
id: titleText;
|
|
text: root.titleText;
|
|
anchors.top: parent.top;
|
|
anchors.topMargin: 30;
|
|
anchors.left: parent.left;
|
|
anchors.leftMargin: 30;
|
|
anchors.right: parent.right;
|
|
anchors.rightMargin: 30;
|
|
height: paintedHeight;
|
|
color: hifi.colors.baseGray;
|
|
size: 24;
|
|
verticalAlignment: Text.AlignTop;
|
|
wrapMode: Text.WordWrap;
|
|
}
|
|
|
|
Image {
|
|
id: bodyImage;
|
|
visible: root.bodyImageSource;
|
|
source: root.bodyImageSource ? root.bodyImageSource : "";
|
|
anchors.top: root.titleText ? titleText.bottom : parent.top;
|
|
anchors.topMargin: root.titleText ? 20 : 30;
|
|
anchors.left: parent.left;
|
|
anchors.leftMargin: 30;
|
|
anchors.right: parent.right;
|
|
anchors.rightMargin: 30;
|
|
height: 140;
|
|
fillMode: Image.PreserveAspectFit;
|
|
mipmap: true;
|
|
cache: false;
|
|
}
|
|
|
|
RalewayRegular {
|
|
id: bodyText;
|
|
text: root.bodyText;
|
|
anchors.top: root.bodyImageSource ? bodyImage.bottom : (root.titleText ? titleText.bottom : parent.top);
|
|
anchors.topMargin: root.bodyImageSource ? 20 : (root.titleText ? 20 : 30);
|
|
anchors.left: parent.left;
|
|
anchors.leftMargin: 30;
|
|
anchors.right: parent.right;
|
|
anchors.rightMargin: 30;
|
|
height: paintedHeight;
|
|
color: hifi.colors.baseGray;
|
|
size: 20;
|
|
verticalAlignment: Text.AlignTop;
|
|
wrapMode: Text.WordWrap;
|
|
|
|
onLinkActivated: {
|
|
sendToParent({ method: 'commerceLightboxLinkClicked', linkUrl: link });
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: buttons;
|
|
anchors.top: bodyText.bottom;
|
|
anchors.topMargin: 30;
|
|
anchors.left: parent.left;
|
|
anchors.right: parent.right;
|
|
height: root.buttonLayout === "leftright" ? 70 : 150;
|
|
|
|
// Button 1
|
|
HifiControlsUit.Button {
|
|
id: button1;
|
|
color: root.button1color;
|
|
colorScheme: hifi.colorSchemes.light;
|
|
anchors.top: root.buttonLayout === "leftright" ? parent.top : parent.top;
|
|
anchors.left: parent.left;
|
|
anchors.leftMargin: 10;
|
|
anchors.right: root.buttonLayout === "leftright" ? undefined : parent.right;
|
|
anchors.rightMargin: root.buttonLayout === "leftright" ? undefined : 10;
|
|
width: root.buttonLayout === "leftright" ? (root.button2text ? parent.width/2 - anchors.leftMargin*2 : parent.width - anchors.leftMargin * 2) :
|
|
(undefined);
|
|
height: 50;
|
|
text: root.button1text;
|
|
onClicked: {
|
|
eval(button1method);
|
|
}
|
|
}
|
|
|
|
// Button 2
|
|
HifiControlsUit.Button {
|
|
id: button2;
|
|
visible: root.button2text;
|
|
color: root.button2color;
|
|
colorScheme: hifi.colorSchemes.light;
|
|
anchors.top: root.buttonLayout === "leftright" ? parent.top : button1.bottom;
|
|
anchors.topMargin: root.buttonLayout === "leftright" ? undefined : 20;
|
|
anchors.left: root.buttonLayout === "leftright" ? undefined : parent.left;
|
|
anchors.leftMargin: root.buttonLayout === "leftright" ? undefined : 10;
|
|
anchors.right: parent.right;
|
|
anchors.rightMargin: 10;
|
|
width: root.buttonLayout === "leftright" ? parent.width/2 - anchors.rightMargin*2 : undefined;
|
|
height: 50;
|
|
text: root.button2text;
|
|
onClicked: {
|
|
eval(button2method);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// FUNCTION DEFINITIONS START
|
|
//
|
|
signal sendToParent(var msg);
|
|
|
|
function resetLightbox() {
|
|
root.titleText = "";
|
|
root.bodyImageSource = "";
|
|
root.bodyText = "";
|
|
root.button1color = hifi.buttons.noneBorderlessGray;
|
|
root.button1text = "";
|
|
root.button1method = "";
|
|
root.button2color = hifi.buttons.noneBorderless;
|
|
root.button2text = "";
|
|
root.button2method = "";
|
|
root.buttonLayout = "leftright";
|
|
}
|
|
//
|
|
// FUNCTION DEFINITIONS END
|
|
//
|
|
}
|