Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1332624 into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 180
Merged at revision: 179
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1332624
Merge into: lp:ubuntu-keyboard
Diff against target: 176 lines (+132/-4)
4 files modified
qml/Keyboard.qml (+14/-1)
src/plugin/inputmethod_p.h (+2/-0)
tests/unittests/ut_keyboardsettings/qgsettings.h (+115/-0)
tests/unittests/ut_keyboardsettings/ut_keyboardsettings.pro (+1/-3)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1332624
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+224419@code.launchpad.net

Commit message

Handle any discrepancy between keyboard's fullScreenItem size and the real screen size (e.g. caused by the shell's top bar)

Description of the change

Handles any discrepancy between keyboard's fullScreenItem size and the real screen size (e.g. caused by the shell's top bar), as described in https://bugs.launchpad.net/ubuntu/+source/ubuntu-keyboard/+bug/1332624

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-keyboard) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed the packaging (debian), did you subscribe a core-dev to this MP?

 * No change

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
180. By Michael Sheldon

Add QGSettings header to fake QGSettings test rather than hard-coding path

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Ok, it's just a workaround but well documented - also, it works pretty well :) So a big +1 on this and the build failure fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Keyboard.qml'
2--- qml/Keyboard.qml 2014-04-09 17:11:33 +0000
3+++ qml/Keyboard.qml 2014-06-25 18:01:22 +0000
4@@ -279,8 +279,21 @@
5 vheight = keyboardSurface.height;
6 }
7
8+ // Handle any discrepancy between our fullScreenItem's size and the real
9+ // screen size (e.g. caused by the shell's top bar).
10+ // Work around for: https://bugs.launchpad.net/ubuntu/+source/ubuntu-keyboard/+bug/1332624
11+ var mappingDifference = 0;
12+ if (fullScreenItem.height > 0) {
13+ if (orientationHelper.orientationAngle == 270 ||
14+ orientationHelper.orientationAngle == 90) {
15+ mappingDifference = maliit_screen_width - fullScreenItem.width;
16+ } else {
17+ mappingDifference = maliit_screen_height - fullScreenItem.height;
18+ }
19+ }
20+
21 var obj = mapFromItem(keyboardSurface, vx, vy, vwidth, vheight);
22- maliit_geometry.visibleRect = Qt.rect(obj.x, obj.y, obj.width, obj.height);
23+ maliit_geometry.visibleRect = Qt.rect(obj.x, obj.y - mappingDifference, obj.width, obj.height);
24 }
25
26 } // fullScreenItem
27
28=== modified file 'src/plugin/inputmethod_p.h'
29--- src/plugin/inputmethod_p.h 2014-06-13 12:24:40 +0000
30+++ src/plugin/inputmethod_p.h 2014-06-25 18:01:22 +0000
31@@ -172,6 +172,8 @@
32 qml_context->setContextProperty("maliit_event_handler", &event_handler);
33 qml_context->setContextProperty("maliit_wordribbon", wordRibbon);
34 qml_context->setContextProperty("maliit_word_engine", editor.wordEngine());
35+ qml_context->setContextProperty("maliit_screen_height", QGuiApplication::primaryScreen()->geometry().height());
36+ qml_context->setContextProperty("maliit_screen_width", QGuiApplication::primaryScreen()->geometry().width());
37 }
38
39
40
41=== added file 'tests/unittests/ut_keyboardsettings/qgsettings.h'
42--- tests/unittests/ut_keyboardsettings/qgsettings.h 1970-01-01 00:00:00 +0000
43+++ tests/unittests/ut_keyboardsettings/qgsettings.h 2014-06-25 18:01:22 +0000
44@@ -0,0 +1,115 @@
45+/*
46+ * Copyright 2013 Canonical Ltd.
47+ *
48+ * This program is free software; you can redistribute it and/or modify
49+ * it under the terms of the GNU Lesser General Public License as published by
50+ * the Free Software Foundation; version 3.
51+ *
52+ * This program is distributed in the hope that it will be useful,
53+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
54+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55+ * GNU Lesser General Public License for more details.
56+ *
57+ * You should have received a copy of the GNU Lesser General Public License
58+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
59+ *
60+ * Author: Lars Uebernickel <lars.uebernickel@canonical.com>
61+ */
62+
63+#ifndef __QGSETTINGS_H__
64+#define __QGSETTINGS_H__
65+
66+#include <QObject>
67+#include <QStringList>
68+
69+/**
70+ * @brief QGSettings provides access to application settings stored with GSettings.
71+ *
72+ * GSettings does not allow keys to contain anything other than lower-case
73+ * characters and dashes. This class converts all keys to camelCase, to make it easier
74+ * for people used to Qt's naming convention.
75+ */
76+class QGSettings: public QObject
77+{
78+ Q_OBJECT
79+
80+public:
81+ /**
82+ * @brief Create a QGSettings object for a given schema_id and path.
83+ * @param schema_id The id of the schema
84+ * @param path If non-empty, specifies the path for a relocatable schema
85+ */
86+ QGSettings(const QByteArray &schema_id, const QByteArray &path = QByteArray(), QObject *parent = NULL);
87+
88+ ~QGSettings();
89+
90+ /**
91+ * @brief Gets the value that is stored at key
92+ * @param key The key for which to retrieve the value (in camelCase)
93+ *
94+ * It is an error if key does not exist in the schema associated with this
95+ * QGSettings object.
96+ */
97+ QVariant get(const QString &key) const;
98+
99+ /**
100+ * @brief Sets the value at key to value
101+ * @key The key for which to set the value (in camelCase)
102+ * @value The value to set
103+ *
104+ * It is an error if key does not exist in the schema associated with this
105+ * QGSettings object.
106+ *
107+ * Not all values that a QVariant can hold can be serialized into a
108+ * setting. Basic types (integers, doubles, strings) and string lists are
109+ * supported.
110+ */
111+ void set(const QString &key, const QVariant &value);
112+
113+ /**
114+ * @brief Sets the value at key to value
115+ * @key The key for which to set the value
116+ * @value The value to set
117+ *
118+ * Behaves just like ::set(key, value), but returns false instead of
119+ * printing a warning if the key couldn't be set.
120+ *
121+ * @return whether the key was set
122+ */
123+ bool trySet(const QString &key, const QVariant &value);
124+
125+ /**
126+ * \brief Retrieves the list of avaliable keys
127+ */
128+ QStringList keys() const;
129+
130+ /**
131+ * \brief Returns the list of values that key can assume
132+ *
133+ * Returns an empty list if the schema doesn't contain that information for
134+ * the key.
135+ */
136+ QVariantList choices(const QString &key) const;
137+
138+ /**
139+ * @brief Resets the setting for @key to its default value.
140+ */
141+ void reset(const QString &key);
142+
143+ /**
144+ * @brief Checks if a schema with the given id is installed.
145+ */
146+ static bool isSchemaInstalled(const QByteArray &schema_id);
147+
148+Q_SIGNALS:
149+ /**
150+ * \brief Emitted when the value associated with key has changed
151+ */
152+ void changed(const QString &key);
153+
154+private:
155+ struct QGSettingsPrivate *priv;
156+ friend struct QGSettingsPrivate;
157+};
158+
159+#endif
160
161=== modified file 'tests/unittests/ut_keyboardsettings/ut_keyboardsettings.pro'
162--- tests/unittests/ut_keyboardsettings/ut_keyboardsettings.pro 2013-11-06 09:31:37 +0000
163+++ tests/unittests/ut_keyboardsettings/ut_keyboardsettings.pro 2014-06-25 18:01:22 +0000
164@@ -8,11 +8,9 @@
165 TARGET = ut_keyboardsettings
166 QT = core testlib
167
168-QGSETTINGS_INCDIR = /usr/include/qt5/QGSettings
169-
170 HEADERS += \
171 $${TOP_SRCDIR}/src/plugin/keyboardsettings.h \
172- $${QGSETTINGS_INCDIR}/qgsettings.h \
173+ qgsettings.h
174
175 SOURCES += \
176 ut_keyboardsettings.cpp \

Subscribers

People subscribed via source and target branches