init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
8
Telegram/ThirdParty/fcitx5-qt/qt4/CMakeLists.txt
vendored
Normal file
8
Telegram/ThirdParty/fcitx5-qt/qt4/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
find_package(Qt4 ${REQUIRED_QT4_VERSION} REQUIRED)
|
||||
|
||||
add_subdirectory(dbusaddons)
|
||||
add_subdirectory(inputcontext)
|
||||
|
||||
if(NOT BUILD_ONLY_PLUGIN)
|
||||
add_subdirectory(immodule-probing)
|
||||
endif()
|
||||
78
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/CMakeLists.txt
vendored
Normal file
78
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
ecm_setup_version(PROJECT VARIABLE_PREFIX FCITX5QT4DBUSADDONS
|
||||
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fcitx5qt4dbusaddons_version.h"
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Fcitx5Qt4DBusAddonsConfigVersion.cmake"
|
||||
SOVERSION 1)
|
||||
|
||||
# create a Config.cmake and a ConfigVersion.cmake file and install them
|
||||
set(CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Fcitx5Qt4DBusAddons")
|
||||
|
||||
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Fcitx5Qt4DBusAddonsConfig.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Fcitx5Qt4DBusAddonsConfig.cmake"
|
||||
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
set(dbusaddons_SOURCES
|
||||
fcitxqtwatcher.cpp
|
||||
fcitxqtdbustypes.cpp
|
||||
fcitxqtinputcontextproxy.cpp
|
||||
fcitxqtinputcontextproxyimpl.cpp
|
||||
fcitxqtinputmethodproxy.cpp
|
||||
)
|
||||
|
||||
set(dbusaddons_HEADERS
|
||||
fcitxqtwatcher.h
|
||||
fcitxqtdbustypes.h
|
||||
fcitxqtinputcontextproxy.h
|
||||
fcitxqtinputmethodproxy.h
|
||||
)
|
||||
|
||||
set(fcitxqtdbusaddons_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_library(Fcitx5Qt4DBusAddons ${LIBRARY_TYPE} ${dbusaddons_SOURCES})
|
||||
generate_export_header(Fcitx5Qt4DBusAddons BASE_NAME Fcitx5Qt4DBusAddons)
|
||||
add_library(Fcitx5Qt4::DBusAddons ALIAS Fcitx5Qt4DBusAddons)
|
||||
|
||||
target_include_directories(Fcitx5Qt4DBusAddons PUBLIC "$<BUILD_INTERFACE:${fcitxqtdbusaddons_INCLUDE_DIRS}>")
|
||||
target_include_directories(Fcitx5Qt4DBusAddons INTERFACE "$<INSTALL_INTERFACE:${Fcitx5Qt4_INCLUDE_INSTALL_DIR}/Fcitx5Qt4DBusAddons>")
|
||||
|
||||
set_target_properties(Fcitx5Qt4DBusAddons
|
||||
PROPERTIES VERSION ${FCITX5QT4DBUSADDONS_VERSION}
|
||||
AUTOMOC TRUE
|
||||
SOVERSION ${FCITX5QT4DBUSADDONS_SOVERSION}
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
EXPORT_NAME DBusAddons
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
Fcitx5Qt4DBusAddons
|
||||
PUBLIC
|
||||
Qt4::QtCore
|
||||
Qt4::QtDBus
|
||||
)
|
||||
|
||||
if(BUILD_ONLY_PLUGIN)
|
||||
set_target_properties(Fcitx5Qt4DBusAddons PROPERTIES
|
||||
COMPILE_DEFINITIONS "FCITX5QT4DBUSADDONS_STATIC_DEFINE")
|
||||
|
||||
else()
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Fcitx5Qt4DBusAddonsConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Fcitx5Qt4DBusAddonsConfigVersion.cmake"
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel )
|
||||
|
||||
install(EXPORT Fcitx5Qt4DBusAddonsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE Fcitx5Qt4DBusAddonsTargets.cmake NAMESPACE Fcitx5Qt4:: )
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fcitx5qt4dbusaddons_version.h
|
||||
DESTINATION ${Fcitx5Qt4_INCLUDE_INSTALL_DIR} COMPONENT Devel )
|
||||
|
||||
install(TARGETS Fcitx5Qt4DBusAddons EXPORT Fcitx5Qt4DBusAddonsTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
install(FILES ${dbusaddons_HEADERS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/fcitx5qt4dbusaddons_export.h
|
||||
DESTINATION "${Fcitx5Qt4_INCLUDE_INSTALL_DIR}/Fcitx5Qt4DBusAddons")
|
||||
endif()
|
||||
|
||||
|
||||
7
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/Fcitx5Qt4DBusAddonsConfig.cmake.in
vendored
Normal file
7
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/Fcitx5Qt4DBusAddonsConfig.cmake.in
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
find_dependency(Qt4 @REQUIRED_QT4_VERSION@)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/Fcitx5Qt4DBusAddonsTargets.cmake")
|
||||
298
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtdbustypes.cpp
vendored
Normal file
298
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtdbustypes.cpp
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QDBusMetaType>
|
||||
|
||||
#include "fcitxqtdbustypes.h"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
#define FCITX5_QT_DEFINE_DBUS_TYPE(TYPE) \
|
||||
qRegisterMetaType<TYPE>(#TYPE); \
|
||||
qDBusRegisterMetaType<TYPE>(); \
|
||||
qRegisterMetaType<TYPE##List>(#TYPE "List"); \
|
||||
qDBusRegisterMetaType<TYPE##List>();
|
||||
|
||||
void registerFcitxQtDBusTypes() {
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtFormattedPreedit);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtStringKeyValue);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtInputMethodEntry);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtLayoutInfo);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtVariantInfo);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtConfigOption);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtConfigType);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtAddonInfo);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtAddonState);
|
||||
FCITX5_QT_DEFINE_DBUS_TYPE(FcitxQtAddonInfoV2);
|
||||
}
|
||||
|
||||
bool FcitxQtFormattedPreedit::operator==(
|
||||
const FcitxQtFormattedPreedit &preedit) const {
|
||||
return (preedit.format_ == format_) && (preedit.string_ == string_);
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtFormattedPreedit &preedit) {
|
||||
argument.beginStructure();
|
||||
argument << preedit.string();
|
||||
argument << preedit.format();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtFormattedPreedit &preedit) {
|
||||
QString str;
|
||||
qint32 format;
|
||||
argument.beginStructure();
|
||||
argument >> str >> format;
|
||||
argument.endStructure();
|
||||
preedit.setString(str);
|
||||
preedit.setFormat(format);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtStringKeyValue &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.key();
|
||||
argument << arg.value();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtStringKeyValue &arg) {
|
||||
QString key, value;
|
||||
argument.beginStructure();
|
||||
argument >> key >> value;
|
||||
argument.endStructure();
|
||||
arg.setKey(key);
|
||||
arg.setValue(value);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtInputMethodEntry &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.uniqueName();
|
||||
argument << arg.name();
|
||||
argument << arg.nativeName();
|
||||
argument << arg.icon();
|
||||
argument << arg.label();
|
||||
argument << arg.languageCode();
|
||||
argument << arg.configurable();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtInputMethodEntry &arg) {
|
||||
QString uniqueName, name, nativeName, icon, label, languageCode;
|
||||
bool configurable;
|
||||
argument.beginStructure();
|
||||
argument >> uniqueName >> name >> nativeName >> icon >> label >>
|
||||
languageCode >> configurable;
|
||||
argument.endStructure();
|
||||
arg.setUniqueName(uniqueName);
|
||||
arg.setName(name);
|
||||
arg.setNativeName(nativeName);
|
||||
arg.setIcon(icon);
|
||||
arg.setLabel(label);
|
||||
arg.setLanguageCode(languageCode);
|
||||
arg.setConfigurable(configurable);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtVariantInfo &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.variant();
|
||||
argument << arg.description();
|
||||
argument << arg.languages();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtVariantInfo &arg) {
|
||||
QString variant, description;
|
||||
QStringList languages;
|
||||
argument.beginStructure();
|
||||
argument >> variant >> description >> languages;
|
||||
argument.endStructure();
|
||||
arg.setVariant(variant);
|
||||
arg.setDescription(description);
|
||||
arg.setLanguages(languages);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtLayoutInfo &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.layout();
|
||||
argument << arg.description();
|
||||
argument << arg.languages();
|
||||
argument << arg.variants();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtLayoutInfo &arg) {
|
||||
QString layout, description;
|
||||
QStringList languages;
|
||||
FcitxQtVariantInfoList variants;
|
||||
argument.beginStructure();
|
||||
argument >> layout >> description >> languages >> variants;
|
||||
argument.endStructure();
|
||||
arg.setLayout(layout);
|
||||
arg.setDescription(description);
|
||||
arg.setLanguages(languages);
|
||||
arg.setVariants(variants);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtConfigOption &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.name();
|
||||
argument << arg.type();
|
||||
argument << arg.description();
|
||||
argument << arg.defaultValue();
|
||||
argument << arg.properties();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtConfigOption &arg) {
|
||||
QString name, description, type;
|
||||
QDBusVariant defaultValue;
|
||||
QVariantMap properties;
|
||||
argument.beginStructure();
|
||||
argument >> name >> type >> description >> defaultValue >> properties;
|
||||
argument.endStructure();
|
||||
arg.setName(name);
|
||||
arg.setType(type);
|
||||
arg.setDescription(description);
|
||||
arg.setDefaultValue(defaultValue);
|
||||
arg.setProperties(properties);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtConfigType &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.name();
|
||||
argument << arg.options();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtConfigType &arg) {
|
||||
QString name;
|
||||
FcitxQtConfigOptionList options;
|
||||
argument.beginStructure();
|
||||
argument >> name >> options;
|
||||
argument.endStructure();
|
||||
arg.setName(name);
|
||||
arg.setOptions(options);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtAddonInfo &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.uniqueName();
|
||||
argument << arg.name();
|
||||
argument << arg.comment();
|
||||
argument << arg.category();
|
||||
argument << arg.configurable();
|
||||
argument << arg.enabled();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtAddonInfo &arg) {
|
||||
QString uniqueName, name, comment;
|
||||
int category;
|
||||
bool configurable, enabled;
|
||||
argument.beginStructure();
|
||||
argument >> uniqueName >> name >> comment >> category >> configurable >>
|
||||
enabled;
|
||||
argument.endStructure();
|
||||
arg.setUniqueName(uniqueName);
|
||||
arg.setName(name);
|
||||
arg.setComment(comment);
|
||||
arg.setCategory(category);
|
||||
arg.setConfigurable(configurable);
|
||||
arg.setEnabled(enabled);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtAddonInfoV2 &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.uniqueName();
|
||||
argument << arg.name();
|
||||
argument << arg.comment();
|
||||
argument << arg.category();
|
||||
argument << arg.configurable();
|
||||
argument << arg.enabled();
|
||||
argument << arg.onDemand();
|
||||
argument << arg.dependencies();
|
||||
argument << arg.optionalDependencies();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtAddonInfoV2 &arg) {
|
||||
QString uniqueName, name, comment;
|
||||
int category;
|
||||
bool configurable, enabled, onDemand;
|
||||
QStringList dependencies, optionalDependencies;
|
||||
argument.beginStructure();
|
||||
argument >> uniqueName >> name >> comment >> category >> configurable >>
|
||||
enabled >> onDemand >> dependencies >> optionalDependencies;
|
||||
argument.endStructure();
|
||||
arg.setUniqueName(uniqueName);
|
||||
arg.setName(name);
|
||||
arg.setComment(comment);
|
||||
arg.setCategory(category);
|
||||
arg.setConfigurable(configurable);
|
||||
arg.setEnabled(enabled);
|
||||
arg.setOnDemand(onDemand);
|
||||
arg.setDependencies(dependencies);
|
||||
arg.setOptionalDependencies(optionalDependencies);
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
||||
const FcitxQtAddonState &arg) {
|
||||
argument.beginStructure();
|
||||
argument << arg.uniqueName();
|
||||
argument << arg.enabled();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
||||
FcitxQtAddonState &arg) {
|
||||
QString uniqueName;
|
||||
bool enabled;
|
||||
argument.beginStructure();
|
||||
argument >> uniqueName >> enabled;
|
||||
argument.endStructure();
|
||||
arg.setUniqueName(uniqueName);
|
||||
arg.setEnabled(enabled);
|
||||
return argument;
|
||||
}
|
||||
} // namespace fcitx
|
||||
157
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtdbustypes.h
vendored
Normal file
157
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtdbustypes.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DBUSADDONS_FCITXQTDBUSTYPES_H_
|
||||
#define _DBUSADDONS_FCITXQTDBUSTYPES_H_
|
||||
|
||||
#include "fcitx5qt4dbusaddons_export.h"
|
||||
|
||||
#include <QDBusArgument>
|
||||
#include <QList>
|
||||
#include <QMetaType>
|
||||
#include <type_traits>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
FCITX5QT4DBUSADDONS_EXPORT void registerFcitxQtDBusTypes();
|
||||
|
||||
#define FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(TYPE) \
|
||||
class FCITX5QT4DBUSADDONS_EXPORT TYPE { \
|
||||
public:
|
||||
|
||||
#define FCITX5_QT_DECLARE_FIELD(TYPE, GETTER, SETTER) \
|
||||
public: \
|
||||
std::conditional_t<std::is_class<TYPE>::value, const TYPE &, TYPE> \
|
||||
GETTER() const { \
|
||||
return GETTER##_; \
|
||||
} \
|
||||
void SETTER( \
|
||||
std::conditional_t<std::is_class<TYPE>::value, const TYPE &, TYPE> \
|
||||
value) { \
|
||||
GETTER##_ = value; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
TYPE GETTER##_ = TYPE();
|
||||
|
||||
#define FCITX5_QT_END_DECLARE_DBUS_TYPE(TYPE) \
|
||||
} \
|
||||
; \
|
||||
typedef QList<TYPE> TYPE##List; \
|
||||
FCITX5QT4DBUSADDONS_EXPORT QDBusArgument &operator<<( \
|
||||
QDBusArgument &argument, const TYPE &value); \
|
||||
FCITX5QT4DBUSADDONS_EXPORT const QDBusArgument &operator>>( \
|
||||
const QDBusArgument &argument, TYPE &value);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtFormattedPreedit);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, string, setString);
|
||||
FCITX5_QT_DECLARE_FIELD(qint32, format, setFormat);
|
||||
|
||||
public:
|
||||
bool operator==(const FcitxQtFormattedPreedit &preedit) const;
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtFormattedPreedit);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtStringKeyValue);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, key, setKey);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, value, setValue);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtStringKeyValue);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtInputMethodEntry);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, uniqueName, setUniqueName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, name, setName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, nativeName, setNativeName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, icon, setIcon);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, label, setLabel);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, languageCode, setLanguageCode);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, configurable, setConfigurable);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtInputMethodEntry);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtVariantInfo);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, variant, setVariant);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, description, setDescription);
|
||||
FCITX5_QT_DECLARE_FIELD(QStringList, languages, setLanguages);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtVariantInfo);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtLayoutInfo);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, layout, setLayout);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, description, setDescription);
|
||||
FCITX5_QT_DECLARE_FIELD(QStringList, languages, setLanguages);
|
||||
FCITX5_QT_DECLARE_FIELD(FcitxQtVariantInfoList, variants, setVariants);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtLayoutInfo);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtConfigOption);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, name, setName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, type, setType);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, description, setDescription);
|
||||
FCITX5_QT_DECLARE_FIELD(QDBusVariant, defaultValue, setDefaultValue);
|
||||
FCITX5_QT_DECLARE_FIELD(QVariantMap, properties, setProperties);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtConfigOption);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtConfigType);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, name, setName);
|
||||
FCITX5_QT_DECLARE_FIELD(FcitxQtConfigOptionList, options, setOptions);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtConfigType);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtAddonInfo);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, uniqueName, setUniqueName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, name, setName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, comment, setComment);
|
||||
FCITX5_QT_DECLARE_FIELD(int, category, setCategory);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, configurable, setConfigurable);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, enabled, setEnabled);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtAddonInfo);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtAddonInfoV2);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, uniqueName, setUniqueName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, name, setName);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, comment, setComment);
|
||||
FCITX5_QT_DECLARE_FIELD(int, category, setCategory);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, configurable, setConfigurable);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, enabled, setEnabled);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, onDemand, setOnDemand);
|
||||
FCITX5_QT_DECLARE_FIELD(QStringList, dependencies, setDependencies);
|
||||
FCITX5_QT_DECLARE_FIELD(QStringList, optionalDependencies,
|
||||
setOptionalDependencies);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtAddonInfoV2);
|
||||
|
||||
FCITX5_QT_BEGIN_DECLARE_DBUS_TYPE(FcitxQtAddonState);
|
||||
FCITX5_QT_DECLARE_FIELD(QString, uniqueName, setUniqueName);
|
||||
FCITX5_QT_DECLARE_FIELD(bool, enabled, setEnabled);
|
||||
FCITX5_QT_END_DECLARE_DBUS_TYPE(FcitxQtAddonState);
|
||||
} // namespace fcitx
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtFormattedPreedit)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtFormattedPreeditList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtStringKeyValue)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtStringKeyValueList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtInputMethodEntry)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtInputMethodEntryList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtVariantInfo)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtVariantInfoList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtLayoutInfo)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtLayoutInfoList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtConfigOption)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtConfigOptionList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtConfigType)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtConfigTypeList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtAddonInfo)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtAddonInfoList)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtAddonInfoV2)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtAddonInfoV2List)
|
||||
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtAddonState)
|
||||
Q_DECLARE_METATYPE(fcitx::FcitxQtAddonStateList)
|
||||
|
||||
#endif // _DBUSADDONS_FCITXQTDBUSTYPES_H_
|
||||
133
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxy.cpp
vendored
Normal file
133
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxy.cpp
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fcitxqtinputcontextproxy_p.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusConnectionInterface>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMetaType>
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
FcitxQtInputContextProxy::FcitxQtInputContextProxy(FcitxQtWatcher *watcher,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
d_ptr(new FcitxQtInputContextProxyPrivate(watcher, this)) {}
|
||||
|
||||
FcitxQtInputContextProxy::~FcitxQtInputContextProxy() {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
if (isValid()) {
|
||||
d->icproxy_->DestroyIC();
|
||||
}
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
void FcitxQtInputContextProxy::setDisplay(const QString &display) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
d->display_ = display;
|
||||
}
|
||||
|
||||
const QString &FcitxQtInputContextProxy::display() const {
|
||||
Q_D(const FcitxQtInputContextProxy);
|
||||
return d->display_;
|
||||
}
|
||||
|
||||
bool FcitxQtInputContextProxy::isValid() const {
|
||||
Q_D(const FcitxQtInputContextProxy);
|
||||
return d->isValid();
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::focusIn() {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->FocusIn();
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::focusOut() {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->FocusOut();
|
||||
}
|
||||
|
||||
QDBusPendingReply<bool> FcitxQtInputContextProxy::processKeyEvent(
|
||||
unsigned int keyval, unsigned int keycode, unsigned int state, bool type,
|
||||
unsigned int time) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->ProcessKeyEvent(keyval, keycode, state, type, time);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::reset() {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->Reset();
|
||||
}
|
||||
|
||||
QDBusPendingReply<>
|
||||
FcitxQtInputContextProxy::setSupportedCapability(qulonglong caps) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SetSupportedCapability(caps);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::setCapability(qulonglong caps) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SetCapability(caps);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::setCursorRect(int x, int y, int w,
|
||||
int h) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SetCursorRect(x, y, w, h);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::setCursorRectV2(int x, int y,
|
||||
int w, int h,
|
||||
double scale) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SetCursorRectV2(x, y, w, h, scale);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::setSurroundingText(
|
||||
const QString &text, unsigned int cursor, unsigned int anchor) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SetSurroundingText(text, cursor, anchor);
|
||||
}
|
||||
|
||||
QDBusPendingReply<>
|
||||
FcitxQtInputContextProxy::setSurroundingTextPosition(unsigned int cursor,
|
||||
unsigned int anchor) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SetSurroundingTextPosition(cursor, anchor);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::prevPage() {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->PrevPage();
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::nextPage() {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->NextPage();
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::selectCandidate(int i) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->SelectCandidate(i);
|
||||
}
|
||||
|
||||
QDBusPendingReply<> FcitxQtInputContextProxy::invokeAction(unsigned int action,
|
||||
int cursor) {
|
||||
Q_D(FcitxQtInputContextProxy);
|
||||
return d->icproxy_->InvokeAction(action, cursor);
|
||||
}
|
||||
|
||||
bool FcitxQtInputContextProxy::supportInvokeAction() const {
|
||||
Q_D(const FcitxQtInputContextProxy);
|
||||
return d->supportInvokeAction_;
|
||||
}
|
||||
|
||||
} // namespace fcitx
|
||||
|
||||
#include "moc_fcitxqtinputcontextproxy.cpp"
|
||||
93
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxy.h
vendored
Normal file
93
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxy.h
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DBUSADDONS_FCITXQTINPUTCONTEXTPROXY_H_
|
||||
#define _DBUSADDONS_FCITXQTINPUTCONTEXTPROXY_H_
|
||||
|
||||
#include "fcitx5qt4dbusaddons_export.h"
|
||||
|
||||
#include "fcitxqtdbustypes.h"
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusPendingReply>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QObject>
|
||||
|
||||
class QDBusPendingCallWatcher;
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class FcitxQtWatcher;
|
||||
class FcitxQtInputContextProxyPrivate;
|
||||
|
||||
class FCITX5QT4DBUSADDONS_EXPORT FcitxQtInputContextProxy : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FcitxQtInputContextProxy(FcitxQtWatcher *watcher, QObject *parent);
|
||||
~FcitxQtInputContextProxy();
|
||||
|
||||
bool isValid() const;
|
||||
void setDisplay(const QString &display);
|
||||
const QString &display() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
QDBusPendingReply<> focusIn();
|
||||
QDBusPendingReply<> focusOut();
|
||||
QDBusPendingReply<bool> processKeyEvent(unsigned int keyval,
|
||||
unsigned int keycode,
|
||||
unsigned int state, bool type,
|
||||
unsigned int time);
|
||||
QDBusPendingReply<> reset();
|
||||
QDBusPendingReply<> setSupportedCapability(qulonglong caps);
|
||||
QDBusPendingReply<> setCapability(qulonglong caps);
|
||||
QDBusPendingReply<> setCursorRect(int x, int y, int w, int h);
|
||||
QDBusPendingReply<> setCursorRectV2(int x, int y, int w, int h,
|
||||
double scale);
|
||||
QDBusPendingReply<> setSurroundingText(const QString &text,
|
||||
unsigned int cursor,
|
||||
unsigned int anchor);
|
||||
QDBusPendingReply<> setSurroundingTextPosition(unsigned int cursor,
|
||||
unsigned int anchor);
|
||||
QDBusPendingReply<> prevPage();
|
||||
QDBusPendingReply<> nextPage();
|
||||
QDBusPendingReply<> selectCandidate(int i);
|
||||
QDBusPendingReply<> invokeAction(unsigned int action, int cursor);
|
||||
|
||||
bool supportInvokeAction() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void commitString(const QString &str);
|
||||
void currentIM(const QString &name, const QString &uniqueName,
|
||||
const QString &langCode);
|
||||
void deleteSurroundingText(int offset, unsigned int nchar);
|
||||
void forwardKey(unsigned int keyval, unsigned int state, bool isRelease);
|
||||
void updateFormattedPreedit(const FcitxQtFormattedPreeditList &str,
|
||||
int cursorpos);
|
||||
void updateClientSideUI(const FcitxQtFormattedPreeditList &preedit,
|
||||
int cursorpos,
|
||||
const FcitxQtFormattedPreeditList &auxUp,
|
||||
const FcitxQtFormattedPreeditList &auxDown,
|
||||
const FcitxQtStringKeyValueList &candidates,
|
||||
int candidateIndex, int layoutHint, bool hasPrev,
|
||||
bool hasNext);
|
||||
void inputContextCreated(const QByteArray &uuid);
|
||||
void notifyFocusOut();
|
||||
|
||||
private:
|
||||
Q_PRIVATE_SLOT(d_func(), void availabilityChanged());
|
||||
Q_PRIVATE_SLOT(d_func(), void recheck());
|
||||
Q_PRIVATE_SLOT(d_func(), void cleanUp());
|
||||
Q_PRIVATE_SLOT(d_func(), void serviceUnregistered());
|
||||
Q_PRIVATE_SLOT(d_func(), void createInputContextFinished());
|
||||
Q_PRIVATE_SLOT(d_func(), void introspectFinished());
|
||||
|
||||
FcitxQtInputContextProxyPrivate *const d_ptr;
|
||||
Q_DECLARE_PRIVATE(FcitxQtInputContextProxy);
|
||||
};
|
||||
|
||||
} // namespace fcitx
|
||||
|
||||
#endif // _DBUSADDONS_FCITXQTINPUTCONTEXTPROXY_H_
|
||||
218
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxy_p.h
vendored
Normal file
218
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxy_p.h
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DBUSADDONS_FCITXQTINPUTCONTEXTPROXY_P_H_
|
||||
#define _DBUSADDONS_FCITXQTINPUTCONTEXTPROXY_P_H_
|
||||
|
||||
#include "fcitxqtinputcontextproxy.h"
|
||||
#include "fcitxqtinputcontextproxyimpl.h"
|
||||
#include "fcitxqtinputmethodproxy.h"
|
||||
#include "fcitxqtwatcher.h"
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class FcitxQtInputContextProxyPrivate {
|
||||
public:
|
||||
FcitxQtInputContextProxyPrivate(FcitxQtWatcher *watcher,
|
||||
FcitxQtInputContextProxy *q)
|
||||
: q_ptr(q), fcitxWatcher_(watcher), watcher_(q) {
|
||||
registerFcitxQtDBusTypes();
|
||||
QObject::connect(fcitxWatcher_, SIGNAL(availabilityChanged(bool)), q,
|
||||
SLOT(availabilityChanged()));
|
||||
watcher_.setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
||||
QObject::connect(&watcher_, SIGNAL(serviceUnregistered(QString)), q,
|
||||
SLOT(serviceUnregistered()));
|
||||
availabilityChanged();
|
||||
}
|
||||
|
||||
~FcitxQtInputContextProxyPrivate() {
|
||||
if (isValid()) {
|
||||
icproxy_->DestroyIC();
|
||||
}
|
||||
}
|
||||
|
||||
bool isValid() const { return (icproxy_ && icproxy_->isValid()); }
|
||||
|
||||
void serviceUnregistered() {
|
||||
cleanUp();
|
||||
availabilityChanged();
|
||||
}
|
||||
|
||||
void availabilityChanged() {
|
||||
QTimer::singleShot(100, q_ptr, SLOT(recheck()));
|
||||
}
|
||||
|
||||
void recheck() {
|
||||
if (!isValid() && fcitxWatcher_->availability()) {
|
||||
createInputContext();
|
||||
}
|
||||
if (!fcitxWatcher_->availability()) {
|
||||
cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
void cleanUp() {
|
||||
auto services = watcher_.watchedServices();
|
||||
for (const auto &service : services) {
|
||||
watcher_.removeWatchedService(service);
|
||||
}
|
||||
|
||||
delete improxy_;
|
||||
improxy_ = nullptr;
|
||||
delete icproxy_;
|
||||
icproxy_ = nullptr;
|
||||
delete createInputContextWatcher_;
|
||||
createInputContextWatcher_ = nullptr;
|
||||
delete introspectWatcher_;
|
||||
introspectWatcher_ = nullptr;
|
||||
supportInvokeAction_ = false;
|
||||
}
|
||||
|
||||
void createInputContext() {
|
||||
Q_Q(FcitxQtInputContextProxy);
|
||||
if (!fcitxWatcher_->availability()) {
|
||||
return;
|
||||
}
|
||||
|
||||
cleanUp();
|
||||
|
||||
auto service = fcitxWatcher_->serviceName();
|
||||
auto connection = fcitxWatcher_->connection();
|
||||
|
||||
auto owner = connection.interface()->serviceOwner(service);
|
||||
if (!owner.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
watcher_.setConnection(connection);
|
||||
watcher_.setWatchedServices(QStringList() << owner);
|
||||
// Avoid race, query again.
|
||||
if (!connection.interface()->isServiceRegistered(owner)) {
|
||||
cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
QFileInfo info(QCoreApplication::applicationFilePath());
|
||||
portal_ = true;
|
||||
improxy_ = new FcitxQtInputMethodProxy(
|
||||
owner, "/org/freedesktop/portal/inputmethod", connection, q);
|
||||
FcitxQtStringKeyValueList list;
|
||||
FcitxQtStringKeyValue arg;
|
||||
arg.setKey("program");
|
||||
arg.setValue(info.fileName());
|
||||
list << arg;
|
||||
if (!display_.isEmpty()) {
|
||||
FcitxQtStringKeyValue arg2;
|
||||
arg2.setKey("display");
|
||||
arg2.setValue(display_);
|
||||
list << arg2;
|
||||
}
|
||||
// Qt has good support for showing virtual keyboard, so we should
|
||||
// disable the default behavior supported by fcitx5
|
||||
FcitxQtStringKeyValue clientControlVirtualkeyboardShow;
|
||||
clientControlVirtualkeyboardShow.setKey(
|
||||
"clientControlVirtualkeyboardShow");
|
||||
clientControlVirtualkeyboardShow.setValue("true");
|
||||
list << clientControlVirtualkeyboardShow;
|
||||
// Qt has poor support for hiding virtual keyboard, so we should enable
|
||||
// the default behavior supported by fcitx5
|
||||
FcitxQtStringKeyValue clientControlVirtualkeyboardHide;
|
||||
clientControlVirtualkeyboardHide.setKey(
|
||||
"clientControlVirtualkeyboardHide");
|
||||
clientControlVirtualkeyboardHide.setValue("false");
|
||||
list << clientControlVirtualkeyboardHide;
|
||||
|
||||
auto result = improxy_->CreateInputContext(list);
|
||||
createInputContextWatcher_ = new QDBusPendingCallWatcher(result);
|
||||
QObject::connect(createInputContextWatcher_,
|
||||
SIGNAL(finished(QDBusPendingCallWatcher *)), q,
|
||||
SLOT(createInputContextFinished()));
|
||||
}
|
||||
|
||||
void createInputContextFinished() {
|
||||
Q_Q(FcitxQtInputContextProxy);
|
||||
if (createInputContextWatcher_->isError()) {
|
||||
cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusPendingReply<QDBusObjectPath, QByteArray> reply(
|
||||
*createInputContextWatcher_);
|
||||
icproxy_ = new FcitxQtInputContextProxyImpl(improxy_->service(),
|
||||
reply.value().path(),
|
||||
improxy_->connection(), q);
|
||||
QObject::connect(icproxy_, SIGNAL(CommitString(QString)), q,
|
||||
SIGNAL(commitString(QString)));
|
||||
QObject::connect(icproxy_, SIGNAL(CurrentIM(QString, QString, QString)),
|
||||
q, SIGNAL(currentIM(QString, QString, QString)));
|
||||
QObject::connect(
|
||||
icproxy_, SIGNAL(ForwardKey(unsigned int, unsigned int, bool)), q,
|
||||
SIGNAL(forwardKey(unsigned int, unsigned int, bool)));
|
||||
QObject::connect(
|
||||
icproxy_,
|
||||
SIGNAL(UpdateFormattedPreedit(FcitxQtFormattedPreeditList, int)), q,
|
||||
SIGNAL(updateFormattedPreedit(FcitxQtFormattedPreeditList, int)));
|
||||
QObject::connect(icproxy_,
|
||||
SIGNAL(DeleteSurroundingText(int, unsigned int)), q,
|
||||
SIGNAL(deleteSurroundingText(int, unsigned int)));
|
||||
QObject::connect(icproxy_, SIGNAL(NotifyFocusOut()), q,
|
||||
SIGNAL(notifyFocusOut()));
|
||||
|
||||
delete createInputContextWatcher_;
|
||||
createInputContextWatcher_ = nullptr;
|
||||
Q_EMIT q->inputContextCreated(reply.argumentAt<1>());
|
||||
|
||||
introspect();
|
||||
}
|
||||
|
||||
void introspect() {
|
||||
Q_Q(FcitxQtInputContextProxy);
|
||||
if (introspectWatcher_) {
|
||||
delete introspectWatcher_;
|
||||
introspectWatcher_ = nullptr;
|
||||
}
|
||||
QDBusMessage call = QDBusMessage::createMethodCall(
|
||||
icproxy_->service(), icproxy_->path(),
|
||||
"org.freedesktop.DBus.Introspectable", "Introspect");
|
||||
|
||||
introspectWatcher_ = new QDBusPendingCallWatcher(
|
||||
fcitxWatcher_->connection().asyncCall(call));
|
||||
QObject::connect(introspectWatcher_,
|
||||
SIGNAL(finished(QDBusPendingCallWatcher *)), q,
|
||||
SLOT(introspectFinished()));
|
||||
}
|
||||
|
||||
void introspectFinished() {
|
||||
if (introspectWatcher_->isFinished() &&
|
||||
!introspectWatcher_->isError()) {
|
||||
QDBusPendingReply<QString> reply = *introspectWatcher_;
|
||||
|
||||
if (reply.value().contains("InvokeAction")) {
|
||||
supportInvokeAction_ = true;
|
||||
}
|
||||
}
|
||||
delete introspectWatcher_;
|
||||
introspectWatcher_ = nullptr;
|
||||
}
|
||||
|
||||
FcitxQtInputContextProxy *q_ptr;
|
||||
Q_DECLARE_PUBLIC(FcitxQtInputContextProxy);
|
||||
|
||||
FcitxQtWatcher *fcitxWatcher_;
|
||||
QDBusServiceWatcher watcher_;
|
||||
FcitxQtInputMethodProxy *improxy_ = nullptr;
|
||||
FcitxQtInputContextProxyImpl *icproxy_ = nullptr;
|
||||
bool supportInvokeAction_ = false;
|
||||
QDBusPendingCallWatcher *createInputContextWatcher_ = nullptr;
|
||||
QDBusPendingCallWatcher *introspectWatcher_ = nullptr;
|
||||
QString display_;
|
||||
bool portal_ = false;
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
#endif // _DBUSADDONS_FCITXQTINPUTCONTEXTPROXY_P_H_
|
||||
29
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxyimpl.cpp
vendored
Normal file
29
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxyimpl.cpp
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.7
|
||||
* Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxyimpl -c
|
||||
* FcitxQtInputContextProxyImpl interfaces/org.fcitx.Fcitx.InputContext1.xml -i
|
||||
* fcitxqtdbustypes.h -i fcitx5qt4dbusaddons_export.h
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#include "fcitxqtinputcontextproxyimpl.h"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
/*
|
||||
* Implementation of interface class FcitxQtInputContextProxyImpl
|
||||
*/
|
||||
|
||||
FcitxQtInputContextProxyImpl::FcitxQtInputContextProxyImpl(
|
||||
const QString &service, const QString &path,
|
||||
const QDBusConnection &connection, QObject *parent)
|
||||
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection,
|
||||
parent) {}
|
||||
|
||||
FcitxQtInputContextProxyImpl::~FcitxQtInputContextProxyImpl() {}
|
||||
} // namespace fcitx
|
||||
176
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxyimpl.h
vendored
Normal file
176
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputcontextproxyimpl.h
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.7
|
||||
* Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxyimpl -c
|
||||
* FcitxQtInputContextProxyImpl interfaces/org.fcitx.Fcitx.InputContext1.xml -i
|
||||
* fcitxqtdbustypes.h -i fcitx5qt4dbusaddons_export.h
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* Do not edit! All changes made to it will be lost.
|
||||
*/
|
||||
|
||||
#ifndef FCITXQTINPUTCONTEXTPROXYIMPL_H_1637715099
|
||||
#define FCITXQTINPUTCONTEXTPROXYIMPL_H_1637715099
|
||||
|
||||
#include "fcitx5qt4dbusaddons_export.h"
|
||||
#include "fcitxqtdbustypes.h"
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
/*
|
||||
* Proxy class for interface org.fcitx.Fcitx.InputContext1
|
||||
*/
|
||||
class FcitxQtInputContextProxyImpl : public QDBusAbstractInterface {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static inline const char *staticInterfaceName() {
|
||||
return "org.fcitx.Fcitx.InputContext1";
|
||||
}
|
||||
|
||||
public:
|
||||
FcitxQtInputContextProxyImpl(const QString &service, const QString &path,
|
||||
const QDBusConnection &connection,
|
||||
QObject *parent = 0);
|
||||
|
||||
~FcitxQtInputContextProxyImpl();
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
inline QDBusPendingReply<> DestroyIC() {
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("DestroyIC"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> FocusIn() {
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("FocusIn"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> FocusOut() {
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("FocusOut"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> InvokeAction(unsigned int action, int cursor) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(action)
|
||||
<< QVariant::fromValue(cursor);
|
||||
return asyncCallWithArgumentList(QLatin1String("InvokeAction"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> NextPage() {
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("NextPage"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> PrevPage() {
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("PrevPage"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<bool> ProcessKeyEvent(unsigned int keyval, unsigned int keycode,
|
||||
unsigned int state, bool type,
|
||||
unsigned int time) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(keyval)
|
||||
<< QVariant::fromValue(keycode)
|
||||
<< QVariant::fromValue(state) << QVariant::fromValue(type)
|
||||
<< QVariant::fromValue(time);
|
||||
return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> Reset() {
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SelectCandidate(int index) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(index);
|
||||
return asyncCallWithArgumentList(QLatin1String("SelectCandidate"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetSupportedCapability(qulonglong caps)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(caps);
|
||||
return asyncCallWithArgumentList(QLatin1String("SetSupportedCapability"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetCapability(qulonglong caps) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(caps);
|
||||
return asyncCallWithArgumentList(QLatin1String("SetCapability"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetCursorRect(int x, int y, int w, int h) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(x) << QVariant::fromValue(y)
|
||||
<< QVariant::fromValue(w) << QVariant::fromValue(h);
|
||||
return asyncCallWithArgumentList(QLatin1String("SetCursorRect"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetCursorRectV2(int x, int y, int w, int h,
|
||||
double scale) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(x) << QVariant::fromValue(y)
|
||||
<< QVariant::fromValue(w) << QVariant::fromValue(h)
|
||||
<< QVariant::fromValue(scale);
|
||||
return asyncCallWithArgumentList(QLatin1String("SetCursorRectV2"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetSurroundingText(const QString &text,
|
||||
unsigned int cursor, unsigned int anchor) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(text) << QVariant::fromValue(cursor)
|
||||
<< QVariant::fromValue(anchor);
|
||||
return asyncCallWithArgumentList(QLatin1String("SetSurroundingText"),
|
||||
argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetSurroundingTextPosition(unsigned int cursor,
|
||||
unsigned int anchor) {
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(cursor)
|
||||
<< QVariant::fromValue(anchor);
|
||||
return asyncCallWithArgumentList(
|
||||
QLatin1String("SetSurroundingTextPosition"), argumentList);
|
||||
}
|
||||
|
||||
Q_SIGNALS: // SIGNALS
|
||||
void CommitString(const QString &str);
|
||||
void CurrentIM(const QString &name, const QString &uniqueName,
|
||||
const QString &langCode);
|
||||
void DeleteSurroundingText(int offset, unsigned int nchar);
|
||||
void ForwardKey(unsigned int keyval, unsigned int state, bool type);
|
||||
void NotifyFocusOut();
|
||||
void UpdateClientSideUI(FcitxQtFormattedPreeditList preedit, int cursorpos,
|
||||
FcitxQtFormattedPreeditList auxUp,
|
||||
FcitxQtFormattedPreeditList auxDown,
|
||||
FcitxQtFormattedPreeditList candidates,
|
||||
int candidateIndex, int layoutHint, bool hasPrev,
|
||||
bool hasNext);
|
||||
void UpdateFormattedPreedit(FcitxQtFormattedPreeditList str, int cursorpos);
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
#endif
|
||||
29
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputmethodproxy.cpp
vendored
Normal file
29
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputmethodproxy.cpp
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.7
|
||||
* Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod1.xml -i fcitxqtdbustypes.h -i fcitx5qt4dbusaddons_export.h
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#include "fcitxqtinputmethodproxy.h"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
/*
|
||||
* Implementation of interface class FcitxQtInputMethodProxy
|
||||
*/
|
||||
|
||||
FcitxQtInputMethodProxy::FcitxQtInputMethodProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
|
||||
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
|
||||
{
|
||||
}
|
||||
|
||||
FcitxQtInputMethodProxy::~FcitxQtInputMethodProxy()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
65
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputmethodproxy.h
vendored
Normal file
65
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtinputmethodproxy.h
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.7
|
||||
* Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod1.xml -i fcitxqtdbustypes.h -i fcitx5qt4dbusaddons_export.h
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* Do not edit! All changes made to it will be lost.
|
||||
*/
|
||||
|
||||
#ifndef FCITXQTINPUTMETHODPROXY_H_1637715099
|
||||
#define FCITXQTINPUTMETHODPROXY_H_1637715099
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include "fcitxqtdbustypes.h"
|
||||
#include "fcitx5qt4dbusaddons_export.h"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
/*
|
||||
* Proxy class for interface org.fcitx.Fcitx.InputMethod1
|
||||
*/
|
||||
class FCITX5QT4DBUSADDONS_EXPORT FcitxQtInputMethodProxy: public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static inline const char *staticInterfaceName()
|
||||
{ return "org.fcitx.Fcitx.InputMethod1"; }
|
||||
|
||||
public:
|
||||
FcitxQtInputMethodProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
|
||||
|
||||
~FcitxQtInputMethodProxy();
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
inline QDBusPendingReply<QDBusObjectPath, QByteArray> CreateInputContext(FcitxQtStringKeyValueList in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QLatin1String("CreateInputContext"), argumentList);
|
||||
}
|
||||
inline QDBusReply<QDBusObjectPath> CreateInputContext(FcitxQtStringKeyValueList in0, QByteArray &out1)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CreateInputContext"), argumentList);
|
||||
if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
|
||||
out1 = qdbus_cast<QByteArray>(reply.arguments().at(1));
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
Q_SIGNALS: // SIGNALS
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
142
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtwatcher.cpp
vendored
Normal file
142
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtwatcher.cpp
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fcitxqtwatcher_p.h"
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusConnectionInterface>
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
FcitxQtWatcher::FcitxQtWatcher(QObject *parent)
|
||||
: QObject(parent), d_ptr(new FcitxQtWatcherPrivate(this)) {}
|
||||
|
||||
FcitxQtWatcher::FcitxQtWatcher(const QDBusConnection &connection,
|
||||
QObject *parent)
|
||||
: FcitxQtWatcher(parent) {
|
||||
setConnection(connection);
|
||||
}
|
||||
|
||||
FcitxQtWatcher::~FcitxQtWatcher() { delete d_ptr; }
|
||||
|
||||
bool FcitxQtWatcher::availability() const {
|
||||
Q_D(const FcitxQtWatcher);
|
||||
return d->availability_;
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::setConnection(const QDBusConnection &connection) {
|
||||
Q_D(FcitxQtWatcher);
|
||||
return d->serviceWatcher_.setConnection(connection);
|
||||
}
|
||||
|
||||
QDBusConnection FcitxQtWatcher::connection() const {
|
||||
Q_D(const FcitxQtWatcher);
|
||||
return d->serviceWatcher_.connection();
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::setWatchPortal(bool portal) {
|
||||
Q_D(FcitxQtWatcher);
|
||||
d->watchPortal_ = portal;
|
||||
}
|
||||
|
||||
bool FcitxQtWatcher::watchPortal() const {
|
||||
Q_D(const FcitxQtWatcher);
|
||||
return d->watchPortal_;
|
||||
}
|
||||
|
||||
QString FcitxQtWatcher::serviceName() const {
|
||||
Q_D(const FcitxQtWatcher);
|
||||
if (d->mainPresent_) {
|
||||
return FCITX_MAIN_SERVICE_NAME;
|
||||
}
|
||||
if (d->portalPresent_) {
|
||||
return FCITX_PORTAL_SERVICE_NAME;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::setAvailability(bool availability) {
|
||||
Q_D(FcitxQtWatcher);
|
||||
if (d->availability_ != availability) {
|
||||
d->availability_ = availability;
|
||||
Q_EMIT availabilityChanged(d->availability_);
|
||||
}
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::watch() {
|
||||
Q_D(FcitxQtWatcher);
|
||||
if (d->watched_) {
|
||||
return;
|
||||
}
|
||||
|
||||
connect(&d->serviceWatcher_,
|
||||
SIGNAL(serviceOwnerChanged(QString, QString, QString)), this,
|
||||
SLOT(imChanged(QString, QString, QString)));
|
||||
d->serviceWatcher_.addWatchedService(FCITX_MAIN_SERVICE_NAME);
|
||||
if (d->watchPortal_) {
|
||||
d->serviceWatcher_.addWatchedService(FCITX_PORTAL_SERVICE_NAME);
|
||||
}
|
||||
|
||||
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
||||
FCITX_MAIN_SERVICE_NAME)) {
|
||||
d->mainPresent_ = true;
|
||||
}
|
||||
if (d->watchPortal_ &&
|
||||
QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
||||
FCITX_PORTAL_SERVICE_NAME)) {
|
||||
d->portalPresent_ = true;
|
||||
}
|
||||
|
||||
updateAvailability();
|
||||
|
||||
d->watched_ = true;
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::unwatch() {
|
||||
Q_D(FcitxQtWatcher);
|
||||
if (!d->watched_) {
|
||||
return;
|
||||
}
|
||||
disconnect(&d->serviceWatcher_,
|
||||
SIGNAL(serviceOwnerChanged(QString, QString, QString)), this,
|
||||
SLOT(imChanged(QString, QString, QString)));
|
||||
d->mainPresent_ = false;
|
||||
d->portalPresent_ = false;
|
||||
d->watched_ = false;
|
||||
updateAvailability();
|
||||
}
|
||||
|
||||
bool FcitxQtWatcher::isWatching() const {
|
||||
Q_D(const FcitxQtWatcher);
|
||||
return d->watched_;
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::imChanged(const QString &service, const QString &,
|
||||
const QString &newOwner) {
|
||||
Q_D(FcitxQtWatcher);
|
||||
if (service == FCITX_MAIN_SERVICE_NAME) {
|
||||
if (!newOwner.isEmpty()) {
|
||||
d->mainPresent_ = true;
|
||||
} else {
|
||||
d->mainPresent_ = false;
|
||||
}
|
||||
} else if (service == FCITX_PORTAL_SERVICE_NAME) {
|
||||
if (!newOwner.isEmpty()) {
|
||||
d->portalPresent_ = true;
|
||||
} else {
|
||||
d->portalPresent_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
updateAvailability();
|
||||
}
|
||||
|
||||
void FcitxQtWatcher::updateAvailability() {
|
||||
Q_D(FcitxQtWatcher);
|
||||
setAvailability(d->mainPresent_ || d->portalPresent_);
|
||||
}
|
||||
} // namespace fcitx
|
||||
54
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtwatcher.h
vendored
Normal file
54
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtwatcher.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DBUSADDONS_FCITXQTWATCHER_H_
|
||||
#define _DBUSADDONS_FCITXQTWATCHER_H_
|
||||
|
||||
#include "fcitx5qt4dbusaddons_export.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QObject>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class FcitxQtWatcherPrivate;
|
||||
|
||||
class FCITX5QT4DBUSADDONS_EXPORT FcitxQtWatcher : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FcitxQtWatcher(QObject *parent = nullptr);
|
||||
explicit FcitxQtWatcher(const QDBusConnection &connection,
|
||||
QObject *parent = nullptr);
|
||||
~FcitxQtWatcher();
|
||||
void watch();
|
||||
void unwatch();
|
||||
void setConnection(const QDBusConnection &connection);
|
||||
QDBusConnection connection() const;
|
||||
void setWatchPortal(bool portal);
|
||||
bool watchPortal() const;
|
||||
bool isWatching() const;
|
||||
bool availability() const;
|
||||
|
||||
QString serviceName() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void availabilityChanged(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
void imChanged(const QString &service, const QString &oldOwner,
|
||||
const QString &newOwner);
|
||||
|
||||
private:
|
||||
void setAvailability(bool availability);
|
||||
void updateAvailability();
|
||||
|
||||
FcitxQtWatcherPrivate *const d_ptr;
|
||||
Q_DECLARE_PRIVATE(FcitxQtWatcher);
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
#endif // _DBUSADDONS_FCITXQTWATCHER_H_
|
||||
32
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtwatcher_p.h
vendored
Normal file
32
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/fcitxqtwatcher_p.h
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DBUSADDONS_FCITXQTWATCHER_P_H_
|
||||
#define _DBUSADDONS_FCITXQTWATCHER_P_H_
|
||||
|
||||
#include "fcitxqtwatcher.h"
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
#define FCITX_MAIN_SERVICE_NAME "org.fcitx.Fcitx5"
|
||||
#define FCITX_PORTAL_SERVICE_NAME "org.freedesktop.portal.Fcitx"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class FcitxQtWatcherPrivate {
|
||||
public:
|
||||
FcitxQtWatcherPrivate(FcitxQtWatcher *q) : serviceWatcher_(q) {}
|
||||
|
||||
QDBusServiceWatcher serviceWatcher_;
|
||||
bool watchPortal_ = false;
|
||||
bool availability_ = false;
|
||||
bool mainPresent_ = false;
|
||||
bool portalPresent_ = false;
|
||||
bool watched_ = false;
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
#endif // _DBUSADDONS_FCITXQTWATCHER_P_H_
|
||||
4
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/gen_dbus.sh
vendored
Executable file
4
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/gen_dbus.sh
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
qdbusxml2cpp-qt4 -N -p fcitxqtinputcontextproxyimpl -c FcitxQtInputContextProxyImpl interfaces/org.fcitx.Fcitx.InputContext1.xml -i fcitxqtdbustypes.h -i fcitx5qt4dbusaddons_export.h
|
||||
qdbusxml2cpp-qt4 -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod1.xml -i fcitxqtdbustypes.h -i fcitx5qt4dbusaddons_export.h
|
||||
1
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml
vendored
Symbolic link
1
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../qt5/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml
|
||||
1
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/interfaces/org.fcitx.Fcitx.InputMethod1.xml
vendored
Symbolic link
1
Telegram/ThirdParty/fcitx5-qt/qt4/dbusaddons/interfaces/org.fcitx.Fcitx.InputMethod1.xml
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../qt5/dbusaddons/interfaces/org.fcitx.Fcitx.InputMethod1.xml
|
||||
4
Telegram/ThirdParty/fcitx5-qt/qt4/immodule-probing/CMakeLists.txt
vendored
Normal file
4
Telegram/ThirdParty/fcitx5-qt/qt4/immodule-probing/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
add_executable(fcitx5-qt4-immodule-probing main.cpp)
|
||||
target_link_libraries(fcitx5-qt4-immodule-probing Qt4::QtGui)
|
||||
|
||||
install(TARGETS fcitx5-qt4-immodule-probing DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
20
Telegram/ThirdParty/fcitx5-qt/qt4/immodule-probing/main.cpp
vendored
Normal file
20
Telegram/ThirdParty/fcitx5-qt/qt4/immodule-probing/main.cpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023~2023 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
*/
|
||||
#include <QApplication>
|
||||
#include <QInputContext>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
auto *inputContext = app.inputContext();
|
||||
std::cout << "QT_IM_MODULE=";
|
||||
if (inputContext) {
|
||||
std::cout << inputContext->identifierName().toUtf8().constData();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return 0;
|
||||
}
|
||||
39
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/CMakeLists.txt
vendored
Normal file
39
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
set(plugin_SRCS
|
||||
qfcitxinputcontext.cpp
|
||||
qtkey.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
if (BUILD_ONLY_PLUGIN AND BUILD_STATIC_PLUGIN)
|
||||
set(plugin_SRCS ${plugin_SRCS} $<TARGET_OBJECTS:Fcitx5Qt4DBusAddons>)
|
||||
endif()
|
||||
|
||||
|
||||
add_library(qtim-fcitx5 ${PLUGIN_LIBRARY_TYPE} ${plugin_SRCS})
|
||||
set_target_properties(qtim-fcitx5 PROPERTIES
|
||||
AUTOMOC TRUE
|
||||
)
|
||||
target_include_directories(qtim-fcitx5 PRIVATE "${PROJECT_SOURCE_DIR}/common")
|
||||
if (BUILD_ONLY_PLUGIN AND BUILD_STATIC_PLUGIN)
|
||||
target_compile_definitions(qtim-fcitx5 PRIVATE "-DQT_STATICPLUGIN")
|
||||
endif()
|
||||
if (WITH_FCITX_PLUGIN_NAME)
|
||||
target_compile_definitions(qtim-fcitx5 PRIVATE "-DFCITX5_QT_WITH_FCITX_NAME")
|
||||
endif()
|
||||
|
||||
target_link_libraries(qtim-fcitx5
|
||||
Qt4::QtCore
|
||||
Qt4::QtGui
|
||||
Qt4::QtDBus
|
||||
Fcitx5Qt4::DBusAddons
|
||||
XKBCommon::XKBCommon
|
||||
)
|
||||
|
||||
if (ENABLE_X11)
|
||||
target_link_libraries(qtim-fcitx5 X11Import)
|
||||
target_compile_definitions(qtim-fcitx5 PRIVATE "-DENABLE_X11")
|
||||
endif()
|
||||
|
||||
set(CMAKE_INSTALL_QT4PLUGINDIR ${QT_PLUGINS_DIR} CACHE PATH "Qt4 plugin dir")
|
||||
install(TARGETS qtim-fcitx5 DESTINATION ${CMAKE_INSTALL_QT4PLUGINDIR}/inputmethods)
|
||||
59
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/main.cpp
vendored
Normal file
59
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/main.cpp
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
namespace {
|
||||
bool isFcitx(const QString &key) {
|
||||
return key.toLower() == "fcitx5" || key.toLower() == "fcitx";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
QStringList QFcitxInputContextPlugin::keys() const {
|
||||
#ifdef FCITX5_QT_WITH_FCITX_NAME
|
||||
return QStringList() << "fcitx5"
|
||||
<< "fcitx";
|
||||
#else
|
||||
return QStringList() << "fcitx5";
|
||||
#endif
|
||||
}
|
||||
|
||||
QInputContext *QFcitxInputContextPlugin::create(const QString &key) {
|
||||
if (!isFcitx(key)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return static_cast<QInputContext *>(new QFcitxInputContext());
|
||||
}
|
||||
|
||||
QString QFcitxInputContextPlugin::description(const QString &key) {
|
||||
if (!isFcitx(key)) {
|
||||
return QString("");
|
||||
}
|
||||
|
||||
return QString::fromUtf8("Qt immodule plugin for Fcitx 5");
|
||||
}
|
||||
|
||||
QStringList QFcitxInputContextPlugin::languages(const QString &key) {
|
||||
QStringList result;
|
||||
if (!isFcitx(key)) {
|
||||
result << "zh";
|
||||
result << "ja";
|
||||
result << "ko";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString QFcitxInputContextPlugin::displayName(const QString &key) {
|
||||
return key;
|
||||
}
|
||||
} // namespace fcitx
|
||||
|
||||
Q_EXPORT_PLUGIN2(QFcitxInputContextPlugin, fcitx::QFcitxInputContextPlugin)
|
||||
33
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/main.h
vendored
Normal file
33
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/main.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <QInputContextPlugin>
|
||||
#include <QStringList>
|
||||
|
||||
#include "qfcitxinputcontext.h"
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class QFcitxInputContextPlugin : public QInputContextPlugin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QStringList keys() const override;
|
||||
|
||||
QStringList languages(const QString &key) override;
|
||||
|
||||
QString description(const QString &key) override;
|
||||
|
||||
QInputContext *create(const QString &key) override;
|
||||
|
||||
QString displayName(const QString &key) override;
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
#endif // MAIN_H
|
||||
837
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qfcitxinputcontext.cpp
vendored
Normal file
837
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qfcitxinputcontext.cpp
vendored
Normal file
@@ -0,0 +1,837 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
#include <QPalette>
|
||||
#include <QTextCharFormat>
|
||||
#include <QTextCodec>
|
||||
#include <QWidget>
|
||||
#ifdef ENABLE_X11
|
||||
#include <QX11Info>
|
||||
#endif
|
||||
#include <array>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "qtkey.h"
|
||||
|
||||
#include "fcitxflags.h"
|
||||
#include "fcitxqtinputcontextproxy.h"
|
||||
#include "fcitxqtwatcher.h"
|
||||
#include "qfcitxinputcontext.h"
|
||||
|
||||
#ifdef ENABLE_X11
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
#include <memory>
|
||||
#undef KeyPress
|
||||
#undef KeyRelease
|
||||
#undef FocusIn
|
||||
#undef FocusOut
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
#ifdef ENABLE_X11
|
||||
void setFocusGroupForX11(const QByteArray &uuid) {
|
||||
if (uuid.size() != 16) {
|
||||
return;
|
||||
}
|
||||
|
||||
Display *xdisplay = QX11Info::display();
|
||||
if (!xdisplay) {
|
||||
return;
|
||||
}
|
||||
|
||||
Atom atom = XInternAtom(xdisplay, "_FCITX_SERVER", False);
|
||||
if (!atom) {
|
||||
return;
|
||||
}
|
||||
Window window = XGetSelectionOwner(xdisplay, atom);
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
XEvent ev;
|
||||
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.window = window;
|
||||
ev.xclient.message_type = atom;
|
||||
ev.xclient.format = 8;
|
||||
memcpy(ev.xclient.data.b, uuid.constData(), 16);
|
||||
|
||||
XSendEvent(xdisplay, window, False, NoEventMask, &ev);
|
||||
XSync(xdisplay, False);
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool key_filtered = false;
|
||||
|
||||
static bool get_boolean_env(const char *name, bool defval) {
|
||||
const char *value = getenv(name);
|
||||
|
||||
if (value == nullptr)
|
||||
return defval;
|
||||
|
||||
if (strcmp(value, "") == 0 || strcmp(value, "0") == 0 ||
|
||||
strcmp(value, "false") == 0 || strcmp(value, "False") == 0 ||
|
||||
strcmp(value, "FALSE") == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline const char *get_locale() {
|
||||
const char *locale = getenv("LC_ALL");
|
||||
if (!locale)
|
||||
locale = getenv("LC_CTYPE");
|
||||
if (!locale)
|
||||
locale = getenv("LANG");
|
||||
if (!locale)
|
||||
locale = "C";
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
struct xkb_context *_xkb_context_new_helper() {
|
||||
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
if (context) {
|
||||
xkb_context_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
QFcitxInputContext::QFcitxInputContext()
|
||||
: watcher_(new FcitxQtWatcher(
|
||||
QDBusConnection::connectToBus(QDBusConnection::SessionBus, "fcitx"),
|
||||
this)),
|
||||
cursorPos_(0), useSurroundingText_(false),
|
||||
syncMode_(get_boolean_env("FCITX_QT_USE_SYNC", false)), destroy_(false),
|
||||
xkbContext_(_xkb_context_new_helper()),
|
||||
xkbComposeTable_(xkbContext_ ? xkb_compose_table_new_from_locale(
|
||||
xkbContext_.data(), get_locale(),
|
||||
XKB_COMPOSE_COMPILE_NO_FLAGS)
|
||||
: 0),
|
||||
xkbComposeState_(xkbComposeTable_
|
||||
? xkb_compose_state_new(xkbComposeTable_.data(),
|
||||
XKB_COMPOSE_STATE_NO_FLAGS)
|
||||
: 0) {
|
||||
registerFcitxQtDBusTypes();
|
||||
watcher_->setWatchPortal(true);
|
||||
watcher_->watch();
|
||||
}
|
||||
|
||||
QFcitxInputContext::~QFcitxInputContext() {
|
||||
destroy_ = true;
|
||||
watcher_->unwatch();
|
||||
cleanUp();
|
||||
delete watcher_;
|
||||
}
|
||||
|
||||
void QFcitxInputContext::cleanUp() {
|
||||
icMap_.clear();
|
||||
|
||||
if (!destroy_) {
|
||||
commitPreedit();
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::mouseHandler(int cursorPosition, QMouseEvent *event) {
|
||||
if (event->type() != QEvent::MouseButtonRelease) {
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int action;
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
action = 0;
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
action = 1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (FcitxQtInputContextProxy *proxy = validIC();
|
||||
proxy->supportInvokeAction()) {
|
||||
proxy->invokeAction(action, cursorPosition);
|
||||
} else {
|
||||
if (cursorPosition <= 0 || cursorPosition >= preedit_.length()) {
|
||||
// qDebug() << action << cursorPosition;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::commitPreedit(QPointer<QWidget> input) {
|
||||
if (!input)
|
||||
return;
|
||||
if (commitPreedit_.length() <= 0)
|
||||
return;
|
||||
QInputMethodEvent e;
|
||||
e.setCommitString(commitPreedit_);
|
||||
QCoreApplication::sendEvent(input, &e);
|
||||
commitPreedit_.clear();
|
||||
preeditList_.clear();
|
||||
}
|
||||
|
||||
bool checkUtf8(const QByteArray &byteArray) {
|
||||
QTextCodec::ConverterState state;
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
const QString text =
|
||||
codec->toUnicode(byteArray.constData(), byteArray.size(), &state);
|
||||
return state.invalidChars == 0;
|
||||
}
|
||||
|
||||
void QFcitxInputContext::reset() {
|
||||
commitPreedit();
|
||||
if (FcitxQtInputContextProxy *proxy = validIC()) {
|
||||
proxy->reset();
|
||||
}
|
||||
if (xkbComposeState_) {
|
||||
xkb_compose_state_reset(xkbComposeState_.data());
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::update() {
|
||||
QWidget *window = qApp->focusWidget();
|
||||
FcitxQtInputContextProxy *proxy = validICByWindow(window);
|
||||
if (!proxy)
|
||||
return;
|
||||
|
||||
FcitxQtICData &data = *static_cast<FcitxQtICData *>(
|
||||
proxy->property("icData").value<void *>());
|
||||
|
||||
QWidget *input = qApp->focusWidget();
|
||||
if (!input)
|
||||
return;
|
||||
|
||||
cursorRectChanged();
|
||||
|
||||
if (true) {
|
||||
Qt::InputMethodHints hints = input->inputMethodHints();
|
||||
|
||||
#define CHECK_HINTS(_HINTS, _CAPABILITY) \
|
||||
if (hints & _HINTS) \
|
||||
addCapability(data, FcitxCapabilityFlag_##_CAPABILITY); \
|
||||
else \
|
||||
removeCapability(data, FcitxCapabilityFlag_##_CAPABILITY);
|
||||
|
||||
CHECK_HINTS(Qt::ImhHiddenText, Password)
|
||||
CHECK_HINTS(Qt::ImhNoAutoUppercase, NoAutoUpperCase)
|
||||
CHECK_HINTS(Qt::ImhPreferNumbers, Number)
|
||||
CHECK_HINTS(Qt::ImhPreferUppercase, Uppercase)
|
||||
CHECK_HINTS(Qt::ImhPreferLowercase, Lowercase)
|
||||
CHECK_HINTS(Qt::ImhNoPredictiveText, NoSpellCheck)
|
||||
CHECK_HINTS(Qt::ImhDigitsOnly, Digit)
|
||||
CHECK_HINTS(Qt::ImhFormattedNumbersOnly, Number)
|
||||
CHECK_HINTS(Qt::ImhUppercaseOnly, Uppercase)
|
||||
CHECK_HINTS(Qt::ImhLowercaseOnly, Lowercase)
|
||||
CHECK_HINTS(Qt::ImhDialableCharactersOnly, Dialable)
|
||||
CHECK_HINTS(Qt::ImhEmailCharactersOnly, Email)
|
||||
CHECK_HINTS(Qt::ImhUrlCharactersOnly, Url)
|
||||
}
|
||||
|
||||
bool setSurrounding = false;
|
||||
do {
|
||||
if (!useSurroundingText_)
|
||||
break;
|
||||
if ((data.capability & FcitxCapabilityFlag_Password) ||
|
||||
(data.capability & FcitxCapabilityFlag_Sensitive))
|
||||
break;
|
||||
QVariant var = input->inputMethodQuery(Qt::ImSurroundingText);
|
||||
QVariant var1 = input->inputMethodQuery(Qt::ImCursorPosition);
|
||||
QVariant var2 = input->inputMethodQuery(Qt::ImAnchorPosition);
|
||||
if (!var.isValid() || !var1.isValid())
|
||||
break;
|
||||
QString text = var.toString();
|
||||
/* we don't want to waste too much memory here */
|
||||
#define SURROUNDING_THRESHOLD 4096
|
||||
if (text.length() < SURROUNDING_THRESHOLD) {
|
||||
if (checkUtf8(text.toUtf8())) {
|
||||
addCapability(data, FcitxCapabilityFlag_SurroundingText);
|
||||
|
||||
int cursor = var1.toInt();
|
||||
int anchor;
|
||||
if (var2.isValid()) {
|
||||
anchor = var2.toInt();
|
||||
} else {
|
||||
anchor = cursor;
|
||||
}
|
||||
|
||||
// adjust it to real character size
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
||||
QVector<unsigned int> tempUCS4 = text.leftRef(cursor).toUcs4();
|
||||
#else
|
||||
QVector<unsigned int> tempUCS4 = text.left(cursor).toUcs4();
|
||||
#endif
|
||||
cursor = tempUCS4.size();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
||||
tempUCS4 = text.leftRef(anchor).toUcs4();
|
||||
#else
|
||||
tempUCS4 = text.left(anchor).toUcs4();
|
||||
#endif
|
||||
anchor = tempUCS4.size();
|
||||
if (data.surroundingText != text) {
|
||||
data.surroundingText = text;
|
||||
proxy->setSurroundingText(text, cursor, anchor);
|
||||
} else {
|
||||
if (data.surroundingAnchor != anchor ||
|
||||
data.surroundingCursor != cursor)
|
||||
proxy->setSurroundingTextPosition(cursor, anchor);
|
||||
}
|
||||
data.surroundingCursor = cursor;
|
||||
data.surroundingAnchor = anchor;
|
||||
setSurrounding = true;
|
||||
}
|
||||
}
|
||||
if (!setSurrounding) {
|
||||
data.surroundingAnchor = -1;
|
||||
data.surroundingCursor = -1;
|
||||
data.surroundingText = QString();
|
||||
removeCapability(data, FcitxCapabilityFlag_SurroundingText);
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::setFocusWidget(QWidget *object) {
|
||||
Q_UNUSED(object);
|
||||
FcitxQtInputContextProxy *proxy = validICByWindow(lastWindow_);
|
||||
if (proxy) {
|
||||
proxy->focusOut();
|
||||
}
|
||||
|
||||
QWidget *window = qApp->focusWidget();
|
||||
lastWindow_ = window;
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
proxy = validICByWindow(window);
|
||||
if (proxy) {
|
||||
cursorRectChanged();
|
||||
proxy->focusIn();
|
||||
} else {
|
||||
createICData(window);
|
||||
}
|
||||
QInputContext::setFocusWidget(object);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::widgetDestroyed(QWidget *w) {
|
||||
QInputContext::widgetDestroyed(w);
|
||||
|
||||
icMap_.erase(w);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::windowDestroyed(QObject *object) {
|
||||
/* access QWindow is not possible here, so we use our own map to do so */
|
||||
icMap_.erase(reinterpret_cast<QWidget *>(object));
|
||||
// qDebug() << "Window Destroyed and we destroy IC correctly, horray!";
|
||||
}
|
||||
|
||||
void QFcitxInputContext::cursorRectChanged() {
|
||||
QWidget *inputWindow = qApp->focusWidget();
|
||||
if (!inputWindow)
|
||||
return;
|
||||
FcitxQtInputContextProxy *proxy = validICByWindow(inputWindow);
|
||||
if (!proxy)
|
||||
return;
|
||||
|
||||
FcitxQtICData &data = *static_cast<FcitxQtICData *>(
|
||||
proxy->property("icData").value<void *>());
|
||||
|
||||
QRect r = inputWindow->inputMethodQuery(Qt::ImMicroFocus).toRect();
|
||||
|
||||
auto point = inputWindow->mapToGlobal(r.topLeft());
|
||||
QRect newRect(point, r.size());
|
||||
|
||||
if (data.rect != newRect) {
|
||||
data.rect = newRect;
|
||||
proxy->setCursorRect(newRect.x(), newRect.y(), newRect.width(),
|
||||
newRect.height());
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::createInputContextFinished(const QByteArray &uuid) {
|
||||
auto proxy = qobject_cast<FcitxQtInputContextProxy *>(sender());
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
auto w =
|
||||
reinterpret_cast<QWidget *>(proxy->property("wid").value<void *>());
|
||||
FcitxQtICData *data =
|
||||
static_cast<FcitxQtICData *>(proxy->property("icData").value<void *>());
|
||||
data->rect = QRect();
|
||||
|
||||
if (proxy->isValid()) {
|
||||
QWidget *window = qApp->focusWidget();
|
||||
#ifdef ENABLE_X11
|
||||
setFocusGroupForX11(uuid);
|
||||
#else
|
||||
Q_UNUSED(uuid);
|
||||
#endif
|
||||
if (window && window == w) {
|
||||
cursorRectChanged();
|
||||
proxy->focusIn();
|
||||
}
|
||||
}
|
||||
|
||||
quint64 flag = 0;
|
||||
flag |= FcitxCapabilityFlag_Preedit;
|
||||
flag |= FcitxCapabilityFlag_FormattedPreedit;
|
||||
flag |= FcitxCapabilityFlag_ClientUnfocusCommit;
|
||||
flag |= FcitxCapabilityFlag_GetIMInfoOnFocus;
|
||||
flag |= FcitxCapabilityFlag_KeyEventOrderFix;
|
||||
flag |= FcitxCapabilityFlag_ReportKeyRepeat;
|
||||
useSurroundingText_ =
|
||||
get_boolean_env("FCITX_QT_ENABLE_SURROUNDING_TEXT", true);
|
||||
if (useSurroundingText_)
|
||||
flag |= FcitxCapabilityFlag_SurroundingText;
|
||||
|
||||
addCapability(*data, flag, true);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::updateCapability(const FcitxQtICData &data) {
|
||||
if (!data.proxy || !data.proxy->isValid())
|
||||
return;
|
||||
|
||||
QDBusPendingReply<void> result = data.proxy->setCapability(data.capability);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::commitString(const QString &str) {
|
||||
cursorPos_ = 0;
|
||||
preeditList_.clear();
|
||||
commitPreedit_.clear();
|
||||
QWidget *input = qApp->focusWidget();
|
||||
if (!input)
|
||||
return;
|
||||
|
||||
QInputMethodEvent event;
|
||||
event.setCommitString(str);
|
||||
QCoreApplication::sendEvent(input, &event);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::updateFormattedPreedit(
|
||||
const FcitxQtFormattedPreeditList &preeditList, int cursorPos) {
|
||||
QWidget *input = qApp->focusWidget();
|
||||
if (!input)
|
||||
return;
|
||||
if (cursorPos == cursorPos_ && preeditList == preeditList_)
|
||||
return;
|
||||
preeditList_ = preeditList;
|
||||
cursorPos_ = cursorPos;
|
||||
QString str, commitStr;
|
||||
int pos = 0;
|
||||
QList<QInputMethodEvent::Attribute> attrList;
|
||||
Q_FOREACH (const FcitxQtFormattedPreedit &preedit, preeditList) {
|
||||
str += preedit.string();
|
||||
if (!(preedit.format() & FcitxTextFormatFlag_DontCommit))
|
||||
commitStr += preedit.string();
|
||||
QTextCharFormat format;
|
||||
if (preedit.format() & FcitxTextFormatFlag_Underline) {
|
||||
format.setUnderlineStyle(QTextCharFormat::DashUnderline);
|
||||
}
|
||||
if (preedit.format() & FcitxTextFormatFlag_Strike) {
|
||||
format.setFontStrikeOut(true);
|
||||
}
|
||||
if (preedit.format() & FcitxTextFormatFlag_Bold) {
|
||||
format.setFontWeight(QFont::Bold);
|
||||
}
|
||||
if (preedit.format() & FcitxTextFormatFlag_Italic) {
|
||||
format.setFontItalic(true);
|
||||
}
|
||||
if (preedit.format() & FcitxTextFormatFlag_HighLight) {
|
||||
QBrush brush;
|
||||
QPalette palette;
|
||||
palette = QApplication::palette();
|
||||
format.setBackground(QBrush(
|
||||
QColor(palette.color(QPalette::Active, QPalette::Highlight))));
|
||||
format.setForeground(QBrush(QColor(
|
||||
palette.color(QPalette::Active, QPalette::HighlightedText))));
|
||||
}
|
||||
attrList.append(
|
||||
QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, pos,
|
||||
preedit.string().length(), format));
|
||||
pos += preedit.string().length();
|
||||
}
|
||||
|
||||
QByteArray array = str.toUtf8();
|
||||
array.truncate(cursorPos);
|
||||
cursorPos = QString::fromUtf8(array).length();
|
||||
|
||||
attrList.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
|
||||
cursorPos, 1, 0));
|
||||
preedit_ = str;
|
||||
commitPreedit_ = commitStr;
|
||||
QInputMethodEvent event(str, attrList);
|
||||
QCoreApplication::sendEvent(input, &event);
|
||||
update();
|
||||
}
|
||||
|
||||
void QFcitxInputContext::deleteSurroundingText(int offset,
|
||||
unsigned int _nchar) {
|
||||
QWidget *input = qApp->focusWidget();
|
||||
if (!input)
|
||||
return;
|
||||
|
||||
QInputMethodEvent event;
|
||||
|
||||
FcitxQtInputContextProxy *proxy =
|
||||
qobject_cast<FcitxQtInputContextProxy *>(sender());
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
FcitxQtICData *data =
|
||||
static_cast<FcitxQtICData *>(proxy->property("icData").value<void *>());
|
||||
QVector<unsigned int> ucsText = data->surroundingText.toUcs4();
|
||||
|
||||
int cursor = data->surroundingCursor;
|
||||
// make nchar signed so we are safer
|
||||
int nchar = _nchar;
|
||||
// Qt's reconvert semantics is different from gtk's. It doesn't count the
|
||||
// current
|
||||
// selection. Discard selection from nchar.
|
||||
if (data->surroundingAnchor < data->surroundingCursor) {
|
||||
nchar -= data->surroundingCursor - data->surroundingAnchor;
|
||||
offset += data->surroundingCursor - data->surroundingAnchor;
|
||||
cursor = data->surroundingAnchor;
|
||||
} else if (data->surroundingAnchor > data->surroundingCursor) {
|
||||
nchar -= data->surroundingAnchor - data->surroundingCursor;
|
||||
cursor = data->surroundingCursor;
|
||||
}
|
||||
|
||||
// validates
|
||||
if (nchar >= 0 && cursor + offset >= 0 &&
|
||||
cursor + offset + nchar <= ucsText.size()) {
|
||||
// order matters
|
||||
QVector<unsigned int> replacedChars =
|
||||
ucsText.mid(cursor + offset, nchar);
|
||||
nchar = QString::fromUcs4(replacedChars.data(), replacedChars.size())
|
||||
.size();
|
||||
|
||||
int start, len;
|
||||
if (offset >= 0) {
|
||||
start = cursor;
|
||||
len = offset;
|
||||
} else {
|
||||
start = cursor + offset;
|
||||
len = -offset;
|
||||
}
|
||||
|
||||
QVector<unsigned int> prefixedChars = ucsText.mid(start, len);
|
||||
offset = QString::fromUcs4(prefixedChars.data(), prefixedChars.size())
|
||||
.size() *
|
||||
(offset >= 0 ? 1 : -1);
|
||||
event.setCommitString("", offset, nchar);
|
||||
QCoreApplication::sendEvent(input, &event);
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::forwardKey(unsigned int keyval, unsigned int state,
|
||||
bool type) {
|
||||
auto proxy = qobject_cast<FcitxQtInputContextProxy *>(sender());
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
FcitxQtICData &data = *static_cast<FcitxQtICData *>(
|
||||
proxy->property("icData").value<void *>());
|
||||
QWidget *input = qApp->focusWidget();
|
||||
if (input != nullptr) {
|
||||
key_filtered = true;
|
||||
QKeyEvent *keyevent =
|
||||
createKeyEvent(keyval, state, type, data.event.get());
|
||||
|
||||
QCoreApplication::sendEvent(input, keyevent);
|
||||
delete keyevent;
|
||||
key_filtered = false;
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::serverSideFocusOut() {
|
||||
if (lastWindow_ == qApp->focusWidget()) {
|
||||
commitPreedit();
|
||||
}
|
||||
}
|
||||
|
||||
void QFcitxInputContext::createICData(QWidget *w) {
|
||||
auto iter = icMap_.find(w);
|
||||
if (iter == icMap_.end()) {
|
||||
auto result =
|
||||
icMap_.emplace(std::piecewise_construct, std::forward_as_tuple(w),
|
||||
std::forward_as_tuple(watcher_));
|
||||
iter = result.first;
|
||||
auto &data = iter->second;
|
||||
|
||||
data.proxy->setDisplay("x11:");
|
||||
data.proxy->setProperty("wid",
|
||||
qVariantFromValue(static_cast<void *>(w)));
|
||||
data.proxy->setProperty("icData",
|
||||
qVariantFromValue(static_cast<void *>(&data)));
|
||||
connect(data.proxy, SIGNAL(inputContextCreated(QByteArray)), this,
|
||||
SLOT(createInputContextFinished(QByteArray)));
|
||||
connect(data.proxy, SIGNAL(commitString(QString)), this,
|
||||
SLOT(commitString(QString)));
|
||||
connect(data.proxy,
|
||||
SIGNAL(forwardKey(unsigned int, unsigned int, bool)), this,
|
||||
SLOT(forwardKey(unsigned int, unsigned int, bool)));
|
||||
connect(
|
||||
data.proxy,
|
||||
SIGNAL(updateFormattedPreedit(FcitxQtFormattedPreeditList, int)),
|
||||
this,
|
||||
SLOT(updateFormattedPreedit(FcitxQtFormattedPreeditList, int)));
|
||||
connect(data.proxy, SIGNAL(deleteSurroundingText(int, uint)), this,
|
||||
SLOT(deleteSurroundingText(int, uint)));
|
||||
connect(data.proxy, SIGNAL(notifyFocusOut()), this,
|
||||
SLOT(serverSideFocusOut()));
|
||||
}
|
||||
}
|
||||
|
||||
QKeyEvent *QFcitxInputContext::createKeyEvent(unsigned int keyval,
|
||||
unsigned int state,
|
||||
bool isRelease,
|
||||
const QKeyEvent *event) {
|
||||
QKeyEvent *newEvent = nullptr;
|
||||
if (event && event->nativeVirtualKey() == keyval &&
|
||||
event->nativeModifiers() == state &&
|
||||
isRelease == (event->type() == QEvent::KeyRelease)) {
|
||||
newEvent = new QKeyEvent(*event);
|
||||
} else {
|
||||
Qt::KeyboardModifiers qstate = Qt::NoModifier;
|
||||
|
||||
int count = 1;
|
||||
if (state & FcitxKeyState_Alt) {
|
||||
qstate |= Qt::AltModifier;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (state & FcitxKeyState_Shift) {
|
||||
qstate |= Qt::ShiftModifier;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (state & FcitxKeyState_Ctrl) {
|
||||
qstate |= Qt::ControlModifier;
|
||||
count++;
|
||||
}
|
||||
|
||||
auto unicode = xkb_keysym_to_utf32(keyval);
|
||||
QString text;
|
||||
if (unicode) {
|
||||
text = QString::fromUcs4(&unicode, 1);
|
||||
}
|
||||
|
||||
int key = keysymToQtKey(keyval, text);
|
||||
|
||||
newEvent = QKeyEvent::createExtendedKeyEvent(
|
||||
isRelease ? (QEvent::KeyRelease) : (QEvent::KeyPress), key, qstate,
|
||||
0, keyval, state, text, false, count);
|
||||
}
|
||||
|
||||
return newEvent;
|
||||
}
|
||||
|
||||
bool QFcitxInputContext::filterEvent(const QEvent *event) {
|
||||
do {
|
||||
if (event->type() != QEvent::KeyPress &&
|
||||
event->type() != QEvent::KeyRelease) {
|
||||
break;
|
||||
}
|
||||
|
||||
const QKeyEvent *keyEvent = static_cast<const QKeyEvent *>(event);
|
||||
quint32 keyval = keyEvent->nativeVirtualKey();
|
||||
quint32 keycode = keyEvent->nativeScanCode();
|
||||
quint32 state = keyEvent->nativeModifiers();
|
||||
bool isRelease = keyEvent->type() == QEvent::KeyRelease;
|
||||
|
||||
if (key_filtered) {
|
||||
break;
|
||||
}
|
||||
|
||||
QWidget *input = qApp->focusWidget();
|
||||
|
||||
if (!input) {
|
||||
break;
|
||||
}
|
||||
|
||||
FcitxQtInputContextProxy *proxy = validICByWindow(input);
|
||||
|
||||
if (!proxy) {
|
||||
if (filterEventFallback(keyval, keycode, state, isRelease)) {
|
||||
return true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
proxy->focusIn();
|
||||
update();
|
||||
|
||||
auto stateToFcitx = state;
|
||||
if (keyEvent->isAutoRepeat()) {
|
||||
// KeyState::Repeat
|
||||
stateToFcitx |= (1u << 31);
|
||||
}
|
||||
auto reply =
|
||||
proxy->processKeyEvent(keyval, keycode, stateToFcitx, isRelease,
|
||||
QDateTime::currentDateTime().toTime_t());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
||||
if (Q_UNLIKELY(syncMode_)) {
|
||||
#else
|
||||
if (syncMode_) {
|
||||
#endif
|
||||
reply.waitForFinished();
|
||||
|
||||
if (reply.isError() || !reply.value()) {
|
||||
if (filterEventFallback(keyval, keycode, state, isRelease)) {
|
||||
return true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
update();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ProcessKeyWatcher *watcher = new ProcessKeyWatcher(
|
||||
*keyEvent, qApp->focusWidget(), reply, proxy);
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this,
|
||||
SLOT(processKeyEventFinished(QDBusPendingCallWatcher *)));
|
||||
return true;
|
||||
}
|
||||
} while (0);
|
||||
return QInputContext::filterEvent(event);
|
||||
}
|
||||
|
||||
void QFcitxInputContext::processKeyEventFinished(QDBusPendingCallWatcher *w) {
|
||||
ProcessKeyWatcher *watcher = static_cast<ProcessKeyWatcher *>(w);
|
||||
QDBusPendingReply<bool> result(*watcher);
|
||||
bool filtered = false;
|
||||
|
||||
QWidget *window = watcher->window();
|
||||
// if window is already destroyed, we can only throw this event away.
|
||||
if (!window) {
|
||||
delete watcher;
|
||||
return;
|
||||
}
|
||||
|
||||
QKeyEvent &keyEvent = watcher->keyEvent();
|
||||
|
||||
// use same variable name as in QXcbKeyboard::handleKeyEvent
|
||||
QEvent::Type type = keyEvent.type();
|
||||
quint32 code = keyEvent.nativeScanCode();
|
||||
quint32 sym = keyEvent.nativeVirtualKey();
|
||||
quint32 state = keyEvent.nativeModifiers();
|
||||
QString string = keyEvent.text();
|
||||
|
||||
if (result.isError() || !result.value()) {
|
||||
filtered =
|
||||
filterEventFallback(sym, code, state, type == QEvent::KeyRelease);
|
||||
} else {
|
||||
filtered = true;
|
||||
}
|
||||
|
||||
if (!watcher->isError()) {
|
||||
update();
|
||||
}
|
||||
|
||||
if (!filtered) {
|
||||
key_filtered = true;
|
||||
QCoreApplication::sendEvent(window, &keyEvent);
|
||||
key_filtered = false;
|
||||
} else {
|
||||
auto proxy =
|
||||
qobject_cast<FcitxQtInputContextProxy *>(watcher->parent());
|
||||
if (proxy) {
|
||||
FcitxQtICData &data = *static_cast<FcitxQtICData *>(
|
||||
proxy->property("icData").value<void *>());
|
||||
data.event = std::make_unique<QKeyEvent>(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
delete watcher;
|
||||
}
|
||||
|
||||
bool QFcitxInputContext::filterEventFallback(unsigned int keyval,
|
||||
unsigned int keycode,
|
||||
unsigned int state,
|
||||
bool isRelease) {
|
||||
Q_UNUSED(keycode);
|
||||
if (processCompose(keyval, state, isRelease)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FcitxQtInputContextProxy *QFcitxInputContext::validIC() {
|
||||
if (icMap_.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
QWidget *window = qApp->focusWidget();
|
||||
return validICByWindow(window);
|
||||
}
|
||||
|
||||
FcitxQtInputContextProxy *QFcitxInputContext::validICByWindow(QWidget *w) {
|
||||
if (!w) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (icMap_.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto iter = icMap_.find(w);
|
||||
if (iter == icMap_.end())
|
||||
return nullptr;
|
||||
auto &data = iter->second;
|
||||
if (!data.proxy || !data.proxy->isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return data.proxy;
|
||||
}
|
||||
|
||||
bool QFcitxInputContext::processCompose(unsigned int keyval, unsigned int state,
|
||||
bool isRelease) {
|
||||
Q_UNUSED(state);
|
||||
|
||||
if (!xkbComposeTable_ || isRelease)
|
||||
return false;
|
||||
|
||||
struct xkb_compose_state *xkbComposeState = xkbComposeState_.data();
|
||||
|
||||
enum xkb_compose_feed_result result =
|
||||
xkb_compose_state_feed(xkbComposeState, keyval);
|
||||
if (result == XKB_COMPOSE_FEED_IGNORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enum xkb_compose_status status =
|
||||
xkb_compose_state_get_status(xkbComposeState);
|
||||
if (status == XKB_COMPOSE_NOTHING) {
|
||||
return 0;
|
||||
} else if (status == XKB_COMPOSE_COMPOSED) {
|
||||
std::array<char, 256> buffer;
|
||||
int length = xkb_compose_state_get_utf8(xkbComposeState, buffer.data(),
|
||||
buffer.size());
|
||||
xkb_compose_state_reset(xkbComposeState);
|
||||
if (length != 0) {
|
||||
commitString(QString::fromUtf8(buffer.data(), length));
|
||||
}
|
||||
} else if (status == XKB_COMPOSE_CANCELLED) {
|
||||
xkb_compose_state_reset(xkbComposeState);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString QFcitxInputContext::identifierName() { return "fcitx5"; }
|
||||
|
||||
QString QFcitxInputContext::language() { return ""; }
|
||||
} // namespace fcitx
|
||||
|
||||
// kate: indent-mode cstyle; space-indent on; indent-width 0;
|
||||
173
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qfcitxinputcontext.h
vendored
Normal file
173
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qfcitxinputcontext.h
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012~2017 CSSlayer <wengxt@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QFCITXINPUTCONTEXT_H
|
||||
#define QFCITXINPUTCONTEXT_H
|
||||
|
||||
#include "fcitxqtinputcontextproxy.h"
|
||||
#include "fcitxqtwatcher.h"
|
||||
#include <QApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QInputContext>
|
||||
#include <QKeyEvent>
|
||||
#include <QPointer>
|
||||
#include <QRect>
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <xkbcommon/xkbcommon-compose.h>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class FcitxQtConnection;
|
||||
|
||||
struct FcitxQtICData {
|
||||
FcitxQtICData(FcitxQtWatcher *watcher)
|
||||
: proxy(new FcitxQtInputContextProxy(watcher, watcher)) {}
|
||||
FcitxQtICData(const FcitxQtICData &that) = delete;
|
||||
~FcitxQtICData() { delete proxy; }
|
||||
quint64 capability = 0;
|
||||
FcitxQtInputContextProxy *proxy;
|
||||
QRect rect;
|
||||
// Last key event forwarded.
|
||||
std::unique_ptr<QKeyEvent> event;
|
||||
QString surroundingText;
|
||||
int surroundingAnchor = -1;
|
||||
int surroundingCursor = -1;
|
||||
};
|
||||
|
||||
class ProcessKeyWatcher : public QDBusPendingCallWatcher {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProcessKeyWatcher(const QKeyEvent &event, QWidget *window,
|
||||
const QDBusPendingCall &call, QObject *parent = 0)
|
||||
: QDBusPendingCallWatcher(call, parent),
|
||||
event_(QKeyEvent::createExtendedKeyEvent(
|
||||
event.type(), event.key(), event.modifiers(),
|
||||
event.nativeScanCode(), event.nativeVirtualKey(),
|
||||
event.nativeModifiers(), event.text(), event.isAutoRepeat(),
|
||||
event.count())),
|
||||
window_(window) {}
|
||||
|
||||
virtual ~ProcessKeyWatcher() { delete event_; }
|
||||
|
||||
QKeyEvent &keyEvent() { return *event_; }
|
||||
|
||||
QWidget *window() { return window_.data(); }
|
||||
|
||||
private:
|
||||
QKeyEvent *event_;
|
||||
QPointer<QWidget> window_;
|
||||
};
|
||||
|
||||
struct XkbContextDeleter {
|
||||
static inline void cleanup(struct xkb_context *pointer) {
|
||||
if (pointer)
|
||||
xkb_context_unref(pointer);
|
||||
}
|
||||
};
|
||||
|
||||
struct XkbComposeTableDeleter {
|
||||
static inline void cleanup(struct xkb_compose_table *pointer) {
|
||||
if (pointer)
|
||||
xkb_compose_table_unref(pointer);
|
||||
}
|
||||
};
|
||||
|
||||
struct XkbComposeStateDeleter {
|
||||
static inline void cleanup(struct xkb_compose_state *pointer) {
|
||||
if (pointer)
|
||||
xkb_compose_state_unref(pointer);
|
||||
}
|
||||
};
|
||||
|
||||
class FcitxQtInputMethodProxy;
|
||||
|
||||
class QFcitxInputContext : public QInputContext {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QFcitxInputContext();
|
||||
virtual ~QFcitxInputContext();
|
||||
|
||||
QString identifierName() override;
|
||||
QString language() override;
|
||||
void reset() override;
|
||||
bool isComposing() const override { return false; };
|
||||
void update() override;
|
||||
void setFocusWidget(QWidget *w) override;
|
||||
|
||||
void widgetDestroyed(QWidget *w) override;
|
||||
|
||||
bool filterEvent(const QEvent *event) override;
|
||||
void mouseHandler(int x, QMouseEvent *event) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void cursorRectChanged();
|
||||
void commitString(const QString &str);
|
||||
void updateFormattedPreedit(const FcitxQtFormattedPreeditList &preeditList,
|
||||
int cursorPos);
|
||||
void deleteSurroundingText(int offset, unsigned int nchar);
|
||||
void forwardKey(unsigned int keyval, unsigned int state, bool type);
|
||||
void createInputContextFinished(const QByteArray &uuid);
|
||||
void serverSideFocusOut();
|
||||
void cleanUp();
|
||||
void windowDestroyed(QObject *object);
|
||||
|
||||
private:
|
||||
bool processCompose(unsigned int keyval, unsigned int state,
|
||||
bool isRelaese);
|
||||
QKeyEvent *createKeyEvent(unsigned int keyval, unsigned int state,
|
||||
bool isRelaese, const QKeyEvent *event);
|
||||
|
||||
void addCapability(FcitxQtICData &data, quint64 capability,
|
||||
bool forceUpdate = false) {
|
||||
auto newcaps = data.capability | capability;
|
||||
if (data.capability != newcaps || forceUpdate) {
|
||||
data.capability = newcaps;
|
||||
updateCapability(data);
|
||||
}
|
||||
}
|
||||
|
||||
void removeCapability(FcitxQtICData &data, quint64 capability,
|
||||
bool forceUpdate = false) {
|
||||
auto newcaps = data.capability & (~capability);
|
||||
if (data.capability != newcaps || forceUpdate) {
|
||||
data.capability = newcaps;
|
||||
updateCapability(data);
|
||||
}
|
||||
}
|
||||
|
||||
void updateCapability(const FcitxQtICData &data);
|
||||
void commitPreedit(QPointer<QWidget> input = qApp->focusWidget());
|
||||
void createICData(QWidget *w);
|
||||
FcitxQtInputContextProxy *validIC();
|
||||
FcitxQtInputContextProxy *validICByWindow(QWidget *window);
|
||||
bool filterEventFallback(unsigned int keyval, unsigned int keycode,
|
||||
unsigned int state, bool isRelaese);
|
||||
|
||||
FcitxQtWatcher *watcher_;
|
||||
QString preedit_;
|
||||
QString commitPreedit_;
|
||||
FcitxQtFormattedPreeditList preeditList_;
|
||||
int cursorPos_;
|
||||
bool useSurroundingText_;
|
||||
bool syncMode_;
|
||||
std::unordered_map<QWidget *, FcitxQtICData> icMap_;
|
||||
QPointer<QWidget> lastWindow_;
|
||||
bool destroy_;
|
||||
QScopedPointer<struct xkb_context, XkbContextDeleter> xkbContext_;
|
||||
QScopedPointer<struct xkb_compose_table, XkbComposeTableDeleter>
|
||||
xkbComposeTable_;
|
||||
QScopedPointer<struct xkb_compose_state, XkbComposeStateDeleter>
|
||||
xkbComposeState_;
|
||||
private Q_SLOTS:
|
||||
void processKeyEventFinished(QDBusPendingCallWatcher *);
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
#endif // QFCITXINPUTCONTEXT_H
|
||||
1
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qtkey.cpp
vendored
Symbolic link
1
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qtkey.cpp
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../qt5/platforminputcontext/qtkey.cpp
|
||||
1
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qtkey.h
vendored
Symbolic link
1
Telegram/ThirdParty/fcitx5-qt/qt4/inputcontext/qtkey.h
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../qt5/platforminputcontext/qtkey.h
|
||||
Reference in New Issue
Block a user