on xenial help sign in
rename HomeKeyWatcher.cpp => WindowInputMonitor.cpp
commit17b5515fb092931a5af072db32758b9cd6f1702e authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 2 Dec 2015, 17:34 (11 years ago) parentb157fc9
7 files changed+37−37
plugins/Utils/CMakeLists.txt+1−1 plugins/Utils/HomeKeyWatcher.cpp → plugins/Utils/WindowInputMonitor.cpp+11−11 plugins/Utils/HomeKeyWatcher.h → plugins/Utils/WindowInputMonitor.h+7−7 plugins/Utils/plugin.cpp+2−2 qml/Shell.qml+1−1 tests/plugins/Utils/CMakeLists.txt+1−1 tests/plugins/Utils/HomeKeyWatcherTest.cpp → tests/plugins/Utils/WindowInputMonitorTest.cpp+14−14
plugins/Utils/CMakeLists.txt+1−1
@@ -13,7 +13,7 @@ set(QMLPLUGIN_SRC
1313 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
1414 applicationsfiltermodel.cpp
1515 constants.cpp
16− HomeKeyWatcher.cpp
16+ WindowInputMonitor.cpp
1717 inputwatcher.cpp
1818 qlimitproxymodelqml.cpp
1919 unitysortfilterproxymodelqml.cpp
plugins/Utils/HomeKeyWatcher.cpp → plugins/Utils/WindowInputMonitor.cpprenamed+11−11
@@ -14,18 +14,18 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#include "HomeKeyWatcher.h"
17+#include "WindowInputMonitor.h"
1818
1919#include <QQuickWindow>
2020
2121using namespace UnityUtil;
2222
23−HomeKeyWatcher::HomeKeyWatcher(QQuickItem *parent)
24− : HomeKeyWatcher(new Timer, new ElapsedTimer, parent)
23+WindowInputMonitor::WindowInputMonitor(QQuickItem *parent)
24+ : WindowInputMonitor(new Timer, new ElapsedTimer, parent)
2525{
2626}
2727
28−HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
28+WindowInputMonitor::WindowInputMonitor(UnityUtil::AbstractTimer *timer,
2929 UnityUtil::AbstractElapsedTimer *elapsedTimer,
3030 QQuickItem *parent)
3131 : QQuickItem(parent)
@@ -37,20 +37,20 @@ HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
3737 m_windowLastTouchedTimer->start();
3838
3939 connect(this, &QQuickItem::windowChanged,
40− this, &HomeKeyWatcher::setupFilterOnWindow);
40+ this, &WindowInputMonitor::setupFilterOnWindow);
4141
4242 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
43− this, &HomeKeyWatcher::emitActivatedIfNoTouchesAround);
43+ this, &WindowInputMonitor::emitActivatedIfNoTouchesAround);
4444 m_activationTimer->setInterval(msecsWithoutTouches);
4545}
4646
47−HomeKeyWatcher::~HomeKeyWatcher()
47+WindowInputMonitor::~WindowInputMonitor()
4848{
4949 delete m_windowLastTouchedTimer;
5050 delete m_activationTimer;
5151}
5252
53−bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
53+bool WindowInputMonitor::eventFilter(QObject *watched, QEvent *event)
5454{
5555 Q_ASSERT(!m_filteredWindow.isNull());
5656 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
@@ -62,7 +62,7 @@ bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
6262 return false;
6363}
6464
65−void HomeKeyWatcher::update(QEvent *event)
65+void WindowInputMonitor::update(QEvent *event)
6666{
6767 if (event->type() == QEvent::KeyPress) {
6868 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
@@ -101,7 +101,7 @@ void HomeKeyWatcher::update(QEvent *event)
101101 }
102102}
103103
104−void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
104+void WindowInputMonitor::setupFilterOnWindow(QQuickWindow *window)
105105{
106106 if (!m_filteredWindow.isNull()) {
107107 m_filteredWindow->removeEventFilter(this);
@@ -114,7 +114,7 @@ void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
114114 }
115115}
116116
117−void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
117+void WindowInputMonitor::emitActivatedIfNoTouchesAround()
118118{
119119 if (!m_homeKeyPressed && !m_windowBeingTouched &&
120120 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
plugins/Utils/HomeKeyWatcher.h → plugins/Utils/WindowInputMonitor.hrenamed+7−7
@@ -14,8 +14,8 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#ifndef UNITY_HOMEKEYWATCHER_H
18−#define UNITY_HOMEKEYWATCHER_H
17+#ifndef UNITY_WINDOWINPUTMONITOR_H
18+#define UNITY_WINDOWINPUTMONITOR_H
1919
2020#include <QQuickItem>
2121#include <QPointer>
@@ -35,19 +35,19 @@
3535 a swipe from a screen edge, for instance. That's particularly the case when the
3636 home key is a capacitive key.
3737 */
38−class HomeKeyWatcher : public QQuickItem
38+class WindowInputMonitor : public QQuickItem
3939{
4040 Q_OBJECT
4141public:
4242
43− HomeKeyWatcher(QQuickItem *parent = 0);
43+ WindowInputMonitor(QQuickItem *parent = 0);
4444
4545 // for testing
46− HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
46+ WindowInputMonitor(UnityUtil::AbstractTimer *timer,
4747 UnityUtil::AbstractElapsedTimer *elapsedTimer,
4848 QQuickItem *parent = 0);
4949
50− virtual ~HomeKeyWatcher();
50+ virtual ~WindowInputMonitor();
5151
5252 bool eventFilter(QObject *watched, QEvent *event) override;
5353
@@ -74,4 +74,4 @@ private:
7474 UnityUtil::AbstractTimer *m_activationTimer;
7575};
7676
77−#endif // UNITY_HOMEKEYWATCHER_H
77+#endif // UNITY_WINDOWINPUTMONITOR_H
plugins/Utils/plugin.cpp+2−2
@@ -25,7 +25,7 @@
2525// local
2626#include "activefocuslogger.h"
2727#include "easingcurve.h"
28−#include "HomeKeyWatcher.h"
28+#include "WindowInputMonitor.h"
2929#include "inputwatcher.h"
3030#include "qlimitproxymodelqml.h"
3131#include "unitysortfilterproxymodelqml.h"
@@ -54,7 +54,7 @@ static QObject *createConstants(QQmlEngine *engine, QJSEngine *scriptEngine)
5454void UtilsPlugin::registerTypes(const char *uri)
5555{
5656 Q_ASSERT(uri == QLatin1String("Utils"));
57− qmlRegisterType<HomeKeyWatcher>(uri, 0, 1, "HomeKeyWatcher");
57+ qmlRegisterType<WindowInputMonitor>(uri, 0, 1, "WindowInputMonitor");
5858 qmlRegisterType<QAbstractItemModel>();
5959 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
6060 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
qml/Shell.qml+1−1
@@ -195,7 +195,7 @@ Item {
195195 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
196196 }
197197
198− HomeKeyWatcher {
198+ WindowInputMonitor {
199199 onActivated: { launcher.fadeOut(); shell.showHome(); }
200200 onWindowTouched: { cursorPriv.hideCursor(); }
201201 onWindowReleased: {
tests/plugins/Utils/CMakeLists.txt+1−1
@@ -7,7 +7,7 @@ include_directories(
77foreach(util_test
88 QLimitProxyModel
99 UnitySortFilterProxyModel
10− HomeKeyWatcher
10+ WindowInputMonitor
1111)
1212 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
1313 qt5_use_modules(${util_test}TestExec Test Core Qml)
tests/plugins/Utils/HomeKeyWatcherTest.cpp → tests/plugins/Utils/WindowInputMonitorTest.cpprenamed+14−14
@@ -14,7 +14,7 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#include "HomeKeyWatcher.h"
17+#include "WindowInputMonitor.h"
1818
1919#include <QTest>
2020#include <QSignalSpy>
@@ -71,7 +71,7 @@ public:
7171
7272using namespace UnityUtil;
7373
74−class HomeKeyWatcherTest : public QObject {
74+class WindowInputMonitorTest : public QObject {
7575 Q_OBJECT
7676private Q_SLOTS:
7777 void init(); // called right before each and every test function is executed
@@ -88,25 +88,25 @@ private:
8888 FakeTimerFactory *m_fakeTimerFactory;
8989};
9090
91−void HomeKeyWatcherTest::init()
91+void WindowInputMonitorTest::init()
9292{
9393 m_fakeTimerFactory = new FakeTimerFactory;
9494}
9595
96−void HomeKeyWatcherTest::cleanup()
96+void WindowInputMonitorTest::cleanup()
9797{
9898 delete m_fakeTimerFactory;
9999 m_fakeTimerFactory = nullptr;
100100}
101101
102102
103−void HomeKeyWatcherTest::passTime(qint64 timeSpanMs)
103+void WindowInputMonitorTest::passTime(qint64 timeSpanMs)
104104{
105105 qint64 finalTime = FakeElapsedTimer::msecsSinceEpoch + timeSpanMs;
106106 m_fakeTimerFactory->updateTime(finalTime);
107107}
108108
109−void HomeKeyWatcherTest::touchTapTouch_data()
109+void WindowInputMonitorTest::touchTapTouch_data()
110110{
111111 QTest::addColumn<int>("silenceBeforeTap");
112112 QTest::addColumn<int>("tapDuration");
@@ -121,14 +121,14 @@ void HomeKeyWatcherTest::touchTapTouch_data()
121121 QTest::newRow("isolated long press") << 1000 << 200 << 1000 << 0;
122122}
123123
124−void HomeKeyWatcherTest::touchTapTouch()
124+void WindowInputMonitorTest::touchTapTouch()
125125{
126126 QFETCH(int, silenceBeforeTap);
127127 QFETCH(int, tapDuration);
128128 QFETCH(int, silenceAfterTap);
129129 QFETCH(int, expectedActivatedCount);
130− HomeKeyWatcher homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
131− QSignalSpy activatedSpy(&homeKeyWatcher, &HomeKeyWatcher::activated);
130+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
131+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::activated);
132132 QVERIFY(activatedSpy.isValid());
133133
134134 {
@@ -186,10 +186,10 @@ void HomeKeyWatcherTest::touchTapTouch()
186186 QCOMPARE(activatedSpy.count(), expectedActivatedCount);
187187}
188188
189−void HomeKeyWatcherTest::tapWhileTouching()
189+void WindowInputMonitorTest::tapWhileTouching()
190190{
191− HomeKeyWatcher homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
192− QSignalSpy activatedSpy(&homeKeyWatcher, &HomeKeyWatcher::activated);
191+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
192+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::activated);
193193 QVERIFY(activatedSpy.isValid());
194194
195195 {
@@ -318,6 +318,6 @@ AbstractTimer *FakeTimerFactory::create(QObject *parent)
318318 return fakeTimer;
319319}
320320
321−QTEST_GUILESS_MAIN(HomeKeyWatcherTest)
321+QTEST_GUILESS_MAIN(WindowInputMonitorTest)
322322
323−#include "HomeKeyWatcherTest.moc"
323+#include "WindowInputMonitorTest.moc"