Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Add GUI config tool support for fcitx-rime. #40

Merged
merged 3 commits into from
May 29, 2018
Merged

Add GUI config tool support for fcitx-rime. #40

merged 3 commits into from
May 29, 2018

Conversation

xuzhao9
Copy link
Contributor

@xuzhao9 xuzhao9 commented May 20, 2018

If you only want to test the GUI tool, please check out the following repo:
https://github.com/xuzhao9/fcitx-rime-config

CMakeLists.txt Outdated
@@ -29,6 +29,11 @@ configure_file(
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

option(QT5GUI "Build the Rime Config GUI Tool" ON)
Copy link
Member

Choose a reason for hiding this comment

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

call it ENABLE_XXXX

@@ -0,0 +1,8 @@
set(CMAKE_CXX_STANDARD 14)
Copy link
Member

Choose a reason for hiding this comment

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

use set_target_properties for this

@@ -0,0 +1,8 @@
set(CMAKE_CXX_STANDARD 14)
find_package(FcitxQt5WidgetsAddons 1.0.0 REQUIRED)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Widgets Concurrent)
Copy link
Member

Choose a reason for hiding this comment

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

REQUIRED_QT_VERSION is not defined. Also do you need Concurrent?

${FRCU_HDRS}
${FRCU_UIS})

include_directories(
Copy link
Member

Choose a reason for hiding this comment

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

not needed. As long as you use new style target_link_libraries

${RIME_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR})

link_directories(
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed, too.

@@ -0,0 +1,54 @@
#pragma once
Copy link
Member

Choose a reason for hiding this comment

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

I prefer ifndef

}

