/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "GenericApp.h" #include "Session.h" #include #include #include GenericApp::GenericApp(const QString& name, GenericApp::Type type, GenericApp::State state, const QUrl& screenshot, const QString &qmlFilePath, QQuickItem *parent) : MirSurfaceItem(name, type, state, screenshot, qmlFilePath, parent) , m_touchPressCount(0) , m_touchReleaseCount(0) , m_requestedInputMethod(false) { connect(this, &QQuickItem::activeFocusChanged, this, &GenericApp::onActiveFocusChanged); } GenericApp::~GenericApp() { } void GenericApp::onActiveFocusChanged() { if (hasActiveFocus()) { if (m_requestedInputMethod) { Q_EMIT inputMethodRequested(); } } else { Q_EMIT inputMethodDismissed(); } } void GenericApp::touchEvent(QTouchEvent * event) { if (event->touchPointStates() & Qt::TouchPointPressed) { ++m_touchPressCount; Q_EMIT touchPressCountChanged(m_touchPressCount); if (hasActiveFocus()) { if (m_requestedInputMethod) { Q_EMIT inputMethodDismissed(); } else { Q_EMIT inputMethodRequested(); } m_requestedInputMethod = !m_requestedInputMethod; } } else if (event->touchPointStates() & Qt::TouchPointReleased) { ++m_touchReleaseCount; Q_EMIT touchReleaseCountChanged(m_touchReleaseCount); } }