volumekeys.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) 2012 Nokia Corporation.
  3. * All rights reserved.
  4. *
  5. * Part of the VideoPlayer.
  6. * Based on volumekeys.h from Qt GameEnabler.
  7. *
  8. * For the applicable distribution terms see the license text file included in
  9. * the distribution.
  10. */
  11. // Class declaration
  12. #include "volumekeys.h"
  13. /*!
  14. \class VolumeKeys
  15. \brief Symbian specific utility for reacting to hardware volume buttons.
  16. */
  17. /*!
  18. Constructs a new VolumeKeys object.
  19. */
  20. VolumeKeys::VolumeKeys(QObject *parent)
  21. : QObject(parent),
  22. m_interfaceSelector(0),
  23. m_coreTarget(0)
  24. {
  25. QT_TRAP_THROWING(
  26. m_interfaceSelector = CRemConInterfaceSelector::NewL();
  27. m_coreTarget = CRemConCoreApiTarget::NewL(*m_interfaceSelector, *this);
  28. m_interfaceSelector->OpenTargetL();
  29. );
  30. }
  31. /*!
  32. Destructor.
  33. */
  34. VolumeKeys::~VolumeKeys()
  35. {
  36. delete m_interfaceSelector;
  37. m_interfaceSelector = 0;
  38. m_coreTarget = 0; // owned by interfaceselector
  39. }
  40. /*!
  41. Event handler for listening to hardware volume key changes.
  42. \a operationId Tells what was the button operation (volume up / down).
  43. \a buttonAct Defines the button action (press / release / click).
  44. */
  45. void VolumeKeys::MrccatoCommand(TRemConCoreApiOperationId operationId,
  46. TRemConCoreApiButtonAction buttonAct)
  47. {
  48. if (buttonAct == ERemConCoreApiButtonClick) {
  49. if (operationId == ERemConCoreApiVolumeUp) {
  50. emit volumeKeyUp();
  51. }
  52. else if (operationId == ERemConCoreApiVolumeDown) {
  53. emit volumeKeyDown();
  54. }
  55. }
  56. }