void FcitxRimeConfigDataModel::sortKeys() {
sortSingleKeySet(this->toggle_keys);
Copy link
Member

Choose a reason for hiding this comment

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

why you have this-> here?



// convert keyseq to state and sym
FcitxKeySeq::FcitxKeySeq(const char* keyseq) {
Copy link
Member

Choose a reason for hiding this comment

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

Why dup the code? Is there any api not available from libfcitx?

@@ -0,0 +1,399 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

this is availabe in fcitx4.

@@ -0,0 +1,91 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

since you're using qt, consider use QFlags instead. so you don't need cxx14.

@@ -0,0 +1,20 @@
#ifndef FCITX_RIME_CONFIG_COMMON_H
Copy link
Member

Choose a reason for hiding this comment

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

Please add copyright header

Q_OBJECT
public:
explicit ConfigMain(QWidget* parent = 0);
QString title();
Copy link
Member

Choose a reason for hiding this comment

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

Add override after virtual functions.

void availIMSelectionChanged();
void activeIMSelectionChanged();
private:
Ui::MainUI* m_ui;
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I prefer subclass over member for UI class.

gui/src/Main.h Outdated
public:
Q_PLUGIN_METADATA(IID "FcitxQtConfigUIFactoryInterface_iid" FILE "fcitx-rime-config.json")
explicit FcitxRimeConfigTool(QObject* parent = 0);
virtual QString name();
Copy link
Member

Choose a reason for hiding this comment

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

use override

gui/src/Model.h Outdated
#include <qkeysequence.h>
#include <QFlags>

#define MAX_SHORTCUTS 3
Copy link
Member

Choose a reason for hiding this comment

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

maybe constexpr.

#define FCITX_RIME_CONFIG_SUFFIX ".yaml"
#define FCITX_RIME_SCHEMA_SUFFIX ".schema.yaml"

#ifdef __cplusplus
Copy link
Member

Choose a reason for hiding this comment

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

is there any point to check cxx here?

#include "fcitx-utils/utils.h"
#include <stdio.h>

#ifdef __cplusplus
Copy link
Member

Choose a reason for hiding this comment

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

you can use c++ in this file, I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I? The rime api is C API, so I have to call using C interface.

gui/src/Model.h Outdated

#include <rime_api.h>

#include "fcitx-utils/keysym.h"
Copy link
Member

Choose a reason for hiding this comment

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

I prefer you don't use "fcitx-utils/" sub directory here.

gui/src/Model.h Outdated

#include "fcitx-utils/keysym.h"
#include "fcitx-utils/keysymgen.h"
#include <qkeysequence.h>
Copy link
Member

Choose a reason for hiding this comment

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

QKeySequence

@@ -16,39 +32,38 @@

namespace fcitx_rime {
ConfigMain::ConfigMain(QWidget* parent) :
FcitxQtConfigUIWidget(parent), m_ui(new Ui::MainUI),
FcitxQtConfigUIWidget(parent), Ui::MainUI(),
Copy link
Member

Choose a reason for hiding this comment

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

Ui::MainUI(), is not necessary

// key: value of the act_type, Page_Up, Page_Down, etc
// value: shortcut
void FcitxRimeConfigSetKeyBindingSet(RimeConfig* config, int type, const char* key, const char** shortcuts, size_t shortcut_size) {
RimeConfigIterator* iter = (RimeConfigIterator*) fcitx_utils_malloc0(sizeof(RimeConfigIterator));
Copy link
Member

Choose a reason for hiding this comment

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

do you need this on heap? I guess you can put iter on stack.

gui/src/Main.h Outdated
public:
Q_PLUGIN_METADATA(IID "FcitxQtConfigUIFactoryInterface_iid" FILE "fcitx-rime-config.json")
explicit FcitxRimeConfigTool(QObject* parent = 0);
virtual QString name() override;
Copy link
Member

Choose a reason for hiding this comment

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

remove virtual.

@wengxt wengxt merged commit af3897b into fcitx:master May 29, 2018
@Arfrever
Copy link

Arfrever commented May 30, 2018

Why does this patch use some parts of fcitx-qt (e.g.fcitxqtconfiguiwidget.h, fcitxqtkeysequencewidget.h, fcitxqtconfiguiplugin.h headers; fcitx-rime-config-gui is linked against PkgConfig::FcitxQt which theoretically is expanded into libfcitx-qt.so)?
fcitx-qt is for Qt 4.
libfcitx-qt.so library is linked against libQtCore.so.4, libQtDBus.so.4, libQtGui.so.4.
Using both Qt 4 and Qt 5 in the same process can cause misbehavior, crashes etc.
Defined symbols in Qt 4 libraries do not have versions.
Defined symbols in Qt 5 libraries use the same version Qt_5.
Qt-related undefined symbols in libfcitx-qt.so would be resolved by Qt 5 libraries.

Could you port to using Qt 5 only?

Actually libfcitx-rime-config-gui.so fails to build at linking stage:

[100%] Linking CXX shared module libfcitx-rime-config-gui.so
cd /var/tmp/portage/app-i18n/fcitx-rime-4.9999/work/fcitx-rime-4.9999_build/gui/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/fcitx-rime-config-gui.dir/link.txt --verbose=1
/usr/bin/x86_64-pc-linux-gnu-g++ -fPIC -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden -march=native -O2 -fno-ident -frecord-gcc-switches -fstack-clash-protection -mfunction-return=thunk -mindirect-branch=thunk -mindirect-branch-register -pipe -Wall -Werror=terminate -Wl,--no-undefined -Wl,--as-needed -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,--gc-sections -Wl,--sort-common -Wl,-z,now -shared  -o libfcitx-rime-config-gui.so CMakeFiles/fcitx-rime-config-gui.dir/Main.cpp.o CMakeFiles/fcitx-rime-config-gui.dir/ConfigMain.cpp.o CMakeFiles/fcitx-rime-config-gui.dir/Model.cpp.o CMakeFiles/fcitx-rime-config-gui.dir/FcitxRimeConfig.cpp.o CMakeFiles/fcitx-rime-config-gui.dir/fcitx-rime-config-gui_autogen/mocs_compilation.cpp.o -Wl,-rpath,/usr/lib64/qt4: /usr/lib64/libQt5Concurrent.so.5.11.0 /usr/lib64/libFcitxQt5WidgetsAddons.so.1.0 -lfcitx-utils -lfcitx-config -lfcitx-utils /usr/lib64/libQt5Widgets.so.5.11.0 /usr/lib64/libQt5Gui.so.5.11.0 /usr/lib64/libQt5Core.so.5.11.0 -lpkgcfg_lib_FcitxQt_fcitx-qt-NOTFOUND -lpkgcfg_lib_FcitxQt_fcitx-utils-NOTFOUND /usr/lib64/qt4/libQtDBus.so /usr/lib64/qt4/libQtXml.so /usr/lib64/qt4/libQtGui.so /usr/lib64/qt4/libQtCore.so -lrime -lfcitx-config 
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lpkgcfg_lib_FcitxQt_fcitx-qt-NOTFOUND
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lpkgcfg_lib_FcitxQt_fcitx-utils-NOTFOUND
collect2: error: ld returned 1 exit status
make[2]: *** [gui/src/CMakeFiles/fcitx-rime-config-gui.dir/build.make:209: gui/src/libfcitx-rime-config-gui.so] Error 1

@xuzhao9
Copy link
Contributor Author

xuzhao9 commented May 30, 2018

I have removed the libfcitx-qt library from the build. See PR #41.

@Arfrever
Copy link

I confirm that building now works and libfcitx-qt.so is not used.

@Arfrever
Copy link

It would be nice if this GUI configuration tool was also ported to Fcitx 5 (https://github.com/fcitx/fcitx5-rime) :) .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants