~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to maliit-plugins-quick/input-method/minputmethodquick.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * This file is part of Maliit framework *
2
 
 *
3
 
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
 
 * All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License version 2.1 as published by the Free Software Foundation
11
 
 * and appearing in the file LICENSE.LGPL included in the packaging
12
 
 * of this file.
13
 
 */
14
 
 
15
 
#include "minputmethodquick.h"
16
 
 
17
 
#include "mkeyoverridequick.h"
18
 
#include "minputmethodquickplugin.h"
19
 
 
20
 
#include <maliit/plugins/abstractinputmethodhost.h>
21
 
#include <maliit/plugins/abstractsurfacefactory.h>
22
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
23
 
#include <maliit/plugins/quickviewsurface.h>
24
 
#include <QtQuick>
25
 
#include <QtGui>
26
 
#include <qpa/qplatformnativeinterface.h>
27
 
#include <xcb/xcb.h>
28
 
#include <xcb/xfixes.h>
29
 
#else
30
 
#include <maliit/plugins/abstractwidgetssurface.h>
31
 
#endif
32
 
#include <maliit/plugins/keyoverride.h>
33
 
 
34
 
#include <QKeyEvent>
35
 
#include <QApplication>
36
 
#include <QDesktopWidget>
37
 
#include <QDebug>
38
 
#include <QRectF>
39
 
#include <QRect>
40
 
#include <QPainter>
41
 
#include <QPen>
42
 
#include <QBrush>
43
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
44
 
#include <QQmlComponent>
45
 
#include <QQmlContext>
46
 
#include <QQmlEngine>
47
 
#else
48
 
#include <QDeclarativeComponent>
49
 
#include <QDeclarativeContext>
50
 
#include <QDeclarativeEngine>
51
 
#endif
52
 
#include <QGraphicsTextItem>
53
 
#include <QGraphicsScene>
54
 
#include <QGraphicsObject>
55
 
#include <QDir>
56
 
#include <memory>
57
 
 
58
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
59
 
#if defined(Q_WS_X11)
60
 
#include <QX11Info>
61
 
#include <X11/Xlib.h>
62
 
#include <X11/Xatom.h>
63
 
#include <X11/Xutil.h>
64
 
#include <X11/extensions/Xfixes.h>
65
 
#include <X11/extensions/shape.h>
66
 
#endif
67
 
#endif
68
 
 
69
 
//this hack is needed because KeyPress definded by xlib conflicts with QEvent::KeyPress, breaking build
70
 
#undef KeyPress
71
 
 
72
 
namespace
73
 
{
74
 
    const char * const actionKeyName = "actionKey";
75
 
 
76
 
    const QRect &computeDisplayRect(QWidget *w = 0)
77
 
    {
78
 
        static const QRect displayRect(w ? qApp->desktop()->screenGeometry(w)
79
 
                                         : qApp->desktop()->screenGeometry());
80
 
 
81
 
        return displayRect;
82
 
    }
83
 
}
84
 
 
85
 
// TODO: Remove typedefs for Maliit 1.0 and only use the Qt5 types instead.
86
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
87
 
typedef QQmlEngine MaliitQmlEngine;
88
 
typedef QQmlComponent MaliitQmlComponent;
89
 
#else
90
 
typedef QDeclarativeEngine MaliitQmlEngine;
91
 
typedef QDeclarativeComponent MaliitQmlComponent;
92
 
#endif
93
 
 
94
 
//! Helper class to load QML files and set up the declarative view accordingly.
95
 
class MInputMethodQuickLoader
96
 
