First version
[staging/HomeScreen.git] / src / inputdevicesimulator.cpp
1 /*
2  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "inputdevicesimulator.h"
18 #include "ui_inputdevicesimulator.h"
19 #include <QSettings>
20
21
22 InputDeviceSimulator::InputDeviceSimulator(QWidget *parent) :
23     QDialog(parent),
24     mp_ui(new Ui::InputDeviceSimulator),
25     mp_dBusInputevent(0)
26 {
27     mp_ui->setupUi(this);
28
29     // connect to the dBus interface provided by the input device distributor
30     mp_dBusInputevent = new org::agl::inputevent("org.agl.main",
31                                               "/InputEventDistributor",
32                                               QDBusConnection::sessionBus(),
33                                               0);
34
35     QSettings settings;
36     this->restoreGeometry(settings.value("inputdevicesimulator/geometry").toByteArray());
37 }
38
39 InputDeviceSimulator::~InputDeviceSimulator()
40 {
41     QSettings settings;
42     settings.setValue("inputdevicesimulator/geometry", saveGeometry());
43
44     if (0 == mp_dBusInputevent)
45     {
46         delete mp_dBusInputevent;
47     }
48
49     delete mp_ui;
50 }
51
52 void InputDeviceSimulator::on_pushButtonRight_clicked()
53 {
54     qDebug("right");
55     mp_dBusInputevent->keyEvent(SystemInputEvent::INPUTEVENTTYPE_KEY_PRESSED, SystemInputEvent::INPUTEVENTZONE_1, Qt::Key_Right);
56 }