on xenial help sign in
Updated Utils plugin from trunk
commit0ef484e81caf27c91207a24170fadfce56f0c1fc authorNick Dedekind <nick.dedekind@canonical.com> dateWed 15 Apr 2015, 15:52 (12 years ago) parent1b40225
4 files changed+82−3
tests/mocks/Utils/CMakeLists.txt+3−1 tests/mocks/Utils/constants.cpp+23 tests/mocks/Utils/constants.h+43 tests/mocks/Utils/plugin.cpp+13−2
tests/mocks/Utils/CMakeLists.txt+3−1
@@ -9,6 +9,7 @@ include_directories(
99)
1010
1111set(QMLPLUGIN_SRC
12+ ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp
1213 ${CMAKE_SOURCE_DIR}/plugins/Utils/qlimitproxymodelqml.cpp
1314 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
1415 ${CMAKE_SOURCE_DIR}/plugins/Utils/relativetimeformatter.cpp
@@ -16,8 +17,9 @@ set(QMLPLUGIN_SRC
1617 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitymenumodelpaths.cpp
1718 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowkeysfilter.cpp
1819 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
19− windowstatestorage.cpp
20+ constants.cpp
2021 plugin.cpp
22+ windowstatestorage.cpp
2123 )
2224
2325add_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 @@
2424#include "plugin.h"
2525
2626// local
27−#include "easingcurve.h"
27+#include "inputwatcher.h"
2828#include "qlimitproxymodelqml.h"
2929#include "unitysortfilterproxymodelqml.h"
3030#include "relativetimeformatter.h"
3131#include "timeformatter.h"
3232#include "unitymenumodelpaths.h"
3333#include "windowkeysfilter.h"
34+#include "easingcurve.h"
3435#include "windowstatestorage.h"
36+#include "constants.h"
3537
3638static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
3739{
@@ -40,9 +42,16 @@ static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEn
4042 return new WindowStateStorage();
4143}
4244
45+static QObject *createConstants(QQmlEngine *engine, QJSEngine *scriptEngine)
46+{
47+ Q_UNUSED(engine)
48+ Q_UNUSED(scriptEngine)
49+ return new Constants();
50+}
51+
4352void FakeUtilsPlugin::registerTypes(const char *uri)
4453{
45− Q_ASSERT(uri == QLatin1String("Utils"));
54+ Q_ASSERT(uri == QLatin1String("Utils"));;
4655 qmlRegisterType<QAbstractItemModel>();
4756 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
4857 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
@@ -53,6 +62,8 @@ void FakeUtilsPlugin::registerTypes(const char *uri)
5362 qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
5463 qmlRegisterType<RelativeTimeFormatter>(uri, 0, 1, "RelativeTimeFormatter");
5564 qmlRegisterSingletonType<WindowStateStorage>(uri, 0, 1, "WindowStateStorage", createWindowStateStorage);
65+ qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
66+ qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants);
5667}
5768
5869void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)