DebugPanel.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import QtQuick 2.0
  2. import QtQuick.Dialogs 1.2
  3. import DMusic 1.0
  4. import "components"
  5. FloatingPanel {
  6. id: root
  7. width: 320
  8. height: 122
  9. property var player
  10. DTextBox {
  11. id: _id
  12. width: 155
  13. height: 20
  14. anchors.left: parent.left
  15. anchors.top: parent.top
  16. anchors.leftMargin: 20
  17. anchors.topMargin: 20
  18. hint: qsTr("ID")
  19. }
  20. DropPlace {
  21. id: _cover
  22. width: 50
  23. height: 50
  24. anchors.left: _id.left
  25. anchors.top: _id.bottom
  26. anchors.topMargin: 10
  27. filter: qsTr("Image (*.jpg *.png *.svg)")
  28. dropFilter: "(*)"
  29. Icon {
  30. anchors.centerIn: parent
  31. visible: !parent.hasContent
  32. src: "qrc:/resources/debug/drop-cover.svg"
  33. color: Style.dropPlace.border.color
  34. }
  35. RoundedImage {
  36. anchors.fill: parent
  37. anchors.margins: 1
  38. sourceSize: Qt.size(width, height)
  39. visible: parent.hasContent
  40. radius: Style.dropPlace.border.radius
  41. source: parent.content
  42. fillMode: Image.PreserveAspectCrop
  43. clip: true
  44. }
  45. }
  46. DTextBox {
  47. id: _title
  48. width: 100
  49. anchors.left: _cover.right
  50. anchors.top: _cover.top
  51. anchors.leftMargin: 10
  52. hint: qsTr("Title")
  53. }
  54. DTextBox {
  55. id: _comment
  56. width: 115
  57. height: 20
  58. anchors.left: _title.right
  59. anchors.top: _title.top
  60. anchors.leftMargin: 10
  61. hint: qsTr("Comment")
  62. }
  63. DTextBox {
  64. id: _artists
  65. x: 82
  66. width: 169
  67. height: 20
  68. anchors.top: _title.bottom
  69. anchors.topMargin: 10
  70. hint: qsTr("Artists")
  71. }
  72. DropPlace {
  73. id: _media
  74. width: 20
  75. height: 20
  76. antialiasing: true
  77. anchors.left: _artists.right
  78. anchors.top: _artists.top
  79. anchors.leftMargin: 10
  80. filter: qsTr("MP3 (*.mp3)")
  81. Icon {
  82. anchors.centerIn: parent
  83. src: "qrc:/resources/debug/drop-media.svg"
  84. color: parent.hasContent? Style.accent : Style.dropPlace.border.color
  85. }
  86. }
  87. IconButton {
  88. id: _track
  89. width: 20
  90. height: 20
  91. anchors.left: _id.right
  92. anchors.top: _id.top
  93. src: "qrc:/resources/debug/track.svg"
  94. anchors.leftMargin: 12
  95. onClicked: {
  96. if (_id.text === "") return
  97. try {
  98. player.player.play(YClient.oneTrack(parseInt(_id.text)))
  99. } catch (e) {}
  100. }
  101. }
  102. IconButton {
  103. id: _playlist
  104. width: 20
  105. height: 20
  106. anchors.left: _track.right
  107. anchors.top: _id.top
  108. anchors.leftMargin: 12
  109. src: "qrc:/resources/debug/playlist.svg"
  110. onClicked: {
  111. if (_id.text === "") return
  112. try {
  113. YClient.playPlaylist(YClient.playlist(parseInt(_id.text)))
  114. } catch (e) {}
  115. }
  116. }
  117. IconButton {
  118. id: _downloads
  119. width: 20
  120. height: 20
  121. anchors.left: _playlist.right
  122. anchors.top: _id.top
  123. anchors.leftMargin: 12
  124. src: "qrc:/resources/debug/downloads.svg"
  125. onClicked: YClient.playDownloads()
  126. }
  127. IconButton {
  128. id: _user
  129. width: 20
  130. height: 20
  131. anchors.left: _downloads.right
  132. anchors.top: _id.top
  133. anchors.leftMargin: 12
  134. src: "qrc:/resources/debug/user.svg"
  135. onClicked: {
  136. if (_id.text === "") return
  137. try {
  138. player.player.play(YClient.userTrack(parseInt(_id.text)))
  139. } catch (e) {}
  140. }
  141. }
  142. IconButton {
  143. id: _add
  144. width: 20
  145. height: 20
  146. anchors.left: _media.right
  147. anchors.top: _media.top
  148. anchors.leftMargin: 6
  149. src: "qrc:/resources/debug/add.svg"
  150. onClicked: {
  151. if (!_media.hasContent) return
  152. if (!_cover.hasContent) {
  153. YClient.addUserTrack(_media.content.toString(), "", _title.text, _artists.text, _comment.text)
  154. } else {
  155. YClient.addUserTrack(_media.content.toString(), _cover.content.toString(), _title.text, _artists.text, _comment.text)
  156. }
  157. }
  158. }
  159. }