{
97
 
private:
98
 
    QGraphicsScene *const m_scene;
99
 
    MaliitQmlEngine *const m_engine; //!< managed by controller
100
 
    std::auto_ptr<MaliitQmlComponent> m_component;
101
 
 
102
 
    QGraphicsObject *m_content; //!< managed by scene
103
 
    MInputMethodQuick *const m_controller;
104
 
 
105
 
public:
106
 
    MInputMethodQuickLoader(QGraphicsScene *newScene,
107
 
                            MInputMethodQuick *newController)
108
 
        : m_scene(newScene)
109
 
        , m_engine(new MaliitQmlEngine(newController))
110
 
        , m_content(0)
111
 
        , m_controller(newController)
112
 
    {
113
 
        Q_ASSERT(m_scene);
114
 
        Q_ASSERT(m_controller);
115
 
 
116
 
        m_engine->rootContext()->setContextProperty("MInputMethodQuick", m_controller);
117
 
        m_engine->addImportPath(MALIIT_PLUGINS_DATA_DIR);
118
 
 
119
 
        Q_FOREACH (const QString &path, MInputMethodQuickPlugin::qmlImportPaths()) {
120
 
            m_engine->addImportPath(path);
121
 
        }
122
 
 
123
 
        // Assuming that plugin B loads after plugin A, we need to make sure
124
 
        // that plugin B does not use the customized import paths of plugin A:
125
 
        MInputMethodQuickPlugin::setQmlImportPaths(QStringList());
126
 
    }
127
 
 
128
 
    virtual ~MInputMethodQuickLoader()
129
 
    {}
130
 
 
131
 
    // TODO: rename to showContent?
132
 
    void showUI()
133
 
    {
134
 
        if(not m_content) {
135
 
            qWarning() << __PRETTY_FUNCTION__
136
 
                       << "Content or controller missing: Cannot show UI.";
137
 
            return;
138
 
        }
139
 
 
140
 
        m_controller->setActive(true);
141
 
    }
142
 
 
143
 
    void hideUI()
144
 
    {
145
 
        if(not m_content) {
146
 
            return;
147
 
        }
148
 
 
149
 
        m_controller->setActive(false);
150
 
    }
151
 
 
152
 
    void loadQmlFile(const QString &qmlFileName)
153
 
    {
154
 
        if (m_content) {
155
 
            qWarning() << "Qml file already loaded";
156
 
            return;
157
 
        }
158
 
 
159
 
        m_component.reset(new MaliitQmlComponent(m_engine, QUrl(qmlFileName)));
160
 
 
161
 
        if (not m_component->errors().isEmpty()) {
162
 
            qWarning() << "QML errors while loading " << qmlFileName << "\n"
163
 
                       << m_component->errors();
164
 
        }
165
 
 
166
 
        m_content = qobject_cast<QGraphicsObject *>(m_component->create());
167
 
 
168
 
        if (not m_content) {
169
 
            m_content = new QGraphicsTextItem("Error loading QML");
170
 
        }
171
 
 
172
 
        m_content->hide();
173
 
        m_scene->addItem(m_content);
174
 
    }
175
 
 
176
 
    QGraphicsObject *content() const
177
 
    {
178
 
        return m_content;
179
 
    }
180
 
};
181
 
 
182
 
class MInputMethodQuickPrivate
183
 
