Start.qml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 -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 -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 -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. visible: parent.visible
  226. }
  227. }
  228. MouseArea {
  229. x: parent.width - 4 * parent.height
  230. y: parent.y
  231. z: menuAREA.z
  232. width: parent.height //parent.width - 3 * parent.height
  233. height: parent.height
  234. onPressAndHold: {
  235. camURL = whichCamSet();
  236. testWebsite.appName = "curl -m 3 -Is " + camURL;
  237. testWebsite.launchScript();
  238. sysinfo.beep();
  239. sysinfo.beep();
  240. console.debug("RELOAD Website:: " + mainview.url);
  241. }
  242. onClicked: {
  243. stackView.push(Qt.resolvedUrl("PWD_Container.qml"));
  244. sysinfo.beep();
  245. }
  246. }
  247. Timer {
  248. interval: 1
  249. running: Globals.startTO.length > 0 ? true:false
  250. onTriggered: {
  251. if (Globals.startTO.length > 0) {
  252. stackView.push(Qt.resolvedUrl("PWD_Container.qml"));
  253. }
  254. }
  255. }
  256. Label {
  257. id: xLABEL
  258. x: parent.width - parent.height
  259. y: parent.y
  260. z: menuAREA.z
  261. width: parent.height
  262. height: parent.height
  263. opacity: parent.opacity
  264. visible: z === 1 ? true:false
  265. font.family: "FontAwesome"
  266. font.bold: false
  267. color: "red"
  268. text: "\uf057" //remove-sign
  269. font.pixelSize: parent.height
  270. }
  271. Button {
  272. property string in2: Globals.in2Status
  273. id: buttonCam2
  274. x: parent.width - 2 * parent.height
  275. y: parent.y
  276. z: menuAREA.z
  277. height: parent.height
  278. width: height
  279. opacity: parent.opacity
  280. visible: z === 1 ? buttCam2Visible:false
  281. Image {
  282. anchors.centerIn: parent
  283. fillMode: Image.PreserveAspectFit
  284. source: buttCamImage
  285. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  286. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  287. visible: parent.visible
  288. }
  289. background: Rectangle {
  290. radius: buttRadius
  291. visible: parent.visible
  292. gradient: Gradient {
  293. GradientStop { position:0 ; color: camSelected === 2?buttGradientSelectedStart:buttGradientStart }
  294. GradientStop { position:1 ; color: camSelected === 2?buttGradientSelectedStop:buttGradientStop }
  295. }
  296. }
  297. onClicked: {
  298. if(settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  299. settings.setValue("COMMON/CamSelected", "2");
  300. camSelected = 2;
  301. root.visible = false;
  302. root.visible = true;
  303. }
  304. sysinfo.beep();
  305. }
  306. onIn2Changed: {
  307. if((settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  308. (Globals.in2Status == "2")){
  309. settings.setValue("COMMON/CamSelected", "2");
  310. camSelected = 2;
  311. root.visible = false;
  312. root.visible = true;
  313. }
  314. sysinfo.beep();
  315. }
  316. }
  317. Button {
  318. property string in1: Globals.in1Status
  319. id: buttonCam1
  320. x: parent.width - 3 * parent.height
  321. y: parent.y
  322. z: menuAREA.z
  323. height: parent.height
  324. width: height
  325. opacity: parent.opacity
  326. visible: z === 1?buttCam1Visible:false
  327. Image {
  328. anchors.centerIn: parent
  329. fillMode: Image.PreserveAspectFit
  330. source: buttCamImage
  331. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  332. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  333. visible: parent.visible
  334. }
  335. background: Rectangle {
  336. radius: buttRadius
  337. visible: parent.visible
  338. gradient: Gradient {
  339. GradientStop { position:0 ; color: camSelected === 1?buttGradientSelectedStart:buttGradientStart }
  340. GradientStop { position:1 ; color: camSelected === 1?buttGradientSelectedStop:buttGradientStop }
  341. }
  342. }
  343. onClicked: {
  344. if(settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  345. settings.setValue("COMMON/CamSelected", "1");
  346. camSelected = 1;
  347. root.visible = false;
  348. root.visible = true;
  349. }
  350. sysinfo.beep();
  351. }
  352. onIn1Changed: {
  353. if((settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  354. (Globals.in1Status == "1")){
  355. settings.setValue("COMMON/CamSelected", "1");
  356. camSelected = 1;
  357. root.visible = false;
  358. root.visible = true;
  359. }
  360. sysinfo.beep();
  361. }
  362. }
  363. MouseArea {
  364. id: xAREA
  365. x: xLABEL.x
  366. y: xLABEL.y
  367. width: xLABEL.width
  368. height: xLABEL.height
  369. z: menuAREA.z
  370. onClicked: {
  371. menuAREA.z = menuAREA.z === 1 ? -1: 1;
  372. //menuAREATimer.start();
  373. sysinfo.beep();
  374. }
  375. }
  376. }
  377. Timer {
  378. id : menuAREATimer
  379. interval: 15000
  380. running: false
  381. repeat: false
  382. onTriggered: {
  383. menuAREA.z = menuAREA.z === 1 ? -1: 1;
  384. }
  385. }
  386. }
  387. //============================================================================
  388. }
  389. }
  390. }