on xenial help sign in
Read inputMethod surface from the new property int QtMir
9e911d1Michael Zanetti
qml/Components/InputMethod.qml+1−9
@@ -22,15 +22,6 @@ import Ubuntu.Gestures 0.1
22Item {
22Item {
23 id: root
23 id: root
24
24
25− Connections {
26− target: SurfaceManager
27− onSurfaceCreated: {
28− if (surface.type == Mir.InputMethodType) {
29− surfaceItem.surface = surface;
30− }
31− }
32− }
33−
34 property int transitionDuration: UbuntuAnimation.FastDuration
25 property int transitionDuration: UbuntuAnimation.FastDuration
35
26
36 MirSurfaceItem {
27 MirSurfaceItem {
@@ -41,6 +32,7 @@ Item {
41
32
42 surfaceWidth: width
33 surfaceWidth: width
43 surfaceHeight: height
34 surfaceHeight: height
35+ surface: SurfaceManager.inputMethodSurface
44
36
45 onLiveChanged: {
37 onLiveChanged: {
46 if (surface !== null && !live) {
38 if (surface !== null && !live) {
tests/mocks/Unity/Application/MirSurface.cpp+3−2
@@ -23,8 +23,9 @@ MirSurface::MirSurface(const QString& name,
23 Mir::Type type,
23 Mir::Type type,
24 Mir::State state,
24 Mir::State state,
25 const QUrl& screenshot,
25 const QUrl& screenshot,
26− const QUrl &qmlFilePath)
26+ const QUrl &qmlFilePath,
27+ QObject *parent)
27− : unity::shell::application::MirSurfaceInterface(nullptr)
28+ : unity::shell::application::MirSurfaceInterface(parent)
28 , m_name(name)
29 , m_name(name)
29 , m_type(type)
30 , m_type(type)
30 , m_state(state)
31 , m_state(state)
tests/mocks/Unity/Application/MirSurface.h+2−1
@@ -41,7 +41,8 @@ public:
41 Mir::Type type,
41 Mir::Type type,
42 Mir::State state,
42 Mir::State state,
43 const QUrl& screenshot,
43 const QUrl& screenshot,
44− const QUrl &qmlFilePath = QUrl());
44+ const QUrl &qmlFilePath = QUrl(),
45+ QObject *parent = nullptr);
45 virtual ~MirSurface();
46 virtual ~MirSurface();
46
47
47 ////
48 ////
tests/mocks/Unity/Application/SurfaceManager.cpp+8−9
@@ -34,6 +34,13 @@ SurfaceManager::SurfaceManager(QObject *parent) :
34 QObject(parent)
34 QObject(parent)
35 , m_virtualKeyboard(nullptr)
35 , m_virtualKeyboard(nullptr)
36{
36{
37+ m_virtualKeyboard = new VirtualKeyboard(this);
38+ connect(m_virtualKeyboard, &QObject::destroyed, this, [this](QObject *obj) {
39+ MirSurface* surface = qobject_cast<MirSurface*>(obj);
40+ m_virtualKeyboard = nullptr;
41+ Q_EMIT inputMethodSurfaceChanged();
42+ Q_EMIT surfaceDestroyed(surface);
43+ });
37}
44}
38
45
39MirSurface *SurfaceManager::createSurface(const QString& name,
46MirSurface *SurfaceManager::createSurface(const QString& name,
@@ -58,16 +65,8 @@ MirSurface *SurfaceManager::createSurface(const QString& name,
58 return surface;
65 return surface;
59}
66}
60
67
61−MirSurface *SurfaceManager::inputMethodSurface()
68+MirSurface *SurfaceManager::inputMethodSurface() const
62{
69{
63− if (!m_virtualKeyboard) {
64− m_virtualKeyboard = new VirtualKeyboard;
65− connect(m_virtualKeyboard, &QObject::destroyed, this, [this](QObject *obj) {
66− MirSurface* surface = qobject_cast<MirSurface*>(obj);
67− Q_EMIT surfaceDestroyed(surface);
68− });
69− Q_EMIT surfaceCreated(m_virtualKeyboard);
70− }
71 return m_virtualKeyboard;
70 return m_virtualKeyboard;
72}
71}
73
72
tests/mocks/Unity/Application/SurfaceManager.h+3−3
@@ -25,7 +25,7 @@
25class SurfaceManager : public QObject
25class SurfaceManager : public QObject
26{
26{
27 Q_OBJECT
27 Q_OBJECT
28−
28+ Q_PROPERTY(MirSurface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged)
29 Q_PROPERTY(int newSurfaceMinimumWidth READ newSurfaceMinimumWidth WRITE setNewSurfaceMinimumWidth NOTIFY newSurfaceMinimumWidthChanged)
29 Q_PROPERTY(int newSurfaceMinimumWidth READ newSurfaceMinimumWidth WRITE setNewSurfaceMinimumWidth NOTIFY newSurfaceMinimumWidthChanged)
30 Q_PROPERTY(int newSurfaceMaximumWidth READ newSurfaceMaximumWidth WRITE setNewSurfaceMaximumWidth NOTIFY newSurfaceMaximumWidthChanged)
30 Q_PROPERTY(int newSurfaceMaximumWidth READ newSurfaceMaximumWidth WRITE setNewSurfaceMaximumWidth NOTIFY newSurfaceMaximumWidthChanged)
31 Q_PROPERTY(int newSurfaceMinimumHeight READ newSurfaceMinimumHeight WRITE setNewSurfaceMinimumHeight NOTIFY newSurfaceMinimumHeightChanged)
31 Q_PROPERTY(int newSurfaceMinimumHeight READ newSurfaceMinimumHeight WRITE setNewSurfaceMinimumHeight NOTIFY newSurfaceMinimumHeightChanged)
@@ -43,8 +43,7 @@ public:
43 Mir::State state,
43 Mir::State state,
44 const QUrl& screenshot);
44 const QUrl& screenshot);
45
45
46− // To be used in the tests
47− Q_INVOKABLE MirSurface* inputMethodSurface();
46+ MirSurface* inputMethodSurface() const;
48
47
49 int newSurfaceMinimumWidth() const { return m_newSurfaceMinimumWidth; }
48 int newSurfaceMinimumWidth() const { return m_newSurfaceMinimumWidth; }
50 void setNewSurfaceMinimumWidth(int value);
49 void setNewSurfaceMinimumWidth(int value);
@@ -65,6 +64,7 @@ public:
65 void setNewSurfaceHeightIncrement(int);
64 void setNewSurfaceHeightIncrement(int);
66
65
67Q_SIGNALS:
66Q_SIGNALS:
67+ void inputMethodSurfaceChanged();
68 void countChanged();
68 void countChanged();
69 void surfaceCreated(MirSurface *surface);
69 void surfaceCreated(MirSurface *surface);
70 void surfaceDestroyed(MirSurface*surface);
70 void surfaceDestroyed(MirSurface*surface);
tests/mocks/Unity/Application/VirtualKeyboard.cpp+3−2
@@ -22,12 +22,13 @@
22
22
23#include <QDebug>
23#include <QDebug>
24
24
25−VirtualKeyboard::VirtualKeyboard()
25+VirtualKeyboard::VirtualKeyboard(QObject *parent)
26 : MirSurface("input-method",
26 : MirSurface("input-method",
27 Mir::InputMethodType,
27 Mir::InputMethodType,
28 Mir::MinimizedState,
28 Mir::MinimizedState,
29 QUrl("qrc:///Unity/Application/vkb_portrait.png"),
29 QUrl("qrc:///Unity/Application/vkb_portrait.png"),
30− QUrl("qrc:///Unity/Application/VirtualKeyboard.qml"))
30+ QUrl("qrc:///Unity/Application/VirtualKeyboard.qml"),
31+ parent)
31{
32{
32}
33}
33
34
tests/mocks/Unity/Application/VirtualKeyboard.h+1−1
@@ -25,7 +25,7 @@ class VirtualKeyboard : public MirSurface
25{
25{
26 Q_OBJECT
26 Q_OBJECT
27public:
27public:
28− explicit VirtualKeyboard();
28+ explicit VirtualKeyboard(QObject *parent = nullptr);
29 ~VirtualKeyboard();
29 ~VirtualKeyboard();
30};
30};
31
31
tests/mocks/Unity/Application/plugin.cpp+2−1
@@ -78,8 +78,9 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
78 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
78 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
79 qmlRegisterUncreatableType<Session>(uri, 0, 1, "Session", "Session can't be instantiated from QML");
79 qmlRegisterUncreatableType<Session>(uri, 0, 1, "Session", "Session can't be instantiated from QML");
80 qmlRegisterUncreatableType<MirSurface>(uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
80 qmlRegisterUncreatableType<MirSurface>(uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
81+ qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>(
82+ uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
81 qmlRegisterType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");
83 qmlRegisterType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");
82−
83 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
84 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
84
85
85 qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
86 qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
tests/qmltests/tst_OrientedShell.qml+1−1
@@ -314,7 +314,7 @@ Rectangle {
314 checked: false
314 checked: false
315 activeFocusOnPress: false
315 activeFocusOnPress: false
316 onCheckedChanged: {
316 onCheckedChanged: {
317− var surface = SurfaceManager.inputMethodSurface();
317+ var surface = SurfaceManager.inputMethodSurface;
318 if (checked) {
318 if (checked) {
319 surface.setState(Mir.RestoredState);
319 surface.setState(Mir.RestoredState);
320 } else {
320 } else {
tests/qmltests/tst_Shell.qml+1−1
@@ -795,7 +795,7 @@ Rectangle {
795 loadShell("phone");
795 loadShell("phone");
796 swipeAwayGreeter();
796 swipeAwayGreeter();
797 var item = findChild(shell, "inputMethod");
797 var item = findChild(shell, "inputMethod");
798− var surface = SurfaceManager.inputMethodSurface();
798+ var surface = SurfaceManager.inputMethodSurface;
799
799
800 surface.setState(Mir.MinimizedState);
800 surface.setState(Mir.MinimizedState);
801 tryCompare(item, "visible", false);
801 tryCompare(item, "visible", false);