Codebase list fcitx-unikey / 450cc22 debian / patches / 0001-unikey-port-editor-to-qt5.patch
450cc22

Tree @450cc22 (Download .tar.gz)

0001-unikey-port-editor-to-qt5.patch @450cc22raw · history · blame

From: Weng Xuetian <wengxt@gmail.com>
Date: Thu, 28 Sep 2017 18:31:02 -0700
Subject: [unikey] port editor to qt5.

Fix #20.
---
 CMakeLists.txt                 |  5 +++--
 macro-editor/CMakeLists.txt    | 24 ++++++++----------------
 macro-editor/editor.h          |  2 +-
 macro-editor/macro-editor.json |  2 ++
 macro-editor/main.cpp          |  3 ---
 macro-editor/main.h            |  3 ++-
 6 files changed, 16 insertions(+), 23 deletions(-)
 create mode 100644 macro-editor/macro-editor.json

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 280330c..8b8eb11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,9 +25,10 @@ find_package(Gettext REQUIRED)
 find_package(LibIntl REQUIRED)
 
 if (ENABLE_QT)
-find_package(Qt4 4.8)
+find_package(Qt5 5.7 REQUIRED COMPONENTS Core Gui Widgets)
+find_package(FcitxQt5WidgetsAddons 1.1 REQUIRED)
+find_package(FcitxQt5DBusAddons 1.1 REQUIRED)
 
-pkg_check_modules(FCITX_QT "fcitx-qt>=4.2.8")
 endif (ENABLE_QT)
 
 configure_file(config.h.in config.h)
diff --git a/macro-editor/CMakeLists.txt b/macro-editor/CMakeLists.txt
index cc57ea2..71aaabd 100644
--- a/macro-editor/CMakeLists.txt
+++ b/macro-editor/CMakeLists.txt
@@ -16,14 +16,11 @@ fcitx_translate_add_sources(
     ${MACRO_EDITOR_SRCS}
     ${MACRO_EDITOR_HDRS})
 
-if (NOT QT_FOUND OR NOT FCITX_QT_FOUND OR NOT ENABLE_QT)
+if (NOT ENABLE_QT)
     return()
-endif (NOT QT_FOUND OR NOT FCITX_QT_FOUND OR NOT ENABLE_QT)
+endif (NOT ENABLE_QT)
 
 include_directories(
-    ${FCITX_QT_INCLUDE_DIRS}
-    ${QT_QTCORE_INCLUDE_DIR}
-    ${QT_QTGUI_INCLUDE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
     ${PROJECT_SOURCE_DIR}/unikey
     )
@@ -31,27 +28,22 @@ include_directories(
 link_directories(
 ${FCITX4_FCITX_UTILS_LIBRARY_DIRS}
 ${FCITX4_FCITX_CONFIG_LIBRARY_DIRS}
-${FCITX_QT_LIBRARY_DIRS}
 )
-qt4_wrap_cpp(MACRO_EDITOR_MOCS ${MACRO_EDITOR_HDRS})
-qt4_wrap_ui(MACRO_EDITOR_SRCS editor.ui dialog.ui)
+qt5_wrap_ui(MACRO_EDITOR_SRCS editor.ui dialog.ui)
 add_library(fcitx-unikey-macro-editor
   MODULE ${MACRO_EDITOR_SRCS} ${MACRO_EDITOR_MOCS})
 set_target_properties(fcitx-unikey-macro-editor PROPERTIES
                       LINK_FLAGS "-Wl,--no-undefined"
+                      AUTOMOC TRUE
 )
 target_link_libraries(fcitx-unikey-macro-editor
-    debug ${QT_QTCORE_LIBRARY_DEBUG}
-    debug ${QT_QTDBUS_LIBRARY_DEBUG}
-    debug ${QT_QTGUI_LIBRARY_DEBUG}
-    optimized ${QT_QTCORE_LIBRARY_RELEASE}
-    optimized ${QT_QTDBUS_LIBRARY_RELEASE}
-    optimized ${QT_QTGUI_LIBRARY_RELEASE}
+    Qt5::Core
+    Qt5::Widgets
+    FcitxQt5::WidgetsAddons
+    LibIntl::LibIntl
     unikey
     ${FCITX4_FCITX_UTILS_LIBRARIES}
     ${FCITX4_FCITX_CONFIG_LIBRARIES}
-    ${FCITX_QT_LIBRARIES}
-    LibIntl::LibIntl
     )
 
 install(TARGETS fcitx-unikey-macro-editor DESTINATION ${FCITX4_ADDON_INSTALL_DIR}/qt)
diff --git a/macro-editor/editor.h b/macro-editor/editor.h
index 2426032..137e0b0 100644
--- a/macro-editor/editor.h
+++ b/macro-editor/editor.h
@@ -17,7 +17,7 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <fcitx-qt/fcitxqtconfiguiwidget.h>
+#include <fcitxqtconfiguiwidget.h>
 
 class CMacroTable;
 namespace Ui {
diff --git a/macro-editor/macro-editor.json b/macro-editor/macro-editor.json
new file mode 100644
index 0000000..2c63c08
--- /dev/null
+++ b/macro-editor/macro-editor.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/macro-editor/main.cpp b/macro-editor/main.cpp
index 12b769a..890eade 100644
--- a/macro-editor/main.cpp
+++ b/macro-editor/main.cpp
@@ -50,6 +50,3 @@ QString MacroEditorPlugin::domain()
 {
     return "fcitx-unikey";
 }
-
-
-Q_EXPORT_PLUGIN2 (fcitx_macro_editor, MacroEditorPlugin)
diff --git a/macro-editor/main.h b/macro-editor/main.h
index dfd06fc..e6a62c6 100644
--- a/macro-editor/main.h
+++ b/macro-editor/main.h
@@ -20,11 +20,12 @@
 #ifndef _MAIN_H_
 #define _MAIN_H_
 
-#include <fcitx-qt/fcitxqtconfiguiplugin.h>
+#include <fcitxqtconfiguiplugin.h>
 
 class MacroEditorPlugin : public FcitxQtConfigUIPlugin {
     Q_OBJECT
 public:
+    Q_PLUGIN_METADATA(IID FcitxQtConfigUIFactoryInterface_iid FILE "macro-editor.json")
     explicit MacroEditorPlugin(QObject* parent = 0);
     virtual QString name();
     virtual QStringList files();