PageRenderTime 29ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/interfaces/PNDManager/ui.qml

https://github.com/bzar/panorama
QML | 416 lines | 370 code | 46 blank | 0 comment | 58 complexity | bfa090b232ae3839305c75bd2a9bda91 MD5 | raw file
  1. import QtQuick 1.1
  2. import Panorama.Settings 1.0
  3. import Panorama.UI 1.0
  4. import Panorama.PNDManagement 1.0
  5. import Panorama.Pandora 1.0
  6. PanoramaUI {
  7. id: ui
  8. name: "PNDManager"
  9. description: "PND Manager application"
  10. author: "B-ZaR"
  11. anchors.fill: parent
  12. Setting {
  13. id: showSplashScreen
  14. defaultValue: true
  15. key: "showSplashScreen"
  16. section: "PNDManager"
  17. Component.onCompleted: splashScreen.visible = value
  18. }
  19. Setting {
  20. id: showHints
  21. defaultValue: true
  22. key: "showHints"
  23. section: "PNDManager"
  24. }
  25. Setting {
  26. id: mouseCursorVisible
  27. section: "PNDManager"
  28. key: "mouseCursorVisible"
  29. defaultValue: false
  30. onValueChanged: runtime.mouseCursorVisible = value
  31. Component.onCompleted: runtime.mouseCursorVisible = value
  32. }
  33. Setting {
  34. id: lastInstallDevice
  35. section: "PNDManager"
  36. key: "lastInstallDevice"
  37. defaultValue: ""
  38. }
  39. Setting {
  40. id: lastInstallLocation
  41. section: "PNDManager"
  42. key: "lastInstallLocation"
  43. defaultValue: ""
  44. }
  45. Setting {
  46. id: loggingVerbosity
  47. section: "PNDManager"
  48. key: "loggingVerbosity"
  49. defaultValue: 5
  50. onValueChanged: pndManager.verbosity = value
  51. Component.onCompleted: pndManager.verbosity = value
  52. }
  53. Setting {
  54. id: maxDownloads
  55. section: "PNDManager"
  56. key: "maxDownloads"
  57. defaultValue: 4
  58. onValueChanged: pndManager.maxDownloads = value
  59. Component.onCompleted: pndManager.maxDownloads = value
  60. }
  61. Setting {
  62. id: usernameSetting
  63. section: "PNDManager"
  64. key: "username"
  65. defaultValue: ""
  66. }
  67. Setting {
  68. id: apiKeySetting
  69. section: "PNDManager"
  70. key: "apiKey"
  71. defaultValue: ""
  72. }
  73. Setting {
  74. id: customDevices
  75. section: "PNDManager"
  76. key: "customDevices"
  77. defaultValue: ""
  78. Component.onCompleted: pndManager.addCustomDevicesString(value)
  79. }
  80. Setting {
  81. id: flipBX
  82. section: "PNDManager"
  83. key: "flipBX"
  84. defaultValue: false
  85. }
  86. property string okButtonGuiHintControl: flipBX.value ? "game-x" : "game-b"
  87. function init() {
  88. pndManager.crawl();
  89. }
  90. Timer {
  91. interval: 100
  92. repeat: false
  93. running: true
  94. onTriggered: ui.init()
  95. }
  96. PNDManager {
  97. id: pndManager
  98. onSyncing: bottomBar.syncing = true
  99. onSyncDone: {
  100. bottomBar.syncing = false
  101. syncCompleteNotification.show()
  102. }
  103. onSyncError: {
  104. bottomBar.syncing = false
  105. bottomBar.syncError = true
  106. syncFailedNotification.show()
  107. }
  108. username: usernameSetting.value
  109. key: apiKeySetting.value
  110. }
  111. property bool loggedIn: pndManager.username && pndManager.key
  112. PNDUtils { id: pndUtils }
  113. signal buttonA;
  114. signal buttonB;
  115. signal buttonX;
  116. signal buttonY;
  117. signal buttonL;
  118. signal buttonR;
  119. signal button1;
  120. signal button2;
  121. signal button3;
  122. signal button4;
  123. signal buttonStart;
  124. signal buttonSelect;
  125. signal buttonF1;
  126. signal buttonF9;
  127. signal buttonF10;
  128. signal buttonEsc;
  129. onButtonA: {
  130. if(splashScreen.visible) {
  131. splashScreen.dontShowAgain();
  132. } else {
  133. views.current.current.removeButton();
  134. }
  135. }
  136. onButtonB: {
  137. if(splashScreen.visible) {
  138. splashScreen.hide();
  139. } else {
  140. views.current.current.okButton();
  141. }
  142. }
  143. onButtonX: views.current.pop()
  144. onButtonY: views.current.current.installUpgradeButton()
  145. onButtonL: if(!settingsStack.active) views.prev()
  146. onButtonR: if(!settingsStack.active) views.next()
  147. onButtonStart: if(!settingsStack.active) bottomBar.reload()
  148. onButtonSelect: views.current.current.selectButton()
  149. onButton1: installedStack.activate()
  150. onButton2: homeStack.activate()
  151. onButton3: categoriesStack.activate()
  152. onButton4: searchStack.activate()
  153. onButtonF1: showHints.value = !showHints.value
  154. onButtonF9: topBar.settingsButtonClicked()
  155. onButtonF10: runtime.quit()
  156. onButtonEsc: runtime.quit()
  157. Keys.onPressed: {
  158. if(!runtime.isActiveWindow || pndManager.applicationRunning) {
  159. event.accepted = true;
  160. return
  161. }
  162. if(!Pandora.controlsActive && !spinner.visible) {
  163. event.accepted = true;
  164. if(event.key === Qt.Key_PageDown) {
  165. flipBX.value ? buttonB() : buttonX();
  166. } else if(event.key === Qt.Key_End) {
  167. flipBX.value ? buttonX() : buttonB();
  168. } else if(event.key === Qt.Key_Home) {
  169. buttonA();
  170. } else if(event.key === Qt.Key_PageUp) {
  171. buttonY();
  172. } else if(event.key === Qt.Key_Insert) {
  173. buttonL();
  174. } else if(event.key === Qt.Key_Delete) {
  175. buttonR();
  176. } else if(event.key === Qt.Key_1) {
  177. button1();
  178. } else if(event.key === Qt.Key_2) {
  179. button2();
  180. } else if(event.key === Qt.Key_3) {
  181. button3();
  182. } else if(event.key === Qt.Key_4) {
  183. button4();
  184. } else {
  185. event.accepted = false;
  186. }
  187. }
  188. if(event.key === Qt.Key_F1) {
  189. buttonF1();
  190. event.accepted = true;
  191. } else if(event.key === Qt.Key_F9) {
  192. buttonF9();
  193. event.accepted = true;
  194. } else if(event.key === Qt.Key_F10) {
  195. buttonF10();
  196. event.accepted = true;
  197. } else if(event.key === Qt.Key_Escape) {
  198. buttonEsc();
  199. }
  200. }
  201. Pandora.onPressed: {
  202. if(spinner.visible || !runtime.isActiveWindow || pndManager.applicationRunning) {
  203. event.accepted = true;
  204. return
  205. }
  206. event.accepted = true;
  207. if(event.key === Pandora.ButtonX) {
  208. flipBX.value ? buttonB() : buttonX();
  209. } else if(event.key === Pandora.ButtonB) {
  210. flipBX.value ? buttonX() : buttonB();
  211. } else if(event.key === Pandora.ButtonA) {
  212. buttonA();
  213. } else if(event.key === Pandora.ButtonY) {
  214. buttonY();
  215. } else if(event.key === Pandora.TriggerL) {
  216. buttonL();
  217. } else if(event.key === Pandora.TriggerR) {
  218. buttonR();
  219. } else if(event.key === Pandora.ButtonStart) {
  220. buttonStart();
  221. } else if(event.key === Pandora.ButtonSelect) {
  222. buttonSelect();
  223. }
  224. }
  225. Notification {
  226. id: syncCompleteNotification
  227. text: "Sync complete"
  228. anchors.centerIn: parent
  229. z: 2
  230. }
  231. Notification {
  232. id: syncFailedNotification
  233. text: "Sync failed"
  234. anchors.centerIn: parent
  235. z: 2
  236. }
  237. Notification {
  238. id: syncingNotification
  239. text: "Syncing"
  240. anchors.centerIn: parent
  241. z: 2
  242. }
  243. SpinnerOverlay {
  244. id: spinner
  245. anchors.fill: parent
  246. z: 3
  247. }
  248. HelpDialog {
  249. id: splashScreen
  250. anchors.fill: parent
  251. z: 2
  252. visible: false
  253. onHide: visible = false
  254. onDontShowAgain: showSplashScreen.value = false
  255. }
  256. TopBar {
  257. id: topBar
  258. anchors.top: parent.top
  259. anchors.left: parent.left
  260. anchors.right: parent.right
  261. height: 32
  262. title: views.getViewTitle()
  263. z: 1
  264. showCloseButton: fullscreen.value
  265. onCloseButtonClicked: runtime.quit()
  266. onSettingsButtonClicked: settingsStack.active ? views.undo() : settingsStack.activate()
  267. }
  268. ViewStackList {
  269. id: views
  270. currentIndex: 1
  271. anchors.top: topBar.bottom
  272. anchors.bottom: bottomBar.top
  273. anchors.left: parent.left
  274. anchors.right: parent.right
  275. ViewStack {
  276. id: installedStack
  277. onActivate: views.activate(installedStack)
  278. InstalledView {
  279. pndManager: pndManager
  280. }
  281. }
  282. ViewStack {
  283. id: homeStack
  284. onActivate: views.activate(homeStack)
  285. HomeView {
  286. pndManager: pndManager
  287. }
  288. }
  289. ViewStack {
  290. id: categoriesStack
  291. onActivate: views.activate(categoriesStack)
  292. CategoriesView {
  293. pndManager: pndManager
  294. }
  295. }
  296. ViewStack {
  297. id: searchStack
  298. onActivate: views.activate(searchStack)
  299. SearchView {
  300. pndManager: pndManager
  301. }
  302. }
  303. ViewStack {
  304. id: settingsStack
  305. onActivate: views.activate(settingsStack)
  306. browsable: false
  307. SettingsView {
  308. onExit: views.undo()
  309. }
  310. }
  311. }
  312. BottomBar {
  313. id: bottomBar
  314. anchors.bottom: parent.bottom
  315. anchors.left: parent.left
  316. anchors.right: parent.right
  317. height: 64
  318. z: 1
  319. enabled: !settingsStack.active
  320. backArrowVisible: !views.current.atRootView
  321. IconButton {
  322. id: installedIcon
  323. rightHintVisible: searchIcon.highlight
  324. leftHintVisible: homeIcon.highlight
  325. normalImage: "img/bottombar/pndme-0.6.1.0-cat-installed-flimsy.png"
  326. highlightImage: "img/bottombar/pndme-0.6.1.0-cat-installed-flimsy_active.png"
  327. highlight: installedStack.active
  328. height: parent.height
  329. onClicked: installedStack.activate()
  330. }
  331. IconButton {
  332. id: homeIcon
  333. rightHintVisible: installedIcon.highlight
  334. leftHintVisible: categoriesIcon.highlight
  335. normalImage: "img/bottombar/pndme-0.6.1.0-cat-home-flimsy.png"
  336. highlightImage: "img/bottombar/pndme-0.6.1.0-cat-home-flimsy_active.png"
  337. highlight: homeStack.active
  338. height: parent.height
  339. onClicked: homeStack.activate()
  340. }
  341. IconButton {
  342. id: categoriesIcon
  343. rightHintVisible: homeIcon.highlight
  344. leftHintVisible: searchIcon.highlight
  345. normalImage: "img/bottombar/pndme-0.6.1.0-cat-online-flimsy.png"
  346. highlightImage: "img/bottombar/pndme-0.6.1.0-cat-online-flimsy_active.png"
  347. highlight: categoriesStack.active
  348. height: parent.height
  349. onClicked: categoriesStack.activate()
  350. }
  351. IconButton {
  352. id: searchIcon
  353. rightHintVisible: categoriesIcon.highlight
  354. leftHintVisible: installedIcon.highlight
  355. normalImage: "img/bottombar/pndme-0.6.1.0-cat-search-flimsy.png"
  356. highlightImage: "img/bottombar/pndme-0.6.1.0-cat-search-flimsy_active.png"
  357. highlight: searchStack.active
  358. height: parent.height
  359. onClicked: searchStack.activate()
  360. }
  361. onBack: views.current.pop()
  362. onReload: {
  363. syncError = false;
  364. if(!bottomBar.syncing) {
  365. syncingNotification.show()
  366. pndManager.sync();
  367. }
  368. }
  369. }
  370. }