DropPlace.qml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import QtQuick 2.15
  2. import "../external"
  3. import DMusic 1.0
  4. //TODO: Перетаскивание ИЗ DropPlace
  5. DropArea {
  6. id: root
  7. width: 20
  8. height: 20
  9. property bool hasContent: false
  10. property string filter: qsTr("All files (*)")
  11. property string dropFilter: filter
  12. property url content
  13. onEntered: {
  14. drag.accept(Qt.LinkAction)
  15. }
  16. onDropped: {
  17. if (!drop.hasUrls) return
  18. var a = drop.urls[0]
  19. if (!FileDialogs.checkFilter(a, dropFilter)) return
  20. hasContent = true
  21. content = a
  22. }
  23. MouseArea {
  24. id: _mouse
  25. anchors.fill: parent
  26. z: 1
  27. hoverEnabled: true
  28. cursorShape: Qt.PointingHandCursor
  29. onClicked: {
  30. content = FileDialogs.openFile(root.filter)
  31. hasContent = content != ""
  32. }
  33. }
  34. Rectangle {
  35. anchors.fill: parent
  36. z: 1
  37. radius: Style.dropPlace.border.radius
  38. color: root.containsDrag? Style.dropPlace.color.drop : (_mouse.containsMouse? Style.dropPlace.color.hover : Style.dropPlace.color.normal)
  39. }
  40. Border {
  41. anchors.fill: parent
  42. z: 1
  43. antialiasing: true
  44. radius: Style.dropPlace.border.radius
  45. strokeColor: Style.dropPlace.border.color
  46. strokeWidth: Style.dropPlace.border.weight
  47. strokeStyle: 2
  48. dashPattern: [3, 3 + (((width + height) * 2 - radius) % 3)]
  49. }
  50. }