1
0

PatternDetailPage.qml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. import QtQuick.Layouts 1.15
  4. import "../components"
  5. import "../components" as Components
  6. Page {
  7. id: page
  8. property string patternName: ""
  9. property string patternPath: ""
  10. property string patternPreview: ""
  11. property var backend: null
  12. Rectangle {
  13. anchors.fill: parent
  14. color: Components.ThemeManager.backgroundColor
  15. }
  16. ColumnLayout {
  17. anchors.fill: parent
  18. spacing: 0
  19. // Header
  20. Rectangle {
  21. Layout.fillWidth: true
  22. Layout.preferredHeight: 50
  23. color: Components.ThemeManager.surfaceColor
  24. // Bottom border
  25. Rectangle {
  26. anchors.bottom: parent.bottom
  27. width: parent.width
  28. height: 1
  29. color: Components.ThemeManager.borderColor
  30. }
  31. RowLayout {
  32. anchors.fill: parent
  33. anchors.margins: 10
  34. ConnectionStatus {
  35. backend: page.backend
  36. Layout.rightMargin: 8
  37. }
  38. Button {
  39. text: "← Back"
  40. font.pixelSize: 14
  41. flat: true
  42. onClicked: stackView.pop()
  43. contentItem: Text {
  44. text: parent.text
  45. font: parent.font
  46. color: Components.ThemeManager.textPrimary
  47. horizontalAlignment: Text.AlignHCenter
  48. verticalAlignment: Text.AlignVCenter
  49. }
  50. }
  51. Label {
  52. text: patternName
  53. Layout.fillWidth: true
  54. elide: Label.ElideRight
  55. font.pixelSize: 16
  56. font.bold: true
  57. color: Components.ThemeManager.textPrimary
  58. }
  59. }
  60. }
  61. // Content - Side by side layout
  62. Item {
  63. Layout.fillWidth: true
  64. Layout.fillHeight: true
  65. Row {
  66. anchors.fill: parent
  67. spacing: 0
  68. // Left side - Pattern Preview (60% of width)
  69. Rectangle {
  70. width: parent.width * 0.6
  71. height: parent.height
  72. color: Components.ThemeManager.previewBackground
  73. Image {
  74. anchors.fill: parent
  75. anchors.margins: 10
  76. source: patternPreview ? "file:///" + patternPreview : ""
  77. fillMode: Image.PreserveAspectFit
  78. Rectangle {
  79. anchors.fill: parent
  80. color: Components.ThemeManager.placeholderBackground
  81. visible: parent.status === Image.Error || parent.source == ""
  82. Column {
  83. anchors.centerIn: parent
  84. spacing: 10
  85. Text {
  86. text: "○"
  87. font.pixelSize: 48
  88. color: Components.ThemeManager.placeholderText
  89. anchors.horizontalCenter: parent.horizontalCenter
  90. }
  91. Text {
  92. text: "No Preview Available"
  93. color: Components.ThemeManager.textSecondary
  94. font.pixelSize: 14
  95. anchors.horizontalCenter: parent.horizontalCenter
  96. }
  97. }
  98. }
  99. }
  100. }
  101. // Divider
  102. Rectangle {
  103. width: 1
  104. height: parent.height
  105. color: Components.ThemeManager.borderColor
  106. }
  107. // Right side - Controls (40% of width)
  108. Rectangle {
  109. width: parent.width * 0.4 - 1
  110. height: parent.height
  111. color: Components.ThemeManager.surfaceColor
  112. Column {
  113. anchors.fill: parent
  114. anchors.margins: 10
  115. spacing: 15
  116. // Play Button - FIRST AND PROMINENT
  117. Rectangle {
  118. width: parent.width
  119. height: 50
  120. radius: 8
  121. color: playMouseArea.pressed ? "#1e40af" : (backend ? "#2563eb" : "#9ca3af")
  122. Text {
  123. anchors.centerIn: parent
  124. text: "▶ Play Pattern"
  125. color: "white"
  126. font.pixelSize: 16
  127. font.bold: true
  128. }
  129. MouseArea {
  130. id: playMouseArea
  131. anchors.fill: parent
  132. enabled: backend !== null
  133. onClicked: {
  134. if (backend) {
  135. var preExecution = "adaptive"
  136. if (centerRadio.checked) preExecution = "clear_center"
  137. else if (perimeterRadio.checked) preExecution = "clear_perimeter"
  138. else if (noneRadio.checked) preExecution = "none"
  139. backend.executePattern(patternName, preExecution)
  140. }
  141. }
  142. }
  143. }
  144. // Pre-Execution Options
  145. Rectangle {
  146. width: parent.width
  147. height: 160 // Increased height to fit all options
  148. radius: 8
  149. color: Components.ThemeManager.cardColor
  150. border.color: Components.ThemeManager.borderColor
  151. border.width: 1
  152. Column {
  153. id: preExecColumn
  154. anchors.left: parent.left
  155. anchors.right: parent.right
  156. anchors.top: parent.top
  157. anchors.margins: 8 // Reduced margins to save space
  158. spacing: 6 // Reduced spacing
  159. Label {
  160. text: "Pre-Execution"
  161. font.pixelSize: 12
  162. font.bold: true
  163. color: Components.ThemeManager.textPrimary
  164. }
  165. RadioButton {
  166. id: adaptiveRadio
  167. text: "Adaptive"
  168. checked: true
  169. font.pixelSize: 10
  170. contentItem: Text {
  171. text: parent.text
  172. font: parent.font
  173. color: Components.ThemeManager.textPrimary
  174. verticalAlignment: Text.AlignVCenter
  175. leftPadding: parent.indicator.width + parent.spacing
  176. }
  177. }
  178. RadioButton {
  179. id: centerRadio
  180. text: "Clear Center"
  181. font.pixelSize: 10
  182. contentItem: Text {
  183. text: parent.text
  184. font: parent.font
  185. color: Components.ThemeManager.textPrimary
  186. verticalAlignment: Text.AlignVCenter
  187. leftPadding: parent.indicator.width + parent.spacing
  188. }
  189. }
  190. RadioButton {
  191. id: perimeterRadio
  192. text: "Clear Edge"
  193. font.pixelSize: 10
  194. contentItem: Text {
  195. text: parent.text
  196. font: parent.font
  197. color: Components.ThemeManager.textPrimary
  198. verticalAlignment: Text.AlignVCenter
  199. leftPadding: parent.indicator.width + parent.spacing
  200. }
  201. }
  202. RadioButton {
  203. id: noneRadio
  204. text: "None"
  205. font.pixelSize: 10
  206. contentItem: Text {
  207. text: parent.text
  208. font: parent.font
  209. color: Components.ThemeManager.textPrimary
  210. verticalAlignment: Text.AlignVCenter
  211. leftPadding: parent.indicator.width + parent.spacing
  212. }
  213. }
  214. }
  215. }
  216. // Pattern Info
  217. Rectangle {
  218. width: parent.width
  219. height: 80
  220. radius: 8
  221. color: Components.ThemeManager.cardColor
  222. border.color: Components.ThemeManager.borderColor
  223. border.width: 1
  224. Column {
  225. id: infoColumn
  226. anchors.left: parent.left
  227. anchors.right: parent.right
  228. anchors.top: parent.top
  229. anchors.margins: 10
  230. spacing: 6
  231. Label {
  232. text: "Pattern Info"
  233. font.pixelSize: 14
  234. font.bold: true
  235. color: Components.ThemeManager.textPrimary
  236. }
  237. Label {
  238. text: "Name: " + patternName
  239. font.pixelSize: 11
  240. color: Components.ThemeManager.textSecondary
  241. elide: Text.ElideRight
  242. width: parent.width
  243. }
  244. Label {
  245. text: "Type: Sand Pattern"
  246. font.pixelSize: 11
  247. color: Components.ThemeManager.textSecondary
  248. }
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }