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

Qt6 support v2 #125

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
183 changes: 115 additions & 68 deletions CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/maliit-framework.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: Maliit Framework
Description: Maliit provides a flexible and cross platform input method framework. It is usable on all MeeGo user experiences, and in other GNU/Linux distributions as well.
Version: @PROJECT_VERSION@
Cflags: -I${includedir}/maliit-2
Cflags: -I${includedir}/maliit@MALIIT_LIB_SUFFIX@-2
1 change: 1 addition & 0 deletions common/maliit/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef MALIIT_NAMESPACE_H
#define MALIIT_NAMESPACE_H

#include <QList>
#include <QMetaType>
#include <QSharedPointer>

Expand Down
1 change: 1 addition & 0 deletions connection/mimserverconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define MIMSERVERCONNECTION_H

#include <maliit/namespace.h>
#include <maliit/settingdata.h>

#include <QtCore>

Expand Down
60 changes: 30 additions & 30 deletions connection/waylandinputmethodconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "wayland-client.h"
#include <qwayland-input-method-unstable-v1.h>
#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
#include <qwayland-text-input-unstable-v1.h>

#include <xkbcommon/xkbcommon.h>

Expand Down Expand Up @@ -113,37 +113,37 @@ xkb_keysym_t keyFromQt(int qt_key)
}
}

QtWayland::zwp_text_input_v2::preedit_style preeditStyleFromMaliit(Maliit::PreeditFace face)
QtWayland::zwp_text_input_v1::preedit_style preeditStyleFromMaliit(Maliit::PreeditFace face)
{
switch (face) {
case Maliit::PreeditDefault:
return QtWayland::zwp_text_input_v2::preedit_style_default;
return QtWayland::zwp_text_input_v1::preedit_style_default;
case Maliit::PreeditNoCandidates:
return QtWayland::zwp_text_input_v2::preedit_style_incorrect;
return QtWayland::zwp_text_input_v1::preedit_style_incorrect;
case Maliit::PreeditKeyPress:
return QtWayland::zwp_text_input_v2::preedit_style_highlight;
return QtWayland::zwp_text_input_v1::preedit_style_highlight;
case Maliit::PreeditUnconvertible:
return QtWayland::zwp_text_input_v2::preedit_style_inactive;
return QtWayland::zwp_text_input_v1::preedit_style_inactive;
case Maliit::PreeditActive:
return QtWayland::zwp_text_input_v2::preedit_style_active;
return QtWayland::zwp_text_input_v1::preedit_style_active;
default:
return QtWayland::zwp_text_input_v2::preedit_style_none;
return QtWayland::zwp_text_input_v1::preedit_style_none;
}
}

Maliit::TextContentType contentTypeFromWayland(uint32_t purpose)
{
switch (purpose) {
case QtWayland::zwp_text_input_v2::content_purpose_normal:
case QtWayland::zwp_text_input_v1::content_purpose_normal:
return Maliit::FreeTextContentType;
case QtWayland::zwp_text_input_v2::content_purpose_digits:
case QtWayland::zwp_text_input_v2::content_purpose_number:
case QtWayland::zwp_text_input_v1::content_purpose_digits:
case QtWayland::zwp_text_input_v1::content_purpose_number:
return Maliit::NumberContentType;
case QtWayland::zwp_text_input_v2::content_purpose_phone:
case QtWayland::zwp_text_input_v1::content_purpose_phone:
return Maliit::PhoneNumberContentType;
case QtWayland::zwp_text_input_v2::content_purpose_url:
case QtWayland::zwp_text_input_v1::content_purpose_url:
return Maliit::UrlContentType;
case QtWayland::zwp_text_input_v2::content_purpose_email:
case QtWayland::zwp_text_input_v1::content_purpose_email:
return Maliit::EmailContentType;
default:
return Maliit::CustomContentType;
Expand Down Expand Up @@ -338,15 +338,15 @@ void WaylandInputMethodConnection::sendPreeditString(const QString &string,

if (replace_length > 0) {
int cursor = widgetState().value(CursorPositionAttribute).toInt();
uint32_t index = string.midRef(qMin(cursor + replace_start, cursor), qAbs(replace_start)).toUtf8().size();
uint32_t length = string.midRef(cursor + replace_start, replace_length).toUtf8().size();
uint32_t index = string.mid(qMin(cursor + replace_start, cursor), qAbs(replace_start)).toUtf8().size();
uint32_t length = string.mid(cursor + replace_start, replace_length).toUtf8().size();
d->context()->delete_surrounding_text(index, length);
}

Q_FOREACH (const Maliit::PreeditTextFormat& format, preedit_formats) {
QtWayland::zwp_text_input_v2::preedit_style style = preeditStyleFromMaliit(format.preeditFace);
uint32_t index = string.leftRef(format.start).toUtf8().size();
uint32_t length = string.leftRef(format.start + format.length).toUtf8().size() - index;
QtWayland::zwp_text_input_v1::preedit_style style = preeditStyleFromMaliit(format.preeditFace);
uint32_t index = string.left(format.start).toUtf8().size();
uint32_t length = string.left(format.start + format.length).toUtf8().size() - index;
qCDebug(lcWaylandConnection) << Q_FUNC_INFO << "preedit_styling" << index << length;
d->context()->preedit_styling(index, length, style);
}
Expand All @@ -356,8 +356,8 @@ void WaylandInputMethodConnection::sendPreeditString(const QString &string,
cursor_pos = string.size() + 1 - cursor_pos;
}

qCDebug(lcWaylandConnection) << Q_FUNC_INFO << "preedit_cursor" << string.leftRef(cursor_pos).toUtf8().size();
d->context()->preedit_cursor(string.leftRef(cursor_pos).toUtf8().size());
qCDebug(lcWaylandConnection) << Q_FUNC_INFO << "preedit_cursor" << string.left(cursor_pos).toUtf8().size();
d->context()->preedit_cursor(string.left(cursor_pos).toUtf8().size());
qCDebug(lcWaylandConnection) << Q_FUNC_INFO << "preedit_string" << string;
d->context()->preedit_string(d->context()->serial(), string, string);
}
Expand All @@ -384,12 +384,12 @@ void WaylandInputMethodConnection::sendCommitString(const QString &string,

if (replace_length > 0) {
int cursor = widgetState().value(CursorPositionAttribute).toInt();
uint32_t index = string.midRef(qMin(cursor + replace_start, cursor), qAbs(replace_start)).toUtf8().size();
uint32_t length = string.midRef(cursor + replace_start, replace_length).toUtf8().size();
uint32_t index = string.mid(qMin(cursor + replace_start, cursor), qAbs(replace_start)).toUtf8().size();
uint32_t length = string.mid(cursor + replace_start, replace_length).toUtf8().size();
d->context()->delete_surrounding_text(index, length);
}

cursor_pos = string.leftRef(cursor_pos).toUtf8().size();
cursor_pos = string.left(cursor_pos).toUtf8().size();
d->context()->cursor_position(cursor_pos, cursor_pos);
d->context()->commit_string(d->context()->serial(), string);
}
Expand Down Expand Up @@ -470,8 +470,8 @@ void WaylandInputMethodConnection::setSelection(int start, int length)
return;

QString surrounding = widgetState().value(SurroundingTextAttribute).toString();
uint32_t index(surrounding.leftRef(start + length).toUtf8().size());
uint32_t anchor(surrounding.leftRef(start).toUtf8().size());
uint32_t index(surrounding.left(start + length).toUtf8().size());
uint32_t anchor(surrounding.left(start).toUtf8().size());

d->context()->cursor_position(index, anchor);
d->context()->commit_string(d->context()->serial(), QString());
Expand Down Expand Up @@ -563,10 +563,10 @@ void InputMethodContext::zwp_input_method_context_v1_content_type(uint32_t hint,
qCDebug(lcWaylandConnection) << Q_FUNC_INFO;

m_stateInfo[ContentTypeAttribute] = contentTypeFromWayland(purpose);
m_stateInfo[AutoCapitalizationAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v2::content_hint_auto_capitalization);
m_stateInfo[CorrectionAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v2::content_hint_auto_correction);
m_stateInfo[PredictionAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v2::content_hint_auto_completion);
m_stateInfo[HiddenTextAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v2::content_hint_hidden_text);
m_stateInfo[AutoCapitalizationAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v1::content_hint_auto_capitalization);
m_stateInfo[CorrectionAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v1::content_hint_auto_correction);
m_stateInfo[PredictionAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v1::content_hint_auto_completion);
m_stateInfo[HiddenTextAttribute] = matchesFlag(hint, QtWayland::zwp_text_input_v1::content_hint_hidden_text);
}

void InputMethodContext::zwp_input_method_context_v1_invoke_action(uint32_t button, uint32_t index)
Expand Down
6 changes: 3 additions & 3 deletions examples/plugins/cxx/helloworld/helloworldinputmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <maliit/plugins/abstractinputmethodhost.h>

#include <QDebug>
#include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication>
#include <QScreen>

namespace {

Expand Down Expand Up @@ -89,7 +89,7 @@ void HelloWorldInputMethod::show()
}

// Set size of our container to screen size
const QSize screenSize = QApplication::desktop()->screenGeometry().size();
const QSize screenSize = QGuiApplication::primaryScreen()->size();
mainWidget->parentWidget()->resize(screenSize);

// Set size of the input method
Expand Down
6 changes: 3 additions & 3 deletions examples/plugins/cxx/override/overrideinputmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <maliit/plugins/abstractinputmethodhost.h>

#include <QDebug>
#include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication>
#include <QScreen>
#include <QKeyEvent>

namespace {
Expand Down Expand Up @@ -81,7 +81,7 @@ void OverrideInputMethod::show()
}

// Set size of the input method
const QSize &screenSize = QApplication::desktop()->screenGeometry().size();
const QSize &screenSize = QGuiApplication::primaryScreen()->size();
const QSize size(screenSize.width() - 200, 200);

surface->setGeometry(QRect(QPoint((screenSize.width() - size.width()) / 2,
Expand Down
2 changes: 1 addition & 1 deletion input-context/minputcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void MInputContext::onInvokeAction(const QString &action, const QKeySequence &se
const int modifiers = sequence[i] & AllModifiers;
QString text("");
if (modifiers == Qt::NoModifier || modifiers == Qt::ShiftModifier) {
text = QString(key);
text = QString(QChar::fromLatin1(key));
}
keyEvent(QEvent::KeyPress, key, modifiers, text, false, 1);
keyEvent(QEvent::KeyRelease, key, modifiers, text, false, 1);
Expand Down
2 changes: 1 addition & 1 deletion maliit-glib/MaliitGLibConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/MaliitGLibTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Maliit@MALIIT_LIB_SUFFIX@GLibTargets.cmake")
4 changes: 2 additions & 2 deletions maliit-glib/maliit-glib.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Name: Maliit-GLib
Description: Maliit provides a flexible and cross platform input method framework. It is usable on all MeeGo user experiences, and in other GNU/Linux distributions as well.
Version: @PROJECT_VERSION@
Requires: gobject-2.0 gio-2.0
Cflags: -I${includedir}/maliit-2
Libs: -L${libdir} -lmaliit-glib
Cflags: -I${includedir}/maliit@MALIIT_LIB_SUFFIX@-2
Libs: -L${libdir} -lmaliit@MALIIT_LIB_SUFFIX@-glib
8 changes: 4 additions & 4 deletions src/MaliitPluginsConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(CMakeFindDependencyMacro)

find_dependency(Qt5Core @Qt5Core_VERSION@)
find_dependency(Qt5Gui @Qt5Gui_VERSION@)
find_dependency(Qt5Quick @Qt5Quick_VERSION@)
find_dependency(Qt@QT_VERSION_MAJOR@Core @QT_VERSION@)
find_dependency(Qt@QT_VERSION_MAJOR@Gui @QT_VERSION@)
find_dependency(Qt@QT_VERSION_MAJOR@Quick @QT_VERSION@)

include("${CMAKE_CURRENT_LIST_DIR}/MaliitPluginsTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Maliit@MALIIT_LIB_SUFFIX@PluginsTargets.cmake")
8 changes: 4 additions & 4 deletions src/maliit-plugins.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
datarootdir=@CMAKE_INSTALL_FULL_DATADIR@

pluginsdir=${libdir}/maliit/plugins
pluginsdir=${libdir}/maliit@MALIIT_LIB_SUFFIX@/plugins
datadir=${datarootdir}
pluginsdatadir=${datadir}/maliit/plugins
pluginsdatadir=${datadir}/maliit@MALIIT_LIB_SUFFIX@/plugins

Name: Maliit Plugins
Description: Maliit provides a flexible and cross platform input method framework. It is usable on all MeeGo user experiences, and in other GNU/Linux distributions as well.
Version: @PROJECT_VERSION@
Requires: maliit-framework

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Requires: maliit-framework
Requires: maliit@MALIIT_LIB_SUFFIX@-framework

Cflags: -I${includedir}/maliit-2
Libs: -L${libdir} -lmaliit-plugins
Cflags: -I${includedir}/maliit@MALIIT_LIB_SUFFIX@-2
Libs: -L${libdir} -lmaliit@MALIIT_LIB_SUFFIX@-plugins
8 changes: 4 additions & 4 deletions src/maliit-server.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
datarootdir=@CMAKE_INSTALL_FULL_DATADIR@

pluginsdir=${libdir}/maliit/plugins
pluginsdir=${libdir}/maliit@MALIIT_LIB_SUFFIX@/plugins
datadir=${datarootdir}
pluginsdatadir=${datadir}/maliit/plugins
pluginsdatadir=${datadir}/maliit@MALIIT_LIB_SUFFIX@/plugins

Name: Maliit Server
Description: Library for embedding the Maliit IM Server
Version: @PROJECT_VERSION@
Requires: maliit-framework maliit-plugins
Cflags: -I${includedir}/maliit-2
Requires: maliit@MALIIT_LIB_SUFFIX@-framework maliit@MALIIT_LIB_SUFFIX@-plugins
Cflags: -I${includedir}/maliit@MALIIT_LIB_SUFFIX@-2
Libs: -L${libdir}
2 changes: 1 addition & 1 deletion src/msharedattributeextensionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ MSharedAttributeExtensionManager::~MSharedAttributeExtensionManager()
void MSharedAttributeExtensionManager::registerPluginSetting(const QString &fullName, Maliit::SettingEntryType type,
QVariantMap attributes)
{
QString key = fullName.section(1, -1);
QString key = fullName.section(QChar(), 0);
QSharedPointer<MSharedAttributeExtensionManagerPluginSetting> value(new MSharedAttributeExtensionManagerPluginSetting(key, type, attributes));

sharedAttributeExtensions[key] = value;
Expand Down
1 change: 1 addition & 0 deletions src/quick/inputmethodquick.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <maliit/plugins/abstractinputmethod.h>
#include <maliit/plugins/keyoverride.h>
#include "keyoverridequick.h"
#include "maliitquick.h"

#include <QEvent>
Expand Down
1 change: 0 additions & 1 deletion tests/ft_mimpluginmanager/ft_mimpluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <unknownplatform.h>

#include <QProcess>
#include <QRegExp>
#include <QGuiApplication>
#include <QPointer>

Expand Down
1 change: 0 additions & 1 deletion tests/ut_mimpluginmanager/ut_mimpluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "core-utils.h"

#include <QProcess>
#include <QRegExp>
#include <QCoreApplication>
#include <QPointer>
#include <QTimer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <QTest>
#include <QProcess>
#include <QRegExp>
#include <QCoreApplication>
#include <QPointer>
#include <QTimer>
Expand Down
9 changes: 5 additions & 4 deletions tests/utils/core-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <QtDebug>
#include <QtCore>
#include <QtTest>
#include <QRegularExpression>

namespace {
const QString TestingInSandboxEnvVariable("TESTING_IN_SANDBOX");
Expand All @@ -30,12 +31,12 @@ namespace {
// Returns true on success, false on error
bool setPathFromEnvironmentVariable(QString *path, QString envVar) {
const QStringList env(QProcess::systemEnvironment());
int index = env.indexOf(QRegExp('^' + envVar + "=.*", Qt::CaseInsensitive));
int index = env.indexOf(QRegularExpression('^' + envVar + "=.*", QRegularExpression::CaseInsensitiveOption));

if (index != -1) {
QString pathCandidate = env.at(index);
pathCandidate = pathCandidate.remove(
QRegExp('^' + envVar + '=', Qt::CaseInsensitive));
QRegularExpression('^' + envVar + '=', QRegularExpression::CaseInsensitiveOption));
if (!pathCandidate.isEmpty()) {
*path = pathCandidate;
return true;
Expand All @@ -57,11 +58,11 @@ bool isTestingInSandbox()
{
bool testingInSandbox = false;
const QStringList env(QProcess::systemEnvironment());
int index = env.indexOf(QRegExp('^' + TestingInSandboxEnvVariable + "=.*", Qt::CaseInsensitive));
int index = env.indexOf(QRegularExpression('^' + TestingInSandboxEnvVariable + "=.*", QRegularExpression::CaseInsensitiveOption));
if (index != -1) {
QString statusCandidate = env.at(index);
statusCandidate = statusCandidate.remove(
QRegExp('^' + TestingInSandboxEnvVariable + '=', Qt::CaseInsensitive));
QRegularExpression('^' + TestingInSandboxEnvVariable + '=', QRegularExpression::CaseInsensitiveOption));
bool statusOk = false;
int status = statusCandidate.toInt(&statusOk);
if (statusOk && (status == 0 || status == 1)) {
Expand Down