-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolumekeysobserver.cpp
More file actions
66 lines (56 loc) · 2.05 KB
/
volumekeysobserver.cpp
File metadata and controls
66 lines (56 loc) · 2.05 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
#include "volumekeysobserver.h"
#include <QDebug>
#include <remconcoreapitarget.h> // Полное определение класса
#include <remconinterfaceselector.h> // Полное определение класса
VolumeKeysObserver::VolumeKeysObserver(QObject *parent)
: QObject(parent), m_interfaceSelector(0), m_coreTarget(0)
{
m_maxVolume = 100;
m_currentVolume = 50;
QT_TRAP_THROWING(
m_interfaceSelector = CRemConInterfaceSelector::NewL();
m_coreTarget = CRemConCoreApiTarget::NewL(*m_interfaceSelector, *this);
m_interfaceSelector->OpenTargetL();
);
}
VolumeKeysObserver::~VolumeKeysObserver()
{
delete m_interfaceSelector; // Это автоматически удалит m_coreTarget
}
int VolumeKeysObserver::volume() const
{
return m_currentVolume;
}
void VolumeKeysObserver::setVolume(int vol)
{
if (vol < 0) vol = 0;
if (vol > m_maxVolume) vol = m_maxVolume;
if (m_currentVolume != vol) {
m_currentVolume = vol;
emit volumeChanged(m_currentVolume);
}
}
int VolumeKeysObserver::maxVolume() const
{
return m_maxVolume;
}
// Этот метод дергается Symbian OS при нажатии на хард-кнопки телефона
void VolumeKeysObserver::MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct)
{
// ERemConCoreApiButtonClick - одиночное нажатие.
// ERemConCoreApiButtonPress - удержание. Мы будем обрабатывать и то, и то.
if (aButtonAct == ERemConCoreApiButtonClick || aButtonAct == ERemConCoreApiButtonPress) {
switch (aOperationId) {
case ERemConCoreApiVolumeUp:
setVolume(m_currentVolume + 10); // Шаг +10%
emit volumeUpPressed();
break;
case ERemConCoreApiVolumeDown:
setVolume(m_currentVolume - 10); // Шаг -10%
emit volumeDownPressed();
break;
default:
break;
}
}
}