-
Notifications
You must be signed in to change notification settings - Fork 40
Add GUI config tool support for fcitx-rime. #40
Conversation
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call it ENABLE_XXXX
gui/CMakeLists.txt
Outdated
@@ -0,0 +1,8 @@ | |||
set(CMAKE_CXX_STANDARD 14) |
There was a problem hiding this comment.
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
gui/CMakeLists.txt
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
gui/src/CMakeLists.txt
Outdated
${FRCU_HDRS} | ||
${FRCU_UIS}) | ||
|
||
include_directories( |
There was a problem hiding this comment.
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
gui/src/CMakeLists.txt
Outdated
${RIME_INCLUDE_DIRS} | ||
${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
link_directories( |
There was a problem hiding this comment.
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.
gui/src/ConfigMain.h
Outdated
@@ -0,0 +1,54 @@ | |||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer ifndef
gui/src/Model.cpp
Outdated
} | ||
|
||
void FcitxRimeConfigDataModel::sortKeys() { | ||
sortSingleKeySet(this->toggle_keys); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
gui/src/fcitx-utils/cutf8.cpp
Outdated
@@ -0,0 +1,399 @@ | |||
/* |
There was a problem hiding this comment.
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.
gui/src/fcitx-utils/flags.h
Outdated
@@ -0,0 +1,91 @@ | |||
/* |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add copyright header
gui/src/ConfigMain.h
Outdated
Q_OBJECT | ||
public: | ||
explicit ConfigMain(QWidget* parent = 0); | ||
QString title(); |
There was a problem hiding this comment.
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.
gui/src/ConfigMain.h
Outdated
void availIMSelectionChanged(); | ||
void activeIMSelectionChanged(); | ||
private: | ||
Ui::MainUI* m_ui; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe constexpr.
gui/src/rime-utils/FcitxRimeConfig.h
Outdated
#define FCITX_RIME_CONFIG_SUFFIX ".yaml" | ||
#define FCITX_RIME_SCHEMA_SUFFIX ".schema.yaml" | ||
|
||
#ifdef __cplusplus |
There was a problem hiding this comment.
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?
gui/src/rime-utils/FcitxRimeConfig.c
Outdated
#include "fcitx-utils/utils.h" | ||
#include <stdio.h> | ||
|
||
#ifdef __cplusplus |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QKeySequence
gui/src/ConfigMain.cpp
Outdated
@@ -16,39 +32,38 @@ | |||
|
|||
namespace fcitx_rime { | |||
ConfigMain::ConfigMain(QWidget* parent) : | |||
FcitxQtConfigUIWidget(parent), m_ui(new Ui::MainUI), | |||
FcitxQtConfigUIWidget(parent), Ui::MainUI(), |
There was a problem hiding this comment.
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
gui/src/FcitxRimeConfig.cpp
Outdated
// 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)); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove virtual.
Why does this patch use some parts of Could you port to using Qt 5 only? Actually
|
I have removed the libfcitx-qt library from the build. See PR #41. |
I confirm that building now works and |
It would be nice if this GUI configuration tool was also ported to Fcitx 5 (https://github.com/fcitx/fcitx5-rime) :) . |
If you only want to test the GUI tool, please check out the following repo:
https://github.com/xuzhao9/fcitx-rime-config