From 43016b923e18dff40c53a116316110f2fe5c4820 Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Sat, 6 Nov 2010 03:06:24 +0100 Subject: [PATCH] Observe volume keys on Symbian. Add minimal documentation to headers. --- bookview.cpp | 2 +- dorian.pro | 353 +++++++++++++++++++++-------------------- main.cpp | 7 + mainwindow.cpp | 7 + searchdialog.h | 1 + searchresultinfodialog.h | 1 + searchresultsdialog.h | 1 + settingswindow.cpp | 4 +- widgets/adopterwindow.cpp | 31 +++- widgets/adopterwindow.h | 17 +- widgets/fullscreenwindow.h | 2 + widgets/mediakeysobserver.cpp | 152 ++++++++++++++++++ widgets/mediakeysobserver.h | 86 ++++++++++ widgets/progress.h | 2 + widgets/progressdialog.h | 8 +- widgets/translucentbutton.h | 3 +- 16 files changed, 489 insertions(+), 188 deletions(-) create mode 100755 widgets/mediakeysobserver.cpp create mode 100755 widgets/mediakeysobserver.h diff --git a/bookview.cpp b/bookview.cpp index 45bdd2a..4f78291 100644 --- a/bookview.cpp +++ b/bookview.cpp @@ -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: diff --git a/dorian.pro b/dorian.pro index 7c4f1eb..53529b7 100644 --- a/dorian.pro +++ b/dorian.pro @@ -1,174 +1,179 @@ -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 + +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 = UserEnvironment NetworkServices ReadUserData WriteUserData SwEvent + 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 \ + widgets/mediakeysobserver.h + SOURCES += \ + widgets/flickcharm.cpp \ + widgets/mediakeysobserver.cpp + LIBS += -lremconinterfacebase -lremconcoreapi +} + +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 +} diff --git a/main.cpp b/main.cpp index 5977925..306ea83 100644 --- 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) { diff --git a/mainwindow.cpp b/mainwindow.cpp index 31c952c..37b66eb 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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 diff --git a/searchdialog.h b/searchdialog.h index d75368c..8b15e7a 100644 --- a/searchdialog.h +++ b/searchdialog.h @@ -8,6 +8,7 @@ class QLineEdit; +/** Request author and title for searching books. */ class SearchDialog: public Dyalog { Q_OBJECT diff --git a/searchresultinfodialog.h b/searchresultinfodialog.h index e5e84f7..ed611da 100644 --- a/searchresultinfodialog.h +++ b/searchresultinfodialog.h @@ -4,6 +4,7 @@ #include "dyalog.h" #include "search.h" +/** Details of a single search result. */ class SearchResultInfoDialog: public Dyalog { Q_OBJECT diff --git a/searchresultsdialog.h b/searchresultsdialog.h index bf8a389..29427bf 100644 --- a/searchresultsdialog.h +++ b/searchresultsdialog.h @@ -11,6 +11,7 @@ class ListView; class QModelIndex; class ProgressDialog; +/** Search result list. */ class SearchResultsDialog: public ListWindow { Q_OBJECT diff --git a/settingswindow.cpp b/settingswindow.cpp index 7b8c91e..1bf3b8d 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -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 &)), diff --git a/widgets/adopterwindow.cpp b/widgets/adopterwindow.cpp index fc20cdb..fa8c640 100644 --- a/widgets/adopterwindow.cpp +++ b/widgets/adopterwindow.cpp @@ -1,10 +1,12 @@ #include -#ifdef Q_WS_MAEMO_5 +#if defined(Q_WS_MAEMO_5) # include # include # include -#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 diff --git a/widgets/adopterwindow.h b/widgets/adopterwindow.h index ba486b1..f09a05b 100644 --- a/widgets/adopterwindow.h +++ b/widgets/adopterwindow.h @@ -4,6 +4,10 @@ #include #include +#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 &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); diff --git a/widgets/fullscreenwindow.h b/widgets/fullscreenwindow.h index 9717c2c..601269b 100644 --- a/widgets/fullscreenwindow.h +++ b/widgets/fullscreenwindow.h @@ -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 index 0000000..64665ac --- /dev/null +++ b/widgets/mediakeysobserver.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mediakeysobserver.h" +#include "trace.h" + +static MediaKeysObserver *theInstance; + +MediaKeysObserver *MediaKeysObserver::instance() +{ + if (!theInstance) { + theInstance = new MediaKeysObserver(); + } + return theInstance; +} + +void MediaKeysObserver::close() +{ + delete theInstance; + theInstance = 0; +} + +MediaKeysObserver::MediaKeysObserver(QObject *parent) : QObject(parent) +{ + TRACE; + iInterfaceSelector = CRemConInterfaceSelector::NewL(); + iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this); + iInterfaceSelector->OpenTargetL(); +} + +MediaKeysObserver::~MediaKeysObserver() +{ + TRACE; + delete iInterfaceSelector; +} + +void MediaKeysObserver::MrccatoCommand(TRemConCoreApiOperationId aOperationId, + TRemConCoreApiButtonAction aButtonAct) +{ + TRACE; + TRequestStatus status; + switch(aOperationId) + { + case ERemConCoreApiPausePlayFunction: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EPlayPauseKey); + + //Send the response back to Remcon server + iCoreTarget->PausePlayFunctionResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + + case ERemConCoreApiStop: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EStopKey); + iCoreTarget->StopResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + case ERemConCoreApiRewind: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EFastRewindKey); + iCoreTarget->RewindResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + case ERemConCoreApiForward: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EForwardKey); + iCoreTarget->ForwardResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + case ERemConCoreApiVolumeUp: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EVolIncKey); + iCoreTarget->VolumeUpResponse(status, KErrNone); + User::WaitForRequest(status); + + break; + } + case ERemConCoreApiVolumeDown: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EVolDecKey); + iCoreTarget->VolumeDownResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + case ERemConCoreApiFastForward: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EFastForwardKey); + iCoreTarget->FastForwardResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + case ERemConCoreApiBackward: + { + if (aButtonAct == ERemConCoreApiButtonClick) + emit mediaKeyPressed(MediaKeysObserver::EBackwardKey); + iCoreTarget->BackwardResponse(status, KErrNone); + User::WaitForRequest(status); + break; + } + default: + break; + } +} diff --git a/widgets/mediakeysobserver.h b/widgets/mediakeysobserver.h new file mode 100755 index 0000000..178b970 --- /dev/null +++ b/widgets/mediakeysobserver.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MEDIAKEYSOBSERVER_H_ +#define MEDIAKEYSOBSERVER_H_ + +#include +#include +#include +#include +#include + +class MediaKeysObserver : public QObject, public MRemConCoreApiTargetObserver +{ + Q_OBJECT + +public: + enum MediaKeys { + EVolIncKey, + EVolDecKey, + EPlayPauseKey, + EStopKey, + EBackwardKey, + EForwardKey, + EFastForwardKey, + EFastRewindKey + }; + + static MediaKeysObserver *instance(); + static void close(); + +protected: + MediaKeysObserver(QObject *parent = 0); + virtual ~MediaKeysObserver(); + void MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct); + void MrccatoPlay(TRemConCoreApiPlaybackSpeed /*aSpeed*/, TRemConCoreApiButtonAction /*aButtonAct*/) {} + void MrccatoTuneFunction(TBool /*aTwoPart*/, TUint /*aMajorChannel*/, TUint /*aMinorChannel*/, TRemConCoreApiButtonAction /*aButtonAct*/) {} + void MrccatoSelectDiskFunction(TUint /*aDisk*/, TRemConCoreApiButtonAction /*aButtonAct*/) {} + void MrccatoSelectAvInputFunction(TUint8 /*aAvInputSignalNumber*/, TRemConCoreApiButtonAction /*aButtonAct*/) {} + void MrccatoSelectAudioInputFunction(TUint8 /*aAudioInputSignalNumber*/, TRemConCoreApiButtonAction /*aButtonAct*/) {} + +Q_SIGNALS: + void mediaKeyPressed(MediaKeysObserver::MediaKeys key); + +private: + CRemConInterfaceSelector* iInterfaceSelector; + CRemConCoreApiTarget* iCoreTarget; +}; +#endif diff --git a/widgets/progress.h b/widgets/progress.h index 92b60ac..630bc4f 100644 --- a/widgets/progress.h +++ b/widgets/progress.h @@ -21,6 +21,8 @@ public slots: protected: void paintEvent(QPaintEvent *e); void timerEvent(QTimerEvent *e); + +private: qreal progress; int timer; }; diff --git a/widgets/progressdialog.h b/widgets/progressdialog.h index 23a0df1..6303468 100644 --- a/widgets/progressdialog.h +++ b/widgets/progressdialog.h @@ -4,18 +4,16 @@ #include #include +/** 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 diff --git a/widgets/translucentbutton.h b/widgets/translucentbutton.h index d96050b..e1a1ca6 100644 --- a/widgets/translucentbutton.h +++ b/widgets/translucentbutton.h @@ -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 { -- 1.7.9.5