Observe volume keys on Symbian. Add minimal documentation to headers.
authorAkos Polster <akos@pipacs.com>
Sat, 6 Nov 2010 02:06:24 +0000 (03:06 +0100)
committerAkos Polster <akos@pipacs.com>
Sat, 6 Nov 2010 02:06:24 +0000 (03:06 +0100)
16 files changed:
bookview.cpp
dorian.pro
main.cpp
mainwindow.cpp
searchdialog.h
searchresultinfodialog.h
searchresultsdialog.h
settingswindow.cpp
widgets/adopterwindow.cpp
widgets/adopterwindow.h
widgets/fullscreenwindow.h
widgets/mediakeysobserver.cpp [new file with mode: 0755]
widgets/mediakeysobserver.h [new file with mode: 0755]
widgets/progress.h
widgets/progressdialog.h
widgets/translucentbutton.h

index 45bdd2a..4f78291 100644 (file)
@@ -444,7 +444,7 @@ void BookView::timerEvent(QTimerEvent *e)
     QWebView::timerEvent(e);
 }
 
-void BookView::keyPressEvent(QKeyEvent* event)
+void BookView::keyPressEvent(QKeyEvent *event)
 {
     switch (event->key()) {
     case Qt::Key_F7:
index 7c4f1eb..53529b7 100644 (file)
-QT += webkit xml sql network
-
-INCLUDEPATH += $$PWD \
-    $$PWD/model \
-    $$PWD/widgets
-
-SOURCES += \
-    main.cpp \
-    mainwindow.cpp \
-    bookview.cpp \
-    model/unzip/unzip.c \
-    model/unzip/ioapi.c \
-    model/extractzip.cpp \
-    model/library.cpp \
-    model/book.cpp \
-    librarydialog.cpp \
-    devtools.cpp \
-    infodialog.cpp \
-    widgets/translucentbutton.cpp \
-    settingswindow.cpp \
-    model/settings.cpp \
-    bookmarksdialog.cpp \
-    model/sortedlibrary.cpp \
-    bookmarkinfodialog.cpp \
-    widgets/dyalog.cpp \
-    chaptersdialog.cpp \
-    widgets/fullscreenwindow.cpp \
-    trace.cpp \
-    widgets/toolbuttonbox.cpp \
-    model/bookfinder.cpp \
-    widgets/listwindow.cpp \
-    widgets/progress.cpp \
-    widgets/adopterwindow.cpp \
-    platform.cpp \
-    model/bookdb.cpp \
-    searchdialog.cpp \
-    search.cpp \
-    widgets/flickable.cpp \
-    widgets/listview.cpp \
-    searchresultsdialog.cpp \
-    searchresultinfodialog.cpp \
-    widgets/progressdialog.cpp
-
-HEADERS += \
-    mainwindow.h \
-    bookview.h \
-    model/opshandler.h \
-    model/unzip/unzip.h \
-    model/unzip/ioapi.h \
-    model/extractzip.h \
-    model/library.h \
-    model/book.h \
-    librarydialog.h \
-    devtools.h \
-    infodialog.h \
-    widgets/translucentbutton.h \
-    settingswindow.h \
-    model/settings.h \
-    bookmarksdialog.h \
-    model/xmlerrorhandler.h \
-    model/containerhandler.h \
-    model/sortedlibrary.h \
-    model/ncxhandler.h \
-    bookmarkinfodialog.h \
-    widgets/dyalog.h \
-    chaptersdialog.h \
-    widgets/fullscreenwindow.h \
-    trace.h \
-    widgets/toolbuttonbox.h \
-    model/bookfinder.h \
-    widgets/listwindow.h \
-    widgets/progress.h \
-    widgets/adopterwindow.h \
-    widgets/listview.h \
-    model/xmlhandler.h \
-    platform.h \
-    model/bookdb.h \
-    searchdialog.h \
-    search.h \
-    widgets/flickable.h \
-    searchresultsdialog.h \
-    searchresultinfodialog.h \
-    widgets/progressdialog.h
-
-RESOURCES += \
-    dorian.qrc
-
-OTHER_FILES += \
-    TODO.txt \
-    pkg/acknowledgements.txt \
-    pkg/maemo/postinst \
-    pkg/maemo/dorian.desktop \
-    pkg/maemo/control \
-    pkg/maemo/changelog \
-    pkg/maemo/build.sh \
-    styles/night.css \
-    pkg/changelog \
-    pkg/maemo/build-scratchbox.sh \
-    styles/sand.css \
-    styles/default.css \
-    pkg/version.txt \
-    styles/sand.js \
-    styles/night.js \
-    styles/default.js \
-    styles/day.js \
-    www/index.html \
-    pkg/maemo/autobuild.sh \
-    pkg/maemo/autobuild-scratchbox.sh \
-    LICENSE.txt \
-    pkg/symbian/book.svg
-
-DEFINES += \
-    USE_FILE32API
-
-!symbian {
-    DEFINES += DORIAN_TEST_MODEL
-    include(model/modeltest/modeltest.pri)
-}
-
-unix {
-    symbian {
-    } else {
-        LIBS += -lz
-    }
-}
-
-win32 {
-    DEFINES += ZLIB_WINAPI
-    INCLUDEPATH += $$PWD/model/zlib
-    LIBS += pkg/win32/zlibstat.lib
-}
-
-symbian {
-    TARGET = Dorian
-    TARGET.UID3 = 0xEA633557
-    TARGET.CAPABILITY = NetworkServices ReadUserData WriteUserData
-    TARGET.EPOCHEAPSIZE = 0x080000 0x4000000
-    ICON = $$PWD/pkg/symbian/book.svg
-    packageheader = "$${LITERAL_HASH}{\"Dorian\"}, (0xEA633557), 0, 3, 4"
-    vendorinfo = \
-        "%{\"Nokia Betalabs \"}" \
-        ":\"Nokia Betalabs \""
-    my_deployment.pkg_prerules = packageheader vendorinfo
-    DEPLOYMENT += my_deployment
-
-    INCLUDEPATH += $(QTDIR)/src/3rdparty/zlib
-    HEADERS += widgets/flickcharm.h
-    SOURCES += widgets/flickcharm.cpp
-}
-
-maemo5 {
-    QT += maemo5 dbus
-    isEmpty(PREFIX) {
-        PREFIX = /usr
-    }
-    BINDIR = $$PREFIX/bin
-    DATADIR =$$PREFIX/share
-    DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
-
-    # For "make install"
-
-    INSTALLS += target desktop icon48 iconscalable
-
-    target.path = $$BINDIR
-
-    desktop.path = $$DATADIR/applications/hildon
-    desktop.files += pkg/maemo/dorian.desktop
-
-    icon48.path = $$DATADIR/icons/hicolor/48x48/hildon
-    icon48.files += pkg/maemo/icon-48/dorian.png
-
-    iconscalable.path = $$DATADIR/icons/hicolor/scalable/hildon
-    iconscalable.files += pkg/maemo/icon-scalable/dorian.png
-}
+QT += webkit xml sql network\r
+\r
+INCLUDEPATH += $$PWD \\r
+    $$PWD/model \\r
+    $$PWD/widgets\r
+\r
+SOURCES += \\r
+    main.cpp \\r
+    mainwindow.cpp \\r
+    bookview.cpp \\r
+    model/unzip/unzip.c \\r
+    model/unzip/ioapi.c \\r
+    model/extractzip.cpp \\r
+    model/library.cpp \\r
+    model/book.cpp \\r
+    librarydialog.cpp \\r
+    devtools.cpp \\r
+    infodialog.cpp \\r
+    widgets/translucentbutton.cpp \\r
+    settingswindow.cpp \\r
+    model/settings.cpp \\r
+    bookmarksdialog.cpp \\r
+    model/sortedlibrary.cpp \\r
+    bookmarkinfodialog.cpp \\r
+    widgets/dyalog.cpp \\r
+    chaptersdialog.cpp \\r
+    widgets/fullscreenwindow.cpp \\r
+    trace.cpp \\r
+    widgets/toolbuttonbox.cpp \\r
+    model/bookfinder.cpp \\r
+    widgets/listwindow.cpp \\r
+    widgets/progress.cpp \\r
+    widgets/adopterwindow.cpp \\r
+    platform.cpp \\r
+    model/bookdb.cpp \\r
+    searchdialog.cpp \\r
+    search.cpp \\r
+    widgets/flickable.cpp \\r
+    widgets/listview.cpp \\r
+    searchresultsdialog.cpp \\r
+    searchresultinfodialog.cpp \\r
+    widgets/progressdialog.cpp\r
+\r
+HEADERS += \\r
+    mainwindow.h \\r
+    bookview.h \\r
+    model/opshandler.h \\r
+    model/unzip/unzip.h \\r
+    model/unzip/ioapi.h \\r
+    model/extractzip.h \\r
+    model/library.h \\r
+    model/book.h \\r
+    librarydialog.h \\r
+    devtools.h \\r
+    infodialog.h \\r
+    widgets/translucentbutton.h \\r
+    settingswindow.h \\r
+    model/settings.h \\r
+    bookmarksdialog.h \\r
+    model/xmlerrorhandler.h \\r
+    model/containerhandler.h \\r
+    model/sortedlibrary.h \\r
+    model/ncxhandler.h \\r
+    bookmarkinfodialog.h \\r
+    widgets/dyalog.h \\r
+    chaptersdialog.h \\r
+    widgets/fullscreenwindow.h \\r
+    trace.h \\r
+    widgets/toolbuttonbox.h \\r
+    model/bookfinder.h \\r
+    widgets/listwindow.h \\r
+    widgets/progress.h \\r
+    widgets/adopterwindow.h \\r
+    widgets/listview.h \\r
+    model/xmlhandler.h \\r
+    platform.h \\r
+    model/bookdb.h \\r
+    searchdialog.h \\r
+    search.h \\r
+    widgets/flickable.h \\r
+    searchresultsdialog.h \\r
+    searchresultinfodialog.h \\r
+    widgets/progressdialog.h\r
+\r
+RESOURCES += \\r
+    dorian.qrc\r
+\r
+OTHER_FILES += \\r
+    TODO.txt \\r
+    pkg/acknowledgements.txt \\r
+    pkg/maemo/postinst \\r
+    pkg/maemo/dorian.desktop \\r
+    pkg/maemo/control \\r
+    pkg/maemo/changelog \\r
+    pkg/maemo/build.sh \\r
+    styles/night.css \\r
+    pkg/changelog \\r
+    pkg/maemo/build-scratchbox.sh \\r
+    styles/sand.css \\r
+    styles/default.css \\r
+    pkg/version.txt \\r
+    styles/sand.js \\r
+    styles/night.js \\r
+    styles/default.js \\r
+    styles/day.js \\r
+    www/index.html \\r
+    pkg/maemo/autobuild.sh \\r
+    pkg/maemo/autobuild-scratchbox.sh \\r
+    LICENSE.txt \\r
+    pkg/symbian/book.svg\r
+\r
+DEFINES += \\r
+    USE_FILE32API\r
+\r
+!symbian {\r
+    DEFINES += DORIAN_TEST_MODEL\r
+    include(model/modeltest/modeltest.pri)\r
+}\r
+\r
+unix {\r
+    symbian {\r
+    } else {\r
+        LIBS += -lz\r
+    }\r
+}\r
+\r
+win32 {\r
+    DEFINES += ZLIB_WINAPI\r
+    INCLUDEPATH += $$PWD/model/zlib\r
+    LIBS += pkg/win32/zlibstat.lib\r
+}\r
+\r
+symbian {\r
+    TARGET = Dorian\r
+    TARGET.UID3 = 0xEA633557\r
+    TARGET.CAPABILITY = UserEnvironment NetworkServices ReadUserData WriteUserData SwEvent\r
+    TARGET.EPOCHEAPSIZE = 0x080000 0x4000000\r
+    ICON = $$PWD/pkg/symbian/book.svg\r
+    packageheader = "$${LITERAL_HASH}{\"Dorian\"}, (0xEA633557), 0, 3, 4"\r
+    vendorinfo = \\r
+        "%{\"Nokia Betalabs \"}" \\r
+        ":\"Nokia Betalabs \""\r
+    my_deployment.pkg_prerules = packageheader vendorinfo\r
+    DEPLOYMENT += my_deployment\r
+\r
+    INCLUDEPATH += $(QTDIR)/src/3rdparty/zlib\r
+    HEADERS += \\r
+        widgets/flickcharm.h \\r
+        widgets/mediakeysobserver.h\r
+    SOURCES += \\r
+        widgets/flickcharm.cpp \\r
+        widgets/mediakeysobserver.cpp\r
+    LIBS += -lremconinterfacebase -lremconcoreapi\r
+}\r
+\r
+maemo5 {\r
+    QT += maemo5 dbus\r
+    isEmpty(PREFIX) {\r
+        PREFIX = /usr\r
+    }\r
+    BINDIR = $$PREFIX/bin\r
+    DATADIR =$$PREFIX/share\r
+    DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"\r
+\r
+    # For "make install"\r
+\r
+    INSTALLS += target desktop icon48 iconscalable\r
+\r
+    target.path = $$BINDIR\r
+\r
+    desktop.path = $$DATADIR/applications/hildon\r
+    desktop.files += pkg/maemo/dorian.desktop\r
+\r
+    icon48.path = $$DATADIR/icons/hicolor/48x48/hildon\r
+    icon48.files += pkg/maemo/icon-48/dorian.png\r
+\r
+    iconscalable.path = $$DATADIR/icons/hicolor/scalable/hildon\r
+    iconscalable.files += pkg/maemo/icon-scalable/dorian.png\r
+}\r
index 5977925..306ea83 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -9,6 +9,10 @@
 #include "search.h"
 #include "platform.h"
 
+#ifdef Q_OS_SYMBIAN
+#   include "mediakeysobserver.h"
+#endif
+
 static const char *DORIAN_VERSION =
 #include "pkg/version.txt"
 ;
@@ -46,6 +50,9 @@ int main(int argc, char *argv[])
     BookDb::close();
     Settings::close();
     Search::close();
+#ifdef Q_OS_SYMBIAN
+    MediaKeysObserver::close();
+#endif
 
     // Re-start application if event loop exit code was 1000
     if (ret == 1000) {
index 31c952c..37b66eb 100755 (executable)
@@ -340,6 +340,13 @@ void MainWindow::onSettingsChanged(const QString &key)
         grabZoomKeys(value);
         fullScreenWindow->grabZoomKeys(value);
     }
+#elif defined Q_OS_SYMBIAN
+    if (key == "usevolumekeys") {
+        bool value = Settings::instance()->value(key).toBool();
+        qDebug() << "MainWindow::onSettingsChanged: usevolumekeys" << value;
+        grabZoomKeys(value);
+        fullScreenWindow->grabZoomKeys(value);
+    }
 #else
     Q_UNUSED(key);
 #endif // Q_WS_MAEMO_5
index d75368c..8b15e7a 100644 (file)
@@ -8,6 +8,7 @@
 
 class QLineEdit;
 
+/** Request author and title for searching books. */
 class SearchDialog: public Dyalog
 {
     Q_OBJECT
index e5e84f7..ed611da 100644 (file)
@@ -4,6 +4,7 @@
 #include "dyalog.h"
 #include "search.h"
 
+/** Details of a single search result. */
 class SearchResultInfoDialog: public Dyalog
 {
     Q_OBJECT
index bf8a389..29427bf 100644 (file)
@@ -11,6 +11,7 @@ class ListView;
 class QModelIndex;
 class ProgressDialog;
 
+/** Search result list. */
 class SearchResultsDialog: public ListWindow
 {
     Q_OBJECT
index 7b8c91e..1bf3b8d 100644 (file)
@@ -52,12 +52,10 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
     backlight->setChecked(settings->value("lightson", false).toBool());
 #endif
 
-#ifndef Q_OS_SYMBIAN
     QCheckBox *grabVolume =
             new QCheckBox(tr("Navigate with volume keys"), contents);
     layout->addWidget(grabVolume);
     grabVolume->setChecked(settings->value("usevolumekeys", false).toBool());
-#endif
 
     int zoom = Settings::instance()->value("zoom").toInt();
     if (zoom < ZOOM_MIN) {
@@ -135,9 +133,9 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
 #ifndef Q_OS_SYMBIAN
     connect(backlight, SIGNAL(toggled(bool)),
             this, SLOT(onLightsToggled(bool)));
+#endif
     connect(grabVolume, SIGNAL(toggled(bool)),
             this, SLOT(onGrabVolumeToggled(bool)));
-#endif
     connect(zoomSlider, SIGNAL(valueChanged(int)),
             this, SLOT(onSliderValueChanged(int)));
     connect(fontButton, SIGNAL(currentFontChanged(const QFont &)),
index fc20cdb..fa8c640 100644 (file)
@@ -1,10 +1,12 @@
 #include <QtGui>
 
-#ifdef Q_WS_MAEMO_5
+#if defined(Q_WS_MAEMO_5)
 #   include <QtGui/QX11Info>
 #   include <X11/Xlib.h>
 #   include <X11/Xatom.h>
-#endif // Q_WS_MAEMO_5
+#elif defined(Q_OS_SYMBIAN)
+#   include "mediakeysobserver.h"
+#endif
 
 #include "trace.h"
 #include "adopterwindow.h"
@@ -30,6 +32,9 @@ AdopterWindow::AdopterWindow(QWidget *parent):
     closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
     QMainWindow::addAction(closeAction);
+    MediaKeysObserver *observer = MediaKeysObserver::instance();
+    connect(observer, SIGNAL(mediaKeyPressed(MediaKeysObserver::MediaKeys)),
+            this, SLOT(onMediaKeysPressed(MediaKeysObserver::MediaKeys)));
 #else
     // Tool bar
     setUnifiedTitleAndToolBarOnMac(true);
@@ -153,3 +158,25 @@ void AdopterWindow::addToolBarSpace()
     toolBar->addWidget(frame);
 #endif
 }
+
+#ifdef Q_OS_SYMBIAN
+
+void AdopterWindow::onMediaKeysPressed(MediaKeysObserver::MediaKeys key)
+{
+    qDebug() << "AdopterWindow::onMediaKeysPressed:" << (int)key;
+
+    if ((key != MediaKeysObserver::EVolIncKey) &&
+        (key != MediaKeysObserver::EVolDecKey)) {
+        return;
+    }
+
+    if (grabbingZoomKeys) {
+        qDebug() << "Posting"
+                << ((key == MediaKeysObserver::EVolIncKey)? "Key_F7": "Key_F8");
+        QKeyEvent *event = new QKeyEvent(QEvent::KeyPress,
+            (key == MediaKeysObserver::EVolIncKey)? Qt::Key_F7: Qt::Key_F8, 0);
+        QCoreApplication::sendEvent(this, event);
+    }
+}
+
+#endif // Q_OS_SYMBIAN
index ba486b1..f09a05b 100644 (file)
@@ -4,6 +4,10 @@
 #include <QMainWindow>
 #include <QList>
 
+#ifdef Q_OS_SYMBIAN
+#   include "mediakeysobserver.h"
+#endif
+
 class QWidget;
 class QToolBar;
 class QAction;
@@ -17,13 +21,19 @@ class AdopterWindow: public QMainWindow
     Q_OBJECT
 public:
     explicit AdopterWindow(QWidget *parent = 0);
+
+    /* If true, zoom (volume) keys will generate Key_F7 and Key_F8 events. */
     void grabZoomKeys(bool grab);
+
+    /** Adopt children "main" and "others". */
     void takeChildren(QWidget *main, const QList<QWidget *> &others);
+
+    /** Release current children (adopted in @see takeChildren). */
     void leaveChildren();
 
     /**
      * Add action that is visible on the tool bar (except on Symbian, where
-     * it is visible on the Options menu.
+     * it is visible on the Options menu).
      */
     QAction *addToolBarAction(QObject *receiver, const char *slot,
                               const QString &iconName, const QString &text);
@@ -36,7 +46,10 @@ public:
 
 signals:
 
-public slots:
+protected slots:
+#ifdef Q_OS_SYMBIAN
+    void onMediaKeysPressed(MediaKeysObserver::MediaKeys key);
+#endif
 
 protected:
     void showEvent(QShowEvent *e);
index 9717c2c..601269b 100644 (file)
@@ -26,6 +26,8 @@ signals:
 
 protected:
     void resizeEvent(QResizeEvent *e);
+
+private:
     TranslucentButton *restoreButton;
 };
 
diff --git a/widgets/mediakeysobserver.cpp b/widgets/mediakeysobserver.cpp
new file mode 100755 (executable)
index 0000000..64665ac
--- /dev/null
@@ -0,0 +1,152 @@
+/****************************************************************************\r
+**\r
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\r
+** All rights reserved.\r
+** Contact: Nokia Corporation (qt-info@nokia.com)\r
+**\r
+** This file is part of the Qt Mobility Components.\r
+**\r
+** $QT_BEGIN_LICENSE:BSD$\r
+** You may use this file under the terms of the BSD license as follows:\r
+**\r
+** "Redistribution and use in source and binary forms, with or without\r
+** modification, are permitted provided that the following conditions are\r
+** met:\r
+**   * Redistributions of source code must retain the above copyright\r
+**     notice, this list of conditions and the following disclaimer.\r
+**   * Redistributions in binary form must reproduce the above copyright\r
+**     notice, this list of conditions and the following disclaimer in\r
+**     the documentation and/or other materials provided with the\r
+**     distribution.\r
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor\r
+**     the names of its contributors may be used to endorse or promote\r
+**     products derived from this software without specific prior written\r
+**     permission.\r
+**\r
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."\r
+** $QT_END_LICENSE$\r
+**\r
+****************************************************************************/\r
+\r
+#include "mediakeysobserver.h"\r
+#include "trace.h"\r
+\r
+static MediaKeysObserver *theInstance;\r
+\r
+MediaKeysObserver *MediaKeysObserver::instance()\r
+{\r
+    if (!theInstance) {\r
+        theInstance = new MediaKeysObserver();\r
+    }\r
+    return theInstance;\r
+}\r
+\r
+void MediaKeysObserver::close()\r
+{\r
+    delete theInstance;\r
+    theInstance = 0;\r
+}\r
+\r
+MediaKeysObserver::MediaKeysObserver(QObject *parent) : QObject(parent)\r
+{\r
+    TRACE;\r
+    iInterfaceSelector = CRemConInterfaceSelector::NewL();\r
+    iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this);\r
+    iInterfaceSelector->OpenTargetL();\r
+}\r
+\r
+MediaKeysObserver::~MediaKeysObserver()\r
+{\r
+    TRACE;\r
+    delete iInterfaceSelector;\r
+}\r
+\r
+void MediaKeysObserver::MrccatoCommand(TRemConCoreApiOperationId aOperationId,\r
+                                       TRemConCoreApiButtonAction aButtonAct)\r
+{\r
+    TRACE;\r
+    TRequestStatus status;\r
+    switch(aOperationId)\r
+    {\r
+    case ERemConCoreApiPausePlayFunction:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EPlayPauseKey);\r
+\r
+            //Send the response back to Remcon server\r
+            iCoreTarget->PausePlayFunctionResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+\r
+    case ERemConCoreApiStop:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EStopKey);\r
+            iCoreTarget->StopResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+    case ERemConCoreApiRewind:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EFastRewindKey);\r
+            iCoreTarget->RewindResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+    case ERemConCoreApiForward:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EForwardKey);\r
+            iCoreTarget->ForwardResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+    case ERemConCoreApiVolumeUp:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EVolIncKey);\r
+            iCoreTarget->VolumeUpResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+\r
+            break;\r
+        }\r
+    case ERemConCoreApiVolumeDown:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EVolDecKey);\r
+            iCoreTarget->VolumeDownResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+    case ERemConCoreApiFastForward:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EFastForwardKey);\r
+            iCoreTarget->FastForwardResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+    case ERemConCoreApiBackward:\r
+        {\r
+            if (aButtonAct == ERemConCoreApiButtonClick)\r
+                emit mediaKeyPressed(MediaKeysObserver::EBackwardKey);\r
+            iCoreTarget->BackwardResponse(status, KErrNone);\r
+            User::WaitForRequest(status);\r
+            break;\r
+        }\r
+    default:\r
+        break;\r
+    }\r
+}\r
diff --git a/widgets/mediakeysobserver.h b/widgets/mediakeysobserver.h
new file mode 100755 (executable)
index 0000000..178b970
--- /dev/null
@@ -0,0 +1,86 @@
+/****************************************************************************\r
+**\r
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\r
+** All rights reserved.\r
+** Contact: Nokia Corporation (qt-info@nokia.com)\r
+**\r
+** This file is part of the Qt Mobility Components.\r
+**\r
+** $QT_BEGIN_LICENSE:BSD$\r
+** You may use this file under the terms of the BSD license as follows:\r
+**\r
+** "Redistribution and use in source and binary forms, with or without\r
+** modification, are permitted provided that the following conditions are\r
+** met:\r
+**   * Redistributions of source code must retain the above copyright\r
+**     notice, this list of conditions and the following disclaimer.\r
+**   * Redistributions in binary form must reproduce the above copyright\r
+**     notice, this list of conditions and the following disclaimer in\r
+**     the documentation and/or other materials provided with the\r
+**     distribution.\r
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor\r
+**     the names of its contributors may be used to endorse or promote\r
+**     products derived from this software without specific prior written\r
+**     permission.\r
+**\r
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."\r
+** $QT_END_LICENSE$\r
+**\r
+****************************************************************************/\r
+\r
+#ifndef MEDIAKEYSOBSERVER_H_\r
+#define MEDIAKEYSOBSERVER_H_\r
+\r
+#include <remconcoreapitargetobserver.h>\r
+#include <remconcoreapitarget.h>\r
+#include <remconinterfaceselector.h>\r
+#include <aknappui.h>\r
+#include <QObject>\r
+\r
+class MediaKeysObserver : public QObject, public MRemConCoreApiTargetObserver\r
+{\r
+    Q_OBJECT\r
+\r
+public:\r
+    enum MediaKeys {\r
+        EVolIncKey,\r
+        EVolDecKey,\r
+        EPlayPauseKey,\r
+        EStopKey,\r
+        EBackwardKey,\r
+        EForwardKey,\r
+        EFastForwardKey,\r
+        EFastRewindKey\r
+    };\r
+\r
+    static MediaKeysObserver *instance();\r
+    static void close();\r
+\r
+protected:\r
+    MediaKeysObserver(QObject *parent = 0);\r
+    virtual ~MediaKeysObserver();\r
+    void MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct);\r
+    void MrccatoPlay(TRemConCoreApiPlaybackSpeed /*aSpeed*/, TRemConCoreApiButtonAction /*aButtonAct*/) {}\r
+    void MrccatoTuneFunction(TBool /*aTwoPart*/, TUint /*aMajorChannel*/, TUint /*aMinorChannel*/, TRemConCoreApiButtonAction /*aButtonAct*/) {}\r
+    void MrccatoSelectDiskFunction(TUint /*aDisk*/, TRemConCoreApiButtonAction /*aButtonAct*/) {}\r
+    void MrccatoSelectAvInputFunction(TUint8 /*aAvInputSignalNumber*/, TRemConCoreApiButtonAction /*aButtonAct*/) {}\r
+    void MrccatoSelectAudioInputFunction(TUint8 /*aAudioInputSignalNumber*/, TRemConCoreApiButtonAction /*aButtonAct*/) {}\r
+\r
+Q_SIGNALS:\r
+    void mediaKeyPressed(MediaKeysObserver::MediaKeys key);\r
+\r
+private:\r
+    CRemConInterfaceSelector* iInterfaceSelector;\r
+    CRemConCoreApiTarget*     iCoreTarget;\r
+};\r
+#endif\r
index 92b60ac..630bc4f 100644 (file)
@@ -21,6 +21,8 @@ public slots:
 protected:
     void paintEvent(QPaintEvent *e);
     void timerEvent(QTimerEvent *e);
+
+private:
     qreal progress;
     int timer;
 };
index 23a0df1..6303468 100644 (file)
@@ -4,18 +4,16 @@
 #include <QString>
 #include <QProgressDialog>
 
+/** Simple wrapper for QProgressDialog. */
 class ProgressDialog: public QProgressDialog
 {
     Q_OBJECT
 
 public:
     explicit ProgressDialog(const QString &label, QWidget *parent = 0);
-    void showWait();
-
-signals:
-
-public slots:
 
+    /** Show wait animation instead of progress bar. */
+    void showWait();
 };
 
 #endif // PROGRESSDIALOG_H
index d96050b..e1a1ca6 100644 (file)
@@ -10,7 +10,8 @@ class QMouseEvent;
 class QTimer;
 
 /**
- * A button that is transparent, but can temporarily made opaque by flashing it.
+ * A button that is transparent, but can temporarily be made opaque by
+ * flashing it.
  */
 class TranslucentButton: public QLabel
 {