Merge lp:~schwann/ubuntu-keyboard/keyboard-autocaps2 into lp:ubuntu-keyboard

Proposed by Günter Schwann
Status: Merged
Approved by: Thomas Moenicke
Approved revision: 79
Merged at revision: 83
Proposed branch: lp:~schwann/ubuntu-keyboard/keyboard-autocaps2
Merge into: lp:ubuntu-keyboard
Diff against target: 298 lines (+64/-59)
5 files modified
qml/Keyboard.qml (+9/-8)
qml/keys/KeyPad.qml (+0/-25)
src/plugin/inputmethod.cpp (+47/-22)
src/plugin/inputmethod.h (+4/-2)
src/plugin/inputmethod_p.h (+4/-2)
To merge this branch: bzr merge lp:~schwann/ubuntu-keyboard/keyboard-autocaps2
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Thomas Moenicke (community) Approve
Review via email: mp+191137@code.launchpad.net

Commit message

Disable auto capitalization for any other content type than FreeTextContentType
Wieth auto capitalizatin start with a capital on empty text fields

Description of the change

Disable auto capitalization for any other content type than FreeTextContentType
Wieth auto capitalizatin start with a capital on empty text fields

To post a comment you must log in.
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)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

looking good

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

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 2013-10-14 08:02:30 +0000
3+++ qml/Keyboard.qml 2013-10-15 19:14:17 +0000
4@@ -40,6 +40,7 @@
5 id: fullScreenItem
6 objectName: "fullScreenItem"
7
8+ property variant input_method: maliit_input_method
9 property variant layout: maliit_layout
10 property variant event_handler: maliit_event_handler
11
12@@ -75,14 +76,6 @@
13
14 property bool shown: false;
15 property bool wordribbon_visible: false;
16- property bool autoCapsActivated: false
17- onAutoCapsActivatedChanged: {
18- if (autoCapsActivated) {
19- keypad.state = "CHARACTERS"
20- keypad.activeKeypadState = "SHIFTED";
21- autoCapsActivated = false;
22- }
23- }
24
25 MouseArea {
26 id: swipeArea
27@@ -209,6 +202,14 @@
28 PropertyAnimation { target: canvas; properties: "y"; easing.type: Easing.InOutQuad }
29 }
30
31+ Connections {
32+ target: input_method
33+ onActivateAutocaps: {
34+ keypad.state = "CHARACTERS";
35+ keypad.activeKeypadState = "SHIFTED";
36+ }
37+ }
38+
39 } // canvas
40 } // OrientationHelper
41 } // fullScreenItem
42
43=== modified file 'qml/keys/KeyPad.qml'
44--- qml/keys/KeyPad.qml 2013-09-10 15:45:28 +0000
45+++ qml/keys/KeyPad.qml 2013-10-15 19:14:17 +0000
46@@ -60,29 +60,4 @@
47 function calculateKeyHeight() {
48 panel.keyHeight = panel.height / numberOfRows();
49 }
50-
51- states: [
52- State {
53- name: "NORMAL"
54- PropertyChanges {
55- target: panel
56- }
57- PropertyChanges {
58- target: canvas
59- autoCapsActivated: false
60- }
61- },
62- State {
63- name: "SHIFTED"
64- PropertyChanges {
65- target: panel
66- }
67- },
68- State {
69- name: "CAPSLOCK"
70- PropertyChanges {
71- target: panel
72- }
73- }
74- ]
75 }
76
77=== modified file 'src/plugin/inputmethod.cpp'
78--- src/plugin/inputmethod.cpp 2013-09-30 12:06:45 +0000
79+++ src/plugin/inputmethod.cpp 2013-10-15 19:14:17 +0000
80@@ -93,7 +93,7 @@
81 connect(&d->layout.helper, SIGNAL(centerPanelChanged(KeyArea,Logic::KeyOverrides)),
82 &d->layout.model, SLOT(setKeyArea(KeyArea)));
83
84- connect(&d->editor, SIGNAL(autoCapsActivated()), this, SLOT(onAutoCapsActivated()));
85+ connect(&d->editor, SIGNAL(autoCapsActivated()), this, SIGNAL(activateAutocaps()));
86
87 connect(this, SIGNAL(wordRibbonEnabledChanged(bool)), uiConst, SLOT(onWordEngineSettingsChanged(bool)));
88
89@@ -208,8 +208,11 @@
90
91 void InputMethod::handleFocusChange(bool focusIn)
92 {
93- if (not focusIn)
94+ if (focusIn) {
95+ checkInitialAutocaps();
96+ } else {
97 hide();
98+ }
99 }
100
101 void InputMethod::handleAppOrientationChanged(int angle)
102@@ -265,10 +268,23 @@
103 d->editor.setAutoCorrectEnabled(d->m_settings.autoCompletion());
104 }
105
106-void InputMethod::onAutoCapsSettingChanged()
107+/*!
108+ * \brief InputMethod::updateAutoCaps enabled the use of auto capitalization
109+ * when the setting iss eto true, and the text area does not prevent to use it
110+ */
111+void InputMethod::updateAutoCaps()
112 {
113 Q_D(InputMethod);
114- d->editor.setAutoCapsEnabled(d->m_settings.autoCapitalization());
115+ bool enabled = d->m_settings.autoCapitalization();
116+ enabled &= d->contentType == Maliit::FreeTextContentType;
117+ bool valid = true;
118+ bool autocap = d->host->autoCapitalizationEnabled(valid);
119+ enabled &= autocap;
120+
121+ if (enabled != d->autocapsEnabled) {
122+ d->autocapsEnabled = enabled;
123+ d->editor.setAutoCapsEnabled(enabled);
124+ }
125 }
126
127 void InputMethod::setKeyOverrides(const QMap<QString, QSharedPointer<MKeyOverride> > &overrides)
128@@ -326,12 +342,12 @@
129
130 void InputMethod::onLayoutWidthChanged(int width)
131 {
132- Q_UNUSED(width);
133+ Q_UNUSED(width);
134 }
135
136 void InputMethod::onLayoutHeightChanged(int height)
137 {
138- Q_UNUSED(height);
139+ Q_UNUSED(height);
140 }
141
142 void InputMethod::deviceOrientationChanged(Qt::ScreenOrientation orientation)
143@@ -349,7 +365,6 @@
144 bool valid;
145
146 bool emitPredictionEnabled = false;
147- bool emitContentType = false;
148
149 bool newPredictionEnabled = inputMethodHost()->predictionEnabled(valid);
150
151@@ -365,19 +380,12 @@
152 if (!valid) {
153 newContentType = Maliit::FreeTextContentType;
154 }
155-
156- if (newContentType != d->contentType) {
157- d->contentType = newContentType;
158- emitContentType = true;
159- }
160-
161+ onContentTypeChanged(newContentType);
162
163 if (emitPredictionEnabled)
164 Q_EMIT predictionEnabledChanged();
165
166- if (emitContentType)
167- Q_EMIT contentTypeChanged(d->contentType);
168-
169+ updateAutoCaps();
170 }
171
172 void InputMethod::updateWordEngine()
173@@ -411,6 +419,11 @@
174 {
175 Q_D(InputMethod);
176
177+ if (contentType == d->contentType)
178+ return;
179+
180+ d->contentType = contentType;
181+
182 // TODO when refactoring, forward the enum to QML
183
184 if (contentType == Maliit::FreeTextContentType)
185@@ -429,6 +442,10 @@
186 d->setActiveKeyboardId("url");
187
188 updateWordEngine();
189+
190+ Q_EMIT contentTypeChanged(contentType);
191+
192+ updateAutoCaps();
193 }
194
195 void InputMethod::onQMLStateChanged(QString state)
196@@ -455,14 +472,22 @@
197 }
198 }
199
200-/*
201- * activated by the editor after e.g. pressing period
202- **/
203-
204-void InputMethod::onAutoCapsActivated()
205+/*!
206+ * \brief InputMethod::checkInitialAutocaps Checks if the keyboard should be
207+ * set to uppercase, because the auto caps is enabled and the text is empty.
208+ */
209+void InputMethod::checkInitialAutocaps()
210 {
211 Q_D(InputMethod);
212- d->qmlRootItem->setProperty("autoCapsActivated", true);
213+ update();
214+
215+ if (d->autocapsEnabled) {
216+ QString text;
217+ int position;
218+ bool ok = d->host->surroundingText(text, position);
219+ if (ok && text.isEmpty() && position == 0)
220+ Q_EMIT activateAutocaps();
221+ }
222 }
223
224 } // namespace MaliitKeyboard
225
226=== modified file 'src/plugin/inputmethod.h'
227--- src/plugin/inputmethod.h 2013-09-17 13:13:18 +0000
228+++ src/plugin/inputmethod.h 2013-10-15 19:14:17 +0000
229@@ -76,7 +76,6 @@
230
231 Q_SLOT void updateWordEngine();
232 Q_SLOT void onQQuickViewStatusChanged(QQuickView::Status status);
233- Q_SLOT void onAutoCapsActivated();
234
235 Q_PROPERTY(bool predictionEnabled READ predictionEnabled NOTIFY predictionEnabledChanged)
236 Q_PROPERTY(Maliit::TextContentType contentType READ contentType NOTIFY contentTypeChanged)
237@@ -89,12 +88,13 @@
238 Q_SIGNALS:
239 void predictionEnabledChanged();
240 void contentTypeChanged(Maliit::TextContentType contentType);
241+ void activateAutocaps();
242
243 private:
244 Q_SLOT void onStyleSettingChanged();
245 Q_SLOT void onFeedbackSettingChanged();
246 Q_SLOT void onAutoCorrectSettingChanged();
247- Q_SLOT void onAutoCapsSettingChanged();
248+ Q_SLOT void updateAutoCaps();
249 Q_SLOT void updateKey(const QString &key_id,
250 const MKeyOverride::KeyOverrideAttributes changed_attributes);
251 Q_SLOT void onKeyboardClosed();
252@@ -108,6 +108,8 @@
253 Q_SIGNAL void wordEngineEnabledChanged(bool wordEngineEnabled);
254 Q_SIGNAL void wordRibbonEnabledChanged(bool wordRibbonEnabled);
255
256+ void checkInitialAutocaps();
257+
258 const QScopedPointer<InputMethodPrivate> d_ptr;
259 };
260
261
262=== modified file 'src/plugin/inputmethod_p.h'
263--- src/plugin/inputmethod_p.h 2013-09-30 12:06:45 +0000
264+++ src/plugin/inputmethod_p.h 2013-10-15 19:14:17 +0000
265@@ -88,6 +88,7 @@
266 QQuickView* view;
267 UbuntuApplicationApiWrapper* applicationApiWrapper;
268
269+ bool autocapsEnabled;
270 bool predictionEnabled;
271 Maliit::TextContentType contentType;
272 QString activeLanguageId;
273@@ -109,6 +110,7 @@
274 , host(host)
275 , view(0)
276 , applicationApiWrapper(new UbuntuApplicationApiWrapper)
277+ , autocapsEnabled(false)
278 , predictionEnabled(false)
279 , contentType(Maliit::FreeTextContentType)
280 , activeLanguageId("en_us")
281@@ -275,6 +277,7 @@
282
283 void setContextProperties(QQmlContext *qml_context)
284 {
285+ qml_context->setContextProperty("maliit_input_method", q);
286 qml_context->setContextProperty("maliit_layout", &layout.model);
287 qml_context->setContextProperty("maliit_event_handler", &layout.event_handler);
288 qml_context->setContextProperty("maliit_wordribbon", layout.helper.wordRibbon());
289@@ -321,8 +324,7 @@
290 void registerAutoCapsSetting()
291 {
292 QObject::connect(&m_settings, SIGNAL(autoCapitalizationChanged()),
293- q, SLOT(onAutoCapsSettingChanged()));
294- editor.setAutoCapsEnabled(m_settings.autoCapitalization());
295+ q, SLOT(updateAutoCaps()));
296 }
297
298 void registerWordEngineSetting()

Subscribers

People subscribed via source and target branches