MenuHeader.qml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. height: sourceSize.height
  78. width:sourceSize.width
  79. }
  80. background: Rectangle {
  81. radius: buttRadius
  82. gradient: Gradient {
  83. GradientStop { position:0 ; color: buttGradientStart }
  84. GradientStop { position:1 ; color: buttGradientStop }
  85. }
  86. }
  87. onClicked: {
  88. buttClicked += 1;
  89. sysinfo.beep();
  90. stackView.pop(StackView.Transition); }
  91. }
  92. Button {
  93. id: buttonHome
  94. anchors.right: buttonUndo.left
  95. anchors.rightMargin: itemMargin
  96. anchors.top: parent.top
  97. anchors.topMargin: itemMargin
  98. height: parent.height - parent.height * (buttImgBorder / 100.0)
  99. width: height
  100. Image {
  101. anchors.centerIn: parent
  102. fillMode: Image.PreserveAspectFit
  103. source: buttHomeImage
  104. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  105. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  106. height: sourceSize.height
  107. width:sourceSize.width
  108. }
  109. background: Rectangle {
  110. radius: buttRadius
  111. gradient: Gradient {
  112. GradientStop { position:0 ; color: buttGradientStart }
  113. GradientStop { position:1 ; color: buttGradientStop }
  114. }
  115. }
  116. onClicked: {
  117. buttClicked += 1;
  118. sysinfo.beep();
  119. stackView.pop(null, StackView.Transition); }
  120. }
  121. Button {
  122. id: buttonLoc
  123. anchors.right: buttonHome.left
  124. anchors.rightMargin: itemMargin
  125. anchors.top: parent.top
  126. anchors.topMargin: itemMargin
  127. height: parent.height - parent.height * (buttImgBorder / 100.0)
  128. width: height
  129. Image {
  130. anchors.centerIn: parent
  131. fillMode: Image.PreserveAspectFit
  132. source: buttLockImage
  133. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  134. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  135. height: sourceSize.height
  136. width:sourceSize.width
  137. }
  138. background: Rectangle {
  139. radius: buttRadius
  140. gradient: Gradient {
  141. GradientStop { position:0 ; color: buttGradientStart }
  142. GradientStop { position:1 ; color: buttGradientStop }
  143. }
  144. }
  145. onClicked: {
  146. buttClicked += 1;
  147. sysinfo.beep();
  148. while (stackView.depth > 2) {
  149. stackView.pop(StackView.Transition);
  150. }
  151. }
  152. }
  153. Button {
  154. property string in2: Globals.in2Status
  155. id: buttonCam2
  156. anchors.right: buttonLoc.left
  157. anchors.rightMargin: itemMargin * 3
  158. anchors.top: parent.top
  159. anchors.topMargin: itemMargin
  160. height: parent.height - parent.height * (buttImgBorder / 100.0)
  161. width: height
  162. visible: buttCam2Visible
  163. Image {
  164. anchors.centerIn: parent
  165. fillMode: Image.PreserveAspectFit
  166. source: buttCamImage
  167. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  168. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  169. height: sourceSize.height
  170. width:sourceSize.width
  171. visible: parent.visible
  172. }
  173. background: Rectangle {
  174. radius: buttRadius
  175. visible: parent.visible
  176. gradient: Gradient {
  177. GradientStop { position:0 ; color: camSelected === 2?buttGradientSelectedStart:buttGradientStart }
  178. GradientStop { position:1 ; color: camSelected === 2?buttGradientSelectedStop:buttGradientStop }
  179. }
  180. }
  181. onClicked: {
  182. sysinfo.beep();
  183. if(settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  184. settings.setValue("COMMON/CamSelected", "2");
  185. camSelected = 2;
  186. }
  187. }
  188. onIn2Changed: {
  189. if((settings.value("CAM2SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  190. (Globals.in2Status == "2")){
  191. settings.setValue("COMMON/CamSelected", "2");
  192. camSelected = 2;
  193. }
  194. }
  195. }
  196. Button {
  197. property string in1: Globals.in1Status
  198. id: buttonCam1
  199. anchors.right: buttonCam2.left
  200. anchors.rightMargin: itemMargin
  201. anchors.top: parent.top
  202. anchors.topMargin: itemMargin
  203. height: parent.height - parent.height * (buttImgBorder / 100.0)
  204. width: height
  205. visible: buttCam1Visible
  206. Image {
  207. anchors.centerIn: parent
  208. fillMode: Image.PreserveAspectFit
  209. source: buttCamImage
  210. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  211. sourceSize.width: parent.width - parent.width * (buttImgBorder / 100.0)
  212. height: sourceSize.height
  213. width:sourceSize.width
  214. visible: parent.visible
  215. }
  216. background: Rectangle {
  217. radius: buttRadius
  218. visible: parent.visible
  219. gradient: Gradient {
  220. GradientStop { position:0 ; color: camSelected === 1?buttGradientSelectedStart:buttGradientStart }
  221. GradientStop { position:1 ; color: camSelected === 1?buttGradientSelectedStop:buttGradientStop }
  222. }
  223. }
  224. onClicked: {
  225. sysinfo.beep();
  226. if(settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) {
  227. settings.setValue("COMMON/CamSelected", "1");
  228. camSelected = 1;
  229. }
  230. }
  231. onIn1Changed: {
  232. if((settings.value("CAM1SETTINGS/IpAddress","0.0.0.0") !== "0.0.0.0" ) &&
  233. (Globals.in1Status == "1")){
  234. settings.setValue("COMMON/CamSelected", "1");
  235. camSelected = 1;
  236. }
  237. }
  238. }
  239. Image {
  240. anchors.left: parent.left
  241. anchors.leftMargin: itemMargin
  242. anchors.top: parent.top
  243. anchors.topMargin: itemMargin
  244. source: headerLogoImage
  245. fillMode: Image.PreserveAspectFit
  246. sourceSize.height: parent.height - parent.height * (buttImgBorder / 100.0)
  247. sourceSize.width: parent.width/3.0 - parent.width/3.0 * (buttImgBorder / 100.0)
  248. height: sourceSize.height
  249. width:sourceSize.width
  250. }
  251. Text {
  252. anchors.centerIn: parent
  253. anchors.top: parent.top
  254. anchors.topMargin: itemMargin
  255. color: "white"
  256. font.pixelSize: (parent.height * 0.5)
  257. text : headerText
  258. }
  259. }