blob: 8311c2ee4781d680b2390604fcb9bdc0a29e28dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
import "." as Skin
import Mixxx 0.1 as Mixxx
import QtQuick 2.12
import "Theme"
Item {
Rectangle {
color: Theme.deckBackgroundColor
anchors.fill: parent
Mixxx.ControlProxy {
id: focusedWidgetControl
group: "[Library]"
key: "focused_widget"
Component.onCompleted: value = 3
}
Mixxx.ControlProxy {
group: "[Playlist]"
key: "SelectTrackKnob"
onValueChanged: {
listView.moveSelection(value);
}
}
Mixxx.ControlProxy {
group: "[Playlist]"
key: "SelectPrevTrack"
onValueChanged: {
if (value != 0)
listView.moveSelection(-1);
}
}
Mixxx.ControlProxy {
group: "[Playlist]"
key: "SelectNextTrack"
onValueChanged: {
if (value != 0)
listView.moveSelection(1);
}
}
Mixxx.ControlProxy {
group: "[Library]"
key: "MoveVertical"
onValueChanged: {
if (focusedWidgetControl.value == 3)
listView.moveSelection(value);
}
}
Mixxx.ControlProxy {
group: "[Library]"
key: "MoveUp"
onValueChanged: {
if (value != 0 && focusedWidgetControl.value == 3)
listView.moveSelection(-1);
}
}
Mixxx.ControlProxy {
group: "[Library]"
key: "MoveDown"
onValueChanged: {
if (value != 0 && focusedWidgetControl.value == 3)
listView.moveSelection(1);
}
}
ListView {
id: listView
function moveSelection(value) {
if (value == 0)
return ;
const rowCount = model.rowCount();
if (rowCount == 0)
return ;
let newIndex = currentIndex = (currentIndex + value) % rowCount;
while (newIndex < 0)newIndex += rowCount
currentIndex = newIndex;
}
anchors.fill: parent
anchors.margins: 10
clip: true
focus: true
highlightMoveDuration: 250
highlightResizeDuration: 50
model: Mixxx.Library.model
delegate: Item {
id: itemDelegate
implicitWidth: listView.width
implicitHeight: 30
Text {
anchors.verticalCenter: parent.verticalCenter
text: artist + " - " + title
color: listView.currentIndex == index ? Theme.blue : Theme.deckTextColor
Behavior on color {
ColorAnimation {
duration: listView.highlightMoveDuration
}
}
}
Image {
id: dragItem
Drag.active: dragArea.drag.active
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.CopyAction
Drag.mimeData: {
"text/uri-list": fileUrl,
"text/plain": fileUrl
}
anchors.fill: parent
}
MouseArea {
id: dragArea
anchors.fill: parent
drag.target: dragItem
onPressed: {
listView.currentIndex = index;
parent.grabToImage((result) => {
dragItem.Drag.imageSource = result.url;
});
}
}
}
highlight: Rectangle {
border.color: Theme.blue
border.width: 1
color: "transparent"
}
}
}
}
|