MenuHeader.qml 9.5 KB

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