{
184
 
public:
185
 
    MInputMethodQuick *const q_ptr;
186
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
187
 
    QSharedPointer<Maliit::Plugins::QuickViewSurface> surface;
188
 
#else
189
 
    QSharedPointer<Maliit::Plugins::AbstractGraphicsViewSurface> surface;
190
 
    QGraphicsScene *const scene;
191
 
    QGraphicsView *const view;
192
 
    MInputMethodQuickLoader *const loader;
193
 
#endif
194
 
    QRect inputMethodArea;
195
 
    int appOrientation;
196
 
    bool haveFocus;
197
 
 
198
 
    //! current active state
199
 
    Maliit::HandlerState activeState;
200
 
 
201
 
    //! In practice show() and hide() correspond to application SIP (close)
202
 
    //! requests.  We track the current shown/SIP requested state using these variables.
203
 
    bool sipRequested;
204
 
    bool sipIsInhibited;
205
 
    QSharedPointer<MKeyOverrideQuick> actionKeyOverride;
206
 
    QSharedPointer<MKeyOverride> sentActionKeyOverride;
207
 
    bool active;
208
 
 
209
 
    Q_DECLARE_PUBLIC(MInputMethodQuick)
210
 
 
211
 
    MInputMethodQuickPrivate(MAbstractInputMethodHost *host,
212
 
                             MInputMethodQuick *im)
213
 
        : q_ptr(im)
214
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
215
 
        , surface(qSharedPointerDynamicCast<Maliit::Plugins::QuickViewSurface>(host->surfaceFactory()->create(Maliit::Plugins::AbstractSurface::PositionCenterBottom | Maliit::Plugins::AbstractSurface::TypeQuick2)))
216
 
#else
217
 
        , surface(qSharedPointerDynamicCast<Maliit::Plugins::AbstractGraphicsViewSurface>(host->surfaceFactory()->create(Maliit::Plugins::AbstractSurface::PositionCenterBottom | Maliit::Plugins::AbstractSurface::TypeGraphicsView)))
218
 
        , scene(surface->scene())
219
 
        , view(surface->view())
220
 
        , loader(new MInputMethodQuickLoader(scene, im))
221
 
#endif
222
 
        , appOrientation(0)
223
 
        , haveFocus(false)
224
 
        , activeState(Maliit::OnScreen)
225
 
        , sipRequested(false)
226
 
        , sipIsInhibited(false)
227
 
        , actionKeyOverride(new MKeyOverrideQuick())
228
 
        , sentActionKeyOverride()
229
 
        , active(false)
230
 
    {
231
 
        Q_ASSERT(surface);
232
 
 
233
 
        updateActionKey(MKeyOverride::All);
234
 
        // Set surface size to fullscreen
235
 
        surface->setSize(QApplication::desktop()->screenGeometry().size());
236
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
237
 
        surface->view()->engine()->addImportPath(MALIIT_PLUGINS_DATA_DIR);
238
 
        surface->view()->engine()->rootContext()->setContextProperty("MInputMethodQuick", im);
239
 
#endif
240
 
    }
241
 
 
242
 
    ~MInputMethodQuickPrivate()
243
 
    {
244
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
245
 
        delete loader;
246
 
#endif
247
 
    }
248
 
 
249
 
    void handleInputMethodAreaUpdate(MAbstractInputMethodHost *host,
250
 
                                     const QRegion &region)
251
 
    {
252
 
        if (not host) {
253
 
            return;
254
 
        }
255
 
 
256
 
        host->setInputMethodArea(region);
257
 
    }
258
 
 
259
 
    void updateActionKey (const MKeyOverride::KeyOverrideAttributes changedAttributes)
260
 
    {
261
 
        actionKeyOverride->applyOverride(sentActionKeyOverride, changedAttributes);
262
 
    }
263
 
    
264
 
    void syncInputMask ()
265
 
    {
266
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
267
 
#if defined(Q_WS_X11)
268
 
        if (!view->effectiveWinId())
269
 
            return;
270
 
 
271
 
        const int size = 1;
272
 
 
273
 
        XRectangle * const rects = new XRectangle[size];
274
 
 
275
 
        quint32 customRegion[size * 4]; // custom region is pack of x, y, w, h
276
 
        rects[0].x = inputMethodArea.x();
277
 
        rects[0].y = inputMethodArea.y();
278
 
        rects[0].width = inputMethodArea.width();
279
 
        rects[0].height = inputMethodArea.height();
280
 
        customRegion[0] = inputMethodArea.x();
281
 
        customRegion[1] = inputMethodArea.y();
282
 
        customRegion[2] = inputMethodArea.width();
283
 
        customRegion[3] = inputMethodArea.height();
284
 
 
285
 
 
286
 
        const XserverRegion shapeRegion = XFixesCreateRegion(QX11Info::display(), rects, size);
287
 
        XFixesSetWindowShapeRegion(QX11Info::display(), view->effectiveWinId(), ShapeBounding, 0, 0, 0);
288
 
        XFixesSetWindowShapeRegion(QX11Info::display(), view->effectiveWinId(), ShapeInput, 0, 0, shapeRegion);
289
 
 
290
 
        XFixesDestroyRegion(QX11Info::display(), shapeRegion);
291
 
 
292
 
        XChangeProperty(QX11Info::display(), view->effectiveWinId(),
293
 
                        XInternAtom(QX11Info::display(), "_MEEGOTOUCH_CUSTOM_REGION", False),
294
 
                        XA_CARDINAL, 32, PropModeReplace,
295
 
                        (unsigned char *) customRegion, size * 4);
296
 
 
297
 
        delete[] rects;
298
 
#endif
299
 
#else
300
 
        if (QGuiApplication::platformName() != "xcb")
301
 
            return;
302
 
 
303
 
        QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
304
 
        xcb_connection_t *connection = static_cast<xcb_connection_t *>(nativeInterface->nativeResourceForWindow("connection", surface->view()));
305
 
 
306
 
        xcb_rectangle_t rect;
307
 
        rect.x = inputMethodArea.x();
308
 
        rect.y = inputMethodArea.y();
309
 
        rect.width = inputMethodArea.width();
310
 
        rect.height = inputMethodArea.height();
311
 
 
312
 
        xcb_xfixes_region_t region = xcb_generate_id(connection);
313
 
        xcb_xfixes_create_region(connection, region, 1, &rect);
314
 
 
315
 
        xcb_window_t window  = surface->view()->winId();
316
 
        xcb_xfixes_set_window_shape_region(connection, window, XCB_SHAPE_SK_BOUNDING, 0, 0, 0);
317
 
        xcb_xfixes_set_window_shape_region(connection, window, XCB_SHAPE_SK_INPUT, 0, 0, region);
318
 
 
319
 
        xcb_xfixes_destroy_region(connection, region);
320
 
#endif
321
 
    }
322
 
};
323
 
 
324
 
