Merge lp:~thomas-moenicke/ubuntu-keyboard/ubuntu-keyboard-cleanup into lp:ubuntu-keyboard

Proposed by Thomas Moenicke
Status: Merged
Merged at revision: 113
Proposed branch: lp:~thomas-moenicke/ubuntu-keyboard/ubuntu-keyboard-cleanup
Merge into: lp:ubuntu-keyboard
Diff against target: 1281 lines (+91/-946)
14 files modified
buildOnDevice.sh (+1/-1)
qml/Keyboard.qml (+34/-6)
qml/keys/key_constants.js (+9/-0)
qml/maliit-ui-constants.qml (+0/-64)
qml/qml.pro (+0/-1)
src/lib/logic/dynamiclayout.cpp (+0/-337)
src/lib/logic/dynamiclayout.h (+0/-110)
src/lib/logic/dynamiclayout_p.h (+0/-325)
src/lib/logic/logic.pri (+0/-2)
src/lib/models/layout.cpp (+0/-16)
src/lib/models/layout.h (+0/-10)
src/plugin/inputmethod.cpp (+28/-23)
src/plugin/inputmethod.h (+2/-0)
src/plugin/inputmethod_p.h (+17/-51)
To merge this branch: bzr merge lp:~thomas-moenicke/ubuntu-keyboard/ubuntu-keyboard-cleanup
Reviewer Review Type Date Requested Status
Günter Schwann (community) Approve
Review via email: mp+195029@code.launchpad.net

Commit message

cleanup

Description of the change

cleanup
moving size related stuff to qml

To post a comment you must log in.
103. By Thomas Moenicke

removing dynamiclayout code

104. By Thomas Moenicke

fix inverted-landscape and inverted-portrait

105. By Thomas Moenicke

rebase

106. By Thomas Moenicke

fixing coding style

107. By Thomas Moenicke

removed unused maliit-ui-constants.qml

108. By Thomas Moenicke

removed file that accidently ended up in this MR

109. By Thomas Moenicke

considering wordribbon size for canvas size

110. By Thomas Moenicke

rebase

111. By Thomas Moenicke

ouch

112. By Thomas Moenicke

resize canvas when wordribbon changes (causes issue of osk being squeezed when going from browser to msg app with wordribbon enabled)

Revision history for this message
Günter Schwann (schwann) wrote :

