Start.qml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. import QtQuick 2.5
  2. import QtWebEngine 1.2
  3. import QtQuick.Window 2.1
  4. //import Qt.labs.controls 1.0
  5. import QtQuick.Controls 2.0
  6. import QtQuick.Layouts 1.1
  7. import ApplicationLauncher 1.0
  8. import "qrc:/Globals"
  9. import "Menu" as Menu
  10. import QtQuick.FreeVirtualKeyboard 1.0
  11. Rectangle {
  12. property int buttImgBorder: 5 // in percent of parent.height defaults to 20%
  13. property string buttCamImage: "/images/LiveMode_Button.svg"
  14. property string buttmenuArea: "/images/LockButton.svg"
  15. property int buttRadius: 0
  16. property bool buttCam1Visible: false
  17. property bool buttCam2Visible: false
  18. property int camSelected: -1
  19. property color buttGradientStart: "darkgray"
  20. property color buttGradientStop: "black"
  21. property color buttGradientSelectedStart: Globals.customer_color_base
  22. property color buttGradientSelectedStop: Globals.customer_color_base
  23. property bool menuRightBorder: true
  24. property int menuOffset: 115
  25. function whichCamSet() {
  26. var _camSelected = settings.value("COMMON/CamSelected","-");
  27. var ret = "0.0.0.0";
  28. if (_camSelected.toString() === "1") {
  29. camSelected = 1;
  30. ret = settings.value("CAM1SETTINGS/IpAddress","0.0.0.0");
  31. } else if (_camSelected.toString() === "2") {
  32. camSelected = 2;
  33. ret = settings.value("CAM2SETTINGS/IpAddress","0.0.0.0");
  34. }
  35. if ((_camSelected === "-" ) || (ret === "0.0.0.0")) {
  36. if (settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0") {
  37. settings.setValue("COMMON/CamSelected", "1");
  38. camSelected = 1;
  39. ret = settings.value("CAM1SETTINGS/IpAddress","0.0.0.0");
  40. } else if (settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0") {
  41. settings.setValue("COMMON/CamSelected", "2");
  42. camSelected = 2;
  43. ret = settings.value("CAM2SETTINGS/IpAddress","0.0.0.0");
  44. }
  45. }
  46. buttCam1Visible = (settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0")?true:false;
  47. buttCam2Visible = (settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0")?true:false;
  48. return ret;
  49. }
  50. property string camURL : ""
  51. id: root
  52. width: parent.width
  53. height: parent.height
  54. color: "white"
  55. Timer {
  56. id: urlTIMER
  57. interval: 2500
  58. running: false
  59. repeat: false
  60. onTriggered: {
  61. testWebsite.appName = "curl --insecure -m 3 -Is " + camURL;
  62. if(menuAREA.z === 1) {
  63. testWebsite.launchScript();
  64. } else {
  65. }
  66. }
  67. }
  68. CustomBusyIndicator{
  69. property alias running: urlchangeBUSY.visible
  70. id:urlchangeBUSY
  71. anchors.centerIn: parent
  72. //x: (popupWIN.width - popupWIN.height) / 2
  73. width: parent.height * 0.75
  74. height: parent.height * 0.75
  75. bBgColor: Globals.customer_color_base
  76. bLength:50
  77. opacity: 0.75
  78. visible: false
  79. }
  80. ApplicationLaunch {
  81. id: testWebsite
  82. arguments: ""
  83. onAppFinished: {
  84. if(exitCode != 0) {
  85. console.debug("----> URL Code ", exitCode );
  86. mainview.visible = false;
  87. mainview.url = "";
  88. mainview.url = "xx";
  89. urlchangeBUSY.visible = true;
  90. urlTIMER.interval = 2500;
  91. if(urlTIMER.running == false) {
  92. urlTIMER.restart();
  93. }
  94. } else {
  95. urlTIMER.stop();
  96. mainview.url = "";
  97. mainview.url = camURL;
  98. urlchangeBUSY.visible = false;
  99. mainview.visible = true;
  100. }
  101. }
  102. }
  103. Component.onCompleted: {
  104. urlchangeBUSY.visible = true;
  105. camURL = whichCamSet();
  106. testWebsite.appName = "curl --insecure -m 3 -Is " + camURL;
  107. testWebsite.launchScript();
  108. console.debug("CAMURL Component.onCompleted :" + camURL);
  109. }
  110. onVisibleChanged: {
  111. console.debug("Start.qml onVisible changed :" + visible);
  112. if (visible) {
  113. if (camURL !== whichCamSet()) {
  114. console.debug("CAMURL onVisible changed :" + camURL);
  115. camURL = whichCamSet();
  116. testWebsite.appName = "curl --insecure -m 3 -Is " + camURL;
  117. testWebsite.launchScript();
  118. console.debug("CAMURL onVisibleChanged :" + camURL);
  119. }
  120. mainview.visible = mainview.focus = true
  121. } else {
  122. mainview.visible = mainview.focus = false
  123. Qt.inputMethod.hide();
  124. }
  125. }
  126. Flickable {
  127. id: flickable
  128. anchors.fill: parent
  129. contentWidth: root.width
  130. contentHeight: root.height
  131. interactive: contentHeight > height
  132. flickableDirection: Flickable.VerticalFlick
  133. clip: true
  134. Item {
  135. id: content
  136. x: 0
  137. y: 0
  138. width: flickable.width
  139. //============================================================================
  140. Rectangle {
  141. id: rectangle
  142. x: 0
  143. y: 0
  144. width: parent.width
  145. height: parent.height
  146. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  147. WebEngineView {
  148. id: mainview
  149. width: flickable.contentWidth
  150. height: flickable.contentHeight
  151. x: 0
  152. y: 0
  153. onCertificateError: {
  154. console.debug("<<<<<<<<<<<<<<<<<<<<<CERT ERROR>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  155. console.log(error.description);
  156. error.ignoreCertificateError();
  157. }
  158. onVisibleChanged: {
  159. console.debug("<<<<<<<<<<<<<<<<<<<<<VISIBLECHANGED>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  160. console.debug("VISIBLE : " + visible);
  161. }
  162. onNewViewRequested: {
  163. console.debug("<<<<<<<<<<<<<<<<<<<<<NEWVIEWREQUESTED>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  164. console.debug("MSG : " + message);
  165. }
  166. onFeaturePermissionRequested: {
  167. console.debug("<<<<<<<<<<<<<<<<<<<<<FEATUREPERMISSIONREQUEST>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  168. console.debug("MSG : " + message);
  169. }
  170. onJavaScriptConsoleMessage: {
  171. console.debug("<<<<<<<<<<<<<<<<<<<<<JSConsoleMessage>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  172. console.debug("MSG : " + message);
  173. }
  174. Component.onCompleted: {
  175. Qt.inputMethod.hide();
  176. }
  177. } // WebEngineView
  178. Rectangle {
  179. id: menuHIDDEN
  180. x: 0
  181. y: 0
  182. z: menuAREA.z === 1 ? -1 : 1
  183. width: height
  184. height: 60
  185. color: "lightgray"
  186. opacity: 0.05
  187. visible: z === 1 ? true:false
  188. MouseArea {
  189. x: parent.x
  190. y: parent.y
  191. width: parent.height
  192. height: parent.width
  193. onClicked: {
  194. menuAREA.z = menuAREA.z === -1 ?menuAREA.z = 1: menuAREA.z = -1;
  195. menuAREATimer.start();
  196. sysinfo.beep();
  197. }
  198. }
  199. }
  200. Rectangle {
  201. id: menuAREA
  202. x: menuRightBorder?parent.width - width - menuOffset:menuOffset
  203. y: 0
  204. z: -1
  205. width: height * 4
  206. height: 60
  207. color: "lightgray"
  208. opacity: 0.75
  209. visible: z === 1 ? true:false
  210. Rectangle {
  211. x: parent.width - 4 * parent.height
  212. y: parent.y
  213. width: parent.height
  214. height: parent.height
  215. z: menuAREA.z
  216. visible: z === 1 ? true:false
  217. color: "lightgray"
  218. opacity: parent.opacity
  219. Image {
  220. anchors.centerIn: parent
  221. fillMode: Image.PreserveAspectFit
  222. source: buttmenuArea
  223. sourceSize.height: parent.height * 0.7 //- parent.height * (buttImgBorder / 100.0)
  224. sourceSize.width: parent.width * 0.7 //- parent.width * (buttImgBorder / 100.0)
  225. height: sourceSize.height
  226. width:sourceSize.width
  227. visible: parent.visible
  228. }
  229. }
  230. MouseArea {
  231. x: parent.width - 4 * parent.height
  232. y: parent.y
  233. z: menuAREA.z
  234. width: parent.height //parent.width - 3 * parent.height
  235. height: parent.height
  236. onPressAndHold: {
  237. camURL = whichCamSet();
  238. testWebsite.appName = "curl --insecure -m 3 -Is " + camURL;
  239. testWebsite.launchScript();
  240. sysinfo.beep();
  241. sysinfo.beep();
  242. console.debug("RELOAD Website:: " + mainview.url);
  243. }
  244. onClicked: {
  245. stackView.push(Qt.resolvedUrl("PWD_Container.qml"));
  246. sysinfo.beep();
  247. }
  248. }
  249. Timer {
  250. interval: 1
  251. running: Globals.startTO.length > 0 ? true:false
  252. onTriggered: {
  253. if (Globals.startTO.length > 0) {
  254. stackView.push(Qt.resolvedUrl("PWD_Container.qml"));
  255. }
  256. }
  257. }
  258. Label {
  259. id: xLABEL
  260. x: parent.width - parent.height
  261. y: parent.y
  262. z: menuAREA.z
  263. width: parent.height
  264. height: parent.height
  265. opacity: parent.opacity
  266. visible: z === 1 ? true:false
  267. font.family: "FontAwesome"
  268. font.bold: false
  269. color: "red"
  270. text: "\uf057" //remove-sign
  271. font.pixelSize: parent.height
  272. }
  273. Button {
  274. property string in2: Globals.in2Status
  275. id: buttonCam2
  276. x: parent.width - 2 * parent.height
  277. y: parent.y
  278. z: menuAREA.z
  279. height: parent.height
  280. width: height
  281. opacity: parent.opacity
  282. visible: z === 1 ? buttCam2Visible:false
  283. Image {
  284. anchors.centerIn: parent
  285. fillMode: Image.PreserveAspectFit
  286. source: buttCamImage
  287. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  288. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  289. height: sourceSize.height
  290. width:sourceSize.width
  291. visible: parent.visible
  292. }
  293. background: Rectangle {
  294. radius: buttRadius
  295. visible: parent.visible
  296. gradient: Gradient {
  297. GradientStop { position:0 ; color: camSelected === 2?buttGradientSelectedStart:buttGradientStart }
  298. GradientStop { position:1 ; color: camSelected === 2?buttGradientSelectedStop:buttGradientStop }
  299. }
  300. }
  301. onClicked: {
  302. if(settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  303. settings.setValue("COMMON/CamSelected", "2");
  304. camSelected = 2;
  305. root.visible = false;
  306. root.visible = true;
  307. }
  308. sysinfo.beep();
  309. }
  310. onIn2Changed: {
  311. if((settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  312. (Globals.in2Status == "2")){
  313. settings.setValue("COMMON/CamSelected", "2");
  314. camSelected = 2;
  315. root.visible = false;
  316. root.visible = true;
  317. }
  318. sysinfo.beep();
  319. }
  320. }
  321. Button {
  322. property string in1: Globals.in1Status
  323. id: buttonCam1
  324. x: parent.width - 3 * parent.height
  325. y: parent.y
  326. z: menuAREA.z
  327. height: parent.height
  328. width: height
  329. opacity: parent.opacity
  330. visible: z === 1?buttCam1Visible:false
  331. Image {
  332. anchors.centerIn: parent
  333. fillMode: Image.PreserveAspectFit
  334. source: buttCamImage
  335. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  336. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  337. height: sourceSize.height
  338. width:sourceSize.width
  339. visible: parent.visible
  340. }
  341. background: Rectangle {
  342. radius: buttRadius
  343. visible: parent.visible
  344. gradient: Gradient {
  345. GradientStop { position:0 ; color: camSelected === 1?buttGradientSelectedStart:buttGradientStart }
  346. GradientStop { position:1 ; color: camSelected === 1?buttGradientSelectedStop:buttGradientStop }
  347. }
  348. }
  349. onClicked: {
  350. if(settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  351. settings.setValue("COMMON/CamSelected", "1");
  352. camSelected = 1;
  353. root.visible = false;
  354. root.visible = true;
  355. }
  356. sysinfo.beep();
  357. }
  358. onIn1Changed: {
  359. if((settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  360. (Globals.in1Status == "1")){
  361. settings.setValue("COMMON/CamSelected", "1");
  362. camSelected = 1;
  363. root.visible = false;
  364. root.visible = true;
  365. }
  366. sysinfo.beep();
  367. }
  368. }
  369. MouseArea {
  370. id: xAREA
  371. x: xLABEL.x
  372. y: xLABEL.y
  373. width: xLABEL.width
  374. height: xLABEL.height
  375. z: menuAREA.z
  376. onClicked: {
  377. menuAREA.z = menuAREA.z === 1 ? -1: 1;
  378. //menuAREATimer.start();
  379. sysinfo.beep();
  380. }
  381. }
  382. }
  383. Timer {
  384. id : menuAREATimer
  385. interval: 15000
  386. running: false
  387. repeat: false
  388. onTriggered: {
  389. menuAREA.z = menuAREA.z === 1 ? -1: 1;
  390. }
  391. }
  392. }
  393. //============================================================================
  394. }
  395. }
  396. }