on 337d819 help sign in
75 lines 2.2 kB history raw
1/*
2 * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "GenericApp.h"
18#include "Session.h"
20#include <paths.h>
22#include <QString>
24#include <QDebug>
26GenericApp::GenericApp(const QString& name,
27 GenericApp::Type type,
28 GenericApp::State state,
29 const QUrl& screenshot,
30 const QString &qmlFilePath,
31 QQuickItem *parent)
32 : MirSurfaceItem(name, type, state, screenshot, qmlFilePath, parent)
33 , m_touchPressCount(0)
34 , m_touchReleaseCount(0)
35 , m_requestedInputMethod(false)
37 connect(this, &QQuickItem::activeFocusChanged,
38 this, &GenericApp::onActiveFocusChanged);
41GenericApp::~GenericApp()
45void GenericApp::onActiveFocusChanged()
47 if (hasActiveFocus()) {
48 if (m_requestedInputMethod) {
49 Q_EMIT inputMethodRequested();
50 }
51 } else {
52 Q_EMIT inputMethodDismissed();
53 }
56void GenericApp::touchEvent(QTouchEvent * event)
58 if (event->touchPointStates() & Qt::TouchPointPressed) {
59 ++m_touchPressCount;
60 Q_EMIT touchPressCountChanged(m_touchPressCount);
62 if (hasActiveFocus()) {
63 if (m_requestedInputMethod) {
64 Q_EMIT inputMethodDismissed();
65 } else {
66 Q_EMIT inputMethodRequested();
67 }
68 m_requestedInputMethod = !m_requestedInputMethod;
69 }
71 } else if (event->touchPointStates() & Qt::TouchPointReleased) {
72 ++m_touchReleaseCount;
73 Q_EMIT touchReleaseCountChanged(m_touchReleaseCount);
74 }