main.qml 6.7 KB

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