-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVolumeControlDlg.cpp
More file actions
60 lines (51 loc) · 1.14 KB
/
Copy pathVolumeControlDlg.cpp
File metadata and controls
60 lines (51 loc) · 1.14 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
#include "VolumeControlDlg.h"
#include "ui_VolumeControlDlg.h"
#include <QProcess>
#include <QDesktopWidget>
#include "HardwareLayer.h"
CVolumeControlDlg::CVolumeControlDlg(QWidget *parent) :
QDialog(parent,Qt::FramelessWindowHint | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint),
ui(new Ui::CVolumeControlDlg)
{
ui->setupUi(this);
timerID=0;
volume=192;
move((QApplication::desktop()->width()-this->width())/2,
(QApplication::desktop()->height()-this->height())/2);
}
CVolumeControlDlg::~CVolumeControlDlg()
{
if(timerID)
{
killTimer(timerID);
}
delete ui;
}
bool CVolumeControlDlg::AdjustVolume(int delta)
{
volume+=delta;
if(volume<128)
{
volume=128;
}
if(volume>255)
{
volume=255;
}
ui->progressVolume->setValue(volume-128);
//-F- Showing dialog
show();
if(timerID)
{
killTimer(timerID);
}
timerID=startTimer(1000);
//-F- Sending message to amixer
CHardwareLayer::GetInstance()->SetVolume(volume);
return true;
}
void CVolumeControlDlg::timerEvent(QTimerEvent *)
{
hide();
killTimer(timerID);
}