MInputMethodQuick::MInputMethodQuick(MAbstractInputMethodHost *host,
325
 
                                     const QString &qmlFileName)
326
 
    : MAbstractInputMethod(host)
327
 
    , d_ptr(new MInputMethodQuickPrivate(host, this))
328
 
{
329
 
    Q_D(MInputMethodQuick);
330
 
 
331
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
332
 
    d->surface->view()->setSource(QUrl::fromLocalFile(qmlFileName));
333
 
#else
334
 
    d->loader->loadQmlFile(qmlFileName);
335
 
#endif
336
 
    
337
 
    propagateScreenSize();
338
 
}
339
 
 
340
 
MInputMethodQuick::~MInputMethodQuick()
341
 
{}
342
 
 
343
 
void MInputMethodQuick::handleFocusChange(bool focusIn)
344
 
{
345
 
    Q_D(MInputMethodQuick);
346
 
    d->haveFocus = focusIn;
347
 
}
348
 
 
349
 
void MInputMethodQuick::show()
350
 
{
351
 
    Q_D(MInputMethodQuick);
352
 
    d->sipRequested = true;
353
 
    if (d->sipIsInhibited) {
354
 
        return;
355
 
    }
356
 
 
357
 
    handleAppOrientationChanged(d->appOrientation);
358
 
    
359
 
    if (d->activeState == Maliit::OnScreen) {
360
 
      d->surface->show();
361
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
362
 
      d->loader->showUI();
363
 
#else
364
 
      setActive(true);
365
 
#endif
366
 
      d->syncInputMask();
367
 
    }
368
 
}
369
 
 
370
 
void MInputMethodQuick::hide()
371
 
{
372
 
    Q_D(MInputMethodQuick);
373
 
    if (!d->sipRequested) {
374
 
        return;
375
 
    }
376
 
    d->sipRequested = false;
377
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
378
 
    d->loader->hideUI();
379
 
#else
380
 
    setActive(false);
381
 
#endif
382
 
    d->surface->hide();
383
 
    const QRegion r;
384
 
    d->handleInputMethodAreaUpdate(inputMethodHost(), r);
385
 
}
386
 
 
387
 
void MInputMethodQuick::handleAppOrientationChanged(int angle)
388
 
{
389
 
    Q_D(MInputMethodQuick);
390
 
 
391
 
    MAbstractInputMethod::handleAppOrientationChanged(angle);
392
 
 
393
 
    if (d->appOrientation != angle) {
394
 
 
395
 
        d->appOrientation = angle;
396
 
        // When emitted, QML Plugin will realice a state
397
 
        // change and update InputMethodArea. Don't propagate those changes except if
398
 
        // VkB is currently showed
399
 
        Q_EMIT appOrientationChanged(d->appOrientation);
400
 
        if (d->sipRequested && !d->sipIsInhibited) {
401
 
            d->handleInputMethodAreaUpdate(inputMethodHost(), inputMethodArea().toRect());
402
 
        }
403
 
    }
404
 
}
405
 
 
406
 
void MInputMethodQuick::setState(const QSet<Maliit::HandlerState> &state)
407
 
