-
Notifications
You must be signed in to change notification settings - Fork 3
/
mainwindow.hpp
88 lines (79 loc) · 2.01 KB
/
mainwindow.hpp
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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDragEnterEvent>
#include <QAudioFormat>
#include <QAudioDevice>
#include <QAudioSink>
#include <QBuffer>
#include <QTimer>
#include <QSlider>
#include <QCommandLineParser>
#include <QFileInfo>
#include <thread>
#include "songlist.hpp"
#include "thdatwrapper.hpp"
namespace Ui
{
class MainWindow;
}
class QClickableSlider: public QSlider
{
Q_OBJECT
public:
explicit QClickableSlider(QWidget *parent = 0): QSlider(parent) {}
protected:
void mouseReleaseEvent(QMouseEvent *e)
{
QSlider::mouseReleaseEvent(e);
if (e->buttons()^Qt::LeftButton)
{
double p = e->pos().x() / (double)width();
setValue(p * (maximum() - minimum()) + minimum());
emit sliderReleased();
}
}
};
class LoopedPCMStreamer;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
bool LoadFile(QString filepath);
bool SetupSongList();
bool args(QCommandLineParser &p);
~MainWindow();
private:
unsigned loopStart;
Ui::MainWindow *ui;
SongList songs;
song_t cursong;
LoopedPCMStreamer *st = nullptr;
QAudioSink *audioOutput = nullptr;
QAudioFormat getAudioFormat(unsigned rate);
QTimer *timer;
thDatWrapper *datw;
QCommandLineParser *argp;
int devi;
int thver;
int thVersionDetect(QFileInfo fi);
void setPlayListTableHeader();
void play(int index = -1);
void stop();
private slots:
// drag n drop
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void updateWidgets();
void seek();
void on_playlistTable_doubleClicked(const QModelIndex &index);
void on_loopButton_clicked();
void on_prevButton_clicked();
void on_nextButton_clicked();
void on_pauseButton_clicked(bool checked);
void on_action_Open_triggered();
void on_actionAbout_Qt_triggered();
void on_action_About_triggered();
};
#endif // MAINWINDOW_H