Repository navigation
Expand file tree
/
Copy pathmainwindow.h
More file actions
363 lines (303 loc) · 13.3 KB
/
Copy pathmainwindow.h
File metadata and controls
363 lines (303 loc) · 13.3 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/**
* Copyright (C) 2021 Jo2003 (olenka.joerg@gmail.com)
* This file is part of cd2netmd_gui
*
* cd2netmd is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cd2netmd is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*/
#pragma once
#include <QMainWindow>
#include <QTemporaryFile>
#include <QDir>
#include <QLabel>
#include <QMovie>
#include "cjacktheripper.h"
#include "ccddb.h"
#include "ccddbentriesdialog.h"
#include "ccditemmodel.h"
#include "cnetmd.h"
#include "cxenc.h"
#include "cmdtreemodel.h"
#include "defines.h"
#include "caboutdialog.h"
#include "settingsdlg.h"
#include "cdaoconfdlg.h"
#include "statuswidget.h"
#include "transfermode.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
//------------------------------------------------------------------------------
//! @brief This class describes a main window.
//------------------------------------------------------------------------------
class MainWindow : public QMainWindow
{
Q_OBJECT
using TransferQueue = c2n::TransferQueue;
using WorkStep = c2n::WorkStep;
enum eDiscFlags
{
WRITEABLE = (1 << 4),
WRITE_LOCK = (1 << 6)
};
enum ePopUp
{
INFORMATION,
WARNING,
CRITICAL
};
public:
//--------------------------------------------------------------------------
//! @brief creates the object
//!
//! @param parent The parent
//--------------------------------------------------------------------------
MainWindow(QWidget *parent = nullptr);
//--------------------------------------------------------------------------
//! @brief Destroys the object.
//--------------------------------------------------------------------------
~MainWindow();
//--------------------------------------------------------------------------
//! @brief get ms value for CDDA block count
//!
//! @param blonks CDDA block count
//!
//! @return time in milliseconds
//--------------------------------------------------------------------------
static inline uint32_t blocksToMs(long blocks)
{
return std::round((static_cast<double>(blocks) * 1000.0) / static_cast<double>(CDIO_CD_FRAMES_PER_SEC));
}
protected:
//--------------------------------------------------------------------------
//! @brief app is about to close
//!
//! @param[in] e pointer to close event
//--------------------------------------------------------------------------
void closeEvent(QCloseEvent* e) override;
//--------------------------------------------------------------------------
//! @brief something changed
//!
//! @param[in] e pointer to event
//--------------------------------------------------------------------------
void changeEvent(QEvent* e) override;
//--------------------------------------------------------------------------
//! @brief Adds a md track.
//!
//! @param[in] number The number
//! @param[in] title The title
//! @param[in] length The length
//--------------------------------------------------------------------------
void addMDTrack(int number, const QString &title, double length);
//--------------------------------------------------------------------------
//! @brief Sets the md title.
//!
//! @param[in] title The title
//--------------------------------------------------------------------------
void setMDTitle(const QString& title);
//--------------------------------------------------------------------------
//! @brief Enables the dialog items.
//!
//! @param[in] ena enable or disable
//--------------------------------------------------------------------------
void enableDialogItems(bool ena);
//--------------------------------------------------------------------------
//! @brief recreate MD content tree view
//!
//! @param[in] json The json
//--------------------------------------------------------------------------
void recreateTreeView(const QString& json);
//--------------------------------------------------------------------------
//! @brief update count label
//!
//! @param pLabel The label
//! @param[in] step The step
//! @param[in] text The text
//--------------------------------------------------------------------------
void countLabel(QLabel *pLabel, WorkStep step, const QString& text);
//--------------------------------------------------------------------------
//! @brief revert track order changes for DAO
//--------------------------------------------------------------------------
void revertCDEntries();
//--------------------------------------------------------------------------
//! @brief show a popup message delayed (asynchronous)
//!
//! @param tp Popup type
//! @param[in] caption window title
//! @param[in] msg message text
//! @param[in] wait delay time in ms
//--------------------------------------------------------------------------
void delayedPopUp(ePopUp tp, const QString& caption, const QString& msg, int wait = 500);
private slots:
//--------------------------------------------------------------------------
//! @brief load settings
//--------------------------------------------------------------------------
void loadSettings();
//--------------------------------------------------------------------------
//! @brief get the list of matching CDDB entries
//!
//! @param[in] l entries
//--------------------------------------------------------------------------
void catchCDDBEntries(QStringList l);
//--------------------------------------------------------------------------
//! @brief get the one matching CDDB entry
//!
//! @param[in] tracks audio tracks vector
//--------------------------------------------------------------------------
void catchCDDBEntry(c2n::AudioTracks tracks);
//--------------------------------------------------------------------------
//! @brief get json data from MD
//!
//! @param[in] <unnamed> json data as string
//--------------------------------------------------------------------------
void catchJson(QString);
//--------------------------------------------------------------------------
//! @brief Called when push initialize cd clicked.
//--------------------------------------------------------------------------
void on_pushInitCD_clicked();
//--------------------------------------------------------------------------
//! @brief Called when push load md clicked.
//--------------------------------------------------------------------------
void on_pushLoadMD_clicked();
//--------------------------------------------------------------------------
//! @brief MD titling
//!
//! @param[in] role The role
//! @param[in] title The title
//! @param[in] no number
//--------------------------------------------------------------------------
void mdTitling(CMDTreeModel::ItemRole role, QString title, int no);
//--------------------------------------------------------------------------
//! @brief Called when push transfer clicked.
//--------------------------------------------------------------------------
void on_pushTransfer_clicked();
//--------------------------------------------------------------------------
//! @brief rip of one track finsihed
//--------------------------------------------------------------------------
void ripFinished();
//--------------------------------------------------------------------------
//! @brief one encode finished.
//!
//! @param[in] checkBusy The check busy
//--------------------------------------------------------------------------
void encodeFinished(bool checkBusy = false);
//--------------------------------------------------------------------------
//! @brief one transfer finished
//!
//! @param[in] checkBusy The check busy
//! @param[in] ret if given return value from last transfer
//--------------------------------------------------------------------------
void transferFinished(bool checkBusy, int ret);
//--------------------------------------------------------------------------
//! @brief Adds a md group.
//!
//! @param[in] title The title
//! @param[in] first The first
//! @param[in] last The last
//--------------------------------------------------------------------------
void addMDGroup(const QString& title, int16_t first, int16_t last);
//--------------------------------------------------------------------------
//! @brief delete one MD group
//!
//! @param[in] number The group number
//--------------------------------------------------------------------------
void delMDGroup(int16_t number);
//--------------------------------------------------------------------------
//! @brief delete track
//!
//! @param[in] <unnamed> track number
//--------------------------------------------------------------------------
void delTrack(int16_t);
//--------------------------------------------------------------------------
//! @brief erase MD
//--------------------------------------------------------------------------
void eraseDisc();
//--------------------------------------------------------------------------
//! @brief Called when push about clicked.
//--------------------------------------------------------------------------
void on_pushAbout_clicked();
//--------------------------------------------------------------------------
//! @brief Called when push settings clicked.
//--------------------------------------------------------------------------
void on_pushSettings_clicked();
//--------------------------------------------------------------------------
//! @brief Called when load image button was clicked.
//--------------------------------------------------------------------------
void on_pushLoadImg_clicked();
//--------------------------------------------------------------------------
//! @brief catch dropped files from cd table view
//!
//! @param[in] sl string list with file pathes
//--------------------------------------------------------------------------
void catchDropped(QStringList sl);
//--------------------------------------------------------------------------
//! @brief catch new audio length in list
//!
//! @param length in blocks
//--------------------------------------------------------------------------
void audioLength(long blocks);
//--------------------------------------------------------------------------
//! @brief parse cue file
//!
//! @param[in] fileName cue sheet file name
//--------------------------------------------------------------------------
int parseCueFile(QString fileName);
void on_pushHelp_clicked();
void on_pushLog_clicked();
//--------------------------------------------------------------------------
//! @brief transfer mode changed
//!
//! @param[in] index new activated index
//--------------------------------------------------------------------------
void on_cbxTranferMode_currentIndexChanged(int index);
//--------------------------------------------------------------------------
//! @brief update free time label
//--------------------------------------------------------------------------
void updateFreeTimeLabel();
private:
/// GUI pointer
Ui::MainWindow *ui;
/// CD Ripper pointer
CJackTheRipper *mpRipper;
/// NetMD handling pointer
CNetMD *mpNetMD;
/// external encoder pointer
CXEnc *mpXEnc;
/// tree model for MD
CMDTreeModel *mpMDmodel;
/// job list
TransferQueue mWorkQueue;
/// MD device info
StatusWidget *mpMDDevice;
/// CD device info
StatusWidget *mpCDDevice;
/// settings dialog class
SettingsDlg *mpSettings;
/// keep a clean backup of the tracks
c2n::AudioTracks mTracksBackup;
/// can the device SP upload
bool mSpUpload;
/// does the device support forced TOC edit
bool mTocManip;
/// does the device support pcm2Mono
bool mPcm2Mono;
/// show SP download support
StatusWidget *mpSpUpload;
/// show on-the-fly support
StatusWidget *mpOtfEncode;
/// show TOC manipulation support
StatusWidget *mpTocManip;
/// show SP Mono support
StatusWidget *mpPcm2Mono;
/// chosen transfer mode
TransferMode mTransferMode;
};