{
408
 
    Q_D(MInputMethodQuick);
409
 
 
410
 
    if (state.isEmpty()) {
411
 
        return;
412
 
    }
413
 
 
414
 
    if (state.contains(Maliit::OnScreen)) {
415
 
        d->activeState = Maliit::OnScreen;
416
 
        if (d->sipRequested && !d->sipIsInhibited) {
417
 
            show(); // Force reparent of client widgets.
418
 
        }
419
 
    } else {
420
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
421
 
        d->loader->hideUI();
422
 
#else
423
 
        setActive(false);
424
 
#endif
425
 
        // Allow client to make use of InputMethodArea
426
 
        const QRegion r;
427
 
        d->handleInputMethodAreaUpdate(inputMethodHost(), r);
428
 
        d->activeState = *state.begin();
429
 
    }
430
 
}
431
 
 
432
 
void MInputMethodQuick::handleClientChange()
433
 
{
434
 
    Q_D(MInputMethodQuick);
435
 
 
436
 
    if (d->sipRequested) {
437
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
438
 
        d->loader->hideUI();
439
 
#else
440
 
        setActive(false);
441
 
#endif
442
 
    }
443
 
}
444
 
 
445
 
void MInputMethodQuick::handleVisualizationPriorityChange(bool inhibitShow)
446
 
{
447
 
    Q_D(MInputMethodQuick);
448
 
 
449
 
    if (d->sipIsInhibited == inhibitShow) {
450
 
        return;
451
 
    }
452
 
    d->sipIsInhibited = inhibitShow;
453
 
 
454
 
    if (d->sipRequested) {
455
 
        if (inhibitShow) {
456
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
457
 
            d->loader->hideUI();
458
 
#else
459
 
            setActive(false);
460
 
#endif
461
 
        } else {
462
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
463
 
            d->loader->showUI();
464
 
#else
465
 
            setActive(true);
466
 
#endif
467
 
        }
468
 
    }
469
 
}
470
 
 
471
 
 
472
 
void MInputMethodQuick::propagateScreenSize()
473
 
{
474
 
    Q_EMIT screenWidthChanged(computeDisplayRect().width());
475
 
    Q_EMIT screenHeightChanged(computeDisplayRect().height());
476
 
}
477
 
 
478
 
int MInputMethodQuick::screenHeight() const
479
 
{
480
 
    return computeDisplayRect().height();
481
 
}
482
 
 
483
 
int MInputMethodQuick::screenWidth() const
484
 
{
485
 
    return computeDisplayRect().width();
486
 
}
487
 
 
488
 
int MInputMethodQuick::appOrientation() const
489
 
{
490
 
    Q_D(const MInputMethodQuick);
491
 
    return d->appOrientation;
492
 
}
493
 
 
494
 
QRectF MInputMethodQuick::inputMethodArea() const
495
 
{
496
 
    Q_D(const MInputMethodQuick);
497
 
    return d->inputMethodArea;
498
 
}
499
 
 
500
 
void MInputMethodQuick::setInputMethodArea(const QRectF &area)
501
 
{
502
 
    Q_D(MInputMethodQuick);
503
 
 
504
 
    if (d->inputMethodArea != area.toRect()) {
505
 
        d->inputMethodArea = area.toRect();
506
 
        d->handleInputMethodAreaUpdate(inputMethodHost(), d->inputMethodArea);
507
 
 
508
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
509
 
        qDebug() << __PRETTY_FUNCTION__ << "QWidget::effectiveWinId(): " << d_ptr->view->effectiveWinId();
510
 
#endif
511
 
 
512
 
        Q_EMIT inputMethodAreaChanged(d->inputMethodArea);
513
 
        d->syncInputMask();
514
 
    }
515
 
}
516
 
 
517
 
void MInputMethodQuick::setScreenRegion(const QRect &region)
518
 
{
519
 
    inputMethodHost()->setScreenRegion(region);
520
 
}
521
 
 
522
 
void MInputMethodQuick::sendPreedit(const QString &text)
523
 
{
524
 
    QList<Maliit::PreeditTextFormat> lst;
525
 
    inputMethodHost()->sendPreeditString(text, lst, text.length());
526
 
}
527
 
 
528
 
void MInputMethodQuick::sendKey(int key, int modifiers, const QString &text)
529
 
{
530
 
    QKeyEvent event(QEvent::KeyPress, key, (~(Qt::KeyboardModifiers(Qt::NoModifier))) & modifiers, text);
531
 
    inputMethodHost()->sendKeyEvent(event);
532
 
}
533
 
 
534
 
