File: dummyinputmethod3.cpp

package info (click to toggle)
maliit-framework 2.3.0-3.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,488 kB
  • sloc: cpp: 13,098; ansic: 2,506; xml: 299; sh: 34; makefile: 23; sed: 4
file content (98 lines) | stat: -rw-r--r-- 2,683 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "dummyinputmethod3.h"
#include <maliit/plugins/abstractinputmethodhost.h>

#include <QDebug>
#include <QRegion>

void DummyInputMethod3::addSubView(const QString &id, const QString &title)
{
    MAbstractInputMethod::MInputMethodSubView sv;
    sv.subViewId = id;
    sv.subViewTitle = title;
    sViews.append(sv);
}

DummyInputMethod3::DummyInputMethod3(MAbstractInputMethodHost *host)
    : MAbstractInputMethod(host),
      setStateCount(0),
      switchContextCallCount(0),
      directionParam(Maliit::SwitchUndefined),
      enableAnimationParam(false)
{
    addSubView("dummyim3sv1", "dummyim3sv1");
    addSubView("dummyim3sv2", "dummyim3sv2");
    addSubView("en_gb", "en_gb");
    addSubView("es", "es");
    addSubView("fr_fr", "fr_fr");

    activeSView = "dummyim3sv1";

    // Register setting
    QVariantMap settingAttributes;

    settingAttributes[Maliit::SettingEntryAttributes::defaultValue] = "Test";

    setting.reset(host->registerPluginSetting("setting", QT_TR_NOOP("Example setting"),
                                              Maliit::StringType, settingAttributes));

    connect(setting.data(), SIGNAL(valueChanged()),
            this,           SLOT(handleSettingChanged()));
}

void DummyInputMethod3::setState(const QSet<Maliit::HandlerState> &state)
{
    qDebug() << Q_FUNC_INFO << state;
    ++setStateCount;
    setStateParam = state;
}

void DummyInputMethod3::switchContext(Maliit::SwitchDirection direction,
                              bool enableAnimation)
{
    ++switchContextCallCount;
    directionParam = direction;
    enableAnimationParam = enableAnimation;
}

QList<MAbstractInputMethod::MInputMethodSubView>
DummyInputMethod3::subViews(Maliit::HandlerState state) const
{
    qDebug() << Q_FUNC_INFO;
    QList<MAbstractInputMethod::MInputMethodSubView> svs;
    if (state == Maliit::OnScreen) {
        svs = sViews;
    }
    return svs;
}

void DummyInputMethod3::setActiveSubView(const QString &sVId, Maliit::HandlerState state)
{
    qDebug() << Q_FUNC_INFO;
    if (state == Maliit::OnScreen) {
        Q_FOREACH (const MAbstractInputMethod::MInputMethodSubView &sv, sViews) {
            if (sv.subViewId == sVId) {
                activeSView = sVId;
            }
        }
    }
}

QString DummyInputMethod3::activeSubView(Maliit::HandlerState state) const
{
    qDebug() << Q_FUNC_INFO;
    if (state == Maliit::OnScreen)
        return activeSView;
    else
        return QString();
}

void DummyInputMethod3::show()
{
    inputMethodHost()->setScreenRegion(QRegion(0, 0, 100, 100));
    Q_EMIT showCalled();
}

void DummyInputMethod3::handleSettingChanged()
{
    localSettingValue = setting->value();
}