Merge lp:~thomas-moenicke/phablet-extras/maliit-plugins_stretched-sizes into lp:phablet-extras/maliit-plugins

Proposed by Thomas Moenicke
Status: Merged
Approved by: Bill Filler
Approved revision: 2131
Merged at revision: 2112
Proposed branch: lp:~thomas-moenicke/phablet-extras/maliit-plugins_stretched-sizes
Merge into: lp:phablet-extras/maliit-plugins
Diff against target: 986 lines (+580/-80)
12 files modified
debian/changelog (+8/-0)
debian/rules (+2/-2)
maliit-keyboard/data/styles/ubuntu/main.ini (+21/-21)
maliit-keyboard/lib/logic/keyareaconverter.cpp (+182/-42)
maliit-keyboard/lib/logic/keyareaconverter.h (+69/-4)
maliit-keyboard/plugin/inputmethod.cpp (+22/-0)
maliit-keyboard/plugin/inputmethod.h (+1/-0)
maliit-keyboard/qml/Keyboard.qml (+9/-1)
maliit-keyboard/qml/maliit-ui-constants.qml (+27/-10)
maliit-keyboard/tests/qml-test-app/keyboard-test.qml (+226/-0)
maliit-keyboard/tests/qml-test-app/qml-test-app.pro (+12/-0)
maliit-keyboard/tests/tests.pro (+1/-0)
To merge this branch: bzr merge lp:~thomas-moenicke/phablet-extras/maliit-plugins_stretched-sizes
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+160295@code.launchpad.net

Commit message

calculating key sizes
allow any keyboard width/height proportionally to the screen
report inputMethodArea rect

Description of the change

calculating key sizes
allow any keyboard width/height proportionally to the screen
report inputMethodArea rect

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
2126. By Thomas Moenicke

more work on the test app:
     2 input fields with buttons to focus/unfocus
     hide/show osk buttons
     shows inputMethodArea rect
     shows visibility
     detects clicks that go through the osk

2127. By Thomas Moenicke

some smaller fixed on osk test app

2128. By Thomas Moenicke

temporarily disabled word engine

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
2129. By Thomas Moenicke

* improved scaling of keys in maliit-keyboard
* maliit-keyboard reports inputMethodArea
* test app

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
2130. By Thomas Moenicke

fix merge issue

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
2131. By Thomas Moenicke

