-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMP3Widget.cpp
More file actions
113 lines (94 loc) · 2.04 KB
/
Copy pathCMP3Widget.cpp
File metadata and controls
113 lines (94 loc) · 2.04 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
#include "CMP3Widget.h"
#include "ui_CMP3Widget.h"
#include <QFileDialog>
CMP3Widget::CMP3Widget(QWidget *parent):
CWidgetBase(parent),
ui(new Ui::CMP3Widget)
{
setObjectName("MP3 Player");
ui->setupUi(this);
ui->listView->setModel(&playerCore);
ui->btnStop->hide();
connect(&playerCore,SIGNAL(OnSongChanged(QModelIndex)),SLOT(OnSongChanged(QModelIndex)));
}
CMP3Widget::~CMP3Widget()
{
delete ui;
}
void CMP3Widget::on_btnDel_clicked()
{
playerCore.removeRow(ui->listView->currentIndex().row());
}
void CMP3Widget::on_btnClr_clicked()
{
playerCore.ClearPlaylist();
}
void CMP3Widget::on_btnAdd_clicked()
{
QFileDialog dlg(
this,
tr("Open Document"),
tr("/mnt/usb"),
tr("MP3 files(*.mp3);;All files (*.*)"));
QString strFileName;
dlg.resize(320,220);
dlg.exec();
if(dlg.selectedFiles().size()>0)
{
playerCore.AddFile(dlg.selectedFiles().at(0));
}
}
void CMP3Widget::on_btnPlay_clicked()
{
if(playerCore.GetStatus()==CMP3PlayerCore::PAUSED)
{
playerCore.ContinuePlayout();
}
else
{
playerCore.Play(ui->listView->currentIndex().row());
}
ui->btnStop->show();
ui->btnPlay->hide();
}
void CMP3Widget::on_btnPause_pressed()
{
if(playerCore.GetStatus()==CMP3PlayerCore::PLAYING)
{
playerCore.Pause();
}
else if(playerCore.GetStatus()==CMP3PlayerCore::PAUSED)
{
playerCore.ContinuePlayout();
}
}
void CMP3Widget::on_btnStop_clicked()
{
playerCore.Stop();
ui->btnStop->hide();
ui->btnPlay->show();
}
void CMP3Widget::on_btnNext_clicked()
{
playerCore.Next();
}
void CMP3Widget::on_btnPrev_clicked()
{
playerCore.Prev();
}
void CMP3Widget::on_btnShuffle_clicked()
{
playerCore.SetShuffle(ui->btnShuffle->isChecked());
}
void CMP3Widget::OnSongChanged(QModelIndex index)
{
ui->listView->setCurrentIndex(index);
}
void CMP3Widget::StartAlarmPlayout()
{
playerCore.Play(0);
}
void CMP3Widget::StopPlayout()
{
playerCore.Stop();
}