blob: f7155194985c2f734ca434fbefe993282dd4e5b3 (
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
|
import "." as Skin
import Mixxx 0.1 as Mixxx
import QtQml.Models 2.12
import QtQuick 2.12
import "Theme"
Item {
Rectangle {
color: Theme.deckBackgroundColor
anchors.fill: parent
LibraryControl {
id: libraryControl
onMoveVertical: listView.moveSelectionVertical(offset)
onLoadSelectedTrack: listView.loadSelectedTrack(group, play)
onLoadSelectedTrackIntoNextAvailableDeck: listView.loadSelectedTrackIntoNextAvailableDeck(play)
onFocusWidgetChanged: {
switch (focusWidget) {
case FocusedWidgetControl.WidgetKind.LibraryView:
listView.forceActiveFocus();
break;
}
}
}
ListView {
id: listView
function moveSelectionVertical(value) {
if (value == 0)
return ;
const rowCount = model.rowCount();
if (rowCount == 0)
return ;
currentIndex = Mixxx.MathUtils.positiveModulo(currentIndex + value, rowCount);
}
function loadSelectedTrackIntoNextAvailableDeck(play) {
const url = model.get(currentIndex).fileUrl;
if (!url)
return ;
Mixxx.PlayerManager.loadLocationUrlIntoNextAvailableDeck(url, play);
}
function loadSelectedTrack(group, play) {
const url = model.get(currentIndex).fileUrl;
if (!url)
return ;
const player = Mixxx.PlayerManager.getPlayer(group);
if (!player)
return ;
player.loadTrackFromLocationUrl(url, play);
}
anchors.fill: parent
anchors.margins: 10
clip: true
keyNavigationWraps: true
highlightMoveDuration: 250
highlightResizeDuration: 50
model: Mixxx.Library.model
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Enter:
case Qt.Key_Return:
listView.loadSelectedTrackIntoNextAvailableDeck(false);
break;
}
}
delegate: Item {
id: itemDelegate
implicitWidth: listView.width
implicitHeight: 30
Text {
anchors.verticalCenter: parent.verticalCenter
text: artist + " - " + title
color: (listView.currentIndex == index && listView.activeFocus) ? 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.forceActiveFocus();
listView.currentIndex = index;
parent.grabToImage((result) => {
dragItem.Drag.imageSource = result.url;
});
}
onDoubleClicked: listView.loadSelectedTrackIntoNextAvailableDeck(false)
}
}
highlight: Rectangle {
border.color: listView.activeFocus ? Theme.blue : Theme.deckTextColor
border.width: 1
color: "transparent"
}
}
}
}
|