on xenial help sign in
Updated Utils plugin from trunk
0ef484eNick Dedekind
tests/mocks/Utils/CMakeLists.txt+3−1
@@ -9,6 +9,7 @@ include_directories(
9)
9)
10
10
11set(QMLPLUGIN_SRC
11set(QMLPLUGIN_SRC
12+ ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp
12 ${CMAKE_SOURCE_DIR}/plugins/Utils/qlimitproxymodelqml.cpp
13 ${CMAKE_SOURCE_DIR}/plugins/Utils/qlimitproxymodelqml.cpp
13 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
14 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
14 ${CMAKE_SOURCE_DIR}/plugins/Utils/relativetimeformatter.cpp
15 ${CMAKE_SOURCE_DIR}/plugins/Utils/relativetimeformatter.cpp
@@ -16,8 +17,9 @@ set(QMLPLUGIN_SRC
16 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitymenumodelpaths.cpp
17 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitymenumodelpaths.cpp
17 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowkeysfilter.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowkeysfilter.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
19− windowstatestorage.cpp
20+ constants.cpp
20 plugin.cpp
21 plugin.cpp
22+ windowstatestorage.cpp
21 )
23 )
22
24
23add_library(FakeUtils-qml SHARED
25add_library(FakeUtils-qml SHARED
tests/mocks/Utils/constants.cppnew file+23
@@ -0,0 +1,23 @@
1+/*
2+ * Copyright 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 Lesser 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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+*/
16+
17+#include "constants.h"
18+
19+Constants::Constants(QObject *parent)
20+ : QObject(parent)
21+{
22+ m_indicatorValueTimeout = 5000;
23+}
tests/mocks/Utils/constants.hnew file+43
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright 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 Lesser 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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+*/
16+
17+#ifndef CONSTANTS_H
18+#define CONSTANTS_H
19+
20+#include <QObject>
21+
22+/**
23+ * @brief The Constants class
24+ *
25+ * This singleton class exposes contants to Qml
26+ *
27+ */
28+
29+class Constants: public QObject
30+{
31+ Q_OBJECT
32+ Q_PROPERTY(int indicatorValueTimeout READ indicatorValueTimeout CONSTANT)
33+
34+public:
35+ Constants(QObject *parent = 0);
36+
37+ int indicatorValueTimeout() const { return m_indicatorValueTimeout; }
38+
39+private:
40+ int m_indicatorValueTimeout;
41+};
42+
43+#endif
tests/mocks/Utils/plugin.cpp+13−2
@@ -24,14 +24,16 @@
24#include "plugin.h"
24#include "plugin.h"
25
25
26// local
26// local
27−#include "easingcurve.h"
27+#include "inputwatcher.h"
28#include "qlimitproxymodelqml.h"
28#include "qlimitproxymodelqml.h"
29#include "unitysortfilterproxymodelqml.h"
29#include "unitysortfilterproxymodelqml.h"
30#include "relativetimeformatter.h"
30#include "relativetimeformatter.h"
31#include "timeformatter.h"
31#include "timeformatter.h"
32#include "unitymenumodelpaths.h"
32#include "unitymenumodelpaths.h"
33#include "windowkeysfilter.h"
33#include "windowkeysfilter.h"
34+#include "easingcurve.h"
34#include "windowstatestorage.h"
35#include "windowstatestorage.h"
36+#include "constants.h"
35
37
36static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
38static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
37{
39{
@@ -40,9 +42,16 @@ static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEn
40 return new WindowStateStorage();
42 return new WindowStateStorage();
41}
43}
42
44
45+static QObject *createConstants(QQmlEngine *engine, QJSEngine *scriptEngine)
46+{
47+ Q_UNUSED(engine)
48+ Q_UNUSED(scriptEngine)
49+ return new Constants();
50+}
51+
43void FakeUtilsPlugin::registerTypes(const char *uri)
52void FakeUtilsPlugin::registerTypes(const char *uri)
44{
53{
45− Q_ASSERT(uri == QLatin1String("Utils"));
54+ Q_ASSERT(uri == QLatin1String("Utils"));;
46 qmlRegisterType<QAbstractItemModel>();
55 qmlRegisterType<QAbstractItemModel>();
47 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
56 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
48 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
57 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
@@ -53,6 +62,8 @@ void FakeUtilsPlugin::registerTypes(const char *uri)
53 qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
62 qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
54 qmlRegisterType<RelativeTimeFormatter>(uri, 0, 1, "RelativeTimeFormatter");
63 qmlRegisterType<RelativeTimeFormatter>(uri, 0, 1, "RelativeTimeFormatter");
55 qmlRegisterSingletonType<WindowStateStorage>(uri, 0, 1, "WindowStateStorage", createWindowStateStorage);
64 qmlRegisterSingletonType<WindowStateStorage>(uri, 0, 1, "WindowStateStorage", createWindowStateStorage);
65+ qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
66+ qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants);
56}
67}
57
68
58void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
69void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)