void MInputMethodQuick::sendCommit(const QString &text)
535
 
{
536
 
    if (text == "\b") {
537
 
        QKeyEvent event(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier);
538
 
        inputMethodHost()->sendKeyEvent(event);
539
 
    } else
540
 
    if ((text == "\r\n") || (text == "\n") || (text == "\r")) {
541
 
        QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
542
 
        inputMethodHost()->sendKeyEvent(event);
543
 
    } else {
544
 
        inputMethodHost()->sendCommitString(text);
545
 
    }
546
 
}
547
 
 
548
 
void MInputMethodQuick::pluginSwitchRequired(int switchDirection)
549
 
{
550
 
    inputMethodHost()->switchPlugin(
551
 
        static_cast<Maliit::SwitchDirection>(switchDirection));
552
 
}
553
 
 
554
 
void MInputMethodQuick::userHide()
555
 
{
556
 
    hide();
557
 
    inputMethodHost()->notifyImInitiatedHiding();
558
 
}
559
 
 
560
 
void MInputMethodQuick::setKeyOverrides(const QMap<QString, QSharedPointer<MKeyOverride> > &overrides)
561
 
{
562
 
    Q_D(MInputMethodQuick);
563
 
    const QMap<QString, QSharedPointer<MKeyOverride> >::const_iterator iter(overrides.find(actionKeyName));
564
 
 
565
 
    if (d->sentActionKeyOverride) {
566
 
        disconnect(d->sentActionKeyOverride.data(), SIGNAL(keyAttributesChanged(const QString &, const MKeyOverride::KeyOverrideAttributes)),
567
 
                   this, SLOT(onSentActionKeyAttributesChanged(const QString &, const MKeyOverride::KeyOverrideAttributes)));
568
 
        d->sentActionKeyOverride.clear();
569
 
    }
570
 
 
571
 
    if (iter != overrides.end()) {
572
 
        QSharedPointer<MKeyOverride> sentActionKeyOverride(*iter);
573
 
 
574
 
        if (sentActionKeyOverride) {
575
 
            d->sentActionKeyOverride = sentActionKeyOverride;
576
 
            connect(d->sentActionKeyOverride.data(), SIGNAL(keyAttributesChanged(const QString &, const MKeyOverride::KeyOverrideAttributes)),
577
 
                    this, SLOT(onSentActionKeyAttributesChanged(const QString &, const MKeyOverride::KeyOverrideAttributes)));
578
 
        }
579
 
    }
580
 
    d->updateActionKey(MKeyOverride::All);
581
 
}
582
 
 
583
 
QList<MAbstractInputMethod::MInputMethodSubView> MInputMethodQuick::subViews(Maliit::HandlerState state) const
584
 
{
585
 
    Q_UNUSED(state);
586
 
    MAbstractInputMethod::MInputMethodSubView sub_view;
587
 
    sub_view.subViewId = "";
588
 
    sub_view.subViewTitle = "";
589
 
    QList<MAbstractInputMethod::MInputMethodSubView> sub_views;
590
 
    sub_views << sub_view;
591
 
    return sub_views;
592
 
}
593
 
 
594
 
void MInputMethodQuick::onSentActionKeyAttributesChanged(const QString &, const MKeyOverride::KeyOverrideAttributes changedAttributes)
595
 
{
596
 
    Q_D(MInputMethodQuick);
597
 
 
598
 
    d->updateActionKey(changedAttributes);
599
 
}
600
 
 
601
 
MKeyOverrideQuick* MInputMethodQuick::actionKeyOverride() const
602
 
{
603
 
    Q_D(const MInputMethodQuick);
604
 
 
605
 
    return d->actionKeyOverride.data();
606
 
}
607
 
 
608
 
void MInputMethodQuick::activateActionKey()
609
 
{
610
 
    sendCommit("\n");
611
 
}
612
 
 
613
 
bool MInputMethodQuick::isActive() const
614
 
{
615
 
    Q_D(const MInputMethodQuick);
616
 
    return d->active;
617
 
}
618
 
 
619
 
void MInputMethodQuick::setActive(bool enable)
620
 
{
621
 
    Q_D(MInputMethodQuick);
622
 
    if (d->active != enable) {
623
 
        d->active = enable;
624
 
        Q_EMIT activeChanged();
625
 
    }
626
 
}