123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- import QtQuick 2.5
- import QtWebEngine 1.2
- import QtQuick.Window 2.1
- import QtQuick.Controls 1.4
- import Qt.labs.controls 1.0
- import QtQuick.Layouts 1.1
- import ApplicationLauncher 1.0
- import "qrc:/Globals"
- import "Menu" as Menu
- import QtQuick.FreeVirtualKeyboard 1.0
- Rectangle {
- property int buttImgBorder: 5 // in percent of parent.height defaults to 20%
- property string buttCamImage: "/images/LiveMode_Button.svg"
- property string buttmenuArea: "/images/LockButton.svg"
- property int buttRadius: 0
- property bool buttCam1Visible: false
- property bool buttCam2Visible: false
- property int camSelected: -1
- property color buttGradientStart: "darkgray"
- property color buttGradientStop: "black"
- property color buttGradientSelectedStart: Globals.customer_color_base
- property color buttGradientSelectedStop: Globals.customer_color_base
- property bool menuRightBorder: true
- property int menuOffset: 115
- function whichCamSet() {
- var _camSelected = settings.value("COMMON/CamSelected","-");
- var ret = "0.0.0.0";
- if (_camSelected.toString() === "1") {
- camSelected = 1;
- ret = settings.value("CAM1SETTINGS/IpAddress","0.0.0.0");
- } else if (_camSelected.toString() === "2") {
- camSelected = 2;
- ret = settings.value("CAM2SETTINGS/IpAddress","0.0.0.0");
- }
- if ((_camSelected === "-" ) || (ret === "0.0.0.0")) {
- if (settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0") {
- settings.setValue("COMMON/CamSelected", "1");
- camSelected = 1;
- ret = settings.value("CAM1SETTINGS/IpAddress","0.0.0.0");
- } else if (settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0") {
- settings.setValue("COMMON/CamSelected", "2");
- camSelected = 2;
- ret = settings.value("CAM2SETTINGS/IpAddress","0.0.0.0");
- }
- }
- buttCam1Visible = (settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0")?true:false;
- buttCam2Visible = (settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0")?true:false;
- return ret;
- }
- property string camURL : ""
- id: root
- width: parent.width
- height: parent.height
- color: "white"
- Timer {
- id: urlTIMER
- interval: 2500
- running: false
- repeat: false
- onTriggered: {
- testWebsite.appName = "httping -c1 -s -q -G " + camURL;
- if(menuAREA.z === 1) {
- testWebsite.launchScript();
- } else {
- }
- }
- }
- CustomBusyIndicator{
- property alias running: urlchangeBUSY.visible
- id:urlchangeBUSY
- anchors.centerIn: parent
- //x: (popupWIN.width - popupWIN.height) / 2
- width: parent.height * 0.75
- height: parent.height * 0.75
- bBgColor: Globals.customer_color_base
- bLength:50
- opacity: 0.75
- visible: false
- }
- ApplicationLaunch {
- id: testWebsite
- arguments: ""
- onAppFinished: {
- if(exitCode != 0) {
- console.debug("----> URL Code ", exitCode );
- mainview.visible = false;
- mainview.url = "";
- mainview.url = "xx";
- urlchangeBUSY.visible = true;
- urlTIMER.interval = 2500;
- if(urlTIMER.running == false) {
- urlTIMER.restart();
- }
- } else {
- urlTIMER.stop();
- mainview.url = "";
- mainview.url = camURL;
- urlchangeBUSY.visible = false;
- mainview.visible = true;
- }
- }
- }
- Component.onCompleted: {
- urlchangeBUSY.visible = true;
- camURL = whichCamSet();
- testWebsite.appName = "httping -c1 -s -q -G " + camURL;
- testWebsite.launchScript();
- console.debug("CAMURL Component.onCompleted :" + camURL);
- }
- onVisibleChanged: {
- console.debug("Start.qml onVisible changed :" + visible);
- if (visible) {
- if (camURL !== whichCamSet()) {
- console.debug("CAMURL onVisible changed :" + camURL);
- camURL = whichCamSet();
- testWebsite.appName = "httping -c1 -s -q -G " + camURL;
- testWebsite.launchScript();
- console.debug("CAMURL onVisibleChanged :" + camURL);
- }
- mainview.visible = mainview.focus = true
- } else {
- mainview.visible = mainview.focus = false
- Qt.inputMethod.hide();
- }
- }
- Flickable {
- id: flickable
- anchors.fill: parent
- contentWidth: root.width
- contentHeight: root.height
- interactive: contentHeight > height
- flickableDirection: Flickable.VerticalFlick
- clip: true
- Item {
- id: content
- x: 0
- y: 0
- width: flickable.width
- //============================================================================
- Rectangle {
- id: rectangle
- x: 0
- y: 0
- width: parent.width
- height: parent.height
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- WebEngineView {
- id: mainview
- width: flickable.contentWidth
- height: flickable.contentHeight
- x: 0
- y: 0
- onCertificateError: {
- console.debug("<<<<<<<<<<<<<<<<<<<<<CERT ERROR>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- console.log(error.description);
- error.ignoreCertificateError();
- }
- onVisibleChanged: {
- console.debug("<<<<<<<<<<<<<<<<<<<<<VISIBLECHANGED>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- console.debug("VISIBLE : " + visible);
- }
- onNewViewRequested: {
- console.debug("<<<<<<<<<<<<<<<<<<<<<NEWVIEWREQUESTED>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- console.debug("MSG : " + message);
- }
- onFeaturePermissionRequested: {
- console.debug("<<<<<<<<<<<<<<<<<<<<<FEATUREPERMISSIONREQUEST>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- console.debug("MSG : " + message);
- }
- onJavaScriptConsoleMessage: {
- console.debug("<<<<<<<<<<<<<<<<<<<<<JSConsoleMessage>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- console.debug("MSG : " + message);
- }
- Component.onCompleted: {
- Qt.inputMethod.hide();
- }
- } // WebEngineView
- Rectangle {
- id: menuHIDDEN
- x: 0
- y: 0
- z: menuAREA.z === 1 ? -1 : 1
- width: height
- height: 60
- color: "lightgray"
- opacity: 0.05
- visible: z === 1 ? true:false
- MouseArea {
- x: parent.x
- y: parent.y
- width: parent.height
- height: parent.width
- onClicked: {
- menuAREA.z = menuAREA.z === -1 ?menuAREA.z = 1: menuAREA.z = -1;
- menuAREATimer.start();
- sysinfo.beep();
- }
- }
- }
- Rectangle {
- id: menuAREA
- x: menuRightBorder?parent.width - width - menuOffset:menuOffset
- y: 0
- z: -1
- width: height * 4
- height: 60
- color: "lightgray"
- opacity: 0.75
- visible: z === 1 ? true:false
- Rectangle {
- x: parent.width - 4 * parent.height
- y: parent.y
- width: parent.height
- height: parent.height
- z: menuAREA.z
- visible: z === 1 ? true:false
- color: "lightgray"
- opacity: parent.opacity
- Image {
- anchors.centerIn: parent
- fillMode: Image.PreserveAspectFit
- source: buttmenuArea
- sourceSize.height: parent.height * 0.7 //- parent.height * (buttImgBorder / 100.0)
- sourceSize.width: parent.width * 0.7 //- parent.width * (buttImgBorder / 100.0)
- visible: parent.visible
- }
- }
- MouseArea {
- x: parent.width - 4 * parent.height
- y: parent.y
- z: menuAREA.z
- width: parent.height //parent.width - 3 * parent.height
- height: parent.height
- onPressAndHold: {
- camURL = whichCamSet();
- testWebsite.appName = "httping -c1 -s -q -G " + camURL;
- testWebsite.launchScript();
- sysinfo.beep();
- sysinfo.beep();
- console.debug("RELOAD Website:: " + mainview.url);
- }
- onClicked: {
- stackView.push(Qt.resolvedUrl("PWD_Container.qml"));
- sysinfo.beep();
- }
- }
- Timer {
- interval: 1
- running: Globals.startTO.length > 0 ? true:false
- onTriggered: {
- if (Globals.startTO.length > 0) {
- stackView.push(Qt.resolvedUrl("PWD_Container.qml"));
- }
- }
- }
- Label {
- id: xLABEL
- x: parent.width - parent.height
- y: parent.y
- z: menuAREA.z
- width: parent.height
- height: parent.height
- opacity: parent.opacity
- visible: z === 1 ? true:false
- font.family: "FontAwesome"
- font.bold: false
- color: "red"
- text: "\uf057" //remove-sign
- font.pixelSize: parent.height
- }
- Button {
- property string in2: Globals.in2Status
- id: buttonCam2
- x: parent.width - 2 * parent.height
- y: parent.y
- z: menuAREA.z
- height: parent.height
- width: height
- opacity: parent.opacity
- visible: z === 1 ? buttCam2Visible:false
- Image {
- anchors.centerIn: parent
- fillMode: Image.PreserveAspectFit
- source: buttCamImage
- sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
- sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
- visible: parent.visible
- }
- background: Rectangle {
- radius: buttRadius
- visible: parent.visible
- gradient: Gradient {
- GradientStop { position:0 ; color: camSelected === 2?buttGradientSelectedStart:buttGradientStart }
- GradientStop { position:1 ; color: camSelected === 2?buttGradientSelectedStop:buttGradientStop }
- }
- }
- onClicked: {
- if(settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
- settings.setValue("COMMON/CamSelected", "2");
- camSelected = 2;
- root.visible = false;
- root.visible = true;
- }
- sysinfo.beep();
- }
- onIn2Changed: {
- if((settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
- (Globals.in2Status == "2")){
- settings.setValue("COMMON/CamSelected", "2");
- camSelected = 2;
- root.visible = false;
- root.visible = true;
- }
- sysinfo.beep();
- }
- }
- Button {
- property string in1: Globals.in1Status
- id: buttonCam1
- x: parent.width - 3 * parent.height
- y: parent.y
- z: menuAREA.z
- height: parent.height
- width: height
- opacity: parent.opacity
- visible: z === 1?buttCam1Visible:false
- Image {
- anchors.centerIn: parent
- fillMode: Image.PreserveAspectFit
- source: buttCamImage
- sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
- sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
- visible: parent.visible
- }
- background: Rectangle {
- radius: buttRadius
- visible: parent.visible
- gradient: Gradient {
- GradientStop { position:0 ; color: camSelected === 1?buttGradientSelectedStart:buttGradientStart }
- GradientStop { position:1 ; color: camSelected === 1?buttGradientSelectedStop:buttGradientStop }
- }
- }
- onClicked: {
- if(settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
- settings.setValue("COMMON/CamSelected", "1");
- camSelected = 1;
- root.visible = false;
- root.visible = true;
- }
- sysinfo.beep();
- }
- onIn1Changed: {
- if((settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
- (Globals.in1Status == "1")){
- settings.setValue("COMMON/CamSelected", "1");
- camSelected = 1;
- root.visible = false;
- root.visible = true;
- }
- sysinfo.beep();
- }
- }
- MouseArea {
- id: xAREA
- x: xLABEL.x
- y: xLABEL.y
- width: xLABEL.width
- height: xLABEL.height
- z: menuAREA.z
- onClicked: {
- menuAREA.z = menuAREA.z === 1 ? -1: 1;
- //menuAREATimer.start();
- sysinfo.beep();
- }
- }
- }
- Timer {
- id : menuAREATimer
- interval: 15000
- running: false
- repeat: false
- onTriggered: {
- menuAREA.z = menuAREA.z === 1 ? -1: 1;
- }
- }
- }
- //============================================================================
- }
- }
- }
|