main.qml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. import QtQuick.Layouts 1.15
  4. import QtQuick.Dialogs
  5. import QtQuick.VirtualKeyboard 2.15
  6. import DuneWeaver 1.0
  7. import "components"
  8. ApplicationWindow {
  9. id: window
  10. visible: true
  11. width: 800
  12. height: 480
  13. title: "Dune Weaver Touch"
  14. // Auto-detect kiosk mode from environment or platform
  15. // EGLFS platform automatically goes fullscreen, but we can also set visibility
  16. Component.onCompleted: {
  17. // Check if we're running in kiosk mode (eglfs platform)
  18. var isKiosk = Qt.platform.pluginName === "eglfs" || Qt.platform.pluginName === "linuxfb"
  19. if (isKiosk) {
  20. console.log("🖥️ Kiosk mode detected - platform:", Qt.platform.pluginName)
  21. visibility = Window.FullScreen
  22. } else {
  23. console.log("🪟 Desktop mode - platform:", Qt.platform.pluginName)
  24. }
  25. }
  26. property int currentPageIndex: 0
  27. property alias stackView: stackView
  28. property alias backend: backend
  29. property bool shouldNavigateToExecution: false
  30. onCurrentPageIndexChanged: {
  31. console.log("📱 currentPageIndex changed to:", currentPageIndex)
  32. }
  33. onShouldNavigateToExecutionChanged: {
  34. if (shouldNavigateToExecution) {
  35. console.log("🎯 Navigating to execution page")
  36. console.log("🎯 Current stack depth:", stackView.depth)
  37. // If we're in a sub-page (like PatternDetailPage), pop back to main view first
  38. if (stackView.depth > 1) {
  39. console.log("🎯 Popping back to main view first")
  40. stackView.pop()
  41. }
  42. // Then navigate to ExecutionPage tab
  43. console.log("🎯 Setting currentPageIndex to 3")
  44. currentPageIndex = 3
  45. shouldNavigateToExecution = false
  46. }
  47. }
  48. Backend {
  49. id: backend
  50. onExecutionStarted: function(patternName, patternPreview) {
  51. console.log("🎯 QML: ExecutionStarted signal received! patternName='" + patternName + "', preview='" + patternPreview + "'")
  52. console.log("🎯 Setting shouldNavigateToExecution = true")
  53. // Navigate to Execution tab (index 3) instead of pushing page
  54. shouldNavigateToExecution = true
  55. console.log("🎯 shouldNavigateToExecution set to:", shouldNavigateToExecution)
  56. }
  57. onErrorOccurred: function(error) {
  58. errorDialog.text = error
  59. errorDialog.open()
  60. }
  61. onScreenStateChanged: function(isOn) {
  62. console.log("🖥️ Screen state changed:", isOn ? "ON" : "OFF")
  63. }
  64. }
  65. // Global touch/mouse handler for activity tracking
  66. MouseArea {
  67. anchors.fill: parent
  68. acceptedButtons: Qt.NoButton // Don't interfere with other mouse areas
  69. hoverEnabled: true
  70. propagateComposedEvents: true
  71. onPressed: {
  72. console.log("🖥️ QML: Touch/press detected - resetting activity timer")
  73. backend.resetActivityTimer()
  74. }
  75. onPositionChanged: {
  76. console.log("🖥️ QML: Mouse movement detected - resetting activity timer")
  77. backend.resetActivityTimer()
  78. }
  79. onClicked: {
  80. console.log("🖥️ QML: Click detected - resetting activity timer")
  81. backend.resetActivityTimer()
  82. }
  83. }
  84. PatternModel {
  85. id: patternModel
  86. }
  87. StackView {
  88. id: stackView
  89. anchors.fill: parent
  90. initialItem: mainSwipeView
  91. Component {
  92. id: mainSwipeView
  93. Item {
  94. // Main content area
  95. StackLayout {
  96. id: stackLayout
  97. anchors.top: parent.top
  98. anchors.left: parent.left
  99. anchors.right: parent.right
  100. anchors.bottom: bottomNav.top
  101. currentIndex: window.currentPageIndex
  102. Component.onCompleted: {
  103. console.log("📱 StackLayout created with currentIndex:", currentIndex, "bound to window.currentPageIndex:", window.currentPageIndex)
  104. }
  105. // Patterns Page
  106. Loader {
  107. source: "pages/ModernPatternListPage.qml"
  108. onLoaded: {
  109. item.patternModel = patternModel
  110. item.backend = backend
  111. item.stackView = stackView
  112. }
  113. }
  114. // Playlists Page
  115. Loader {
  116. source: "pages/ModernPlaylistPage.qml"
  117. onLoaded: {
  118. item.backend = backend
  119. item.stackView = stackView
  120. item.mainWindow = window
  121. }
  122. }
  123. // Control Page
  124. Loader {
  125. source: "pages/TableControlPage.qml"
  126. onLoaded: {
  127. item.backend = backend
  128. }
  129. }
  130. // Execution Page
  131. Loader {
  132. source: "pages/ExecutionPage.qml"
  133. onLoaded: {
  134. item.backend = backend
  135. item.stackView = stackView
  136. }
  137. }
  138. }
  139. // Bottom Navigation
  140. BottomNavigation {
  141. id: bottomNav
  142. anchors.bottom: parent.bottom
  143. anchors.left: parent.left
  144. anchors.right: parent.right
  145. currentIndex: window.currentPageIndex
  146. onTabClicked: function(index) {
  147. console.log("📱 Tab clicked:", index)
  148. window.currentPageIndex = index
  149. }
  150. }
  151. }
  152. }
  153. }
  154. MessageDialog {
  155. id: errorDialog
  156. title: "Error"
  157. buttons: MessageDialog.Ok
  158. }
  159. // Virtual Keyboard Support
  160. InputPanel {
  161. id: inputPanel
  162. z: 99999
  163. y: window.height
  164. anchors.left: parent.left
  165. anchors.right: parent.right
  166. states: State {
  167. name: "visible"
  168. when: inputPanel.active
  169. PropertyChanges {
  170. target: inputPanel
  171. y: window.height - inputPanel.height
  172. }
  173. }
  174. transitions: Transition {
  175. from: ""
  176. to: "visible"
  177. reversible: true
  178. ParallelAnimation {
  179. NumberAnimation {
  180. target: inputPanel
  181. property: "y"
  182. duration: 250
  183. easing.type: Easing.InOutQuad
  184. }
  185. }
  186. }
  187. }
  188. }