Diffstat (limited to 'noncore/multimedia/opieplayer2/volumecontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/volumecontrol.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/volumecontrol.cpp b/noncore/multimedia/opieplayer2/volumecontrol.cpp new file mode 100644 index 0000000..b8ec0df --- a/dev/null +++ b/noncore/multimedia/opieplayer2/volumecontrol.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | |||
2 | #include <qpe/qpeapplication.h> | ||
3 | #include <qpe/config.h> | ||
4 | #include "qpe/qcopenvelope_qws.h" | ||
5 | #include <qmessagebox.h> | ||
6 | |||
7 | #include "volumecontrol.h" | ||
8 | |||
9 | int VolumeControl::getVolume() { | ||
10 | int volumePerc; | ||
11 | Config cfg( "qpe" ); | ||
12 | cfg. setGroup( "Volume" ); | ||
13 | volumePerc = cfg. readNumEntry( "VolumePercent", 50 ); | ||
14 | m_volumePerc = volumePerc; | ||
15 | return volumePerc; | ||
16 | } | ||
17 | |||
18 | |||
19 | void VolumeControl::setVolume( int volumePerc ) { | ||
20 | Config cfg("qpe"); | ||
21 | cfg.setGroup("Volume"); | ||
22 | |||
23 | if ( volumePerc > 100 ) { | ||
24 | volumePerc = 100; | ||
25 | } | ||
26 | if ( volumePerc < 0 ) { | ||
27 | volumePerc = 0; | ||
28 | } | ||
29 | |||
30 | m_volumePerc = volumePerc; | ||
31 | cfg.writeEntry("VolumePercent", volumePerc ); | ||
32 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | ||
33 | } | ||
34 | |||
35 | |||
36 | void VolumeControl::incVol( int ammount ) { | ||
37 | int oldVol = getVolume(); | ||
38 | setVolume( oldVol + ammount); | ||
39 | } | ||
40 | |||
41 | void VolumeControl::decVol( int ammount ) { | ||
42 | int oldVol = getVolume(); | ||
43 | setVolume( oldVol - ammount); | ||
44 | } | ||
45 | |||
46 | |||
47 | VolumeControl::VolumeControl( ) { | ||
48 | getVolume(); | ||
49 | } | ||
50 | |||
51 | VolumeControl::~VolumeControl() { | ||
52 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | ||
53 | } | ||
54 | |||
55 | |||
56 | |||
57 | |||
58 | |||
59 | |||