diff options
Diffstat (limited to 'examples/widgets/maemovibration')
-rw-r--r-- | examples/widgets/maemovibration/buttonwidget.cpp | 66 | ||||
-rw-r--r-- | examples/widgets/maemovibration/buttonwidget.h | 64 | ||||
-rw-r--r-- | examples/widgets/maemovibration/data/48x48/maemovibration.png | bin | 2406 -> 0 bytes | |||
-rw-r--r-- | examples/widgets/maemovibration/data/64x64/maemovibration.png | bin | 2989 -> 0 bytes | |||
-rw-r--r-- | examples/widgets/maemovibration/data/maemovibration.desktop | 12 | ||||
-rw-r--r-- | examples/widgets/maemovibration/data/maemovibration.service | 3 | ||||
-rw-r--r-- | examples/widgets/maemovibration/maemovibration.pro | 52 | ||||
-rw-r--r-- | examples/widgets/maemovibration/main.cpp | 84 | ||||
-rw-r--r-- | examples/widgets/maemovibration/mcevibrator.cpp | 119 | ||||
-rw-r--r-- | examples/widgets/maemovibration/mcevibrator.h | 71 |
10 files changed, 0 insertions, 471 deletions
diff --git a/examples/widgets/maemovibration/buttonwidget.cpp b/examples/widgets/maemovibration/buttonwidget.cpp deleted file mode 100644 index d56d7a5160..0000000000 --- a/examples/widgets/maemovibration/buttonwidget.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $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 "buttonwidget.h" -#include <QSignalMapper> -#include <QGridLayout> -#include <QPushButton> - -//! [0] -ButtonWidget::ButtonWidget(QStringList texts, QWidget *parent) - : QWidget(parent) -{ - signalMapper = new QSignalMapper(this); - - QGridLayout *gridLayout = new QGridLayout; - for (int i = 0; i < texts.size(); ++i) { - QPushButton *button = new QPushButton(texts[i]); - connect(button, SIGNAL(clicked()), signalMapper, SLOT(map())); - signalMapper->setMapping(button, texts[i]); - gridLayout->addWidget(button, i / 2, i % 2); - } - - connect(signalMapper, SIGNAL(mapped(const QString &)), - this, SIGNAL(clicked(const QString &))); - - setLayout(gridLayout); -} -//! [0] - diff --git a/examples/widgets/maemovibration/buttonwidget.h b/examples/widgets/maemovibration/buttonwidget.h deleted file mode 100644 index 3068825212..0000000000 --- a/examples/widgets/maemovibration/buttonwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $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 BUTTONWIDGET_H -#define BUTTONWIDGET_H - -#include <QWidget> -#include <QSignalMapper> - -//! [0] -class ButtonWidget : public QWidget -{ - Q_OBJECT - -public: - ButtonWidget(QStringList texts, QWidget *parent = 0); - -signals: - void clicked(const QString &text); - -private: - QSignalMapper *signalMapper; -}; -//! [0] - -#endif // BUTTONWIDGET_H - diff --git a/examples/widgets/maemovibration/data/48x48/maemovibration.png b/examples/widgets/maemovibration/data/48x48/maemovibration.png Binary files differdeleted file mode 100644 index f32e9ced99..0000000000 --- a/examples/widgets/maemovibration/data/48x48/maemovibration.png +++ /dev/null diff --git a/examples/widgets/maemovibration/data/64x64/maemovibration.png b/examples/widgets/maemovibration/data/64x64/maemovibration.png Binary files differdeleted file mode 100644 index f09cf7c3c6..0000000000 --- a/examples/widgets/maemovibration/data/64x64/maemovibration.png +++ /dev/null diff --git a/examples/widgets/maemovibration/data/maemovibration.desktop b/examples/widgets/maemovibration/data/maemovibration.desktop deleted file mode 100644 index a88ed4e0aa..0000000000 --- a/examples/widgets/maemovibration/data/maemovibration.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Name=Maemo Vibration -Exec=/usr/bin/maemovibration -Icon=maemovibration -X-HildonDesk-ShowInToolbar=true -X-Window-Icon=maemovibration -X-Window-Icon-Dimmed=maemovibration -X-Osso-Type=application/x-executable -X-Osso-Service=com.nokia.maemovibration diff --git a/examples/widgets/maemovibration/data/maemovibration.service b/examples/widgets/maemovibration/data/maemovibration.service deleted file mode 100644 index 1fab19f35c..0000000000 --- a/examples/widgets/maemovibration/data/maemovibration.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=com.nokia.maemovibration -Exec=/usr/bin/maemovibration diff --git a/examples/widgets/maemovibration/maemovibration.pro b/examples/widgets/maemovibration/maemovibration.pro deleted file mode 100644 index 5c645dd369..0000000000 --- a/examples/widgets/maemovibration/maemovibration.pro +++ /dev/null @@ -1,52 +0,0 @@ -TARGET = maemovibration -HEADERS += buttonwidget.h mcevibrator.h -SOURCES += main.cpp buttonwidget.cpp mcevibrator.cpp - -# All generated files goes same directory -OBJECTS_DIR = build -MOC_DIR = build -UI_DIR = build -DESTDIR = build - -TEMPLATE = app -CONFIG += debug -QT=core gui - -maemo5 { - QT += dbus - CONFIG += link_pkgconfig - PKG_CONFIG += mce - INSTALLS += target - target.path = /usr/bin/ - - INSTALLS += desktop - desktop.path = /usr/share/applications/hildon - desktop.files = data/maemovibration.desktop - - INSTALLS += service - service.path = /usr/share/dbus-1/services - service.files = data/maemovibration.service - - INSTALLS += icon64 - icon64.path = /usr/share/icons/hicolor/64x64/apps - icon64.files = data/64x64/maemovibration.png - - # - # Targets for debian source and binary package creation - # - debian-src.commands = dpkg-buildpackage -S -r -us -uc -d - debian-bin.commands = dpkg-buildpackage -b -r -uc -d - debian-all.depends = debian-src debian-bin - - # - # Clean all but Makefile - # - compiler_clean.commands = -$(DEL_FILE) $(TARGET) - - QMAKE_EXTRA_TARGETS += debian-all debian-src debian-bin compiler_clean -} - -!maemo5 { - error(The Maemo Vibration Example only works for the maemo target!) -} - diff --git a/examples/widgets/maemovibration/main.cpp b/examples/widgets/maemovibration/main.cpp deleted file mode 100644 index fbac37478a..0000000000 --- a/examples/widgets/maemovibration/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $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 "buttonwidget.h" -#include "mcevibrator.h" - -#include <QtDebug> -#include <QApplication> -#include <QFile> -#include <QTextStream> -#include <QMessageBox> -#include <QTextStream> - -#include <cstdlib> - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QString path = MceVibrator::defaultMceFilePath; - - QFile file(path); - QStringList names; - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream stream(&file); - names = MceVibrator::parsePatternNames(stream); - file.close(); - } - - if (names.isEmpty()){ - qDebug() << "Could not read vibration pattern names from " << path; - a.exit(-1); - } -//! [0] - -//! [1] - ButtonWidget buttonWidget(names); - MceVibrator vibrator; - QObject::connect(&buttonWidget, SIGNAL(clicked(const QString &)), - &vibrator, SLOT(vibrate(const QString &))); - buttonWidget.show(); - - return a.exec(); -} -//! [1] - diff --git a/examples/widgets/maemovibration/mcevibrator.cpp b/examples/widgets/maemovibration/mcevibrator.cpp deleted file mode 100644 index fcae1dc5d2..0000000000 --- a/examples/widgets/maemovibration/mcevibrator.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $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 "mcevibrator.h" - -#include <QStringList> -#include <QDebug> -#include <QDBusConnection> -#include <QDBusMessage> - -#include <mce/dbus-names.h> - -const char MceVibrator::defaultMceFilePath[] = "/etc/mce/mce.ini"; - -//! [5] -static void checkError(QDBusMessage &msg) -{ - if (msg.type() == QDBusMessage::ErrorMessage) - qDebug() << msg.errorName() << msg.errorMessage(); -} -//! [5] - -//! [0] -MceVibrator::MceVibrator(QObject *parent) : - QObject(parent), - mceInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, - QDBusConnection::systemBus()) -{ - QDBusMessage reply = mceInterface.call(MCE_ENABLE_VIBRATOR); - checkError(reply); -} -//! [0] - -//! [3] -MceVibrator::~MceVibrator() -{ - deactivate(lastPatternName); - QDBusMessage reply = mceInterface.call(MCE_DISABLE_VIBRATOR); - checkError(reply); -} -//! [3] - -//! [1] -void MceVibrator::vibrate(const QString &patternName) -{ - deactivate(lastPatternName); - lastPatternName = patternName; - QDBusMessage reply = mceInterface.call(MCE_ACTIVATE_VIBRATOR_PATTERN, patternName); - checkError(reply); -} -//! [1] - -//! [2] -void MceVibrator::deactivate(const QString &patternName) -{ - if (!patternName.isNull()) { - QDBusMessage reply = mceInterface.call(MCE_DEACTIVATE_VIBRATOR_PATTERN, patternName); - checkError(reply); - } -} -//! [2] - -//! [4] -QStringList MceVibrator::parsePatternNames(QTextStream &stream) -{ - QStringList result; - QString line; - - do { - line = stream.readLine(); - if (line.startsWith(QLatin1String("VibratorPatterns="))) { - QString values = line.section('=', 1); - result = values.split(';'); - break; - } - } while (!line.isNull()); - - return result; -} -//! [4] - diff --git a/examples/widgets/maemovibration/mcevibrator.h b/examples/widgets/maemovibration/mcevibrator.h deleted file mode 100644 index fae99be035..0000000000 --- a/examples/widgets/maemovibration/mcevibrator.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $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 MCEVIBRATOR_H -#define MCEVIBRATOR_H - -#include <QObject> -#include <QTextStream> -#include <QDBusInterface> - -//! [0] -class MceVibrator : public QObject -{ - Q_OBJECT -public: - explicit MceVibrator(QObject *parent = 0); - ~MceVibrator(); - - static const char defaultMceFilePath[]; - static QStringList parsePatternNames(QTextStream &stream); - -public slots: - void vibrate(const QString &patternName); - -private: - void deactivate(const QString &patternName); - - QDBusInterface mceInterface; - QString lastPatternName; -}; -//! [0] - -#endif // MCEVIBRATOR_H - |