-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolume.h
56 lines (44 loc) · 995 Bytes
/
volume.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
//
// Created by sc19mta on 30/11/2020(lmao).
//
#ifndef VOLUME_BAR_H
#define VOLUME_BAR_H
#include <QImageReader>
#include <QPushButton>
#include <QSlider>
class VolumeBar;
class VolumeButton;
class VolumeButton : public QPushButton {
Q_OBJECT
private:
int m_volume{0};
public:
VolumeButton(QWidget* parent) : QPushButton(parent) {
setVolume(0);
}
~VolumeButton(){}
public slots:
void setVolume(int v) {
if (v > 50) {
// high volume icon
setIcon(QIcon(":icons/vol_f.png"));
}
else if (v > 0) {
// low volume icon
setIcon(QIcon(":icons/vol_l.png"));
}
else {
// muted volume icon
setIcon(QIcon(":icons/vol_m.png"));
}
m_volume = v;
}
void clicked() {
// flip the bits
setVolume(0 - m_volume);
emit toggleVolume(m_volume);
}
signals:
void toggleVolume(int);
};
#endif // VOLUME_BAR_H