on 436b607 help sign in
unity8/plugins/Utils/windowkeysfilter.h
51 lines 1.7 kB history raw
1/*
2 * Copyright (C) 2014 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 *
16 * Author: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */
19#ifndef UNITY_WINDOWKEYSFILTER_H
20#define UNITY_WINDOWKEYSFILTER_H
22#include <QQuickItem>
23#include <QPointer>
25/*
26 Receives all key events that arrive in the QQuickWindow where this item is placed.
28 Rejected key events will be allowed to be processed normally by the QQuickWindow whereas
29 accepted ones will be filtered out. Events are accepted by default, so make sure you reject
30 the keys you're not interested in.
32 If more than one WindowKeysFilter exist in the same QML scene (and thus in the same QQuickWindow)
33 they will be called in the order of creation, which can be tricky to assess. So the best practice
34 is to have at most one WindowKeysFilter per QML scene.
35 */
36class WindowKeysFilter : public QQuickItem
38 Q_OBJECT
39public:
40 WindowKeysFilter(QQuickItem *parent = 0);
42 bool eventFilter(QObject *watched, QEvent *event);
44private Q_SLOTS:
45 void setupFilterOnWindow(QQuickWindow *window);
47private:
48 QPointer<QQuickWindow> m_filteredWindow;
49};
51#endif // UNITY_WINDOWKEYSFILTER_H