-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplayercontrols.h
executable file
·171 lines (147 loc) · 5.04 KB
/
playercontrols.h
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
/***************************************************************************
* Project created by QtCreator 2018-06-01T17:15:24 *
* *
* goldfinch Copyright (C) 2014 AbouZakaria <yahiaui@gmail.com> *
* *
* This program 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. *
* *
* This program 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 *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PLAYERCONTROLS_H
#define PLAYERCONTROLS_H
#include "slider.h"
#include <QMediaPlayer>
#include <QWidget>
#include <QIcon>
#include <QDebug>
#include <QBoxLayout>
#include <QGraphicsBlurEffect>
#include <QLabel>
QT_BEGIN_NAMESPACE
class QToolButton;
class QAbstractButton;
class QAbstractSlider;
class QComboBox;
class QSlider;
class QLabel;
QT_END_NAMESPACE
//---------------------------------- WidgetInfo ---------------------------------
class WidgetImg : public QWidget
{
Q_OBJECT
public:
explicit WidgetImg(){
setAttribute(Qt::WA_PaintUnclipped,false);
}
virtual void paintEvent(QPaintEvent *event);
signals:
public slots:
void setImage(QImage img){
mImage=img;
update();
}
private:
QImage mImage;
};
//---------------------------------- WidgetInfo ---------------------------------
class WidgetInfo : public QWidget
{
Q_OBJECT
public:
explicit WidgetInfo(){ setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);}
virtual void paintEvent(QPaintEvent *event);
signals:
public slots:
void setTitle(const QString &tit,const QString &info){
mTitle=tit;mInfo=info;update();
setToolTip(mTitle+"\n"+mInfo);
update();
}
private:
QString mTitle;
QString mInfo;
};
//---------------------------------- PlayerControls ---------------------------------
class PlayerControls : public QWidget
{
Q_OBJECT
public:
explicit PlayerControls(QWidget *parent = nullptr);
void resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
m_WidgetImg->setMinimumWidth(this->sizeHint().height()-5);
qDebug()<<this->sizeHint().height()-5;
}
QMediaPlayer::State state() const;
virtual void paintEvent(QPaintEvent *event);
bool isMuted() const;
int volume() const;
void togglePreview(bool minPrev);
public slots:
// void setState(QMediaPlayer::State state);
void setSeekSliderValueChanged(int val);
void setVolume(int volume);
void setLabTitle(const QString title,const QString info);
void setupIcons();
void durationChanged(qint64 duration);
void positionChanged(qint64 progress);
void setMutedChanged(bool mute);
signals:
void play();
void pause();
void stop();
void next();
void previous();
void changeVolume(int volume);
void changeRate(qreal rate);
void seek(int);
void imageChanged(QImage img);
private slots:
void setImage(QImage img);
// void playClicked();
void onVolumeSliderValueChanged();
void updateDurationInfo(qint64 currentInfo);
// void setSliderPressed();
// void setSeeked(int val);
private:
WidgetInfo *m_WidgetInfo;
WidgetImg *m_WidgetImg;
QWidget *widgetMini;
QWidget *widgetButtons;
QToolButton *m_playButton = nullptr;
QToolButton *m_nextButton = nullptr;
QToolButton *m_previousButton = nullptr;
QToolButton *m_muteButton = nullptr;
QToolButton *m_toggleButton=nullptr;
QAbstractSlider *m_volumeSlider = nullptr;
Slider *m_slider = nullptr;
QLabel *m_labelDuration = nullptr;
QLabel *m_labelCurrentTime = nullptr;
//QLabel *m_labelTitle=nullptr;
QIcon playIcon;
QIcon pauseIcon;
QImage mImage;
qint64 m_duration;
QMediaPlayer::State m_playerState = QMediaPlayer::StoppedState;
QBoxLayout *HlayoutDuration ;
QBoxLayout *hlayout ;
QBoxLayout *vMainlayout ;
QBoxLayout *hMainlayout;
QBoxLayout *vlayoutDuration;
QBoxLayout *vMinilayout;
bool m_playerMuted = false;
bool mMinPreview=false;
};
#endif // PLAYERCONTROLS_H