solved merge conflict in changelog

Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Needs an upstream version change

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-04-25 15:50:32 +0000
3+++ debian/changelog 2013-04-25 19:09:24 +0000
4@@ -6,6 +6,14 @@
5
6 -- Sergio Schvezov <sergio.schvezov@canonical.com> Tue, 26 Mar 2013 12:00:15 -0300
7
8+maliit-plugins (0.95.1-w47-springbok0phablet17ubuntu2) quantal; urgency=low
9+
10+ * improved scaling of keys in maliit-keyboard
11+ * maliit-keyboard reports inputMethodArea
12+ * test app
13+
14+ -- Thomas Moenicke <thomas@pachamama> Wed, 24 Apr 2013 11:18:57 +0200
15+
16 maliit-plugins (0.95.1-w47-springbok0phablet17ubuntu1) quantal; urgency=low
17
18 * reading attributes and sizes from qml space, auto-scaling margins
19
20=== modified file 'debian/rules'
21--- debian/rules 2013-03-22 16:40:29 +0000
22+++ debian/rules 2013-04-25 19:09:24 +0000
23@@ -13,8 +13,8 @@
24 QMAKE_OPTIONS = \
25 MALIIT_DEFAULT_PROFILE=ubuntu \
26 CONFIG+=nodoc \
27- CONFIG+=enable-presage \
28- CONFIG+=enable-hunspell \
29+ CONFIG+=disable-presage \
30+ CONFIG+=disable-hunspell \
31 CONFIG+=enable-qt-mobility \
32 CONFIG+=enable-maliit-keyboard \
33 CONFIG+=enable-nemo-keyboard
34
35=== added file 'maliit-keyboard/data/styles/ubuntu/images/keybg_action@18.png'
36Binary files maliit-keyboard/data/styles/ubuntu/images/keybg_action@18.png 1970-01-01 00:00:00 +0000 and maliit-keyboard/data/styles/ubuntu/images/keybg_action@18.png 2013-04-25 19:09:24 +0000 differ
37=== added file 'maliit-keyboard/data/styles/ubuntu/images/keybg_action_active@18.png'
38Binary files maliit-keyboard/data/styles/ubuntu/images/keybg_action_active@18.png 1970-01-01 00:00:00 +0000 and maliit-keyboard/data/styles/ubuntu/images/keybg_action_active@18.png 2013-04-25 19:09:24 +0000 differ
39=== modified file 'maliit-keyboard/data/styles/ubuntu/main.ini'
40--- maliit-keyboard/data/styles/ubuntu/main.ini 2013-04-11 06:57:11 +0000
41+++ maliit-keyboard/data/styles/ubuntu/main.ini 2013-04-25 19:09:24 +0000
42@@ -12,7 +12,7 @@
43 normal-pressed=key-background-pressed.png
44 deadkey=key-background-special.png
45 deadkey-pressed=key-background-pressed.png
46-special=key-background-special.png
47+special=keybg_action@18.png
48 special-pressed=key-background-special-pressed.png
49
50 [icon]
51@@ -41,20 +41,20 @@
52 keyboard-hide=
53
54 [default]
55-landscape\key-area-width=854
56+; landscape\key-area-width=854
57 landscape\key-area-paddings=11
58 landscape\word-ribbon-height=40
59 landscape\magnifier-key-height=96
60 landscape\magnifier-key-width=116
61 landscape\key-margins=4
62-landscape\key-height=56
63-landscape\key-width=76
64-landscape\key-width-large=93
65-landscape\key-width-xlarge=178
66-landscape\key-width-xxlarge=244
67-landscape\key-width-stretched=244
68+; landscape\key-height=56
69+; landscape\key-width=76
70+; landscape\key-width-large=93
71+; landscape\key-width-xlarge=178
72+; landscape\key-width-xxlarge=244
73+; landscape\key-width-stretched=244
74 landscape\vertical-offset=100
75-landscape\font-size=24
76+; landscape\font-size=24
77 landscape\small-font-size=20
78 landscape\font-color=#666666
79 landscape\magnifier-font-size=50
80@@ -62,25 +62,25 @@
81 landscape\candidate-font-stretch=60
82
83 ; 0.9 v, 0.6 h = 1.65
84-portrait\keyboard-total-height=32.777 ; 589 ; 32.777 gu
85-portrait\keyboard-visible-height=468 ; 26gu
86-portrait\key-area-width=100%
87+; portrait\keyboard-total-height=32.777 ; 589 ; 32.777 gu
88+; portrait\keyboard-visible-height=468 ; 26gu
89+; portrait\key-area-width=100%
90 portrait\key-area-paddings=4
91 portrait\word-ribbon-height=40
92 portrait\magnifier-key-height=120
93 portrait\magnifier-key-width=80
94 portrait\key-margins=2.5
95-portrait\key-height=88 ; 4.88
96-portrait\key-width=66 ; 3.666
97-portrait\key-width-large=92
98-portrait\key-width-xlarge=100
99-portrait\key-width-xxlarge=224
100-portrait\key-width-stretched=232
101+; portrait\key-height=88 ; 4.88
102+; portrait\key-width=66 ; 3.666
103+; portrait\key-width-large=92
104+; portrait\key-width-xlarge=100
105+; portrait\key-width-xxlarge=224
106+; portrait\key-width-stretched=232
107 portrait\vertical-offset=100
108-portrait\key-font=Ubuntu Medium
109-portrait\font-size=38 ; 2.111
110+; portrait\key-font=Ubuntu Medium
111+; portrait\font-size=38 ; 2.111
112 portrait\small-font-size=20
113-portrait\font-color=#666666
114+; portrait\font-color=#666666
115 portrait\magnifier-font-size=50
116 portrait\candidate-font-size=20
117 portrait\candidate-font-stretch=60
118
119=== modified file 'maliit-keyboard/lib/logic/keyareaconverter.cpp'
120--- maliit-keyboard/lib/logic/keyareaconverter.cpp 2013-04-12 13:53:03 +0000
121+++ maliit-keyboard/lib/logic/keyareaconverter.cpp 2013-04-25 19:09:24 +0000
122@@ -45,10 +45,21 @@
123 namespace MaliitKeyboard {
124 namespace Logic {
125 namespace Helper {
126+int calculateVerticalMargin(LayoutHelper::Orientation orientation, Keyboard& kb)
127+{
128+ const int freeSpace = uiConst->keyboardVisibleHeight(orientation)
129+ - (uiConst->keyHeight(orientation) * uiConst->numberOfRows());
130+ - uiConst->keyboardTopMargin(orientation);
131+
132+ const int vMargin = (freeSpace / (uiConst->numberOfRows()-1)) / 2;
133+
134+ return vMargin;
135+}
136+
137 QVector<int> calculateMargins(LayoutHelper::Orientation orientation,
138 Keyboard& kb)
139 {
140- const qreal screenWidth = QGuiApplication::primaryScreen()->size().width();
141+ const qreal keyboardWidth = uiConst->keyboardSurfaceRect(orientation).size().width();
142
143 QVector<int> margins;
144
145@@ -56,7 +67,7 @@
146 int numberOfKeysInRow = 0;
147 for (int index = 0; index < kb.keys.count(); ++index) {
148 const KeyDescription &desc(kb.key_descriptions.at(index));
149- int width = uiConst->keyWidth(orientation);
150+ int width = uiConst->keyWidth(orientation, desc.width);
151 spaceTakenByKeys += width;
152 numberOfKeysInRow++;
153
154@@ -65,7 +76,7 @@
155 && kb.key_descriptions.at(index + 1).row > desc.row));
156
157 if (at_row_end) {
158- int marginThisRow = ( (screenWidth - spaceTakenByKeys) / (numberOfKeysInRow-1) ) / 2;
159+ int marginThisRow = ( (keyboardWidth - spaceTakenByKeys) / (numberOfKeysInRow-1) ) / 2;
160 margins.append(marginThisRow);
161 spaceTakenByKeys = 0;
162 }
163@@ -74,6 +85,23 @@
164 return margins;
165 }
166
167+void UiConstants::calculateNumberOfRows(Keyboard& kb)
168+{
169+ if(m_genericStorage->numberOfRows > 0)
170+ return;
171+
172+ m_genericStorage->numberOfRows = 0;
173+ for (int index = 0; index < kb.keys.count(); ++index) {
174+ const KeyDescription &desc(kb.key_descriptions.at(index));
175+ bool at_row_end((index + 1 == kb.keys.count())
176+ || (index + 1 < kb.keys.count()
177+ && kb.key_descriptions.at(index + 1).row > desc.row));
178+
179+ if (at_row_end)
180+ m_genericStorage->numberOfRows++;
181+ }
182+}
183+
184 UiConstants* UiConstants::self = 0;
185
186 void UiConstants::initUiConstants()
187@@ -85,60 +113,172 @@
188
189 QQuickView uiConstantsHelperView;
190 uiConstantsHelperView.setSource(QUrl::fromLocalFile(g_maliit_ui_constants_qml));
191- QQuickItem* portraitConstantsHelper = uiConstantsHelperView.rootObject();
192+ QQuickItem* uiConstantsHelper = uiConstantsHelperView.rootObject();
193
194 const int screenWidth = QGuiApplication::primaryScreen()->size().width();
195 const int screenHeight = QGuiApplication::primaryScreen()->size().height();
196
197 // generic
198
199- m_genericStorage->keyAreaBorders = QMargins(portraitConstantsHelper->property("key_area_borders").toInt(),
200- portraitConstantsHelper->property("key_area_borders").toInt(),
201- portraitConstantsHelper->property("key_area_borders").toInt(),
202- portraitConstantsHelper->property("key_area_borders").toInt()
203+ m_genericStorage->keyAreaBorders = QMargins(uiConstantsHelper->property("key_area_borders").toInt(),
204+ uiConstantsHelper->property("key_area_borders").toInt(),
205+ uiConstantsHelper->property("key_area_borders").toInt(),
206+ uiConstantsHelper->property("key_area_borders").toInt()
207 );
208
209- m_genericStorage->fontColor = portraitConstantsHelper->property("font_color").toByteArray();
210- m_genericStorage->fontFamily = portraitConstantsHelper->property("font_family").toByteArray();
211+ m_genericStorage->fontColor = uiConstantsHelper->property("font_color").toByteArray();
212+ m_genericStorage->fontFamily = uiConstantsHelper->property("font_family").toByteArray();
213
214 // portrait
215-
216- m_portraitStorage->keyboardTotalHeight = portraitConstantsHelper->property("portrait_keyboard_total_height").toInt();
217- m_portraitStorage->keyboardVisibleHeight = portraitConstantsHelper->property("portrait_keyboard_visible_height").toInt();
218- m_portraitStorage->keyboardScreenWidthRatio = portraitConstantsHelper->property("portrait_keyboard_screen_width_ratio").toReal();
219-
220- const int xp = (screenWidth - (screenWidth * m_portraitStorage->keyboardScreenWidthRatio)) / 2;
221+ m_portraitStorage->keyboardTotalHeight = uiConstantsHelper->property("portrait_keyboard_total_height").toInt();
222+ m_portraitStorage->keyboardVisibleHeight = uiConstantsHelper->property("portrait_keyboard_visible_height").toInt();
223+ m_portraitStorage->keyboardScreenWidthRatio = uiConstantsHelper->property("portrait_keyboard_screen_width_ratio").toReal();
224+
225+ const int portraitKeyboardWidth = screenWidth * m_portraitStorage->keyboardScreenWidthRatio;
226+ const int xp = (screenWidth - (portraitKeyboardWidth)) / 2;
227 const int yp = screenHeight - m_portraitStorage->keyboardVisibleHeight;
228
229- m_portraitStorage->keyboardSurfaceRect = QRect(xp, yp, screenWidth, m_portraitStorage->keyboardTotalHeight);
230-
231- m_portraitStorage->keyHeight = portraitConstantsHelper->property("portrait_key_height").toReal();
232- m_portraitStorage->keyWidth = portraitConstantsHelper->property("portrait_key_width").toReal();
233-
234- m_portraitStorage->fontSize = portraitConstantsHelper->property("portrait_font_size").toReal();
235+ m_portraitStorage->keyboardSurfaceRect = QRect(xp, yp, portraitKeyboardWidth, m_portraitStorage->keyboardVisibleHeight);
236+
237+ m_portraitStorage->keyboardTopMargin = uiConstantsHelper->property("portrait_top_margin").toInt();
238+ m_landscapeStorage->keyboardTopMargin = uiConstantsHelper->property("landscape_top_margin").toInt();
239+
240+ m_portraitStorage->keyboardBottomMargin = uiConstantsHelper->property("portrait_bottom_margin").toInt();
241+ m_landscapeStorage->keyboardBottomMargin = uiConstantsHelper->property("landscape_bottom_margin").toInt();
242
243
244 // landscape
245-
246- m_landscapeStorage->keyboardTotalHeight = portraitConstantsHelper->property("landscape_keyboard_total_height").toInt();
247- m_landscapeStorage->keyboardVisibleHeight = portraitConstantsHelper->property("landscape_keyboard_visible_height").toInt();
248- m_landscapeStorage->keyboardScreenWidthRatio = portraitConstantsHelper->property("landscape_keyboard_screen_width_ratio").toReal();
249-
250- const int xl = (screenWidth - (screenWidth * m_landscapeStorage->keyboardScreenWidthRatio)) / 2;
251+ m_landscapeStorage->keyboardTotalHeight = uiConstantsHelper->property("landscape_keyboard_total_height").toInt();
252+ m_landscapeStorage->keyboardVisibleHeight = uiConstantsHelper->property("landscape_keyboard_visible_height").toInt();
253+ m_landscapeStorage->keyboardScreenWidthRatio = uiConstantsHelper->property("landscape_keyboard_screen_width_ratio").toReal();
254+
255+ const int landscapeKeyboardWidth = screenWidth * m_landscapeStorage->keyboardScreenWidthRatio;
256+ const int xl = (screenWidth - (landscapeKeyboardWidth)) / 2;
257 const int yl = screenHeight - m_landscapeStorage->keyboardVisibleHeight;
258
259- m_landscapeStorage->keyboardSurfaceRect = QRect(xl, yl, screenWidth, m_landscapeStorage->keyboardTotalHeight);
260-
261- m_landscapeStorage->keyHeight = portraitConstantsHelper->property("landscape_key_height").toReal();
262- m_landscapeStorage->keyWidth = portraitConstantsHelper->property("landscape_key_width").toReal();
263-
264- m_landscapeStorage->fontSize = portraitConstantsHelper->property("landscape_font_size").toReal();
265-
266+ m_landscapeStorage->keyboardSurfaceRect = QRect(xl, yl, landscapeKeyboardWidth, m_landscapeStorage->keyboardVisibleHeight);
267+
268+ // reference
269+ const QSize referenceSize(
270+ uiConstantsHelper->property("reference_width").toInt(),
271+ uiConstantsHelper->property("reference_height").toInt());
272+
273+ m_landscapeStorage->widthStretchFactor = (qreal) m_landscapeStorage->keyboardSurfaceRect.width() / referenceSize.width();
274+ m_portraitStorage->widthStretchFactor = (qreal) m_portraitStorage->keyboardSurfaceRect.width() / referenceSize.width();
275+
276+ m_genericStorage->keyHeight = uiConstantsHelper->property("key_height").toReal();
277+ m_genericStorage->keyWidthSmall = uiConstantsHelper->property("key_width_small").toReal();
278+ m_genericStorage->keyWidthMedium = uiConstantsHelper->property("key_width_medium").toReal();
279+ m_genericStorage->keyWidthLarge = uiConstantsHelper->property("key_width_large").toReal();
280+ m_genericStorage->keyWidthXLarge = uiConstantsHelper->property("key_width_xlarge").toReal();
281+ m_genericStorage->keyWidthXXLarge = uiConstantsHelper->property("key_width_xxlarge").toReal();
282+
283+
284+ m_landscapeStorage->spaceBetweenRows = uiConstantsHelper->property("landscape_space_between_rows").toReal();
285+ m_landscapeStorage->spaceBetweenKeys = uiConstantsHelper->property("landscape_space_between_keys").toReal();
286+
287+ m_portraitStorage->spaceBetweenRows = uiConstantsHelper->property("portrait_space_between_rows").toReal();
288+ m_portraitStorage->spaceBetweenKeys = uiConstantsHelper->property("portrait_space_between_keys").toReal();
289+
290+ // S M L XL XXL Stretched
291+
292+ m_genericStorage->fontSize = uiConstantsHelper->property("font_size").toReal();
293+
294+ m_genericStorage->keyBackgroundNormal = uiConstantsHelper->property("key_background_normal").toByteArray();
295+ m_genericStorage->keyBackgroundSpecial = uiConstantsHelper->property("key_background_special").toByteArray();
296+ m_genericStorage->keyBackgroundDead = uiConstantsHelper->property("key_background_deadkey").toByteArray();
297
298 m_initialized = true;
299 }
300 }
301
302+qreal UiConstants::keyWidth(LayoutHelper::Orientation orientation, KeyDescription::Width requestedSize)
303+{
304+ qreal width = 1.0;
305+
306+ switch (requestedSize) {
307+ case KeyDescription::Small:
308+ width = m_genericStorage->keyWidthSmall;
309+ break;
310+ case KeyDescription::Medium:
311+ width = m_genericStorage->keyWidthMedium;
312+ break;
313+ case KeyDescription::Large:
314+ width = m_genericStorage->keyWidthLarge;
315+ break;
316+ case KeyDescription::XLarge:
317+ width = m_genericStorage->keyWidthXLarge;
318+ break;
319+ case KeyDescription::XXLarge:
320+ width = m_genericStorage->keyWidthXXLarge;
321+ break;
322+ case KeyDescription::Stretched:
323+ width = m_genericStorage->keyWidthStretched;
324+ break;
325+ default: break;
326+ }
327+
328+ width *= widthStretchFactor(orientation);
329+
330+ return width;
331+}
332+
333+/**
334+ * gaps are defined in dp or gu, while key height stretches
335+ */
336+
337+qreal UiConstants::keyHeight(LayoutHelper::Orientation orientation)
338+{
339+ const qreal numberOfgaps = m_genericStorage->numberOfRows - 1;
340+
341+ switch (orientation) {
342+ case LayoutHelper::Landscape:
343+ {
344+ const qreal gapSize = m_landscapeStorage->spaceBetweenRows;
345+ const qreal bottomMargin = m_landscapeStorage->keyboardBottomMargin;
346+ const qreal topMargin = m_landscapeStorage->keyboardTopMargin;
347+ const qreal keyHeight = (m_landscapeStorage->keyboardSurfaceRect.height()
348+ - (numberOfgaps * gapSize)
349+ - bottomMargin
350+ - topMargin)
351+ / (qreal) m_genericStorage->numberOfRows;
352+ return keyHeight;
353+ }
354+ break;
355+ case LayoutHelper::Portrait:
356+ {
357+ const qreal gapSize = m_portraitStorage->spaceBetweenRows;
358+ const qreal bottomMargin = m_portraitStorage->keyboardBottomMargin;
359+ const qreal topMargin = m_portraitStorage->keyboardTopMargin;
360+ const qreal keyHeight = (m_portraitStorage->keyboardSurfaceRect.height()
361+ - (numberOfgaps * gapSize)
362+ - bottomMargin
363+ - topMargin)
364+ / (qreal) m_genericStorage->numberOfRows;
365+ return keyHeight;
366+ }
367+ break;
368+ default: return 1.0;
369+ }
370+}
371+
372+QByteArray UiConstants::keyBackground(Key::Style style, KeyDescription::State state) const
373+{
374+ Q_UNUSED(state);
375+
376+ switch (style) {
377+ case Key::StyleNormalKey:
378+ return m_genericStorage->keyBackgroundNormal;
379+ case Key::StyleSpecialKey:
380+ return m_genericStorage->keyBackgroundSpecial;
381+ case Key::StyleDeadKey:
382+ return m_genericStorage->keyBackgroundDead;
383+ default: break;
384+ }
385+
386+ return "";
387+}
388+
389 } // namespace Helper
390
391 //! \class KeyAreaConverter
392@@ -166,6 +306,8 @@
393 KeyArea ka;
394 Keyboard kb(source);
395
396+ uiConst->calculateNumberOfRows(kb);
397+
398 if (not attributes) {
399 qCritical() << __PRETTY_FUNCTION__
400 << "No style given, aborting.";
401@@ -191,12 +333,14 @@
402 const qreal padding = attributes->keyAreaPadding(orientation);
403
404
405+
406 QPoint pos(0, 0);
407 QVector<int> row_indices;
408 int spacer_count = 0;
409 qreal consumed_width = 0;
410
411 QVector<int> margins = Helper::calculateMargins(orientation, kb);
412+ qreal margin = margins[0];
413
414 int row = 0;
415 for (int index = 0; index < kb.keys.count(); ++index) {
416@@ -205,16 +349,13 @@
417 const KeyDescription &desc(kb.key_descriptions.at(index));
418
419 int width = 0;
420- pos.setY(key_height * desc.row);
421-
422+ pos.setY((key_height + uiConst->spaceBetweenRows(orientation)) * desc.row + uiConst->keyboardTopMargin(orientation));
423 bool at_row_start((index == 0)
424 || (kb.key_descriptions.at(index - 1).row < desc.row));
425 bool at_row_end((index + 1 == kb.keys.count())
426 || (index + 1 < kb.keys.count()
427 && kb.key_descriptions.at(index + 1).row > desc.row));
428
429- qreal margin = margins[row];
430-
431 if (at_row_end)
432 row++;
433
434@@ -222,13 +363,12 @@
435 ++spacer_count;
436 }
437
438- width = uiConst->keyWidth(orientation);
439- //attributes->keyWidth(orientation, desc.width);
440+ width = uiConst->keyWidth(orientation, desc.width);
441
442 const qreal key_margin((at_row_start || at_row_end) ? margin + padding : margin * 2);
443
444 Area area;
445- area.setBackground(attributes->keyBackground(key.style(), KeyDescription::NormalState));
446+ area.setBackground(uiConst->keyBackground(key.style(), KeyDescription::NormalState));
447 area.setBackgroundBorders(bg_margins);
448 area.setSize(QSize(width + key_margin, key_height));
449 key.setArea(area);
450
451=== modified file 'maliit-keyboard/lib/logic/keyareaconverter.h'
452--- maliit-keyboard/lib/logic/keyareaconverter.h 2013-04-12 13:53:03 +0000
453+++ maliit-keyboard/lib/logic/keyareaconverter.h 2013-04-25 19:09:24 +0000
454@@ -33,6 +33,9 @@
455 #define MALIIT_KEYBOARD_KEYAREACONVERTER_H
456
457 #include "logic/layouthelper.h"
458+#include "models/keydescription.h"
459+#include "models/keyboard.h"
460+
461 #include <QPoint>
462 #include <QColor>
463
464@@ -78,16 +81,40 @@
465 class UiConstants {
466
467 struct UiConstantsStorage {
468+ UiConstantsStorage()
469+ : widthStretchFactor(1.0),
470+ heightStretchFactor(1.0),
471+ numberOfRows(0)
472+ {
473+ }
474+
475 int keyboardTotalHeight;
476 int keyboardVisibleHeight;
477 QRect keyboardSurfaceRect;
478 qreal keyboardScreenWidthRatio;
479 qreal keyHeight;
480- qreal keyWidth;
481+ qreal keyWidthSmall;
482+ qreal keyWidthMedium;
483+ qreal keyWidthLarge;
484+ qreal keyWidthXLarge;
485+ qreal keyWidthXXLarge;
486+ qreal keyWidthStretched;
487 QMargins keyAreaBorders;
488 qreal fontSize;
489 QByteArray fontColor;
490 QByteArray fontFamily;
491+ qreal widthStretchFactor;
492+ qreal heightStretchFactor;
493+ qreal keyboardTopMargin;
494+ qreal keyboardBottomMargin;
495+
496+ QByteArray keyBackgroundNormal;
497+ QByteArray keyBackgroundSpecial;
498+ QByteArray keyBackgroundDead;
499+
500+ int numberOfRows;
501+ qreal spaceBetweenRows;
502+ qreal spaceBetweenKeys;
503 };
504
505 public:
506@@ -105,14 +132,25 @@
507 QRect& keyboardSurfaceRect(LayoutHelper::Orientation orientation) { return storage(orientation)->keyboardSurfaceRect; }
508 qreal keyboardScreenWidthRatio(LayoutHelper::Orientation orientation) { return storage(orientation)->keyboardScreenWidthRatio; }
509
510- qreal keyHeight(LayoutHelper::Orientation orientation) { return storage(orientation)->keyHeight; }
511- qreal keyWidth(LayoutHelper::Orientation orientation) { return storage(orientation)->keyWidth; }
512+ qreal keyHeight(LayoutHelper::Orientation orientation);
513+ qreal keyWidth(LayoutHelper::Orientation orientation, KeyDescription::Width width);
514+
515 QMargins keyAreaBorders() { return m_genericStorage->keyAreaBorders; }
516
517- qreal fontSize(LayoutHelper::Orientation orientation) { return storage(orientation)->fontSize; }
518+ qreal fontSize(LayoutHelper::Orientation orientation) { return m_genericStorage->fontSize; }
519 QByteArray fontColor() { return m_genericStorage->fontColor; }
520 QByteArray fontFamily() { return m_genericStorage->fontFamily; }
521
522+ qreal keyboardTopMargin(LayoutHelper::Orientation orientation) { return storage(orientation)->keyboardTopMargin; }
523+
524+ QByteArray keyBackground(Key::Style style, KeyDescription::State state) const;
525+
526+ qreal spaceBetweenRows(LayoutHelper::Orientation orientation) { return storage(orientation)->spaceBetweenRows; }
527+ qreal spaceBetweenKeys(LayoutHelper::Orientation orientation) { return storage(orientation)->spaceBetweenKeys; }
528+
529+ void calculateNumberOfRows(Keyboard& kb);
530+ int numberOfRows() const { return m_genericStorage->numberOfRows; }
531+
532 private:
533 UiConstants()
534 : m_initialized(false),
535@@ -134,6 +172,33 @@
536 return m_portraitStorage;
537 }
538
539+ qreal widthStretchFactor(LayoutHelper::Orientation orientation)
540+ {
541+ switch (orientation) {
542+ case LayoutHelper::Landscape:
543+ return m_landscapeStorage->widthStretchFactor;
544+ break;
545+ case LayoutHelper::Portrait:
546+ return m_portraitStorage->widthStretchFactor;
547+ break;
548+ default: return 1.0;
549+ }
550+ }
551+
552+ qreal heightStretchFactor(LayoutHelper::Orientation orientation)
553+ {
554+ switch (orientation) {
555+ case LayoutHelper::Landscape:
556+ return m_landscapeStorage->heightStretchFactor;
557+ break;
558+ case LayoutHelper::Portrait:
559+ return m_portraitStorage->heightStretchFactor;
560+ break;
561+ default: return 1.0;
562+ }
563+ }
564+
565+
566 UiConstantsStorage* m_portraitStorage;
567 UiConstantsStorage* m_landscapeStorage;
568 UiConstantsStorage* m_genericStorage;
569
570=== modified file 'maliit-keyboard/plugin/inputmethod.cpp'
571--- maliit-keyboard/plugin/inputmethod.cpp 2013-04-11 11:47:44 +0000
572+++ maliit-keyboard/plugin/inputmethod.cpp 2013-04-25 19:09:24 +0000
573@@ -372,7 +372,18 @@
574 d->extended_surface->show();
575 d->magnifier_surface->show();
576
577+ inputMethodHost()->setScreenRegion(QRegion(d->keyboardSurfaceRect));
578+ inputMethodHost()->setInputMethodArea(QRegion(d->keyboardSurfaceRect));
579+
580 #ifdef HAVE_UBUNTU_PLATFORM_API
581+
582+ qCritical() << "keyboard is reporting <x y w h>: <"
583+ << d->keyboardSurfaceRect.x()
584+ << d->keyboardSurfaceRect.y()
585+ << d->keyboardSurfaceRect.width()
586+ << d->keyboardSurfaceRect.height()
587+ << "> to the app manager.";
588+
589 ubuntu_ui_report_osk_visible(
590 d->keyboardSurfaceRect.x(),
591 d->keyboardSurfaceRect.y(),
592@@ -391,6 +402,9 @@
593 d->extended_surface->hide();
594 d->magnifier_surface->hide();
595
596+ inputMethodHost()->setScreenRegion(QRegion(0,0,0,0));
597+ inputMethodHost()->setInputMethodArea(QRegion(0,0,0,0));
598+
599 #ifdef HAVE_UBUNTU_PLATFORM_API
600 ubuntu_ui_report_osk_invisible();
601 #endif
602@@ -448,6 +462,12 @@
603 return d->layout.updater.activeKeyboardId();
604 }
605
606+void InputMethod::handleFocusChange(bool focusIn) {
607+ qCritical() << "handleFocusChange" << focusIn;
608+ if (not focusIn)
609+ hide();
610+}
611+
612 void InputMethod::handleAppOrientationChanged(int angle)
613 {
614 Q_D(InputMethod);
615@@ -558,6 +578,7 @@
616 QVariantMap attributes;
617 attributes[Maliit::SettingEntryAttributes::defaultValue] = true;
618
619+#ifdef TEMP_DISABLED
620 d->settings.word_engine.reset(host->registerPluginSetting("word_engine_enabled",
621 QT_TR_NOOP("Error correction/word prediction enabled"),
622 Maliit::BoolType,
623@@ -565,6 +586,7 @@
624
625 connect(d->settings.word_engine.data(), SIGNAL(valueChanged()),
626 this, SLOT(onWordEngineSettingChanged()));
627+#endif
628
629 #ifndef DISABLE_PREEDIT
630 d->editor.wordEngine()->setEnabled(d->settings.word_engine->value().toBool());
631
632=== modified file 'maliit-keyboard/plugin/inputmethod.h'
633--- maliit-keyboard/plugin/inputmethod.h 2013-03-22 16:40:29 +0000
634+++ maliit-keyboard/plugin/inputmethod.h 2013-04-25 19:09:24 +0000
635@@ -64,6 +64,7 @@
636 virtual void setActiveSubView(const QString &id,
637 Maliit::HandlerState state = Maliit::OnScreen);
638 virtual QString activeSubView(Maliit::HandlerState state = Maliit::OnScreen) const;
639+ virtual void handleFocusChange(bool focusIn);
640 virtual void handleAppOrientationChanged(int angle);
641 virtual bool imExtensionEvent(MImExtensionEvent *event);
642 virtual void setKeyOverrides(const QMap<QString, QSharedPointer<MKeyOverride> > &overrides);
643
644=== modified file 'maliit-keyboard/qml/Keyboard.qml'
645--- maliit-keyboard/qml/Keyboard.qml 2013-04-09 13:04:53 +0000
646+++ maliit-keyboard/qml/Keyboard.qml 2013-04-25 19:09:24 +0000
647@@ -60,6 +60,14 @@
648 }
649 }
650
651+ Text {
652+ id: debugText
653+ text: "Maliit-Keyboard"
654+ font.pointSize: 18
655+ color: "#BBBBBB"
656+ width: parent.width
657+ }
658+
659 Image {
660 id: borderTop
661 source: "styles/ubuntu/images/border_top.png"
662@@ -82,7 +90,7 @@
663
664 Item {
665 x: key_reactive_area.x
666- y: key_reactive_area.y + 24.3
667+ y: key_reactive_area.y
668 width: key_reactive_area.width
669 height: key_reactive_area.height
670
671
672=== modified file 'maliit-keyboard/qml/maliit-ui-constants.qml'
673--- maliit-keyboard/qml/maliit-ui-constants.qml 2013-04-12 13:53:03 +0000
674+++ maliit-keyboard/qml/maliit-ui-constants.qml 2013-04-25 19:09:24 +0000
675@@ -15,23 +15,40 @@
676 property string font_color: "#666666"
677 property string font_family: "Ubuntu Medium"
678
679+ property int reference_width: units.gu( 40.0 );
680+ property int reference_height: units.gu( 26.0 );
681
682 property int portrait_keyboard_total_height: units.gu( 32.777 );
683 property int portrait_keyboard_visible_height: units.gu( 26.0 );
684- property real portrait_keyboard_screen_width_ratio: 0.8
685-
686- property real portrait_key_height: units.gu( 4.888 );
687- property real portrait_key_width: units.gu( 3.666 );
688- property real portrait_font_size: units.gu( 2.111 );
689+ property real portrait_keyboard_screen_width_ratio: 1.0
690+
691+ property real portrait_top_margin: units.gu( 1.35 );
692+ property real landscape_top_margin: units.gu( 4.35 );
693+ property real portrait_bottom_margin: units.gu( 2.00 );
694+ property real landscape_bottom_margin: units.gu( 2.00 );
695+
696+ property real key_height: units.gu( 4.888 );
697+
698+ property real key_width_small: units.gu( 3.166 );
699+ property real key_width_medium: units.gu( 3.666 );
700+ property real key_width_large: units.gu( 4.222 ); // shift
701+ property real key_width_xlarge: units.gu( 6.0 ); // 123 key
702+ property real key_width_xxlarge: units.gu( 17.0 ); // space
703+ property real key_width_stretched: units.gu( 3.0 ); // ?
704+
705+ property real font_size: units.gu( 2.111 );
706
707
708 property int landscape_keyboard_total_height: units.gu( 39.5 );
709 property int landscape_keyboard_visible_height: units.gu( 33.4 );
710 property real landscape_keyboard_screen_width_ratio: 1.0
711
712- property real landscape_key_height: units.gu( 7.0 );
713- property real landscape_key_width: units.gu( 12.0 );
714- property real landscape_font_size: units.gu( 3.111 );
715-
716-
717+ property real landscape_space_between_rows: units.dp( 2.00 );
718+ property real landscape_space_between_keys: units.dp( 10.00 );
719+ property real portrait_space_between_rows: units.dp( 2.00 );
720+ property real portrait_space_between_keys: units.dp( 10.00 );
721+
722+ property string key_background_normal: "keybg@18.png"
723+ property string key_background_special: "keybg_action@18.png"
724+ property string key_background_deadkey: ""
725 }
726
727=== added directory 'maliit-keyboard/tests/qml-test-app'
728=== added file 'maliit-keyboard/tests/qml-test-app/keyboard-test.qml'
729--- maliit-keyboard/tests/qml-test-app/keyboard-test.qml 1970-01-01 00:00:00 +0000
730+++ maliit-keyboard/tests/qml-test-app/keyboard-test.qml 2013-04-25 19:09:24 +0000
731@@ -0,0 +1,226 @@
732+
733+
734+import QtQuick 2.0
735+import Ubuntu.Components 0.1
736+
737+Item {
738+ id: root
739+
740+ width: units.gu(18)
741+ height: units.gu(18)
742+
743+ Rectangle {
744+ anchors.fill: parent
745+ color: "lightblue"
746+ }
747+
748+ Column {
749+
750+ y: units.gu(3)
751+ width: parent.width
752+ anchors.horizontalCenter: parent.horizontalCenter
753+ spacing: units.gu(1)
754+
755+ anchors.margins: units.gu(1)
756+
757+ Text {
758+ id: label
759+ text: "OSK TestApp"
760+ anchors.horizontalCenter: parent.horizontalCenter
761+ font.pixelSize: units.gu(2)
762+ font.bold: true
763+ }
764+
765+ Row {
766+ anchors.horizontalCenter: parent.horizontalCenter;
767+ spacing: units.gu(1)
768+
769+ Button {
770+ color: "red"
771+ text: "show()"
772+ width: units.gu(18)
773+ onClicked: Qt.inputMethod.show()
774+
775+ }
776+
777+ Button {
778+ color: "red"
779+ text: "hide()"
780+ width: units.gu(18)
781+ onClicked: Qt.inputMethod.hide()
782+ }
783+ }
784+
785+ Text {
786+ anchors.horizontalCenter: parent.horizontalCenter;
787+
788+ text: qsTr("note: show/hide requires focus on a text input")
789+ font.pixelSize: units.gu(1)
790+ color: "gray"
791+ }
792+
793+ Row {
794+ anchors.horizontalCenter: parent.horizontalCenter
795+
796+ spacing: units.gu(1)
797+
798+ Rectangle {
799+ width: units.gu(18);
800+ height: firstInputButton.height;
801+
802+ anchors.leftMargin: units.gu(1)
803+
804+ color: "white"
805+
806+ TextInput {
807+ id: input;
808+ anchors.fill: parent
809+ color: "black"; selectionColor: "red"
810+
811+ inputMethodHints: Qt.ImhPreferNumbers
812+ font.pixelSize: units.gu(3)
813+ font.bold: true
814+ }
815+ }
816+
817+ Button {
818+ id: firstInputButton
819+ color: "yellow"
820+ text: "Focus/Unfocus"
821+ width: units.gu(18)
822+ onClicked: input.focus = !input.focus
823+ }
824+ }
825+
826+ Row {
827+ anchors.horizontalCenter: parent.horizontalCenter;
828+
829+ spacing: units.gu(1)
830+
831+ Rectangle {
832+ width: units.gu(18);
833+ height: secondInputButton.height
834+
835+ color: "white"
836+
837+ TextInput {
838+ id: secondInput;
839+
840+ anchors.fill: parent
841+
842+ font.pixelSize: units.gu(3)
843+ }
844+ }
845+
846+ Button {
847+ id: secondInputButton
848+ color: "yellow"
849+ text: "Focus/Unfocus"
850+ width: units.gu(18)
851+ onClicked: secondInput.focus = !secondInput.focus
852+ }
853+ }
854+
855+ Row {
856+ anchors.horizontalCenter: parent.horizontalCenter;
857+
858+ Text {
859+ id: textRectangle
860+
861+ font.pixelSize: units.gu(1)
862+ text: Qt.inputMethod.keyboardRectangle + " "
863+ }
864+
865+ Rectangle {
866+ id: clickBehindOSKDetectedIndicator
867+
868+ width: units.gu(18)
869+ height: units.gu(3)
870+ state: "default"
871+
872+ Text {
873+ id: clickBehindOSKDetectedIndicatorText
874+ anchors.centerIn: parent
875+ text: "clicked"
876+ font.pixelSize: units.gu(2)
877+ font.bold: true
878+ }
879+
880+ states: [
881+ State {
882+ name: "default"
883+ PropertyChanges {
884+ target: clickBehindOSKDetectedIndicator
885+ color: "gray"
886+ }
887+ PropertyChanges {
888+ target: clickBehindOSKDetectedIndicatorText
889+ color: "gray"
890+ }
891+ },
892+ State {
893+ name: "highlight"
894+ PropertyChanges {
895+ target: clickBehindOSKDetectedIndicator
896+ color: "red"
897+ }
898+ PropertyChanges {
899+ target: clickBehindOSKDetectedIndicatorText
900+ color: "white"
901+ }
902+ }
903+ ]
904+ }
905+
906+ }
907+
908+ Text {
909+ id: textVisible
910+
911+ anchors.horizontalCenter: parent.horizontalCenter;
912+
913+ font.pixelSize: units.gu(2)
914+ text: "keyboard reports visible: " + Qt.inputMethod.visible
915+ }
916+
917+ } // column
918+
919+ Rectangle {
920+ id: fakeBrowserUrlBar
921+ width: keyboardRect.width
922+ height: units.gu(4)
923+ color: "orange"
924+ anchors.bottom: keyboardRect.top
925+
926+ Text {
927+ visible: Qt.inputMethod.visible
928+ anchors.centerIn: parent
929+ font.pixelSize: units.gu(1)
930+ text: "browser url bar"
931+ }
932+ }
933+
934+ Rectangle {
935+ id: keyboardRect
936+
937+ width: Qt.inputMethod.keyboardRectangle.width
938+ height: Qt.inputMethod.keyboardRectangle.height
939+
940+ anchors.bottom: parent.bottom
941+ color: " green"
942+
943+ Text {
944+ visible: Qt.inputMethod.visible
945+ anchors.centerIn: parent
946+ font.pointSize: 24
947+ text: Qt.inputMethod.keyboardRectangle + " "
948+ }
949+
950+ MouseArea {
951+ anchors.fill: parent
952+ onClicked: clickBehindOSKDetectedIndicator.visible = true
953+ onPressed: clickBehindOSKDetectedIndicator.state = "highlight"
954+ onReleased: clickBehindOSKDetectedIndicator.state = "default"
955+ }
956+ }
957+}
958
959=== added file 'maliit-keyboard/tests/qml-test-app/qml-test-app.pro'
960--- maliit-keyboard/tests/qml-test-app/qml-test-app.pro 1970-01-01 00:00:00 +0000
961+++ maliit-keyboard/tests/qml-test-app/qml-test-app.pro 2013-04-25 19:09:24 +0000
962@@ -0,0 +1,12 @@
963+include(../config.pri)
964+
965+TARGET = dummy
966+TEMPLATE = lib
967+
968+qml.path = $$MALIIT_KEYBOARD_DATA_DIR/testapp
969+qml.files = *.qml
970+
971+INSTALLS += qml
972+OTHER_FILES += \
973+ keyboard-test.qml
974+
975
976=== modified file 'maliit-keyboard/tests/tests.pro'
977--- maliit-keyboard/tests/tests.pro 2013-03-22 16:40:29 +0000
978+++ maliit-keyboard/tests/tests.pro 2013-04-25 19:09:24 +0000
979@@ -7,6 +7,7 @@
980 repeat-backspace \
981 word-candidates \
982 language-layout-loading \
983+ qml-test-app \
984
985 CONFIG += ordered
986 QMAKE_EXTRA_TARGETS += check

Subscribers

People subscribed via source and target branches