Title.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import QtQuick 2.15
  2. import QtQuick.Window 2.15
  3. import DMusic 1.0
  4. import "pages"
  5. import "components"
  6. Rectangle {
  7. id: root
  8. height: 40
  9. property size windowSize
  10. property bool clientSideDecorations
  11. property bool maximized
  12. color: Style.header.background
  13. Rectangle {
  14. width: root.width
  15. height: 1
  16. visible: false
  17. color: "#404040"
  18. }
  19. DragHandler {
  20. enabled: root.clientSideDecorations
  21. onActiveChanged: if (active) { _window.startSystemMove(); _root.focus = true }
  22. target: null
  23. }
  24. MouseArea {
  25. anchors.fill: root
  26. enabled: root.clientSideDecorations
  27. acceptedButtons: Qt.LeftButton | Qt.MiddleButton
  28. onDoubleClicked: if (mouse.button == Qt.LeftButton) _window.maximize()
  29. onClicked: if (mouse.button == Qt.MiddleButton) { _window.close() } else { _root.focus = true }
  30. TitleManualButton {
  31. id: _home
  32. anchors.verticalCenter: parent.verticalCenter
  33. anchors.left: parent.left
  34. icon: "qrc:/resources/title/home.svg"
  35. onClick: _pages.gotoMainPage()
  36. }
  37. TitleManualButton {
  38. id: _close
  39. anchors.right: parent.right
  40. anchors.verticalCenter: parent.verticalCenter
  41. enabled: root.clientSideDecorations
  42. icon: "qrc:/resources/title/close.svg"
  43. style: Style.header.closeButton
  44. onClick: _window.close()
  45. }
  46. TitleManualButton {
  47. id: _maximize
  48. anchors.right: _close.left
  49. anchors.verticalCenter: parent.verticalCenter
  50. enabled: root.clientSideDecorations && root.width >= 715
  51. icon: "qrc:/resources/title/maximize.svg"
  52. onClick: _window.maximize()
  53. }
  54. TitleManualButton {
  55. id: _minimize
  56. anchors.right: _maximize.left
  57. anchors.verticalCenter: parent.verticalCenter
  58. enabled: root.clientSideDecorations && root.width >= 620
  59. icon: "qrc:/resources/title/minimize.svg"
  60. onClick: _window.minimize()
  61. }
  62. TitleManualButton {
  63. id: _settings
  64. anchors.verticalCenter: parent.verticalCenter
  65. anchors.right: _minimize.left
  66. icon: "qrc:/resources/title/settings.svg"
  67. onClick: _pages.gotoSettingsPage()
  68. }
  69. }
  70. DTextBox {
  71. id: _search
  72. anchors.centerIn: parent
  73. width: 300
  74. style: Style.header.searchBox
  75. Binding { target: _search; property: "style.background"; value: Config.darkHeader? (_search.text == ""? "#1C1C1C" : Style.panel.background) : "transparent" }
  76. hint: qsTr("search")
  77. input.onAccepted: if (text != "") YClient.searchAndPlayTrack(text);
  78. MouseArea {
  79. anchors.fill: parent
  80. visible: parent.text === ""
  81. cursorShape: Qt.IBeamCursor
  82. onClicked: parent.input.focus = true
  83. }
  84. }
  85. SearchPanel {
  86. id: _searchPanel
  87. width: _search.width
  88. anchors.horizontalCenter: _search.horizontalCenter
  89. anchors.top: root.bottom
  90. anchors.topMargin: 10 - _spc.shift
  91. PopupController {
  92. id: _spc
  93. opened: _search.input.focus
  94. target: parent
  95. }
  96. }
  97. ResizeArea {
  98. id: _lg
  99. width: 12
  100. x: -6
  101. height: windowSize.height - 12
  102. y: 6
  103. enabled: root.clientSideDecorations && !maximized
  104. cursor: Qt.SizeHorCursor
  105. edge: Qt.LeftEdge
  106. }
  107. ResizeArea {
  108. id: _rg
  109. anchors.right: root.right
  110. anchors.rightMargin: -6
  111. width: 12
  112. height: windowSize.height - 12
  113. y: 6
  114. enabled: root.clientSideDecorations && !maximized
  115. cursor: Qt.SizeHorCursor
  116. edge: Qt.RightEdge
  117. }
  118. ResizeArea {
  119. id: _tg
  120. width: windowSize.width - 12
  121. x: 6
  122. height: 12
  123. y: -6
  124. enabled: root.clientSideDecorations && !maximized
  125. cursor: Qt.SizeVerCursor
  126. edge: Qt.TopEdge
  127. }
  128. ResizeArea {
  129. id: _bg
  130. y: windowSize.height - 6
  131. width: windowSize.width - 12
  132. x: 6
  133. height: 12
  134. enabled: root.clientSideDecorations && !maximized
  135. cursor: Qt.SizeVerCursor
  136. edge: Qt.BottomEdge
  137. }
  138. ResizeArea {
  139. id: _ltg
  140. x: -6
  141. y: -6
  142. width: 12
  143. height: 12
  144. enabled: root.clientSideDecorations && !maximized
  145. cursor: Qt.SizeFDiagCursor
  146. edge: Qt.LeftEdge | Qt.TopEdge
  147. }
  148. ResizeArea {
  149. id: _rtg
  150. anchors.right: root.right
  151. anchors.rightMargin: -6
  152. y: -6
  153. width: 12
  154. height: 12
  155. enabled: root.clientSideDecorations && !maximized
  156. cursor: Qt.SizeBDiagCursor
  157. edge: Qt.RightEdge | Qt.TopEdge
  158. }
  159. ResizeArea {
  160. id: _lbg
  161. y: windowSize.height - 6
  162. x: -6
  163. width: 12
  164. height: 12
  165. enabled: root.clientSideDecorations && !maximized
  166. cursor: Qt.SizeBDiagCursor
  167. edge: Qt.LeftEdge | Qt.BottomEdge
  168. }
  169. ResizeArea {
  170. id: _rbg
  171. anchors.right: root.right
  172. anchors.rightMargin: -6
  173. y: windowSize.height - 6
  174. width: 12
  175. height: 12
  176. enabled: root.clientSideDecorations && !maximized
  177. cursor: Qt.SizeFDiagCursor
  178. edge: Qt.RightEdge | Qt.BottomEdge
  179. }
  180. }