summaryrefslogtreecommitdiffstats
path: root/examples/widgets/maemovibration/main.cpp
blob: f81529b18554be67684393b4628b39f1cbf4a08b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

#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]