qtmobileextensions/src/keycapture/xqkeycapture.h
branchRCL_3
changeset 10 cd2778e5acfe
parent 9 5d007b20cfd0
child 11 19a54be74e5e
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  *
       
     5  * This program is free software: you can redistribute it and/or modify
       
     6  * it under the terms of the GNU Lesser General Public License as published by
       
     7  * the Free Software Foundation, version 2.1 of the License.
       
     8  * 
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU Lesser General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU Lesser General Public License
       
    15  * along with this program.  If not, 
       
    16  * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17  *
       
    18  * Description:
       
    19  *
       
    20  */
       
    21 
       
    22 #ifndef XQKEYCAPTURE_H
       
    23 #define XQKEYCAPTURE_H
       
    24 
       
    25 #include <qnamespace.h>
       
    26 #include <QString>
       
    27 #include <QObject>
       
    28 #include <QList>
       
    29 #include <QFlag>
       
    30 #include <QEvent>
       
    31 
       
    32 #include <w32std.h>
       
    33 
       
    34 #ifdef XQKEYCAPTURE_LIBRARY
       
    35 #define XQKEYCAPTURE_EXPORT Q_DECL_EXPORT
       
    36 #else
       
    37 #define XQKEYCAPTURE_EXPORT Q_DECL_IMPORT
       
    38 #endif
       
    39 
       
    40 class KeyCapturePrivate;
       
    41 
       
    42 typedef QList<Qt::Key> XQKeyCaptureKeyList; 
       
    43 typedef QList<TUint> XQKeyCaptureNativeKeyList; 
       
    44 
       
    45 class XQKEYCAPTURE_EXPORT XQKeyCapture {
       
    46 
       
    47 public:
       
    48     enum LongFlags {
       
    49     LongShortEventImmediately = ELongCaptureShortEventImmediately,
       
    50     LongRepeatEvents = ELongCaptureRepeatEvents,
       
    51     LongNormal = ELongCaptureNormal,
       
    52     LongWaitShort = ELongCaptureWaitShort,
       
    53     LongWaitNotApplicable = 0
       
    54     };
       
    55 		
       
    56     enum CapturingFlag {
       
    57       CaptureNone = 0x0,
       
    58       CaptureBasic = 0x1,
       
    59       CaptureCallHandlingExt = 0x2,
       
    60       CaptureEnableRemoteExtEvents = 0x4
       
    61     };
       
    62     
       
    63     Q_DECLARE_FLAGS(CapturingFlags, CapturingFlag)
       
    64     
       
    65 public:
       
    66     XQKeyCapture();
       
    67 
       
    68     ~XQKeyCapture();
       
    69 
       
    70     bool captureKey(Qt::Key aKey,
       
    71         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    72         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
    73     
       
    74     bool captureKey(TUint aKey,
       
    75         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    76         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
    77 
       
    78     bool captureLongKey(Qt::Key aKey,
       
    79         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    80         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
    81         XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
    82 
       
    83     bool captureLongKey(TUint aKey,
       
    84         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    85         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
    86         XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
    87 
       
    88     bool captureKeyUpAndDowns(Qt::Key aKey,
       
    89         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    90         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
    91     
       
    92     bool captureKeyUpAndDowns(TUint aKey,
       
    93         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    94         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
    95 
       
    96     bool captureKey(XQKeyCaptureKeyList list, 
       
    97             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
    98             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
    99     
       
   100     bool captureKey(XQKeyCaptureNativeKeyList list, 
       
   101             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   102             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   103     
       
   104     bool captureLongKey(XQKeyCaptureKeyList list, 
       
   105             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   106             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   107             XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
   108     
       
   109     bool captureLongKey(XQKeyCaptureNativeKeyList list, 
       
   110             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   111             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   112             XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
   113     
       
   114     bool captureKeyUpAndDowns(XQKeyCaptureKeyList list, 
       
   115             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   116             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   117     
       
   118     bool captureKeyUpAndDowns(XQKeyCaptureNativeKeyList list, 
       
   119             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   120             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   121 		
       
   122     bool cancelCaptureKey(Qt::Key aKey,
       
   123         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   124         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   125 
       
   126     bool cancelCaptureKey(TUint aKey,
       
   127         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   128         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   129 
       
   130     bool cancelCaptureLongKey(Qt::Key aKey,
       
   131         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   132         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   133         XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
   134 
       
   135     bool cancelCaptureLongKey(TUint aKey,
       
   136         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   137         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   138         XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
   139 
       
   140     bool cancelCaptureKeyUpAndDowns(Qt::Key aKey,
       
   141         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   142         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   143 
       
   144     bool cancelCaptureKeyUpAndDowns(TUint aKey,
       
   145         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   146         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   147     
       
   148     bool cancelCaptureKey(XQKeyCaptureKeyList list, 
       
   149             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   150             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   151     
       
   152     bool cancelCaptureKey(XQKeyCaptureNativeKeyList list, 
       
   153             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   154             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   155     
       
   156     bool cancelCaptureLongKey(XQKeyCaptureKeyList list, 
       
   157             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   158             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   159             XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
   160     
       
   161     bool cancelCaptureLongKey(XQKeyCaptureNativeKeyList list, 
       
   162             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   163             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   164             XQKeyCapture::LongFlags aLongType = XQKeyCapture::LongNormal);
       
   165     
       
   166     bool cancelCaptureKeyUpAndDowns(XQKeyCaptureKeyList list, 
       
   167             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   168             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   169     
       
   170     bool cancelCaptureKeyUpAndDowns(XQKeyCaptureNativeKeyList list, 
       
   171             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   172             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   173 
       
   174 	bool captureRemoteKeys(CapturingFlags flags = CaptureNone);
       
   175     
       
   176     bool cancelCaptureRemoteKeys(CapturingFlags flags = CaptureNone);
       
   177     
       
   178     static QEvent::Type remoteEventType_KeyPress();
       
   179     
       
   180     static QEvent::Type remoteEventType_KeyRelease();
       
   181 			
       
   182     QString errorString() const;
       
   183 
       
   184     int errorId() const;
       
   185 
       
   186 private:
       
   187     KeyCapturePrivate* d;
       
   188 
       
   189 };
       
   190 
       
   191 /*
       
   192 @deprecated
       
   193 */
       
   194 
       
   195 class XQKEYCAPTURE_EXPORT XqKeyCapture {
       
   196 
       
   197 public:
       
   198     enum LongFlags {
       
   199     LongShortEventImmediately = ELongCaptureShortEventImmediately,
       
   200     LongRepeatEvents = ELongCaptureRepeatEvents,
       
   201     LongNormal = ELongCaptureNormal,
       
   202     LongWaitShort = ELongCaptureWaitShort,
       
   203     LongWaitNotApplicable = 0
       
   204     };
       
   205 	
       
   206 public:
       
   207     XqKeyCapture();
       
   208 
       
   209     ~XqKeyCapture();
       
   210 	
       
   211     bool captureKey(Qt::Key aKey,
       
   212         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   213         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   214     
       
   215     bool captureKey(TUint aKey,
       
   216         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   217         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   218 
       
   219     bool captureLongKey(Qt::Key aKey,
       
   220         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   221         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   222         XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   223 
       
   224     bool captureLongKey(TUint aKey,
       
   225         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   226         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   227         XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   228 
       
   229     bool captureKeyUpAndDowns(Qt::Key aKey,
       
   230         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   231         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   232     
       
   233     bool captureKeyUpAndDowns(TUint aKey,
       
   234         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   235         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   236 
       
   237     bool captureKey(XQKeyCaptureKeyList list, 
       
   238             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   239             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   240     
       
   241     bool captureKey(XQKeyCaptureNativeKeyList list, 
       
   242             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   243             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   244     
       
   245     bool captureLongKey(XQKeyCaptureKeyList list, 
       
   246             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   247             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   248             XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   249     
       
   250     bool captureLongKey(XQKeyCaptureNativeKeyList list, 
       
   251             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   252             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   253             XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   254     
       
   255     bool captureKeyUpAndDowns(XQKeyCaptureKeyList list, 
       
   256             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   257             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   258     
       
   259     bool captureKeyUpAndDowns(XQKeyCaptureNativeKeyList list, 
       
   260             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   261             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   262 		
       
   263     bool cancelCaptureKey(Qt::Key aKey,
       
   264         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   265         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   266 
       
   267     bool cancelCaptureKey(TUint aKey,
       
   268         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   269         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   270 
       
   271     bool cancelCaptureLongKey(Qt::Key aKey,
       
   272         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   273         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   274         XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   275 
       
   276     bool cancelCaptureLongKey(TUint aKey,
       
   277         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   278         Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   279         XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   280 
       
   281     bool cancelCaptureKeyUpAndDowns(Qt::Key aKey,
       
   282         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   283         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   284 
       
   285     bool cancelCaptureKeyUpAndDowns(TUint aKey,
       
   286         Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   287         Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   288     
       
   289     bool cancelCaptureKey(XQKeyCaptureKeyList list, 
       
   290             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   291             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   292     
       
   293     bool cancelCaptureKey(XQKeyCaptureNativeKeyList list, 
       
   294             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   295             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   296     
       
   297     bool cancelCaptureLongKey(XQKeyCaptureKeyList list, 
       
   298             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   299             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   300             XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   301     
       
   302     bool cancelCaptureLongKey(XQKeyCaptureNativeKeyList list, 
       
   303             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   304             Qt::KeyboardModifiers aModifier = Qt::NoModifier,
       
   305             XqKeyCapture::LongFlags aLongType = XqKeyCapture::LongNormal);
       
   306     
       
   307     bool cancelCaptureKeyUpAndDowns(XQKeyCaptureKeyList list, 
       
   308             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   309             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   310     
       
   311     bool cancelCaptureKeyUpAndDowns(XQKeyCaptureNativeKeyList list, 
       
   312             Qt::KeyboardModifiers aModifiersMask = Qt::NoModifier,
       
   313             Qt::KeyboardModifiers aModifier = Qt::NoModifier);
       
   314 
       
   315     QString errorString() const;
       
   316 
       
   317     int errorId() const;
       
   318 
       
   319 private:
       
   320     KeyCapturePrivate* d;
       
   321 
       
   322 };
       
   323 
       
   324 Q_DECLARE_OPERATORS_FOR_FLAGS(XQKeyCapture::CapturingFlags)
       
   325 
       
   326 #endif /* XQKEYCAPTURE_H */