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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
#include <QDesktopServices>
#include "control/controlobject.h"
#include "library/recording/dlgrecording.h"
#include "library/trackcollectionmanager.h"
#include "widget/wwidget.h"
#include "widget/wskincolor.h"
#include "widget/wtracktableview.h"
#include "util/assert.h"
DlgRecording::DlgRecording(QWidget* parent, UserSettingsPointer pConfig,
Library* pLibrary,
RecordingManager* pRecordingManager, KeyboardEventFilter* pKeyboard)
: QWidget(parent),
m_pConfig(pConfig),
m_pTrackTableView(new WTrackTableView(this, pConfig, pLibrary->trackCollections(), true)),
m_browseModel(this, pLibrary->trackCollections(), pRecordingManager),
m_proxyModel(&m_browseModel),
m_bytesRecordedStr("--"),
m_durationRecordedStr("--:--"),
m_pRecordingManager(pRecordingManager) {
setupUi(this);
m_pTrackTableView->installEventFilter(pKeyboard);
connect(m_pTrackTableView,
&WTrackTableView::loadTrack,
this,
&DlgRecording::loadTrack);
connect(m_pTrackTableView,
&WTrackTableView::loadTrackToPlayer,
this,
&DlgRecording::loadTrackToPlayer);
connect(pLibrary,
&Library::setTrackTableFont,
m_pTrackTableView,
&WTrackTableView::setTrackTableFont);
connect(pLibrary,
&Library::setTrackTableRowHeight,
m_pTrackTableView,
&WTrackTableView::setTrackTableRowHeight);
connect(pLibrary,
&Library::setSelectedClick,
m_pTrackTableView,
&WTrackTableView::setSelectedClick);
connect(m_pRecordingManager,
&RecordingManager::isRecording,
this,
&DlgRecording::slotRecordingEnabled);
connect(m_pRecordingManager,
&RecordingManager::bytesRecorded,
this,
&DlgRecording::slotBytesRecorded);
connect(m_pRecordingManager,
&RecordingManager::durationRecorded,
this,
&DlgRecording::slotDurationRecorded);
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
VERIFY_OR_DEBUG_ASSERT(box) { //Assumes the form layout is a QVBox/QHBoxLayout!
} else {
box->removeWidget(m_pTrackTablePlaceholder);
m_pTrackTablePlaceholder->hide();
box->insertWidget(1, m_pTrackTableView);
}
m_recordingDir = m_pRecordingManager->getRecordingDir();
m_proxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive);
m_proxyModel.setSortCaseSensitivity(Qt::CaseInsensitive);
m_browseModel.setPath(m_recordingDir);
m_pTrackTableView->loadTrackModel(&m_proxyModel);
connect(pushButtonRecording,
&QPushButton::toggled,
this,
&DlgRecording::toggleRecording);
label->setText("");
label->setEnabled(false);
}
DlgRecording::~DlgRecording() {
}
void DlgRecording::onShow() {
m_recordingDir = m_pRecordingManager->getRecordingDir();
m_browseModel.setPath(m_recordingDir);
}
bool DlgRecording::hasFocus() const {
return m_pTrackTableView->hasFocus();
}
void DlgRecording::refreshBrowseModel() {
m_browseModel.setPath(m_recordingDir);
}
void DlgRecording::onSearch(const QString& text) {
m_proxyModel.search(text);
}
void DlgRecording::slotRestoreSearch() {
emit restoreSearch(currentSearch());
}
void DlgRecording::loadSelectedTrack() {
m_pTrackTableView->loadSelectedTrack();
}
void DlgRecording::slotAddToAutoDJBottom() {
m_pTrackTableView->slotAddToAutoDJBottom();
}
void DlgRecording::slotAddToAutoDJTop() {
m_pTrackTableView->slotAddToAutoDJTop();
}
void DlgRecording::slotAddToAutoDJReplace() {
m_pTrackTableView->slotAddToAutoDJReplace();
}
void DlgRecording::loadSelectedTrackToGroup(QString group, bool play) {
m_pTrackTableView->loadSelectedTrackToGroup(group, play);
}
void DlgRecording::moveSelection(int delta) {
m_pTrackTableView->moveSelection(delta);
}
void DlgRecording::toggleRecording(bool toggle) {
Q_UNUSED(toggle);
if (!m_pRecordingManager->isRecordingActive()) //If recording is enabled
{
//pushButtonRecording->setText(tr("Stop Recording"));
m_pRecordingManager->startRecording();
}
else if(m_pRecordingManager->isRecordingActive()) //If we disable recording
{
//pushButtonRecording->setText(tr("Start Recording"));
m_pRecordingManager->stopRecording();
}
}
void DlgRecording::slotRecordingEnabled(bool isRecording) {
if (isRecording) {
pushButtonRecording->setText((tr("Stop Recording")));
label->setEnabled(true);
} else {
pushButtonRecording->setText((tr("Start Recording")));
label->setText("");
label->setEnabled(false);
}
//This will update the recorded track table view
m_browseModel.setPath(m_recordingDir);
}
// gets number of recorded bytes and update label
void DlgRecording::slotBytesRecorded(int bytes) {
double megabytes = bytes / 1048576.0;
m_bytesRecordedStr = QString::number(megabytes,'f',2);
refreshLabel();
}
// gets recorded duration and update label
void DlgRecording::slotDurationRecorded(QString durationRecorded) {
m_durationRecordedStr = durationRecorded;
refreshLabel();
}
// update label besides start/stop button
void DlgRecording::refreshLabel() {
QString text = tr("Recording to file: %1 (%2 MiB written in %3)")
.arg(m_pRecordingManager->getRecordingFile())
.arg(m_bytesRecordedStr)
.arg(m_durationRecordedStr);
label->setText(text);
}
|