MenuHeader.qml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. import QtQuick 2.5
  2. import QtQuick.Controls 1.4
  3. import Qt.labs.controls 1.0
  4. import QtQuick.Controls.Styles 1.3
  5. import QtGraphicalEffects 1.0
  6. import ApplicationLauncher 1.0
  7. import "qrc:/Globals"
  8. Item {
  9. property int buttImgBorder: 20 // in percent of parent.height defaults to 20%
  10. property string headerText: ""
  11. property string headerLogoImage: Globals.logoMenu
  12. property string buttUndoImage: "/images/UndoButton.svg"
  13. property string buttHomeImage: "/images/HomeButton.svg"
  14. property string buttLockImage: "/images/LockButton.svg"
  15. property string buttCamImage: "/images/LiveMode_Button.svg"
  16. property bool buttCam1Visible: false
  17. property bool buttCam2Visible: false
  18. property int camSelected: -1
  19. property int buttRadius: 0
  20. property color buttGradientStart: "darkgray"
  21. property color buttGradientStop: "black"
  22. property color buttGradientSelectedStart: Globals.customer_color_base
  23. property color buttGradientSelectedStop: Globals.customer_color_base
  24. property double itemMargin: height * (buttImgBorder / 200.0)
  25. property int buttClicked: 0;
  26. width: parent.width
  27. height: parent.height / 10.0
  28. function whichCamSet() {
  29. var _camSelected = settings.value("COMMON/CamSelected","-");
  30. var ret;
  31. if (_camSelected.toString() === "1") {
  32. camSelected = 1;
  33. ret = settings.value("CAM1SETTINGS/IpAddress","0.0.0.0");
  34. } else if (_camSelected.toString() === "2") {
  35. camSelected = 2;
  36. ret = settings.value("CAM2SETTINGS/IpAddress","0.0.0.0");
  37. }
  38. if ((_camSelected === "-" ) || (ret === "0.0.0.0")) {
  39. if (settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0") {
  40. settings.setValue("COMMON/CamSelected", "1");
  41. camSelected = 1;
  42. ret = settings.value("CAM1SETTINGS/IpAddress","0.0.0.0");
  43. } else if (settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0") {
  44. settings.setValue("COMMON/CamSelected", "2");
  45. camSelected = 2;
  46. ret = settings.value("CAM2SETTINGS/IpAddress","0.0.0.0");
  47. }
  48. }
  49. buttCam1Visible = (settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0")?true:false;
  50. buttCam2Visible = (settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0")?true:false;
  51. return ret;
  52. }
  53. Rectangle {
  54. anchors.fill: parent
  55. gradient: Gradient {
  56. // GradientStop { position: 0.0; color: "black" }
  57. // GradientStop { position: 1.0; color: "lightgray" }
  58. GradientStop { position: 0.0; color: "white" }
  59. GradientStop { position: 1.0; color: "darkgray" }
  60. }
  61. }
  62. Button {
  63. id: buttonUndo
  64. anchors.right: parent.right
  65. anchors.rightMargin: itemMargin
  66. anchors.top: parent.top
  67. anchors.topMargin: itemMargin
  68. height: parent.height - parent.height * (buttImgBorder / 100.0)
  69. width: height
  70. Image {
  71. anchors.centerIn: parent
  72. fillMode: Image.PreserveAspectFit
  73. source: buttUndoImage
  74. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  75. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  76. }
  77. background: Rectangle {
  78. radius: buttRadius
  79. gradient: Gradient {
  80. GradientStop { position:0 ; color: buttGradientStart }
  81. GradientStop { position:1 ; color: buttGradientStop }
  82. }
  83. }
  84. onClicked: {
  85. buttClicked += 1;
  86. sysinfo.beep();
  87. stackView.pop(StackView.Transition); }
  88. }
  89. Button {
  90. id: buttonHome
  91. anchors.right: buttonUndo.left
  92. anchors.rightMargin: itemMargin
  93. anchors.top: parent.top
  94. anchors.topMargin: itemMargin
  95. height: parent.height - parent.height * (buttImgBorder / 100.0)
  96. width: height
  97. Image {
  98. anchors.centerIn: parent
  99. fillMode: Image.PreserveAspectFit
  100. source: buttHomeImage
  101. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  102. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  103. }
  104. background: Rectangle {
  105. radius: buttRadius
  106. gradient: Gradient {
  107. GradientStop { position:0 ; color: buttGradientStart }
  108. GradientStop { position:1 ; color: buttGradientStop }
  109. }
  110. }
  111. onClicked: {
  112. buttClicked += 1;
  113. sysinfo.beep();
  114. stackView.pop(null, StackView.Transition); }
  115. }
  116. Button {
  117. id: buttonLoc
  118. anchors.right: buttonHome.left
  119. anchors.rightMargin: itemMargin
  120. anchors.top: parent.top
  121. anchors.topMargin: itemMargin
  122. height: parent.height - parent.height * (buttImgBorder / 100.0)
  123. width: height
  124. Image {
  125. anchors.centerIn: parent
  126. fillMode: Image.PreserveAspectFit
  127. source: buttLockImage
  128. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  129. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  130. }
  131. background: Rectangle {
  132. radius: buttRadius
  133. gradient: Gradient {
  134. GradientStop { position:0 ; color: buttGradientStart }
  135. GradientStop { position:1 ; color: buttGradientStop }
  136. }
  137. }
  138. onClicked: {
  139. buttClicked += 1;
  140. sysinfo.beep();
  141. while (stackView.depth > 2) {
  142. stackView.pop(StackView.Transition);
  143. }
  144. }
  145. }
  146. Button {
  147. property string in2: Globals.in2Status
  148. id: buttonCam2
  149. anchors.right: buttonLoc.left
  150. anchors.rightMargin: itemMargin * 3
  151. anchors.top: parent.top
  152. anchors.topMargin: itemMargin
  153. height: parent.height - parent.height * (buttImgBorder / 100.0)
  154. width: height
  155. visible: buttCam2Visible
  156. Image {
  157. anchors.centerIn: parent
  158. fillMode: Image.PreserveAspectFit
  159. source: buttCamImage
  160. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  161. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  162. visible: parent.visible
  163. }
  164. background: Rectangle {
  165. radius: buttRadius
  166. visible: parent.visible
  167. gradient: Gradient {
  168. GradientStop { position:0 ; color: camSelected === 2?buttGradientSelectedStart:buttGradientStart }
  169. GradientStop { position:1 ; color: camSelected === 2?buttGradientSelectedStop:buttGradientStop }
  170. }
  171. }
  172. onClicked: {
  173. sysinfo.beep();
  174. if(settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  175. settings.setValue("COMMON/CamSelected", "2");
  176. camSelected = 2;
  177. }
  178. }
  179. onIn2Changed: {
  180. if((settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  181. (Globals.in2Status == "2")){
  182. settings.setValue("COMMON/CamSelected", "2");
  183. camSelected = 2;
  184. }
  185. }
  186. }
  187. Button {
  188. property string in1: Globals.in1Status
  189. id: buttonCam1
  190. anchors.right: buttonCam2.left
  191. anchors.rightMargin: itemMargin
  192. anchors.top: parent.top
  193. anchors.topMargin: itemMargin
  194. height: parent.height - parent.height * (buttImgBorder / 100.0)
  195. width: height
  196. visible: buttCam1Visible
  197. Image {
  198. anchors.centerIn: parent
  199. fillMode: Image.PreserveAspectFit
  200. source: buttCamImage
  201. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  202. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  203. visible: parent.visible
  204. }
  205. background: Rectangle {
  206. radius: buttRadius
  207. visible: parent.visible
  208. gradient: Gradient {
  209. GradientStop { position:0 ; color: camSelected === 1?buttGradientSelectedStart:buttGradientStart }
  210. GradientStop { position:1 ; color: camSelected === 1?buttGradientSelectedStop:buttGradientStop }
  211. }
  212. }
  213. onClicked: {
  214. sysinfo.beep();
  215. if(settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  216. settings.setValue("COMMON/CamSelected", "1");
  217. camSelected = 1;
  218. }
  219. }
  220. onIn1Changed: {
  221. if((settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  222. (Globals.in1Status == "1")){
  223. settings.setValue("COMMON/CamSelected", "1");
  224. camSelected = 1;
  225. }
  226. }
  227. }
  228. Image {
  229. anchors.left: parent.left
  230. anchors.leftMargin: itemMargin
  231. anchors.top: parent.top
  232. anchors.topMargin: itemMargin
  233. source: headerLogoImage
  234. fillMode: Image.PreserveAspectFit
  235. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  236. sourceSize.width: parent.width/3.0 - parent.width/3.0 * (buttImgBorder / 100.0)
  237. }
  238. Text {
  239. anchors.centerIn: parent
  240. anchors.top: parent.top
  241. anchors.topMargin: itemMargin
  242. color: "white"
  243. font.pixelSize: (parent.height * 0.5)
  244. text : headerText
  245. }
  246. }