Fix build on older Qt5

Get rid of the new overloaded QMetaObject::invokeMethod from Qt 5.10.
This enables building the plugin-only on Qt 5.5, and rest of the project
on Qt 5.7.
(REQUIRED_QT5_VERSION 5.1.0) in cmake is wrong and is updated accordingly.
This commit is contained in:
oldherl 2023-11-18 23:32:30 +11:00 committed by Weng Xuetian
parent 10a67ed28d
commit 924577069f
5 changed files with 27 additions and 15 deletions

View File

@ -3,7 +3,7 @@ project(fcitx5-qt VERSION 5.1.3)
set(FCITX5_QT_VERSION ${PROJECT_VERSION})
set(REQUIRED_QT4_VERSION 4.8.0)
set(REQUIRED_QT5_VERSION 5.1.0)
set(REQUIRED_QT5_VERSION 5.5.0)
set(REQUIRED_QT6_VERSION 6.0.0)
find_package(ECM 1.4.0 REQUIRED)

View File

@ -1,3 +1,7 @@
if(NOT BUILD_ONLY_PLUGIN)
set(REQUIRED_QT5_VERSION 5.7.0)
endif()
find_package(Qt5 ${REQUIRED_QT5_VERSION} CONFIG REQUIRED Core DBus Widgets)
find_package(Qt5Gui ${REQUIRED_QT5_VERSION} REQUIRED Private)

View File

@ -374,7 +374,9 @@ void UpdateLayout(QTextLayout &layout, const FcitxTheme &theme,
std::initializer_list<
std::reference_wrapper<const FcitxQtFormattedPreeditList>>
texts) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
layout.clearFormats();
#endif
layout.setFont(theme.font());
QVector<QTextLayout::FormatRange> formats;
QString str;
@ -405,7 +407,9 @@ void UpdateLayout(QTextLayout &layout, const FcitxTheme &theme,
}
}
layout.setText(str);
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
layout.setFormats(formats);
#endif
}
void FcitxCandidateWindow::updateClientSideUI(

View File

@ -256,13 +256,7 @@ QFcitxPlatformInputContext::QFcitxPlatformInputContext()
// Input context may be created without QApplication with wayland, defer it
// to event loop to ensure event dispatcher is avaiable.
QMetaObject::invokeMethod(
this,
[this]() {
watcher_->watch();
fcitx4Watcher_->watch();
},
Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "watchersCallback", Qt::QueuedConnection);
}
QFcitxPlatformInputContext::~QFcitxPlatformInputContext() {
@ -529,13 +523,7 @@ void QFcitxPlatformInputContext::setFocusObject(QObject *object) {
// certain application like libreoffice.
QMetaObject::invokeMethod(
this,
[this, window = QPointer<QWindow>(lastWindow_)]() {
if (window != lastWindow_) {
return;
}
update(Qt::ImHints | Qt::ImEnabled);
updateCursorRect();
},
"updatesCallback",
Qt::QueuedConnection);
}
@ -1138,6 +1126,20 @@ void QFcitxPlatformInputContext::processKeyEventFinished(
delete watcher;
}
void QFcitxPlatformInputContext::watchersCallback() {
watcher_->watch();
fcitx4Watcher_->watch();
}
void QFcitxPlatformInputContext::updatesCallback() {
auto window = QPointer<QWindow>(lastWindow_);
if (window != lastWindow_) {
return;
}
update(Qt::ImHints | Qt::ImEnabled);
updateCursorRect();
}
bool QFcitxPlatformInputContext::filterEventFallback(unsigned int keyval,
unsigned int keycode,
unsigned int state,

View File

@ -156,6 +156,8 @@ public Q_SLOTS:
bool commitPreedit(QPointer<QObject> input = qApp->focusObject());
private Q_SLOTS:
void processKeyEventFinished(QDBusPendingCallWatcher *);
void watchersCallback();
void updatesCallback();
private:
bool processCompose(unsigned int keyval, unsigned int state,