Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Maliit 3 refactoring #135

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(MaliitPlugins 0.99.1 REQUIRED)
find_package(MaliitPlugins 2.99.0 REQUIRED)

find_package(GLib2 REQUIRED)
find_package(GIO REQUIRED)
Expand Down Expand Up @@ -157,8 +157,6 @@ set(MALIIT_KEYBOARD_COMMON_SOURCES
src/plugin/feedback.h
src/plugin/gettext.cpp
src/plugin/gettext.h
src/plugin/updatenotifier.cpp
src/plugin/updatenotifier.h
src/plugin/inputmethod.cpp
src/plugin/inputmethod.h
src/plugin/inputmethod_p.h
Expand Down
14 changes: 10 additions & 4 deletions qml/KeyboardContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,31 @@ Item {
}

// NumberContentType
if (contentType === 1) {
if (contentType === Keyboard.NumberContentType) {
canvas.layoutId = "number";
return "languages/Keyboard_numbers.qml";
}

// FormattedNumberContentType
if (contentType === Keyboard.FormattedNumberContentType) {
canvas.layoutId = "formatted";
return "languages/Keyboard_formattednumbers.qml";
}

// PhoneNumberContentType
if (contentType === 2) {
if (contentType === Keyboard.PhoneNumberContentType ) {
canvas.layoutId = "telephone";
return "languages/Keyboard_telephone.qml";
}

// EmailContentType
if (contentType === 3) {
if (contentType === Keyboard.EmailContentType) {
canvas.layoutId = "email";
return Keyboard.currentPluginPath + "/Keyboard_" + language + "_email.qml";
}

// UrlContentType
if (contentType === 4) {
if (contentType === Keyboard.UrlContentType) {
canvas.layoutId = "url";
return Keyboard.currentPluginPath + "/Keyboard_" + language + "_url_search.qml";
}
Expand Down
82 changes: 82 additions & 0 deletions qml/languages/Keyboard_formattednumbers.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 2.4

import MaliitKeyboard 2.0

import "../keys"

KeyPad {
anchors.fill: parent

content: c1
symbols: ""

Column {
id: c1
anchors.fill: parent
anchors.leftMargin: Device.gu(1);
anchors.rightMargin: Device.gu(1);
anchors.bottomMargin: Device.gu(1);

property double numKeyWidth: panel.keyWidth - Device.gu(0.75);
property double numKeyHeight: panel.keyHeight - Device.gu(1);

spacing: Device.gu(1);

Row {
anchors.horizontalCenter: parent.horizontalCenter;
spacing: Device.gu(0.5);

CharKey { label: "1"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "2"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "3"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "-"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}

Row {
anchors.horizontalCenter: parent.horizontalCenter;
spacing: Device.gu(0.5);

CharKey { label: "4"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "5"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "6"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: ","; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}

Row {
anchors.horizontalCenter: parent.horizontalCenter;
spacing: Device.gu(0.5);

CharKey { label: "7"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "8"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "9"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
BackspaceKey { padding: 0; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}

Row {
anchors.horizontalCenter: parent.horizontalCenter;
spacing: Device.gu(0.5);

CharKey { label: "."; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "0"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
Item { width: c1.numKeyWidth; height: c1.numKeyHeight; }
ReturnKey { padding: 0; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}
} // column
}

6 changes: 1 addition & 5 deletions qml/languages/Keyboard_numbers.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ KeyPad {
CharKey { label: "1"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "2"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "3"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "-"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}

Row {
Expand All @@ -55,7 +54,6 @@ KeyPad {
CharKey { label: "4"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "5"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "6"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
SmallSpaceKey { padding: 0; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}

Row {
Expand All @@ -65,16 +63,14 @@ KeyPad {
CharKey { label: "7"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "8"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "9"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
BackspaceKey { padding: 0; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}

Row {
anchors.horizontalCenter: parent.horizontalCenter;
spacing: Device.gu(0.5);

CharKey { label: "+"; annotation: "#*"; extended: ["#", "*"]; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
BackspaceKey { padding: 0; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "0"; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
CharKey { label: "."; noMagnifier: true; width: c1.numKeyWidth; height: c1.numKeyHeight; }
ReturnKey { padding: 0; width: c1.numKeyWidth; height: c1.numKeyHeight; }
}
} // column
Expand Down
73 changes: 30 additions & 43 deletions src/plugin/inputmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@
#include "view/setup.h"

#include <maliit/plugins/subviewdescription.h>
#include <maliit/plugins/updateevent.h>
#include <maliit/namespace.h>

#include <QGuiApplication>


class MImUpdateEvent;

using namespace MaliitKeyboard;

namespace {
Expand Down Expand Up @@ -260,45 +257,6 @@ void InputMethod::handleClientChange()
hide();
}

bool InputMethod::imExtensionEvent(MImExtensionEvent *event)
{
Q_D(InputMethod);

if (not event or event->type() != MImExtensionEvent::Update) {
return false;
}

auto enterKeyType = inputMethodHost()->inputMethodQuery(Qt::ImEnterKeyType).value<Qt::EnterKeyType>();

d->actionKeyOverrider.reset(new MKeyOverride(actionKeyName));
switch (enterKeyType) {
case Qt::EnterKeyDefault:
case Qt::EnterKeyReturn:
d->actionKeyOverrider->setLabel(QString());
break;
case Qt::EnterKeyDone:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Done"));
break;
case Qt::EnterKeyGo:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Go"));
break;
case Qt::EnterKeySend:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Send"));
break;
case Qt::EnterKeySearch:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Search"));
break;
case Qt::EnterKeyNext:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Next"));
break;
case Qt::EnterKeyPrevious:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Previous"));
break;
}
emit actionKeyOverrideChanged();
return true;
}

void InputMethod::onAutoCorrectSettingChanged()
{
Q_D(InputMethod);
Expand Down Expand Up @@ -459,6 +417,36 @@ void InputMethod::update()
checkAutocaps();
d->previous_position = position;
}

// Check for action key overrides
auto enterKeyType = inputMethodHost()->inputMethodQuery(Qt::ImEnterKeyType).value<Qt::EnterKeyType>();

d->actionKeyOverrider.reset(new MKeyOverride(actionKeyName));
switch (enterKeyType) {
case Qt::EnterKeyDefault:
case Qt::EnterKeyReturn:
d->actionKeyOverrider->setLabel(QString());
break;
case Qt::EnterKeyDone:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Done"));
break;
case Qt::EnterKeyGo:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Go"));
break;
case Qt::EnterKeySend:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Send"));
break;
case Qt::EnterKeySearch:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Search"));
break;
case Qt::EnterKeyNext:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Next"));
break;
case Qt::EnterKeyPrevious:
d->actionKeyOverrider->setLabel(d->m_gettext->qsTr("Previous"));
break;
}
emit actionKeyOverrideChanged();
}

void InputMethod::updateWordEngine()
Expand Down Expand Up @@ -641,7 +629,6 @@ void InputMethod::setActiveLanguage(const QString &newLanguage)
d->editor.commitPreedit();

d->activeLanguage = newLanguage;
d->host->setLanguage(newLanguage);
d->m_settings.setActiveLanguage(newLanguage);

qDebug() << "in inputMethod.cpp setActiveLanguage() emitting activeLanguageChanged to" << d->activeLanguage;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/inputmethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class InputMethod
enum TextContentType {
FreeTextContentType = Maliit::FreeTextContentType,
NumberContentType = Maliit::NumberContentType,
FormattedNumberContentType = Maliit::FormattedNumberContentType,
PhoneNumberContentType = Maliit::PhoneNumberContentType,
EmailContentType = Maliit::EmailContentType,
UrlContentType = Maliit::UrlContentType,
Expand All @@ -96,7 +97,6 @@ class InputMethod
void handleAppOrientationChanged(int angle) override;
void handleClientChange() override;
void reset() override;
bool imExtensionEvent(MImExtensionEvent *event) override;
void setKeyOverrides(const QMap<QString, QSharedPointer<MKeyOverride> > &overrides) override;
//! \reimp_end

Expand Down
2 changes: 0 additions & 2 deletions src/plugin/inputmethod_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "logic/wordengine.h"

#include <maliit/plugins/abstractinputmethodhost.h>
#include <maliit/plugins/abstractpluginsetting.h>

#include <QtQuick>
#include <QStringList>
Expand All @@ -49,7 +48,6 @@ const Qt::WindowType InputMethodWindowType = (Qt::WindowType)(0x00000080 | Qt::W

using namespace MaliitKeyboard;

typedef QScopedPointer<Maliit::Plugins::AbstractPluginSetting> ScopedSetting;
typedef QSharedPointer<MKeyOverride> SharedOverride;
typedef QMap<QString, SharedOverride>::const_iterator OverridesIterator;

Expand Down
Loading