Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Audio Volume Key Event On Symbian/bg: Difference between revisions
AutoSpider (talk | contribs) m (AutoSpider moved page Audio Volume Key Event On Symbian Bulgarian to Audio Volume Key Event On Symbian/bg: Localisation) |
AutoSpider (talk | contribs) (Mark Outdated: Symbian no longer supported) |
||
Line 1: | Line 1: | ||
{{Outdated|reason=The Symbian platform is no longer supported.}} | |||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | {{Cleanup | reason=Auto-imported from ExpressionEngine.}} | ||
Latest revision as of 15:16, 19 March 2015
IMPORTANT: The content of this page is outdated. Reason: The Symbian platform is no longer supported. If you have checked or updated this page and found the content to be suitable, please remove this notice. |
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
Български English
Прихващане на събития, свързани с бутон за звук на Symbian устройства
В QML за Symbian устройста събитията за бутона за звук не могат да бъдат прихванати чрез Keys.onVolumeDownPressed, Keys.onVolumeUpPressed, or Keys.onPressed. Подходящо решение на този проблем е създаване на клас, обвиващ S60 Remote Control API чрез наследяване на MRemConCoreApiTargetObserver. Този примерен код, който показва как това може да бъде направено при създаване на QML/C++ приложение. Аналогично може да бъде създаден и QML plugin.
Създайте нов QML елемент, които да обработва събития, свързани с бутоните за звук. Всъщност чрез S60 Remote Control API могат да бъдат прихващани и други събития свързвани с бутоните за медия. За подробности вижте линка по-горе.
MediakeyCaptureItem.h
#ifndef MediakeyCaptureItem_H
#define MediakeyCaptureItem_H
#include <QDeclarativeItem>
#ifdef Q_WS_S60
#include <remconcoreapitargetobserver.h> // link against RemConCoreApi.lib
#include <remconcoreapitarget.h> // and
#include <remconinterfaceselector.h> // RemConInterfaceBase.lib
class MediakeyCaptureItemPrivate;
class MediakeyCaptureItem : public QDeclarativeItem
{
Q_OBJECT
public:
MediakeyCaptureItem(QDeclarativeItem *parent = 0);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
signals:
void volumeDownPressed();
void volumeUpPressed();
private:
MediakeyCaptureItemPrivate *d_ptr;
private: // Friend class definitions
friend class MediakeyCaptureItemPrivate;
};
#endif // Q_WS_S60
#endif // MediakeyCaptureItem_H
MediakeyCaptureItem.cpp
#include "MediaKeyCaptureItem.h"
#ifdef Q_WS_S60
// A private class to access Symbian RemCon API
class MediakeyCaptureItemPrivate : public QObject, public MRemConCoreApiTargetObserver
{
public:
MediakeyCaptureItemPrivate(MediakeyCaptureItem '''parent);
~MediakeyCaptureItemPrivate();
virtual void MrccatoCommand(TRemConCoreApiOperationId aOperationId,
TRemConCoreApiButtonAction aButtonAct);
private:
CRemConInterfaceSelector''' iInterfaceSelector;
CRemConCoreApiTarget* iCoreTarget;
MediakeyCaptureItem *d_ptr;
};
// Consructor
MediakeyCaptureItem::MediakeyCaptureItem(QDeclarativeItem *parent): QDeclarativeItem(parent)
{
d_ptr = new MediakeyCaptureItemPrivate(this);
}
// The paint method
void MediakeyCaptureItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
// This item has no visual
}
// Constructor
MediakeyCaptureItemPrivate::MediakeyCaptureItemPrivate(MediakeyCaptureItem *parent): d_ptr(parent)
{
QT_TRAP_THROWING(iInterfaceSelector = CRemConInterfaceSelector::NewL());
QT_TRAP_THROWING(iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, '''this));
iInterfaceSelector->OpenTargetL();
}
// Destructor
MediakeyCaptureItemPrivate::~MediakeyCaptureItemPrivate(){
delete iInterfaceSelector;
delete iCoreTarget;
}
// Callback when media keys are pressed
void MediakeyCaptureItemPrivate::MrccatoCommand(TRemConCoreApiOperationId aOperationId,
TRemConCoreApiButtonAction aButtonAct)
{
//TRequestStatus status;
switch( aOperationId )
{
case ERemConCoreApiVolumeUp:
emit d_ptr->volumeUpPressed();
break;
case ERemConCoreApiVolumeDown:
emit d_ptr->volumeDownPressed();
break;
default:
break;
}
}
#endif // Q_WS_S60
В C++ кода направете регистрация:
qmlRegisterType<MediakeyCaptureItem>("Mediakey", 1, 0, "MediakeyCapture");
Необходимо е да добавите следните няколко реда във .pro файла на вашия проект:
symbian{
INCLUDEPATH ''= MW_LAYER_SYSTEMINCLUDE // Not sure if this is needed…
LIBS''= -L\epoc32\release\armv5\lib -lremconcoreapi
LIBS += -L\epoc32\release\armv5\lib -lremconinterfacebase
}
В QML слушайте за сигнали по следния начин:
import Qt 4.7
import Mediakey 1.0
Item{
…
MediakeyCapture{
onVolumeDownPressed: console.log('VOLUME DOWN PRESSED ')
onVolumeUpPressed: console.log('VOLUME UP PRESSED ')
}
}
Отстраняване на проблеми
Ако използвате Qt SDK 1.1 (Windows, Beta and RC) за Symbian^3 е необходимо да копирате всичко от
C:3Qt472\epoc32\release\armv5\lib\rem'''
в
C:1Qt472\epoc32\release\armv5\lib