works well

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildOnDevice.sh'
2--- buildOnDevice.sh 2013-11-15 09:32:12 +0000
3+++ buildOnDevice.sh 2013-11-15 12:46:02 +0000
4@@ -51,7 +51,7 @@
5 sleep 2
6 exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb libglib2.0-bin unzip
7 # exec_with_ssh $SUDO add-apt-repository -s -y ppa:phablet-team/ppa
8-# exec_with_ssh $SUDO apt-get update
9+ exec_with_ssh $SUDO apt-get update
10 exec_with_ssh $SUDO apt-get -y build-dep $PACKAGE
11 }
12
13
14=== modified file 'qml/Keyboard.qml'
15--- qml/Keyboard.qml 2013-11-08 08:19:50 +0000
16+++ qml/Keyboard.qml 2013-11-15 12:46:02 +0000
17@@ -44,13 +44,18 @@
18 property variant layout: maliit_layout
19 property variant event_handler: maliit_event_handler
20
21+ onHeightChanged: calculateSize();
22+
23 OrientationHelper {
24+ id: orientationHelper
25 automaticOrientation: false
26 transitionEnabled: false
27
28 orientationAngle: Screen.angleBetween(Screen.primaryOrientation, canvas.contentOrientation);
29
30- onOrientationAngleChanged: fullScreenItem.reportKeyboardVisibleRect();
31+ onOrientationAngleChanged: {
32+ calculateSize();
33+ }
34 onXChanged: fullScreenItem.reportKeyboardVisibleRect();
35 onYChanged: fullScreenItem.reportKeyboardVisibleRect();
36 onWidthChanged: fullScreenItem.reportKeyboardVisibleRect();
37@@ -64,9 +69,11 @@
38 anchors.left: parent.left
39
40 width: parent.width
41- height: maliit_geometry.canvasHeight
42-
43- property int keypadHeight: maliit_geometry.keypadHeight
44+ height: 0
45+
46+ property int keypadHeight: height;
47+
48+ onRotationChanged: console.log("now rotation has changed!!" + rotation)
49
50 visible: true
51
52@@ -78,6 +85,7 @@
53 onContentOrientationChanged: fullScreenItem.reportKeyboardVisibleRect();
54
55 property bool wordribbon_visible: maliit_input_method.showWordRibbon
56+ onWordribbon_visibleChanged: calculateSize();
57
58 property bool languageMenuShown: false
59
60@@ -135,8 +143,8 @@
61 anchors.bottom: keyboardComp.top
62 width: parent.width;
63
64- height: visible ? layout.wordribbon_height : 0
65- onHeightChanged: fullScreenItem.reportKeyboardVisibleRect();
66+ height: canvas.wordribbon_visible ? UI.wordribbonHeight : 0
67+ onHeightChanged: calculateSize();
68 }
69
70 Item {
71@@ -245,9 +253,29 @@
72 } // canvas
73 } // OrientationHelper
74
75+function calculateSize()
76+{
77+ // TODO tablet
78+ if (orientationHelper.orientationAngle == 270 ||
79+ orientationHelper.orientationAngle == 90) {
80+ canvas.height = (fullScreenItem.width * UI.phoneKeyboardHeightLandscape) + wordRibbon.height
81+ } else if (orientationHelper.orientationAngle == 0 ||
82+ orientationHelper.orientationAngle == 180) {
83+ canvas.height = (fullScreenItem.height * UI.phoneKeyboardHeightPortrait) + wordRibbon.height
84+ }
85+
86+
87+ else { // fallback
88+ canvas.height = (fullScreenItem.height * UI.phoneKeyboardHeightPortrait) + wordRibbon.height
89+ }
90+
91+ reportKeyboardVisibleRect();
92+}
93+
94 // calculates the size of the visible keyboard to report to the window system
95 // FIXME get the correct size for enabled extended keys instead of that big area
96 function reportKeyboardVisibleRect() {
97+
98 var vx = 0;
99 var vy = wordRibbon.y;
100 var vwidth = keyboardSurface.width;
101
102=== modified file 'qml/keys/key_constants.js'
103--- qml/keys/key_constants.js 2013-10-25 13:16:15 +0000
104+++ qml/keys/key_constants.js 2013-11-15 12:46:02 +0000
105@@ -57,3 +57,12 @@
106 /* language menu */
107 var languageMenuListViewPadding = 2.22; // gu
108 var languageMenuCorner = 2.5; // gu
109+
110+
111+var wordribbonHeight = 72;
112+
113+var phoneKeyboardHeightPortrait = 0.365;
114+var phoneKeyboardHeightLandscape = 0.50;
115+
116+var tabletKeyboardHeightPortrait = 0.28;
117+var tabletKeyboardHeightLandscape = 0.38;
118
119=== removed file 'qml/maliit-ui-constants.qml'
120--- qml/maliit-ui-constants.qml 2013-07-19 12:05:07 +0000
121+++ qml/maliit-ui-constants.qml 1970-01-01 00:00:00 +0000
122@@ -1,64 +0,0 @@
123-
124-
125-import QtQuick 2.0
126-import Ubuntu.Components 0.1
127-
128-
129-/**
130- * these items only hold variables
131- */
132-
133-Item {
134- id: keyboard_constants
135-
136- property real key_area_borders: units.gu( 1.222 );
137- property string font_color: "#666666"
138- property string font_family: "Ubuntu Medium"
139-
140- property int reference_width: units.gu( 40.0 );
141- property int reference_height: units.gu( 26.0 );
142-
143- property int portrait_invisible_touch_area: units.gu( 6.777 );
144- property int portrait_keyboard_visible_height: units.gu( 26.0 );
145- property real portrait_keyboard_screen_width_ratio: 1.0
146-
147- property real portrait_top_margin: units.gu( 1.35 );
148- property real landscape_top_margin: units.gu( 4.35 );
149- property real portrait_bottom_margin: units.gu( 2.00 );
150- property real landscape_bottom_margin: units.gu( 2.00 );
151-
152- property real key_height: units.gu( 4.888 );
153-
154- property real key_width_small: units.gu( 3.166 );
155- property real key_width_medium: units.gu( 3.666 );
156- property real key_width_large: units.gu( 4.222 ); // shift
157- property real key_width_xlarge: units.gu( 6.0 ); // 123 key
158- property real key_width_xxlarge: units.gu( 17.0 ); // space
159- property real key_width_stretched: units.gu( 3.0 ); // ?
160-
161- property real font_size: units.gu( 2.111 );
162- property real font_size_small: units.gu( 1.8 );
163-
164- property int landscape_invisible_touch_area: units.gu( 6.777 );
165- property int landscape_keyboard_visible_height: units.gu( 33.4 );
166- property real landscape_keyboard_screen_width_ratio: 1.0
167-
168- property real landscape_space_between_rows: units.dp( 0.00 );
169- property real landscape_space_between_keys: units.dp( 0.00 );
170- property real portrait_space_between_rows: units.dp( 2.00 );
171- property real portrait_space_between_keys: units.dp( 10.00 );
172-
173- property string key_background_normal: "keybg@18.png"
174- property string key_background_special: "keybg_action@18.png"
175- property string key_background_deadkey: ""
176-
177- property real phone_keyboard_height_portrait: 0.365;
178- property real phone_keyboard_height_landscape: 0.50;
179-
180- property real tablet_keyboard_height_portrait: 0.28;
181- property real tablet_keyboard_height_landscape: 0.38;
182-
183- property int landscape_wordribbon_height: units.gu( 4.0 );
184- property int portrait_wordribbon_height: units.gu( 4.0 );
185-}
186-
187
188=== modified file 'qml/qml.pro'
189--- qml/qml.pro 2013-11-13 16:31:52 +0000
190+++ qml/qml.pro 2013-11-15 12:46:02 +0000
191@@ -91,7 +91,6 @@
192 maliit-keyboard.qml \
193 maliit-keyboard-extended.qml \
194 maliit-magnifier.qml \
195- maliit-ui-constants.qml \
196 Keyboard.qml \
197 KeyboardContainer.qml \
198 Popper.qml \
199
200=== removed file 'src/lib/logic/dynamiclayout.cpp'
201--- src/lib/logic/dynamiclayout.cpp 2013-08-09 15:22:29 +0000
202+++ src/lib/logic/dynamiclayout.cpp 1970-01-01 00:00:00 +0000
203@@ -1,337 +0,0 @@
204-/*
205- * Copyright 2013 Canonical Ltd.
206- *
207- * This program is free software; you can redistribute it and/or modify
208- * it under the terms of the GNU Lesser General Public License as published by
209- * the Free Software Foundation; version 3.
210- *
211- * This program is distributed in the hope that it will be useful,
212- * but WITHOUT ANY WARRANTY; without even the implied warranty of
213- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
214- * GNU Lesser General Public License for more details.
215- *
216- * You should have received a copy of the GNU Lesser General Public License
217- * along with this program. If not, see <http://www.gnu.org/licenses/>.
218- */
219-
220-#include "dynamiclayout.h"
221-#include "dynamiclayout_p.h"
222-
223-namespace MaliitKeyboard {
224-namespace Logic {
225-
226-int calculateVerticalMargin(LayoutHelper::Orientation orientation, Keyboard& kb)
227-{
228- Q_UNUSED(kb);
229-
230- const int freeSpace = uiConst->keypadHeight(orientation)
231- - (uiConst->keyHeight(orientation) * uiConst->numberOfRows())
232- - uiConst->keypadTopMargin(orientation);
233-
234- const int vMargin = (freeSpace / (uiConst->numberOfRows()-1)) / 2;
235-
236- return vMargin;
237-}
238-
239-/*
240- * calculates margin per row
241- **/
242-
243-QVector<int> DynamicLayout::calculateMargins(LayoutHelper::Orientation orientation,
244- Keyboard& kb)
245-{
246- const qreal keyboardWidth = windowWidth(orientation);
247-
248- QVector<int> margins;
249- int spaceTakenByKeys = 0;
250- int numberOfKeysInRow = 0;
251- for (int index = 0; index < kb.keys.count(); ++index) {
252- const KeyDescription &desc(kb.key_descriptions.at(index));
253- int width = uiConst->keyWidth(orientation, desc.width);
254- spaceTakenByKeys += width;
255- numberOfKeysInRow++;
256-
257- bool at_row_end((index + 1 == kb.keys.count())
258- || (index + 1 < kb.keys.count()
259- && kb.key_descriptions.at(index + 1).row > desc.row));
260-
261- if (at_row_end) {
262- int marginThisRow = ( (keyboardWidth - spaceTakenByKeys) / (numberOfKeysInRow-1) ) / 2;
263- margins.append(marginThisRow);
264- spaceTakenByKeys = 0;
265- }
266- }
267-
268- return margins;
269-}
270-
271-void DynamicLayout::calculateNumberOfRows(Keyboard& kb)
272-{
273- if(d->genericStorage->numberOfRows > 0)
274- return;
275-
276- d->genericStorage->numberOfRows = 0;
277- for (int index = 0; index < kb.keys.count(); ++index) {
278- const KeyDescription &desc(kb.key_descriptions.at(index));
279- bool at_row_end((index + 1 == kb.keys.count())
280- || (index + 1 < kb.keys.count()
281- && kb.key_descriptions.at(index + 1).row > desc.row));
282-
283- if (at_row_end)
284- d->genericStorage->numberOfRows++;
285- }
286-}
287-
288-DynamicLayout::DynamicLayout(QObject* parent) : QObject(parent),
289- d(new DynamicLayoutPrivate(this))
290-{
291- const QScreen* screen = qGuiApp->primaryScreen();
292- connect( screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), this, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
293- connect( screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(onPrimaryOrientationChanged(Qt::ScreenOrientation)) );
294- connect( screen, SIGNAL(geometryChanged(QRect)), this, SLOT(onGeometryChanged(QRect)) );
295-
296- d->primaryOrientation = screen->primaryOrientation();
297- d->orientation = screen->orientation();
298- d->geometry = screen->geometry();
299-}
300-
301-
302-DynamicLayout* DynamicLayout::self = 0;
303-
304-void DynamicLayout::initDynamicLayout(QString fileName)
305-{
306- d->initDynamicLayout(fileName);
307-}
308-
309-int DynamicLayout::windowWidth(LayoutHelper::Orientation orientation)
310-{
311- return d->storage(orientation)->windowGeometryRect.width();
312-}
313-
314-QRect DynamicLayout::windowGeometryRect(Qt::ScreenOrientation orientation)
315-{
316- if (orientation != d->cachedOrientation)
317- d->invalidateWindowGeometryCache();
318-
319- if ( !d->windowGeometryCacheValid ) {
320- LayoutHelper::Orientation maliitOrientation = LayoutHelper::Landscape;
321-
322- if (orientation == Qt::PortraitOrientation || orientation == Qt::InvertedPortraitOrientation)
323- maliitOrientation = LayoutHelper::Portrait;
324-
325- if (orientation == Qt::InvertedLandscapeOrientation || orientation == Qt::InvertedPortraitOrientation) {
326- if (!d->wordRibbonEnabled) {
327- return d->writeCache( orientation, d->storage(maliitOrientation)->windowGeometryRectInverted
328- .adjusted (0, wordRibbonHeight(maliitOrientation), 0, 0)
329- .translated(0,-wordRibbonHeight(maliitOrientation)) );
330- } else {
331- return d->writeCache( orientation, d->storage(maliitOrientation)->windowGeometryRectInverted );
332- }
333- }
334-
335- if (!d->wordRibbonEnabled)
336- return d->writeCache( orientation, d->storage(maliitOrientation)->windowGeometryRect.adjusted(0, d->storage(maliitOrientation)->wordRibbonHeight, 0, 0) );
337-
338- return d->writeCache( orientation, d->storage(maliitOrientation)->windowGeometryRect );
339- }
340-
341- return d->windowGeometryRectCached;
342-}
343-
344-qreal DynamicLayout::keyWidth(LayoutHelper::Orientation orientation, KeyDescription::Width requestedSize)
345-{
346- qreal width = 1.0;
347-
348- switch (requestedSize) {
349- case KeyDescription::Small:
350- width = d->genericStorage->keyWidthSmall;
351- break;
352- case KeyDescription::Medium:
353- width = d->genericStorage->keyWidthMedium;
354- break;
355- case KeyDescription::Large:
356- width = d->genericStorage->keyWidthLarge;
357- break;
358- case KeyDescription::XLarge:
359- width = d->genericStorage->keyWidthXLarge;
360- break;
361- case KeyDescription::XXLarge:
362- width = d->genericStorage->keyWidthXXLarge;
363- break;
364- case KeyDescription::Stretched:
365- width = d->genericStorage->keyWidthStretched;
366- break;
367- default: break;
368- }
369-
370- width *= d->widthStretchFactor(orientation);
371-
372- return width;
373-}
374-
375-/**
376- * gaps are defined in dp or gu, while key height stretches
377- */
378-
379-qreal DynamicLayout::keyHeight(LayoutHelper::Orientation orientation)
380-{
381- const qreal numberOfgaps = d->genericStorage->numberOfRows - 1;
382-
383- switch (orientation) {
384- case LayoutHelper::Landscape:
385- {
386- const qreal gapSize = d->landscapeStorage->spaceBetweenRows;
387- const qreal bottomMargin = d->landscapeStorage->keyboardBottomMargin;
388- const qreal topMargin = d->landscapeStorage->keypadTopMargin;
389- const qreal keyHeight = (d->landscapeStorage->keypadHeight
390- - (numberOfgaps * gapSize)
391- - bottomMargin
392- - topMargin)
393- / (qreal) d->genericStorage->numberOfRows;
394- return keyHeight;
395- }
396- break;
397- case LayoutHelper::Portrait:
398- {
399- const qreal gapSize = d->portraitStorage->spaceBetweenRows;
400- const qreal bottomMargin = d->portraitStorage->keyboardBottomMargin;
401- const qreal topMargin = d->portraitStorage->keypadTopMargin;
402- const qreal keyHeight = (d->portraitStorage->keypadHeight
403- - (numberOfgaps * gapSize)
404- - bottomMargin
405- - topMargin)
406- / (qreal) d->genericStorage->numberOfRows;
407- return keyHeight;
408- }
409- break;
410- default: return 1.0;
411- }
412-}
413-
414-QByteArray DynamicLayout::keyBackground(Key::Style style, KeyDescription::State state) const
415-{
416- Q_UNUSED(state);
417-
418- switch (style) {
419- case Key::StyleNormalKey:
420- return d->genericStorage->keyBackgroundNormal;
421- case Key::StyleSpecialKey:
422- return d->genericStorage->keyBackgroundSpecial;
423- case Key::StyleDeadKey:
424- return d->genericStorage->keyBackgroundDead;
425- default: break;
426- }
427-
428- return "";
429-}
430-
431-Logic::LayoutHelper::Orientation DynamicLayout::screenToMaliitOrientation(Qt::ScreenOrientation screenOrientation) const
432-{
433- switch (screenOrientation) {
434- case Qt::LandscapeOrientation:
435- case Qt::InvertedLandscapeOrientation:
436- return Logic::LayoutHelper::Landscape;
437- break;
438- case Qt::PortraitOrientation:
439- case Qt::InvertedPortraitOrientation:
440- case Qt::PrimaryOrientation:
441- default:
442- return Logic::LayoutHelper::Portrait;
443- }
444-
445- return Logic::LayoutHelper::Portrait;
446-}
447-
448-int DynamicLayout::keypadHeight(LayoutHelper::Orientation orientation)
449-{
450- return d->storage(orientation)->keypadHeight;
451-}
452-
453-qreal DynamicLayout::keyboardScreenWidthRatio(LayoutHelper::Orientation orientation)
454-{
455- return d->storage(orientation)->keyboardScreenWidthRatio;
456-}
457-
458-QMargins DynamicLayout::keyAreaBorders()
459-{
460- return d->genericStorage->keyAreaBorders;
461-}
462-
463-qreal DynamicLayout::fontSize(LayoutHelper::Orientation orientation)
464-{
465- Q_UNUSED(orientation);
466- return d->genericStorage->fontSize;
467-}
468-qreal DynamicLayout::fontSizeSmall(LayoutHelper::Orientation orientation)
469-{
470- Q_UNUSED(orientation);
471- return d->genericStorage->fontSizeSmall;
472-}
473-
474-QByteArray DynamicLayout::fontColor()
475-{
476- return d->genericStorage->fontColor;
477-}
478-
479-QByteArray DynamicLayout::fontFamily()
480-{
481- return d->genericStorage->fontFamily;
482-}
483-
484-qreal DynamicLayout::keypadTopMargin(LayoutHelper::Orientation orientation)
485-{
486- return d->storage(orientation)->keypadTopMargin;
487-}
488-
489-qreal DynamicLayout::spaceBetweenRows(LayoutHelper::Orientation orientation)
490-{
491- return d->storage(orientation)->spaceBetweenRows;
492-}
493-
494-qreal DynamicLayout::spaceBetweenKeys(LayoutHelper::Orientation orientation)
495-{
496- return d->storage(orientation)->spaceBetweenKeys;
497-}
498-
499-int DynamicLayout::invisibleTouchAreaHeight(LayoutHelper::Orientation orientation)
500-{
501- return d->storage(orientation)->invisibleTouchAreaHeight;
502-}
503-
504-int DynamicLayout::numberOfRows() const
505-{
506- return d->genericStorage->numberOfRows;
507-}
508-
509-int DynamicLayout::wordRibbonHeight(LayoutHelper::Orientation orientation)
510-{
511- return d->storage(orientation)->wordRibbonHeight;
512-}
513-
514-void DynamicLayout::onWordEngineSettingsChanged(bool wordEngineEnabled)
515-{
516- if (d->wordRibbonEnabled != wordEngineEnabled) {
517- d->wordRibbonEnabled = wordEngineEnabled;
518- d->invalidateWindowGeometryCache();
519- }
520-}
521-
522-void DynamicLayout::onPrimaryOrientationChanged(Qt::ScreenOrientation orientation)
523-{
524- d->primaryOrientation = orientation;
525-}
526-
527-void DynamicLayout::onOrientationChanged(Qt::ScreenOrientation orientation)
528-{
529- d->orientation = orientation;
530-}
531-
532-void DynamicLayout::onGeometryChanged(const QRect & geometry)
533-{
534- d->geometry = geometry;
535- d->invalidateWindowGeometryCache();
536-}
537-
538-
539-
540-}} // namespaces
541
542=== removed file 'src/lib/logic/dynamiclayout.h'
543--- src/lib/logic/dynamiclayout.h 2013-08-09 16:09:07 +0000
544+++ src/lib/logic/dynamiclayout.h 1970-01-01 00:00:00 +0000
545@@ -1,110 +0,0 @@
546-/*
547- * Copyright 2013 Canonical Ltd.
548- *
549- * This program is free software; you can redistribute it and/or modify
550- * it under the terms of the GNU Lesser General Public License as published by
551- * the Free Software Foundation; version 3.
552- *
553- * This program is distributed in the hope that it will be useful,
554- * but WITHOUT ANY WARRANTY; without even the implied warranty of
555- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
556- * GNU Lesser General Public License for more details.
557- *
558- * You should have received a copy of the GNU Lesser General Public License
559- * along with this program. If not, see <http://www.gnu.org/licenses/>.
560- */
561-
562-#ifndef DYNAMICLAYOUT_H
563-#define DYNAMICLAYOUT_H
564-
565-#include "logic/layouthelper.h"
566-#include "models/keydescription.h"
567-#include "models/keyboard.h"
568-
569-#include <QObject>
570-
571-#include <QtCore>
572-#include <QtGui/QGuiApplication>
573-#include <QtGui/QScreen>
574-#include <QtQuick>
575-
576-namespace MaliitKeyboard {
577-namespace Logic {
578-
579-#define uiConst ::MaliitKeyboard::Logic::DynamicLayout::instance()
580-
581-class DynamicLayoutPrivate;
582-
583-class DynamicLayout : public QObject
584-{
585- Q_OBJECT
586-
587-public:
588- static DynamicLayout* instance()
589- {
590- if (!self) {
591- self = new DynamicLayout;
592- }
593- return self;
594- }
595-
596- static void reset()
597- {
598- if (self)
599- self = new DynamicLayout;
600- }
601-
602- void initDynamicLayout(QString fileName = UBUNTU_KEYBOARD_DATA_DIR "/maliit-ui-constants.qml");
603-
604- int keypadHeight(LayoutHelper::Orientation orientation);
605- int windowWidth(LayoutHelper::Orientation orientation);
606- QRect windowGeometryRect(Qt::ScreenOrientation orientation);
607- qreal keyboardScreenWidthRatio(LayoutHelper::Orientation orientation);
608-
609- qreal keyHeight(LayoutHelper::Orientation orientation);
610- qreal keyWidth(LayoutHelper::Orientation orientation, KeyDescription::Width width);
611-
612- QMargins keyAreaBorders();
613-
614- qreal fontSize(LayoutHelper::Orientation orientation);
615- qreal fontSizeSmall(LayoutHelper::Orientation orientation);
616- QByteArray fontColor();
617- QByteArray fontFamily();
618-
619- qreal keypadTopMargin(LayoutHelper::Orientation orientation);
620-
621- QByteArray keyBackground(Key::Style style, KeyDescription::State state) const;
622- Logic::LayoutHelper::Orientation screenToMaliitOrientation(Qt::ScreenOrientation screenOrientation) const;
623-
624- qreal spaceBetweenRows(LayoutHelper::Orientation orientation);
625- qreal spaceBetweenKeys(LayoutHelper::Orientation orientation);
626-
627- int invisibleTouchAreaHeight(LayoutHelper::Orientation orientation);
628-
629- void calculateNumberOfRows(Keyboard& kb);
630- int numberOfRows() const;
631-
632- int wordRibbonHeight(LayoutHelper::Orientation orientation);
633-
634- QVector<int> calculateMargins(LayoutHelper::Orientation orientation, Keyboard& kb);
635-
636- Q_SLOT void onWordEngineSettingsChanged(bool wordEngineEnabled);
637-
638- /* interface to primaryScreen */
639- Q_SLOT void onPrimaryOrientationChanged(Qt::ScreenOrientation orientation);
640- Q_SLOT void onOrientationChanged(Qt::ScreenOrientation orientation);
641- Q_SLOT void onGeometryChanged(const QRect & geometry);
642-
643-private:
644- explicit DynamicLayout(QObject *parent = 0);
645- DynamicLayout(DynamicLayout const&) : QObject(0) {}
646- DynamicLayout& operator=(DynamicLayout const&){ return *this; }
647- static DynamicLayout* self;
648-
649- DynamicLayoutPrivate* d;
650-};
651-
652-#endif // DYNAMICLAYOUT_H
653-
654-}
655-}
656
657=== removed file 'src/lib/logic/dynamiclayout_p.h'
658--- src/lib/logic/dynamiclayout_p.h 2013-08-09 15:22:29 +0000
659+++ src/lib/logic/dynamiclayout_p.h 1970-01-01 00:00:00 +0000
660@@ -1,325 +0,0 @@
661-
662-#include <QtCore>
663-
664-#include "layouthelper.h"
665-
666-namespace MaliitKeyboard {
667-namespace Logic {
668-
669-class DynamicLayout;
670-
671-class DynamicLayoutPrivate {
672-public:
673-
674- struct DynamicLayoutStorage {
675- DynamicLayoutStorage()
676- : widthStretchFactor(1.0),
677- heightStretchFactor(1.0),
678- numberOfRows(0)
679- {
680- }
681-
682- int keypadHeight;
683- int invisibleTouchAreaHeight;
684- int wordRibbonHeight;
685- int keyboardHeight; // everything visible incl wordribbon
686-
687- QRect windowGeometryRect;
688- QRect windowGeometryRectInverted;
689-
690- // includes wordribbon
691- QRect keyboardRect;
692-
693- qreal keyboardScreenWidthRatio;
694- qreal keyHeight;
695- qreal keyWidthSmall;
696- qreal keyWidthMedium;
697- qreal keyWidthLarge;
698- qreal keyWidthXLarge;
699- qreal keyWidthXXLarge;
700- qreal keyWidthStretched;
701- QMargins keyAreaBorders;
702- qreal fontSize;
703- qreal fontSizeSmall;
704- QByteArray fontColor;
705- QByteArray fontFamily;
706- qreal widthStretchFactor;
707- qreal heightStretchFactor;
708- qreal keypadTopMargin;
709- qreal keyboardBottomMargin;
710-
711- QByteArray keyBackgroundNormal;
712- QByteArray keyBackgroundSpecial;
713- QByteArray keyBackgroundDead;
714-
715- int numberOfRows;
716- qreal spaceBetweenRows;
717- qreal spaceBetweenKeys;
718- };
719-
720- DynamicLayoutStorage* storage(LayoutHelper::Orientation orientation)
721- {
722- q->initDynamicLayout();
723-
724- if (orientation == LayoutHelper::Landscape)
725- return landscapeStorage;
726- else if (orientation == LayoutHelper::Portrait)
727- return portraitStorage;
728-
729- return portraitStorage;
730- }
731-
732- qreal widthStretchFactor(LayoutHelper::Orientation orientation)
733- {
734- switch (orientation) {
735- case LayoutHelper::Landscape:
736- return landscapeStorage->widthStretchFactor;
737- break;
738- case LayoutHelper::Portrait:
739- return portraitStorage->widthStretchFactor;
740- break;
741- default: return 1.0;
742- }
743- }
744-
745- qreal heightStretchFactor(LayoutHelper::Orientation orientation)
746- {
747- switch (orientation) {
748- case LayoutHelper::Landscape:
749- return landscapeStorage->heightStretchFactor;
750- break;
751- case LayoutHelper::Portrait:
752- return portraitStorage->heightStretchFactor;
753- break;
754- default: return 1.0;
755- }
756- }
757-
758- DynamicLayout* q;
759- bool initialized;
760- bool wordRibbonEnabled;
761-
762- // short term-caching in memory
763- Qt::ScreenOrientation cachedOrientation;
764- bool windowGeometryCacheValid;
765- QRect windowGeometryRectCached;
766-
767- LayoutHelper::Orientation marginsCachedOrientation;
768- bool marginsCacheValid;
769- QVector<int> marginsCached;
770-
771- DynamicLayoutStorage* portraitStorage;
772- DynamicLayoutStorage* landscapeStorage;
773- DynamicLayoutStorage* genericStorage;
774-
775- Qt::ScreenOrientation primaryOrientation;
776- Qt::ScreenOrientation orientation;
777- QRect geometry;
778-
779- DynamicLayoutPrivate(DynamicLayout* _q) :
780- q(_q),
781- initialized(false),
782- wordRibbonEnabled(false),
783-
784- cachedOrientation(Qt::PortraitOrientation),
785- windowGeometryCacheValid(false),
786- windowGeometryRectCached(QRect(0,0,0,0)),
787-
788- marginsCachedOrientation(LayoutHelper::Portrait),
789- marginsCacheValid(false),
790- marginsCached(0),
791-
792- portraitStorage(new DynamicLayoutStorage),
793- landscapeStorage(new DynamicLayoutStorage),
794- genericStorage(new DynamicLayoutStorage)
795- {
796- }
797-
798- // ToDo this needs to be refactored
799- void initDynamicLayout(QString fileName)
800- {
801- q->instance();
802-
803- if (!initialized) {
804- QQuickView quickView;
805- quickView.setSource(QUrl::fromLocalFile( fileName ));
806- QQuickItem* quickItem = quickView.rootObject();
807-
808- const QRect rLandscape = qGuiApp->primaryScreen()->mapBetween(
809- primaryOrientation,
810- Qt::LandscapeOrientation,
811- geometry);
812-
813- const QRect rInvertedLandscape = qGuiApp->primaryScreen()->mapBetween(
814- primaryOrientation,
815- Qt::InvertedLandscapeOrientation,
816- geometry);
817-
818- const QRect rPortrait = qGuiApp->primaryScreen()->mapBetween(
819- primaryOrientation,
820- Qt::PortraitOrientation,
821- geometry);
822-
823- const QRect rInvertedPortrait = qGuiApp->primaryScreen()->mapBetween(
824- primaryOrientation,
825- Qt::InvertedPortraitOrientation,
826- geometry);
827-
828-
829- // generic
830-
831- genericStorage->keyAreaBorders = QMargins(quickItem->property("key_area_borders").toInt(),
832- quickItem->property("key_area_borders").toInt(),
833- quickItem->property("key_area_borders").toInt(),
834- quickItem->property("key_area_borders").toInt()
835- );
836-
837- genericStorage->fontColor = quickItem->property("font_color").toByteArray();
838- genericStorage->fontFamily = quickItem->property("font_family").toByteArray();
839-
840- landscapeStorage->wordRibbonHeight = quickItem->property("landscape_wordribbon_height").toInt();
841- portraitStorage->wordRibbonHeight = quickItem->property("portrait_wordribbon_height").toInt();
842-
843- // portrait
844-
845- qreal portraitHeightRatio = quickItem->property("phone_keyboard_height_portrait").toReal();
846- if (primaryOrientation == Qt::LandscapeOrientation)
847- portraitHeightRatio = quickItem->property("tablet_keyboard_height_portrait").toReal();
848-
849- portraitStorage->invisibleTouchAreaHeight = quickItem->property("portrait_invisible_touch_area").toInt();
850-
851- portraitStorage->keypadHeight = rPortrait.height() * portraitHeightRatio;
852- portraitStorage->keyboardHeight = portraitStorage->keypadHeight
853- + portraitStorage->wordRibbonHeight;
854- portraitStorage->keyboardScreenWidthRatio = quickItem->property("portrait_keyboard_screen_width_ratio").toReal();
855-
856- const int portraitKeyboardWidth = rPortrait.width() * portraitStorage->keyboardScreenWidthRatio;
857- const int xp = (rPortrait.width() - (portraitKeyboardWidth)) / 2;
858-
859- // point of origin differs when primary orientation is different
860- int yp = 0;
861- if(primaryOrientation == Qt::PortraitOrientation)
862- yp = rPortrait.height() - (portraitStorage->keypadHeight
863- + portraitStorage->wordRibbonHeight
864- + portraitStorage->invisibleTouchAreaHeight);
865-
866- portraitStorage->windowGeometryRect = QRect(xp, yp, portraitKeyboardWidth,
867- portraitStorage->keypadHeight
868- + portraitStorage->wordRibbonHeight
869- + portraitStorage->invisibleTouchAreaHeight);
870-
871- const int invertedPortraitKeyboardWidth = rInvertedPortrait.width() * portraitStorage->keyboardScreenWidthRatio;
872- const int xpi = (rInvertedPortrait.width() - (portraitKeyboardWidth)) / 2;
873-
874- // point of origin differs when primary orientation is different
875- int ypi = 0;
876- if(primaryOrientation == Qt::LandscapeOrientation)
877- ypi = rInvertedPortrait.height() - (portraitStorage->keypadHeight
878- + portraitStorage->wordRibbonHeight
879- + portraitStorage->invisibleTouchAreaHeight);
880-
881- portraitStorage->windowGeometryRectInverted = QRect(xpi, ypi, invertedPortraitKeyboardWidth,
882- portraitStorage->keypadHeight
883- + portraitStorage->wordRibbonHeight
884- + portraitStorage->invisibleTouchAreaHeight);
885-
886- portraitStorage->keypadTopMargin = quickItem->property("portrait_top_margin").toInt();
887- landscapeStorage->keypadTopMargin = 0.02 * rLandscape.height(); //DynamicLayoutHelper->property("landscape_top_margin").toInt();
888-
889- portraitStorage->keyboardBottomMargin = quickItem->property("portrait_bottom_margin").toInt();
890- landscapeStorage->keyboardBottomMargin = 0.02 * rLandscape.height();//DynamicLayoutHelper->property("landscape_bottom_margin").toInt();
891-
892- // landscape
893-
894- qreal landscapeHeightRatio = quickItem->property("phone_keyboard_height_landscape").toReal();
895- if (primaryOrientation == Qt::LandscapeOrientation)
896- landscapeHeightRatio = quickItem->property("tablet_keyboard_height_landscape").toReal();
897-
898- landscapeStorage->invisibleTouchAreaHeight = quickItem->property("landscape_invisible_touch_area").toInt();
899- landscapeStorage->keyboardHeight = landscapeStorage->keypadHeight
900- + landscapeStorage->wordRibbonHeight;
901-
902- landscapeStorage->keypadHeight = rLandscape.height() * landscapeHeightRatio;
903-
904- landscapeStorage->keyboardScreenWidthRatio = quickItem->property("landscape_keyboard_screen_width_ratio").toReal();
905-
906- const int landscapeKeyboardWidth = rLandscape.width() * landscapeStorage->keyboardScreenWidthRatio;
907- const int xl = (rLandscape.width() - (landscapeKeyboardWidth)) / 2;
908- const int yl = rLandscape.height() - (landscapeStorage->keypadHeight
909- + landscapeStorage->wordRibbonHeight
910- + landscapeStorage->invisibleTouchAreaHeight);
911-
912- landscapeStorage->windowGeometryRect = QRect(xl, yl, landscapeKeyboardWidth,
913- landscapeStorage->keypadHeight
914- + landscapeStorage->wordRibbonHeight
915- + landscapeStorage->invisibleTouchAreaHeight);
916-
917- const int invertedLandscapeKeyboardWidth = rInvertedLandscape.width() * landscapeStorage->keyboardScreenWidthRatio;
918- const int xli = (rInvertedLandscape.width() - (invertedLandscapeKeyboardWidth)) / 2;
919- const int yli = 0;
920-
921- landscapeStorage->windowGeometryRectInverted = QRect(xli, yli, invertedLandscapeKeyboardWidth,
922- landscapeStorage->keypadHeight
923- + landscapeStorage->wordRibbonHeight
924- + landscapeStorage->invisibleTouchAreaHeight);
925-
926- // reference
927- const QSize referenceSize(
928- quickItem->property("reference_width").toInt(),
929- quickItem->property("reference_height").toInt());
930-
931- landscapeStorage->widthStretchFactor = (qreal) landscapeStorage->windowGeometryRect.width() / referenceSize.width();
932- portraitStorage->widthStretchFactor = (qreal) portraitStorage->windowGeometryRect.width() / referenceSize.width();
933-
934- genericStorage->keyHeight = quickItem->property("key_height").toReal();
935- genericStorage->keyWidthSmall = quickItem->property("key_width_small").toReal();
936- genericStorage->keyWidthMedium = quickItem->property("key_width_medium").toReal();
937- genericStorage->keyWidthLarge = quickItem->property("key_width_large").toReal();
938- genericStorage->keyWidthXLarge = quickItem->property("key_width_xlarge").toReal();
939- genericStorage->keyWidthXXLarge = quickItem->property("key_width_xxlarge").toReal();
940- genericStorage->keyWidthStretched = quickItem->property("key_width_stretched").toReal();
941-
942- landscapeStorage->spaceBetweenRows = quickItem->property("landscape_space_between_rows").toReal();
943- landscapeStorage->spaceBetweenKeys = quickItem->property("landscape_space_between_keys").toReal();
944-
945- portraitStorage->spaceBetweenRows = quickItem->property("portrait_space_between_rows").toReal();
946- portraitStorage->spaceBetweenKeys = quickItem->property("portrait_space_between_keys").toReal();
947-
948- // S M L XL XXL Stretched
949-
950- genericStorage->fontSize = quickItem->property("font_size").toReal();
951- genericStorage->fontSizeSmall = quickItem->property("font_size_small").toReal();
952-
953- genericStorage->keyBackgroundNormal = quickItem->property("key_background_normal").toByteArray();
954- genericStorage->keyBackgroundSpecial = quickItem->property("key_background_special").toByteArray();
955- genericStorage->keyBackgroundDead = quickItem->property("key_background_deadkey").toByteArray();
956-
957- initialized = true;
958-
959- qDebug() << "landscape " << rLandscape << landscapeStorage->windowGeometryRect;
960- qDebug() << "landscape inverted" << rInvertedLandscape << landscapeStorage->windowGeometryRectInverted;
961-
962- qDebug() << "portrait " << rPortrait << portraitStorage->windowGeometryRect;
963- qDebug() << "portrait inverted " << rInvertedPortrait << portraitStorage->windowGeometryRectInverted;
964- }
965- }
966-
967- const QRect& writeCache( Qt::ScreenOrientation orientation, const QRect& cachedRect ) {
968- windowGeometryCacheValid = true;
969- cachedOrientation = orientation;
970- windowGeometryRectCached = cachedRect;
971- return windowGeometryRectCached;
972- }
973-
974- void invalidateWindowGeometryCache() {
975- windowGeometryCacheValid = false;
976- }
977-
978- void invalidateMarginsCache() {
979- marginsCacheValid = false;
980- marginsCached.clear();
981- }
982-};
983-
984-}
985-}
986
987=== modified file 'src/lib/logic/logic.pri'
988--- src/lib/logic/logic.pri 2013-11-08 08:19:50 +0000
989+++ src/lib/logic/logic.pri 2013-11-15 12:46:02 +0000
990@@ -11,7 +11,6 @@
991 logic/abstractlanguagefeatures.h \
992 logic/languagefeatures.h \
993 logic/eventhandler.h \
994- logic/dynamiclayout.h \
995 logic/pinyinadapter.h \
996 logic/chineselanguagefeatures.h
997
998@@ -26,7 +25,6 @@
999 logic/abstractlanguagefeatures.cpp \
1000 logic/languagefeatures.cpp \
1001 logic/eventhandler.cpp \
1002- logic/dynamiclayout.cpp \
1003 logic/pinyinadapter.cpp \
1004 logic/chineselanguagefeatures.cpp
1005
1006
1007=== modified file 'src/lib/models/layout.cpp'
1008--- src/lib/models/layout.cpp 2013-11-07 17:43:22 +0000
1009+++ src/lib/models/layout.cpp 2013-11-15 12:46:02 +0000
1010@@ -34,8 +34,6 @@
1011 #include "key.h"
1012 #include "keydescription.h"
1013
1014-#include "logic/dynamiclayout.h"
1015-
1016 #include <QtGui/QGuiApplication>
1017 #include <QScreen>
1018
1019@@ -196,13 +194,6 @@
1020 return d->key_area.rect().height();
1021 }
1022
1023-int Layout::wordRibbonHeight() const
1024-{
1025- return uiConst->wordRibbonHeight(
1026- uiConst->screenToMaliitOrientation(
1027- qGuiApp->primaryScreen()->orientation()) );
1028-}
1029-
1030 QPoint Layout::origin() const
1031 {
1032 Q_D(const Layout);
1033@@ -225,13 +216,6 @@
1034 return QRectF(m.left(), m.top(), m.right(), m.bottom());
1035 }
1036
1037-int Layout::invisibleTouchAreaHeight() const
1038-{
1039- return uiConst->invisibleTouchAreaHeight(
1040- uiConst->screenToMaliitOrientation(
1041- qGuiApp->primaryScreen()->orientation()) );
1042-}
1043-
1044 Layout::State Layout::state() const
1045 {
1046 Q_D(const Layout);
1047
1048=== modified file 'src/lib/models/layout.h'
1049--- src/lib/models/layout.h 2013-08-13 03:11:49 +0000
1050+++ src/lib/models/layout.h 2013-11-15 12:46:02 +0000
1051@@ -67,16 +67,12 @@
1052 NOTIFY widthChanged)
1053 Q_PROPERTY(int height READ height
1054 NOTIFY heightChanged)
1055- Q_PROPERTY(int wordribbon_height READ wordRibbonHeight
1056- NOTIFY wordRibbonHeightChanged)
1057 Q_PROPERTY(QPoint origin READ origin
1058 NOTIFY originChanged)
1059 Q_PROPERTY(QUrl background READ background
1060 NOTIFY backgroundChanged)
1061 Q_PROPERTY(QRectF background_borders READ backgroundBorders
1062 NOTIFY backgroundBordersChanged)
1063- Q_PROPERTY(int invisible_toucharea_height READ invisibleTouchAreaHeight
1064- NOTIFY invisibleTouchAreaHeightChanged)
1065
1066 Q_PROPERTY(State keyboard_state READ state WRITE setState
1067 NOTIFY stateChanged)
1068@@ -131,9 +127,6 @@
1069 Q_SLOT int height() const;
1070 Q_SIGNAL void heightChanged(int changed);
1071
1072- Q_SLOT int wordRibbonHeight() const;
1073- Q_SIGNAL void wordRibbonHeightChanged(int changed);
1074-
1075 Q_SLOT QPoint origin() const;
1076 Q_SIGNAL void originChanged(const QPoint &changed);
1077
1078@@ -146,9 +139,6 @@
1079 // FIXME: Turn into class variable?
1080 Q_SLOT void setImageDirectory(const QString &directory);
1081
1082- Q_SLOT int invisibleTouchAreaHeight() const;
1083- Q_SIGNAL void invisibleTouchAreaHeightChanged(int &changed);
1084-
1085 Q_SLOT State state() const;
1086 Q_SLOT void setState(Model::Layout::State state);
1087 Q_SIGNAL void stateChanged(Model::Layout::State state);
1088
1089=== modified file 'src/plugin/inputmethod.cpp'
1090--- src/plugin/inputmethod.cpp 2013-11-15 09:32:12 +0000
1091+++ src/plugin/inputmethod.cpp 2013-11-15 12:46:02 +0000
1092@@ -90,11 +90,10 @@
1093
1094 connect(&d->editor, SIGNAL(autoCapsActivated()), this, SIGNAL(activateAutocaps()));
1095
1096- connect(this, SIGNAL(wordRibbonEnabledChanged(bool)), uiConst, SLOT(onWordEngineSettingsChanged(bool)));
1097-
1098 connect(this, SIGNAL(predictionEnabledChanged()), this, SLOT(updateWordEngine()));
1099 connect(this, SIGNAL(contentTypeChanged(TextContentType)), this, SLOT(setContentType(TextContentType)));
1100 connect(this, SIGNAL(activeLanguageChanged(QString)), d->editor.wordEngine(), SLOT(onLanguageChanged(QString)));
1101+ connect(d->m_geometry, SIGNAL(visibleRectChanged()), this, SLOT(onVisibleRectChanged()));
1102
1103 d->registerStyleSetting(host);
1104
1105@@ -118,27 +117,6 @@
1106 Q_D(InputMethod);
1107
1108 d->view->setVisible(true);
1109-
1110- inputMethodHost()->setScreenRegion(QRegion(d->keyboardVisibleRect));
1111-
1112- QRect rect(d->keyboardVisibleRect);
1113- rect.moveTop( d->windowGeometryRect.height() - d->keyboardVisibleRect.height() );
1114- inputMethodHost()->setInputMethodArea(rect, d->view);
1115-
1116- qDebug() << "keyboard is reporting <x y w h>: <"
1117- << d->keyboardVisibleRect.x()
1118- << d->keyboardVisibleRect.y()
1119- << d->keyboardVisibleRect.width()
1120- << d->keyboardVisibleRect.height()
1121- << "> to the app manager.";
1122-
1123- d->applicationApiWrapper->reportOSKVisible(
1124- d->keyboardVisibleRect.x(),
1125- d->keyboardVisibleRect.y(),
1126- d->keyboardVisibleRect.width(),
1127- d->keyboardVisibleRect.height()
1128- );
1129-
1130 d->m_geometry->setShown(true);
1131 }
1132
1133@@ -522,3 +500,30 @@
1134 d->editor.onLanguageChanged(d->activeLanguage);
1135 Q_EMIT activeLanguageChanged(d->activeLanguage);
1136 }
1137+
1138+void InputMethod::onVisibleRectChanged()
1139+{
1140+ Q_D(InputMethod);
1141+
1142+ QRect visibleRect = qGuiApp->primaryScreen()->mapBetween(
1143+ d->m_geometry->orientation(),
1144+ qGuiApp->primaryScreen()->primaryOrientation(),
1145+ d->m_geometry->visibleRect().toRect());
1146+
1147+ inputMethodHost()->setScreenRegion(QRegion(visibleRect));
1148+ inputMethodHost()->setInputMethodArea(visibleRect, d->view);
1149+
1150+ qDebug() << "keyboard is reporting <x y w h>: <"
1151+ << visibleRect.x()
1152+ << visibleRect.y()
1153+ << visibleRect.width()
1154+ << visibleRect.height()
1155+ << "> to the app manager.";
1156+
1157+ d->applicationApiWrapper->reportOSKVisible(
1158+ visibleRect.x(),
1159+ visibleRect.y(),
1160+ visibleRect.width(),
1161+ visibleRect.height()
1162+ );
1163+}
1164
1165=== modified file 'src/plugin/inputmethod.h'
1166--- src/plugin/inputmethod.h 2013-11-13 15:19:04 +0000
1167+++ src/plugin/inputmethod.h 2013-11-15 12:46:02 +0000
1168@@ -109,6 +109,7 @@
1169
1170 const QString &systemLanguage() const;
1171
1172+ Q_SLOT void onVisibleRectChanged();
1173 bool useAudioFeedback() const;
1174
1175 Q_SIGNALS:
1176@@ -122,6 +123,7 @@
1177 void useAudioFeedbackChanged();
1178 void wordEngineEnabledChanged(bool wordEngineEnabled);
1179 void wordRibbonEnabledChanged(bool wordRibbonEnabled);
1180+ void windowGeometryRectChanged(QRect rect);
1181
1182 private:
1183 Q_SLOT void onStyleSettingChanged();
1184
1185=== modified file 'src/plugin/inputmethod_p.h'
1186--- src/plugin/inputmethod_p.h 2013-11-15 09:33:31 +0000
1187+++ src/plugin/inputmethod_p.h 2013-11-15 12:46:02 +0000
1188@@ -10,7 +10,6 @@
1189 #include "logic/eventhandler.h"
1190 #include "logic/wordengine.h"
1191 #include "logic/languagefeatures.h"
1192-#include "logic/dynamiclayout.h"
1193
1194 #include "ubuntuapplicationapiwrapper.h"
1195
1196@@ -75,8 +74,6 @@
1197 QMap<QString, SharedOverride> key_overrides;
1198 Settings settings;
1199 LayoutGroup layout;
1200- QRect windowGeometryRect;
1201- QRect keyboardVisibleRect;
1202 MAbstractInputMethodHost* host;
1203 QQuickView* view;
1204 UbuntuApplicationApiWrapper* applicationApiWrapper;
1205@@ -185,57 +182,26 @@
1206 delete applicationApiWrapper;
1207 }
1208
1209+ Logic::LayoutHelper::Orientation screenToMaliitOrientation(Qt::ScreenOrientation screenOrientation) const
1210+ {
1211+ switch (screenOrientation) {
1212+ case Qt::LandscapeOrientation:
1213+ case Qt::InvertedLandscapeOrientation:
1214+ return Logic::LayoutHelper::Landscape;
1215+ break;
1216+ case Qt::PortraitOrientation:
1217+ case Qt::InvertedPortraitOrientation:
1218+ case Qt::PrimaryOrientation:
1219+ default:
1220+ return Logic::LayoutHelper::Portrait;
1221+ }
1222+
1223+ return Logic::LayoutHelper::Portrait;
1224+ }
1225+
1226 void setLayoutOrientation(Qt::ScreenOrientation screenOrientation)
1227 {
1228- Logic::LayoutHelper::Orientation orientation = uiConst->screenToMaliitOrientation(screenOrientation);
1229-
1230- layout.updater.setOrientation(orientation);
1231-
1232- windowGeometryRect = uiConst->windowGeometryRect( screenOrientation );
1233-
1234- keyboardVisibleRect = windowGeometryRect.adjusted(0,uiConst->invisibleTouchAreaHeight(orientation),0,0);
1235-
1236- m_geometry->setCanvasHeight(windowGeometryRect.height());
1237- m_geometry->setKeypadHeight(keyboardVisibleRect.height());
1238 m_geometry->setOrientation(screenOrientation);
1239-
1240- // qpa does not rotate the coordinate system
1241- windowGeometryRect = qGuiApp->primaryScreen()->mapBetween(
1242- screenOrientation,
1243- qGuiApp->primaryScreen()->primaryOrientation(),
1244- windowGeometryRect);
1245-
1246- if (m_geometry->shown()) {
1247- host->setScreenRegion(QRegion(keyboardVisibleRect));
1248-
1249- QRect rect(keyboardVisibleRect);
1250- rect.moveTop( windowGeometryRect.height() - keyboardVisibleRect.height() );
1251- host->setInputMethodArea(rect, view);
1252- }
1253-
1254- if (m_geometry->shown()) {
1255- applicationApiWrapper->reportOSKInvisible();
1256-
1257- qDebug() << "keyboard is reporting: total <x y w h>: <"
1258- << windowGeometryRect.x()
1259- << windowGeometryRect.y()
1260- << windowGeometryRect.width()
1261- << windowGeometryRect.height()
1262- << "> and visible <"
1263- << keyboardVisibleRect.x()
1264- << keyboardVisibleRect.y()
1265- << keyboardVisibleRect.width()
1266- << keyboardVisibleRect.height()
1267- << "> to the app manager.";
1268-
1269- // report the visible part as input trap, the invisible part can click through, e.g. browser url bar
1270- applicationApiWrapper->reportOSKVisible(
1271- keyboardVisibleRect.x(),
1272- keyboardVisibleRect.y(),
1273- keyboardVisibleRect.width(),
1274- keyboardVisibleRect.height()
1275- );
1276- }
1277 }
1278
1279 void updateWordRibbon()
1280
1281=== added directory 'tests/unittests/ut_dynamic-layout'

Subscribers

People subscribed via source and target branches