├── .gitignore ├── CMakeLists.txt ├── COPYING ├── README ├── cmake └── FindXkbFile.cmake ├── config.h.in ├── layout ├── CMakeLists.txt ├── deadmapdata.h ├── kbd-layout-viewer.desktop.in ├── keyboardlayoutwidget.cpp ├── keyboardlayoutwidget.h └── main.cpp ├── po ├── CMakeLists.txt ├── ca.po ├── da.po ├── de.po ├── ja.po ├── kcm_fcitx.pot ├── ko.po ├── ru.po ├── tr.po ├── vi.po ├── zh_CN.po └── zh_TW.po └── src ├── CMakeLists.txt ├── addonselector.cpp ├── addonselector.h ├── addonselector_p.h ├── configpage.cpp ├── configpage.h ├── configpage.ui ├── configwidget.cpp ├── configwidget.h ├── dummyconfig.cpp ├── dummyconfig.h ├── erroroverlay.cpp ├── erroroverlay.h ├── fcitx-skin.knsrc ├── fontbutton.cpp ├── fontbutton.h ├── fontbutton.ui ├── global.cpp ├── global.h ├── imconfigdialog.cpp ├── imconfigdialog.h ├── impage.cpp ├── impage.h ├── impage.ui ├── impage_p.h ├── kcm_fcitx.desktop.in ├── main.cpp ├── module.cpp ├── module.h ├── module.ui ├── skinpage.cpp ├── skinpage.h ├── skinpage.ui ├── skinpage_p.h ├── subconfig.cpp ├── subconfig.h ├── subconfigparser.cpp ├── subconfigparser.h ├── subconfigpattern.cpp ├── subconfigpattern.h ├── subconfigwidget.cpp ├── subconfigwidget.h ├── subconfigwidget_p.h ├── test ├── CMakeLists.txt ├── testconfigpage.cpp ├── testdummyconfig.cpp └── testfontbutton.cpp ├── uipage.cpp ├── uipage.h ├── verticalscrollarea.cpp └── verticalscrollarea.h /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | *.kdev4 3 | .kdev_include_paths 4 | .directory 5 | *.kate-swp 6 | *.orig 7 | *~ 8 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3 FATAL_ERROR) 2 | project(kcm-fcitx) 3 | 4 | set(QT_MIN_VERSION "5.11.0") 5 | find_package(ECM 1.0.0 REQUIRED NO_MODULE) 6 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 7 | include(KDEInstallDirs) 8 | include(KDECMakeSettings) 9 | include(KDECompilerSettings) 10 | include(FeatureSummary) 11 | option(ENABLE_TEST "Enable test" Off) 12 | 13 | find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets X11Extras) 14 | 15 | find_package(KF5 5.64 REQUIRED COMPONENTS 16 | CoreAddons 17 | WidgetsAddons 18 | ConfigWidgets 19 | ItemViews 20 | I18n 21 | KIO 22 | ) 23 | 24 | find_package(FcitxQt5DBusAddons 1.1.0 REQUIRED) 25 | find_package(FcitxQt5WidgetsAddons 1.1.0 REQUIRED) 26 | 27 | set(MAJOR_VERSION "0") 28 | set(MINOR_VERSION "5") 29 | set(PATCH_VERSION "4") 30 | set(SUFFIX_VERSION "") 31 | 32 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) 33 | 34 | set(VERSION_STRING "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") 35 | if(NOT SUFFIX_VERSION) 36 | set(VERSION_STRING_FULL "${VERSION_STRING}") 37 | else(NOT SUFFIX_VERSION) 38 | set(VERSION_STRING_FULL "${VERSION_STRING}-${SUFFIX_VERSION}") 39 | endif(NOT SUFFIX_VERSION) 40 | 41 | find_package(PkgConfig REQUIRED) 42 | find_package(Gettext REQUIRED) 43 | find_package(Fcitx 4.2.8 REQUIRED) 44 | find_package(XkbFile REQUIRED) 45 | find_package(X11 REQUIRED) 46 | 47 | set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_C_FLAGS}") 48 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_CXX_FLAGS}") 49 | set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}") 50 | set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}") 51 | 52 | string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" FCITX4_MAJOR_VERSION "${FCITX4_VERSION}") 53 | string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" FCITX4_MINOR_VERSION "${FCITX4_VERSION}") 54 | string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" FCITX4_PATCH_VERSION "${FCITX4_VERSION}") 55 | 56 | EXECUTE_PROCESS(COMMAND "${FCITX4_FCITXCONFIG_EXECUTABLE}" --exec-prefix OUTPUT_VARIABLE FCITX4_EXEC_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 57 | 58 | set(package ${FCITX4_PACKAGE_NAME}) 59 | set(datadir ${CMAKE_INSTALL_PREFIX}/share) 60 | set(localedir ${CMAKE_INSTALL_PREFIX}/share/locale) 61 | set(exec_prefix "${CMAKE_INSTALL_PREFIX}/bin") 62 | 63 | find_program(some_x_program NAMES iceauth xrdb xterm) 64 | if (NOT some_x_program) 65 | set(some_x_program /usr/bin/xrdb) 66 | message("Warning: Could not determine X binary directory. Assuming /usr/bin.") 67 | endif (NOT some_x_program) 68 | get_filename_component(proto_xbindir "${some_x_program}" PATH) 69 | get_filename_component(XBINDIR "${proto_xbindir}" ABSOLUTE) 70 | get_filename_component(xrootdir "${XBINDIR}" PATH) 71 | set(XLIBDIR "${xrootdir}/lib/X11") 72 | 73 | configure_file(config.h.in config.h) 74 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 75 | include_directories( 76 | ${FCITX4_FCITX_INCLUDE_DIRS} 77 | ${FCITX4_FCITX_UTILS_INCLUDE_DIRS} 78 | ${FCITX4_FCITX_CONFIG_INCLUDE_DIRS} 79 | ) 80 | 81 | link_directories( 82 | ${FCITX4_FCITX_LIBRARY_DIRS} 83 | ${FCITX4_FCITX_UTILS_LIBRARY_DIRS} 84 | ${FCITX4_FCITX_CONFIG_LIBRARY_DIRS} 85 | ) 86 | 87 | add_subdirectory(po) 88 | add_subdirectory(src) 89 | add_subdirectory(layout) 90 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcitx/kcm-fcitx/020c09283697c83ead964962e02ea86c894bd042/README -------------------------------------------------------------------------------- /cmake/FindXkbFile.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the XKBFILE libraries 2 | # Once done this will define 3 | # 4 | # XKBFILE_FOUND - system has XKBFILE 5 | # XKBFILE_INCLUDE_DIR - the XKBFILE include directory 6 | # XKBFILE_LIBRARIES - XKBFILE library 7 | # 8 | # Copyright (c) 2012 CSSlayer 9 | # 10 | # Redistribution and use is allowed according to the terms of the BSD license. 11 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 12 | 13 | if(XKBFILE_INCLUDE_DIR AND XKBFILE_LIBRARIES) 14 | # Already in cache, be silent 15 | set(XKBFILE_FIND_QUIETLY TRUE) 16 | endif(XKBFILE_INCLUDE_DIR AND XKBFILE_LIBRARIES) 17 | 18 | find_package(PkgConfig) 19 | pkg_check_modules(PC_LIBXKBFILE xkbfile) 20 | 21 | find_path(XKBFILE_MAIN_INCLUDE_DIR 22 | NAMES XKBfile.h 23 | HINTS ${PC_LIBXKBFILE_INCLUDEDIR} 24 | PATH_SUFFIXES "X11/extensions") 25 | 26 | find_library(XKBFILE_LIBRARIES 27 | NAMES xkbfile 28 | HINTS ${PC_LIBXKBFILE_LIBDIR}) 29 | 30 | set(XKBFILE_INCLUDE_DIR "${XKBFILE_MAIN_INCLUDE_DIR}") 31 | 32 | include(FindPackageHandleStandardArgs) 33 | find_package_handle_standard_args(XkbFile DEFAULT_MSG XKBFILE_LIBRARIES XKBFILE_MAIN_INCLUDE_DIR) 34 | 35 | mark_as_advanced(XKBFILE_INCLUDE_DIR XKBFILE_LIBRARIES) 36 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | #define VERSION_STRING_FULL "@VERSION_STRING_FULL@" 2 | #define DATADIR "@datadir@" 3 | #define LOCALEDIR "@localedir@" 4 | #define EXEC_PREFIX "@exec_prefix@" 5 | #define PACKAGE "@package@" 6 | #cmakedefine XLIBDIR "@XLIBDIR@" 7 | #define FCITX4_EXEC_PREFIX "@FCITX4_EXEC_PREFIX@" 8 | #define FCITX4_MAJOR_VERSION @FCITX4_MAJOR_VERSION@ 9 | #define FCITX4_MINOR_VERSION @FCITX4_MINOR_VERSION@ 10 | #define FCITX4_PATCH_VERSION @FCITX4_PATCH_VERSION@ 11 | 12 | #define FCITX_CHECK_VERSION(major,minor,micro) \ 13 | (FCITX4_MAJOR_VERSION > (major) || \ 14 | (FCITX4_MAJOR_VERSION == (major) && FCITX4_MINOR_VERSION > (minor)) || \ 15 | (FCITX4_MAJOR_VERSION == (major) && FCITX4_MINOR_VERSION == (minor) && \ 16 | FCITX4_PATCH_VERSION >= (micro))) -------------------------------------------------------------------------------- /layout/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | ${X11_Xkb_INCLUDE_PATH} 3 | ${X11_Xkblib_INCLUDE_PATH} 4 | ) 5 | 6 | set(kbd_layout_viewer_SOURCES 7 | main.cpp 8 | keyboardlayoutwidget.cpp 9 | ) 10 | fcitx_translate_add_sources(${kbd_layout_viewer_SOURCES} 11 | kbd-layout-viewer.desktop.in) 12 | 13 | add_executable(kbd-layout-viewer ${kbd_layout_viewer_SOURCES}) 14 | 15 | target_link_libraries(kbd-layout-viewer ${FCITX4_FCITX_CONFIG_LIBRARIES} Qt5::Widgets KF5::I18n Qt5::X11Extras ${X11_X11_LIB} ${XKBFILE_LIBRARIES} ${X11_Xkblib_LIB}) 16 | 17 | install(TARGETS kbd-layout-viewer DESTINATION ${BIN_INSTALL_DIR}) 18 | fcitx_translate_add_apply_source( 19 | kbd-layout-viewer.desktop.in 20 | "${CMAKE_CURRENT_BINARY_DIR}/kbd-layout-viewer.desktop") 21 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kbd-layout-viewer.desktop" 22 | DESTINATION ${CMAKE_INSTALL_APPDIR}) 23 | -------------------------------------------------------------------------------- /layout/deadmapdata.h: -------------------------------------------------------------------------------- 1 | struct DeadMap { 2 | uint dead; 3 | uint nondead; 4 | } deadMapData[] = { 5 | 6 | {XK_dead_grave, 0x0060}, 7 | {XK_dead_acute, 0x00b4}, 8 | {XK_dead_circumflex, 0x02c6}, 9 | {XK_dead_tilde, 0x02dc}, 10 | {XK_dead_macron, 0x00af}, 11 | {XK_dead_breve, 0x02D8}, 12 | {XK_dead_abovedot, 0x02D9}, 13 | {XK_dead_diaeresis, 0x00A8}, 14 | {XK_dead_abovering, 0x02DA}, 15 | {XK_dead_doubleacute, 0x02DD}, 16 | {XK_dead_caron, 0x02C7}, 17 | {XK_dead_cedilla, 0x00B8}, 18 | {XK_dead_ogonek, 0x02DB}, 19 | {XK_dead_iota, 0x0269}, 20 | {XK_dead_voiced_sound, 0x309B}, 21 | {XK_dead_semivoiced_sound, 0x309A}, 22 | {XK_dead_belowdot, 0x0323}, 23 | {XK_dead_hook, 0x0309}, 24 | {XK_dead_horn, 0x031b}, 25 | {XK_dead_stroke, 0x0335}, 26 | {XK_dead_abovecomma, 0x0312}, 27 | {XK_dead_abovereversedcomma, 0x0314}, 28 | {XK_dead_doublegrave, 0x030f}, 29 | {XK_dead_belowring, 0x0325}, 30 | {XK_dead_belowmacron, 0x0331}, 31 | {XK_dead_belowcircumflex, 0x032D}, 32 | {XK_dead_belowtilde, 0x0330}, 33 | {XK_dead_belowbreve, 0x032e}, 34 | {XK_dead_belowdiaeresis, 0x0324}, 35 | {XK_dead_invertedbreve, 0x0311}, 36 | {XK_dead_belowcomma, 0x0326}, 37 | {XK_dead_currency, 0x00A4}, 38 | 39 | /* dead vowels for universal syllable entry */ 40 | {XK_dead_a, 0x0061}, 41 | {XK_dead_A, 0x0041}, 42 | {XK_dead_e, 0x0065}, 43 | {XK_dead_E, 0x0045}, 44 | {XK_dead_i, 0x0069}, 45 | {XK_dead_I, 0x0049}, 46 | {XK_dead_o, 0x006f}, 47 | {XK_dead_O, 0x004f}, 48 | {XK_dead_u, 0x0075}, 49 | {XK_dead_U, 0x0055}, 50 | {XK_dead_small_schwa, 0x0259}, 51 | {XK_dead_capital_schwa, 0x018F}, 52 | }; 53 | -------------------------------------------------------------------------------- /layout/kbd-layout-viewer.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Exec=kbd-layout-viewer 3 | Icon=input-keyboard 4 | Type=Application 5 | 6 | _Name=Keyboard layout viewer 7 | _Comment=View keyboard layout 8 | 9 | _X-KDE-Keywords=keyboard;input;im 10 | 11 | Categories=Qt;KDE;Utility; 12 | -------------------------------------------------------------------------------- /layout/keyboardlayoutwidget.h: -------------------------------------------------------------------------------- 1 | /* this file is based on from libgnomekbd/libgnomekbd/gkbd-keyboard-drawing.c */ 2 | 3 | #ifndef KEYBOARDLAYOUTWIDGET_H 4 | #define KEYBOARDLAYOUTWIDGET_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class QPainter; 12 | struct Doodad; 13 | struct _XkbDesc; 14 | struct _XkbShapeDoodad; 15 | union _XkbDoodad; 16 | 17 | typedef enum { 18 | KEYBOARD_DRAWING_ITEM_TYPE_INVALID = 0, 19 | KEYBOARD_DRAWING_ITEM_TYPE_KEY, 20 | KEYBOARD_DRAWING_ITEM_TYPE_KEY_EXTRA, 21 | KEYBOARD_DRAWING_ITEM_TYPE_DOODAD 22 | } KeyboardDrawingItemType; 23 | 24 | 25 | typedef enum { 26 | KEYBOARD_DRAWING_POS_TOPLEFT, 27 | KEYBOARD_DRAWING_POS_TOPRIGHT, 28 | KEYBOARD_DRAWING_POS_BOTTOMLEFT, 29 | KEYBOARD_DRAWING_POS_BOTTOMRIGHT, 30 | KEYBOARD_DRAWING_POS_TOTAL, 31 | KEYBOARD_DRAWING_POS_FIRST = 32 | KEYBOARD_DRAWING_POS_TOPLEFT, 33 | KEYBOARD_DRAWING_POS_LAST = 34 | KEYBOARD_DRAWING_POS_BOTTOMRIGHT 35 | } KeyboardDrawingGroupLevelPosition; 36 | 37 | struct DrawingItem { 38 | DrawingItem() : 39 | type(KEYBOARD_DRAWING_ITEM_TYPE_INVALID), 40 | originX(0), 41 | originY(0), 42 | angle(0), 43 | priority(0) { } 44 | 45 | virtual ~DrawingItem() {} 46 | KeyboardDrawingItemType type; 47 | int originX; 48 | int originY; 49 | int angle; 50 | uint priority; 51 | }; 52 | 53 | struct Doodad : public DrawingItem{ 54 | Doodad() : doodad(0), on(0) { } 55 | union _XkbDoodad* doodad; 56 | int on; 57 | }; 58 | 59 | struct DrawingKey : public DrawingItem{ 60 | DrawingKey() : xkbkey(0), pressed(false), keycode(0) { } 61 | struct _XkbKey *xkbkey; 62 | bool pressed; 63 | uint keycode; 64 | }; 65 | 66 | 67 | struct KeyboardDrawingGroupLevel { 68 | int group; 69 | int level; 70 | }; 71 | 72 | 73 | class KeyboardLayoutWidget : public QWidget { 74 | Q_OBJECT 75 | public: 76 | explicit KeyboardLayoutWidget(QWidget* parent = 0); 77 | virtual ~KeyboardLayoutWidget(); 78 | void setGroup(int group); 79 | void setKeyboardLayout(const QString& layout, const QString& variant); 80 | void generatePixmap(bool force = false); 81 | 82 | protected: 83 | void keyPressEvent(QKeyEvent * event) override; 84 | void keyReleaseEvent(QKeyEvent * event) override; 85 | void paintEvent(QPaintEvent* event) override; 86 | void init(); 87 | void alloc(); 88 | void release(); 89 | void initInicatorDoodad(union _XkbDoodad* xkbdoodad, Doodad& doodad); 90 | uint findKeycode(const char* keyName); 91 | void rotateRectangle(int origin_x, 92 | int origin_y, 93 | int x, 94 | int y, 95 | int angle, 96 | int& rotated_x, int& rotated_y); 97 | bool parseXkbColorSpec(char* colorspec, QColor& color); 98 | void initColors(); 99 | 100 | void focusOutEvent(QFocusEvent* event) override; 101 | 102 | void drawKey(QPainter* painter, DrawingKey* item); 103 | void drawDoodad(QPainter* painter, Doodad* doodad); 104 | void drawKeyLabel(QPainter* painter, uint keycode, int angle, int arg4, int originY, int x2, int y2, bool pressed); 105 | void drawKeyLabelHelper(QPainter* painter, const QString &text, int angle, int glp, int end_glp, int x, int y, int width, int height, int padding, bool is_pressed); 106 | 107 | void drawShapeDoodad(QPainter* painter, Doodad* doodad, struct _XkbShapeDoodad* shapeDoodad); 108 | void drawTextDoodad(QPainter* painter, Doodad* doodad, struct _XkbTextDoodad* textDoodad); 109 | void drawIndicatorDoodad(QPainter* painter, Doodad* doodad, struct _XkbIndicatorDoodad* indicatorDoodad); 110 | 111 | int calcShapeOriginOffsetX(struct _XkbOutline* outline); 112 | void drawOutline(QPainter* painter, struct _XkbOutline* outline, QColor color, int angle, int originX, int originY); 113 | void drawRectangle(QPainter* painter, QColor color, int angle, int xkb_x, int xkb_y, int xkb_width, int xkb_height, unsigned int radius); 114 | void drawPolygon(QPainter* painter, QColor color, int originX, int originY, struct _XkbPoint* points, unsigned int num_points, unsigned int radius); 115 | void rotateCoordinate(int originX, int originY, int x, int y, int angle, int* rotated_x, int* rotated_y); 116 | int xkbToPixmapCoord (int n); 117 | double xkbToPixmapDouble (double d); 118 | void roundedPolygon(QPainter* painter, bool filled, double radius, const QVector< QPointF >& points); 119 | void drawCurveRectangle(QPainter* painter, bool filled, QColor color, int x, int y, int width, int height, double radius); 120 | void roundedCorner (QPainterPath& path, QPointF b, QPointF c, double radius); 121 | void resizeEvent(QResizeEvent* event) override; 122 | void setKeyboard(struct _XkbComponentNames* xkbDesc); 123 | 124 | private: 125 | void keyEvent(QKeyEvent *keyEvent); 126 | QString keySymToString(unsigned long keysym); 127 | 128 | QList keyboardItems; 129 | DrawingKey* keys; 130 | QList physicalIndicators; 131 | struct _XkbDesc* xkb; 132 | unsigned int l3mod; 133 | int physicalIndicatorsSize; 134 | bool xkbOnDisplay; 135 | QColor* colors; 136 | QPixmap image; 137 | double ratio; 138 | KeyboardDrawingGroupLevel** groupLevels; 139 | bool trackModifiers; 140 | int mods; 141 | QMap deadMap; 142 | }; 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /layout/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "config.h" 28 | #include "keyboardlayoutwidget.h" 29 | 30 | int main(int argc, char* argv[]) 31 | { 32 | QApplication app(argc, argv); 33 | app.setApplicationName(QLatin1String("kbd-layout-viewer")); 34 | app.setApplicationVersion(QLatin1String(VERSION_STRING_FULL)); 35 | 36 | QCommandLineParser parser; 37 | parser.setApplicationDescription(i18n("A general keyboard layout viewer")); 38 | parser.addHelpOption(); 39 | parser.addOptions({ 40 | {{"g", "group"}, 41 | i18n("Keyboard layout (0-3)"), 42 | i18n("group")}, 43 | {{"l", "layout"}, 44 | i18n("Keyboard "), 45 | i18n("layout")}, 46 | {{"v", "variant"}, 47 | i18n("Keyboard layout "), 48 | i18n("variant")} 49 | }); 50 | 51 | parser.process(app); 52 | 53 | int group = -1; 54 | QString variant, layout; 55 | if (parser.isSet("group")) { 56 | group = parser.value("group").toInt(); 57 | } 58 | if (parser.isSet("layout")) { 59 | layout = parser.value("layout"); 60 | } 61 | if (parser.isSet("variant")) { 62 | variant = parser.value("variant"); 63 | } 64 | 65 | if (!QX11Info::isPlatformX11()) { 66 | qFatal("Only X11 is supported"); 67 | return 1; 68 | } 69 | 70 | app.setAttribute(Qt::AA_UseHighDpiPixmaps); 71 | 72 | QMainWindow mainWindow; 73 | mainWindow.setWindowIcon(QIcon::fromTheme("input-keyboard")); 74 | mainWindow.setWindowTitle(i18n("Keyboard Layout viewer")); 75 | mainWindow.setMinimumSize(QSize(900,400)); 76 | KeyboardLayoutWidget widget; 77 | if (group > 0 || layout.isNull()) { 78 | if (group < 0) 79 | group = 0; 80 | widget.setGroup(group); 81 | } 82 | else if (!layout.isNull()) { 83 | widget.setKeyboardLayout(layout, variant); 84 | } 85 | 86 | mainWindow.setCentralWidget(&widget); 87 | mainWindow.show(); 88 | 89 | return app.exec(); 90 | } 91 | -------------------------------------------------------------------------------- /po/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB PO_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.po) 2 | 3 | foreach(po_file ${PO_FILES}) 4 | string(REPLACE ".po" "" po_lang "${po_file}") 5 | fcitx_translate_add_po_file("${po_lang}" "${po_file}") 6 | endforeach() 7 | fcitx_translate_set_pot_target(pot kcm_fcitx kcm_fcitx.pot) 8 | -------------------------------------------------------------------------------- /po/kcm_fcitx.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" 11 | "POT-Creation-Date: 2022-06-02 20:30+0000\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: LANG\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: layout/main.cpp:37 21 | #, kde-format 22 | msgid "A general keyboard layout viewer" 23 | msgstr "" 24 | 25 | #: layout/main.cpp:41 26 | #, kde-format 27 | msgid "Keyboard layout (0-3)" 28 | msgstr "" 29 | 30 | #: layout/main.cpp:42 31 | #, kde-format 32 | msgid "group" 33 | msgstr "" 34 | 35 | #: layout/main.cpp:44 36 | #, kde-format 37 | msgid "Keyboard " 38 | msgstr "" 39 | 40 | #: layout/main.cpp:45 41 | #, kde-format 42 | msgid "layout" 43 | msgstr "" 44 | 45 | #: layout/main.cpp:47 46 | #, kde-format 47 | msgid "Keyboard layout " 48 | msgstr "" 49 | 50 | #: layout/main.cpp:48 51 | #, kde-format 52 | msgid "variant" 53 | msgstr "" 54 | 55 | #: layout/main.cpp:74 56 | #, kde-format 57 | msgid "Keyboard Layout viewer" 58 | msgstr "" 59 | 60 | #: src/addonselector.cpp:375 61 | #, kde-format 62 | msgid "Search Addons" 63 | msgstr "" 64 | 65 | #: src/addonselector.cpp:382 src/configwidget.cpp:606 66 | #, kde-format 67 | msgid "Show &Advance option" 68 | msgstr "" 69 | 70 | #: src/configwidget.cpp:450 71 | #, kde-format 72 | msgid "Other" 73 | msgstr "" 74 | 75 | #: src/configwidget.cpp:560 src/impage.cpp:69 76 | #, kde-format 77 | msgid "Other" 78 | msgstr "" 79 | 80 | #: src/erroroverlay.cpp:43 81 | #, kde-format 82 | msgid "Cannot connect to Fcitx by DBus, is Fcitx running?" 83 | msgstr "" 84 | 85 | #: src/imconfigdialog.cpp:42 86 | #, kde-format 87 | msgid "Keyboard Layout:" 88 | msgstr "" 89 | 90 | #: src/imconfigdialog.cpp:47 91 | #, kde-format 92 | msgid "Default" 93 | msgstr "" 94 | 95 | #: src/imconfigdialog.cpp:49 96 | #, kde-format 97 | msgid "Input Method Default" 98 | msgstr "" 99 | 100 | #: src/imconfigdialog.cpp:98 101 | #, kde-format 102 | msgid "Input Method Setting:" 103 | msgstr "" 104 | 105 | #: src/impage.cpp:50 106 | #, kde-format 107 | msgid "Unknown" 108 | msgstr "" 109 | 110 | #: src/impage.cpp:53 111 | #, kde-format 112 | msgid "Multilingual" 113 | msgstr "" 114 | 115 | #: src/impage.cpp:84 116 | #, kde-format 117 | msgctxt "%1 is language name, %2 is country name" 118 | msgid "%1 (%2)" 119 | msgstr "" 120 | 121 | #: src/impage.cpp:481 122 | #, kde-format 123 | msgid "Search Input Method" 124 | msgstr "" 125 | 126 | #: src/module.cpp:83 127 | #, kde-format 128 | msgid "Fcitx Configuration Module" 129 | msgstr "" 130 | 131 | #: src/module.cpp:85 132 | #, kde-format 133 | msgid "Configure Fcitx" 134 | msgstr "" 135 | 136 | #: src/module.cpp:87 137 | #, kde-format 138 | msgid "Copyright 2012 Xuetian Weng" 139 | msgstr "" 140 | 141 | #: src/module.cpp:91 142 | #, kde-format 143 | msgid "Xuetian Weng" 144 | msgstr "" 145 | 146 | #: src/module.cpp:91 147 | #, kde-format 148 | msgid "Author" 149 | msgstr "" 150 | 151 | #: src/module.cpp:104 src/kcm_fcitx.desktop.in:11 152 | #, kde-format 153 | msgid "Input Method" 154 | msgstr "" 155 | 156 | #: src/module.cpp:113 157 | #, kde-format 158 | msgid "Global Config" 159 | msgstr "" 160 | 161 | #: src/module.cpp:121 162 | #, kde-format 163 | msgid "Appearance" 164 | msgstr "" 165 | 166 | #: src/module.cpp:129 167 | #, kde-format 168 | msgid "Addon Config" 169 | msgstr "" 170 | 171 | #: src/module.cpp:178 172 | #, kde-format 173 | msgid "Manage Skin" 174 | msgstr "" 175 | 176 | #: src/skinpage.cpp:217 177 | #, kde-format 178 | msgid "First candidate" 179 | msgstr "" 180 | 181 | #: src/skinpage.cpp:218 182 | #, kde-format 183 | msgid "Other candidate" 184 | msgstr "" 185 | 186 | #: src/skinpage.cpp:387 187 | #, kde-format 188 | msgid "Skin %1 Cannot be loaded" 189 | msgstr "" 190 | 191 | #: src/subconfigwidget.cpp:230 192 | #, kde-format 193 | msgid "" 194 | "User config doesn't exisits, do you want to open system file or copy system " 195 | "file to user file?" 196 | msgstr "" 197 | 198 | #: src/subconfigwidget.cpp:231 199 | #, kde-format 200 | msgid "What to do" 201 | msgstr "" 202 | 203 | #: src/subconfigwidget.cpp:232 204 | #, kde-format 205 | msgid "Copy" 206 | msgstr "" 207 | 208 | #: src/subconfigwidget.cpp:233 209 | #, kde-format 210 | msgid "View system" 211 | msgstr "" 212 | 213 | #: src/subconfigwidget.cpp:245 214 | #, kde-format 215 | msgid "Copy failed" 216 | msgstr "" 217 | 218 | #: src/uipage.cpp:16 219 | #, kde-format 220 | msgid "Cannot load currently used user interface info" 221 | msgstr "" 222 | 223 | #: src/uipage.cpp:45 224 | #, kde-format 225 | msgid "No configuration options for %1." 226 | msgstr "" 227 | 228 | #: layout/kbd-layout-viewer.desktop.in:6 229 | msgid "Keyboard layout viewer" 230 | msgstr "" 231 | 232 | #: layout/kbd-layout-viewer.desktop.in:7 233 | msgid "View keyboard layout" 234 | msgstr "" 235 | 236 | #: layout/kbd-layout-viewer.desktop.in:9 237 | msgid "keyboard;input;im" 238 | msgstr "" 239 | 240 | #: src/kcm_fcitx.desktop.in:12 241 | msgid "Configure Input Method" 242 | msgstr "" 243 | 244 | #: src/kcm_fcitx.desktop.in:14 245 | msgid "keyboard,input,im,fcitx" 246 | msgstr "" 247 | 248 | #. i18n: file: src/configpage.ui:14 249 | #. i18n: ectx: property (windowTitle), widget (QWidget, ConfigPage) 250 | #. i18n: file: src/fontbutton.ui:20 251 | #. i18n: ectx: property (windowTitle), widget (QWidget, FontButton) 252 | msgid "Form" 253 | msgstr "" 254 | 255 | #. i18n: file: src/configpage.ui:54 256 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 257 | msgid "" 258 | "Options listed here might be overridden by specific input method, usually " 259 | "including candidate number, hotkey of previous page and next page. You may " 260 | "need go to configuration of corresponding input method to change them." 261 | msgstr "" 262 | 263 | #. i18n: file: src/fontbutton.ui:51 264 | #. i18n: ectx: property (text), widget (QPushButton, fontSelectButton) 265 | msgid "Select &Font..." 266 | msgstr "" 267 | 268 | #. i18n: file: src/impage.ui:38 269 | #. i18n: ectx: property (toolTip), widget (QPushButton, defaultLayoutButton) 270 | msgid "Keyboard layout to use when no input method active" 271 | msgstr "" 272 | 273 | #. i18n: file: src/impage.ui:41 274 | #. i18n: ectx: property (text), widget (QPushButton, defaultLayoutButton) 275 | msgid "Select default keyboard layout" 276 | msgstr "" 277 | 278 | #. i18n: file: src/impage.ui:83 279 | #. i18n: ectx: property (text), widget (QLabel, label) 280 | msgid "Available Input Method:" 281 | msgstr "" 282 | 283 | #. i18n: file: src/impage.ui:115 284 | #. i18n: ectx: property (text), widget (QCheckBox, onlyCurrentLanguageCheckBox) 285 | msgid "Only &Show Current Language" 286 | msgstr "" 287 | 288 | #. i18n: file: src/impage.ui:176 289 | #. i18n: ectx: property (text), widget (QLabel, label_2) 290 | msgid "Current Input Method:" 291 | msgstr "" 292 | 293 | #. i18n: file: src/impage.ui:277 294 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 295 | msgid "" 296 | "The first input method will be inactive state. Usually you need to put " 297 | "Keyboard or Keyboard - layout name in the first place." 298 | msgstr "" 299 | 300 | #. i18n: file: src/impage.ui:292 301 | #. i18n: ectx: property (text), widget (QLabel, label_3) 302 | msgid "Default keyboard layout:" 303 | msgstr "" 304 | 305 | #. i18n: file: src/impage.ui:302 306 | #. i18n: ectx: property (text), widget (QLabel, label_4) 307 | msgid "Select Input Method:" 308 | msgstr "" 309 | 310 | #. i18n: file: src/skinpage.ui:41 311 | #. i18n: ectx: property (text), widget (QPushButton, configureSkinButton) 312 | msgid "&Configure Skin" 313 | msgstr "" 314 | 315 | #. i18n: file: src/skinpage.ui:51 316 | #. i18n: ectx: property (text), widget (QPushButton, deleteSkinButton) 317 | msgid "&Delete Skin" 318 | msgstr "" 319 | 320 | #. i18n: file: src/skinpage.ui:65 321 | #. i18n: ectx: property (text), widget (QLabel, label) 322 | msgid "" 323 | "\n" 325 | "\n" 330 | "

Notice:

\n" 333 | "

You need to use Classic UI " 335 | "to use skin function.

" 336 | msgstr "" 337 | 338 | msgctxt "NAME OF TRANSLATORS" 339 | msgid "Your names" 340 | msgstr "" 341 | 342 | msgctxt "EMAIL OF TRANSLATORS" 343 | msgid "Your emails" 344 | msgstr "" 345 | -------------------------------------------------------------------------------- /po/ko.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # 5 | # Translators: 6 | # Bon Keun Seo , 2017 7 | # Junghee Lee , 2021 8 | # Junghee Lee , 2020 9 | # Junghee Lee , 2022 10 | # Junghee Lee , 2021 11 | # Junghee Lee , 2020,2022 12 | msgid "" 13 | msgstr "" 14 | "Project-Id-Version: fcitx\n" 15 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" 16 | "POT-Creation-Date: 2022-06-02 20:30+0000\n" 17 | "PO-Revision-Date: 2011-11-16 06:53+0000\n" 18 | "Last-Translator: Junghee Lee , 2022\n" 19 | "Language-Team: Korean (http://www.transifex.com/fcitx/fcitx/language/ko/)\n" 20 | "Language: ko\n" 21 | "MIME-Version: 1.0\n" 22 | "Content-Type: text/plain; charset=UTF-8\n" 23 | "Content-Transfer-Encoding: 8bit\n" 24 | "Plural-Forms: nplurals=1; plural=0;\n" 25 | 26 | #: src/impage.cpp:84 27 | #, kde-format 28 | msgctxt "%1 is language name, %2 is country name" 29 | msgid "%1 (%2)" 30 | msgstr "%1 (%2)" 31 | 32 | #. i18n: file: src/skinpage.ui:41 33 | #. i18n: ectx: property (text), widget (QPushButton, configureSkinButton) 34 | msgid "&Configure Skin" 35 | msgstr "스킨 구성하기(&C)" 36 | 37 | #. i18n: file: src/skinpage.ui:51 38 | #. i18n: ectx: property (text), widget (QPushButton, deleteSkinButton) 39 | msgid "&Delete Skin" 40 | msgstr "스킨 삭제(&D)" 41 | 42 | #. i18n: file: src/skinpage.ui:65 43 | #. i18n: ectx: property (text), widget (QLabel, label) 44 | msgid "" 45 | "\n" 47 | "\n" 52 | "

Notice:

\n" 55 | "

You need to use Classic UI " 57 | "to use skin function.

" 58 | msgstr "" 59 | "\n" 61 | "\n" 66 | "

주의:

\n" 69 | "

클래식 UI를 사용해야 스킨" 71 | "을 사용할 수 있습니다.

" 72 | 73 | #. i18n: file: src/impage.ui:292 74 | #. i18n: ectx: property (text), widget (QLabel, label_3) 75 | msgid "Default keyboard layout:" 76 | msgstr "기본 키보드 자판:" 77 | 78 | #: src/imconfigdialog.cpp:98 79 | #, kde-format 80 | msgid "Input Method Setting:" 81 | msgstr "입력기 설정:" 82 | 83 | #: src/imconfigdialog.cpp:42 84 | #, kde-format 85 | msgid "Keyboard Layout:" 86 | msgstr "키보드 자판:" 87 | 88 | #: src/configwidget.cpp:450 89 | #, kde-format 90 | msgid "Other" 91 | msgstr "기타" 92 | 93 | #. i18n: file: src/impage.ui:302 94 | #. i18n: ectx: property (text), widget (QLabel, label_4) 95 | msgid "Select Input Method:" 96 | msgstr "입력기 선택:" 97 | 98 | #: layout/main.cpp:37 99 | #, kde-format 100 | msgid "A general keyboard layout viewer" 101 | msgstr "일반 키보드 자판 보기도구" 102 | 103 | #: src/module.cpp:129 104 | #, kde-format 105 | msgid "Addon Config" 106 | msgstr "애드온 구성" 107 | 108 | #: src/module.cpp:121 109 | #, kde-format 110 | msgid "Appearance" 111 | msgstr "모양새" 112 | 113 | #: src/module.cpp:91 114 | #, kde-format 115 | msgid "Author" 116 | msgstr "작성자" 117 | 118 | #. i18n: file: src/impage.ui:83 119 | #. i18n: ectx: property (text), widget (QLabel, label) 120 | msgid "Available Input Method:" 121 | msgstr "사용가능한 입력기:" 122 | 123 | #: src/erroroverlay.cpp:43 124 | #, kde-format 125 | msgid "Cannot connect to Fcitx by DBus, is Fcitx running?" 126 | msgstr "DBus로 Fcitx에 연결할 수 없습니다. Fcitx가 실행되고 있습니까?" 127 | 128 | #: src/uipage.cpp:16 129 | #, kde-format 130 | msgid "Cannot load currently used user interface info" 131 | msgstr "현재 사용자 인터페이스 정보를 불러올 수 없음" 132 | 133 | #: src/module.cpp:85 134 | #, kde-format 135 | msgid "Configure Fcitx" 136 | msgstr "Fcitx 구성하기" 137 | 138 | #: src/kcm_fcitx.desktop.in:12 139 | msgid "Configure Input Method" 140 | msgstr "입력기 구성하기" 141 | 142 | #: src/subconfigwidget.cpp:232 143 | #, kde-format 144 | msgid "Copy" 145 | msgstr "복사" 146 | 147 | #: src/subconfigwidget.cpp:245 148 | #, kde-format 149 | msgid "Copy failed" 150 | msgstr "복사 실패" 151 | 152 | #: src/module.cpp:87 153 | #, kde-format 154 | msgid "Copyright 2012 Xuetian Weng" 155 | msgstr "저작권자 2012 Xuetian Weng" 156 | 157 | #. i18n: file: src/impage.ui:176 158 | #. i18n: ectx: property (text), widget (QLabel, label_2) 159 | msgid "Current Input Method:" 160 | msgstr "현재 입력기:" 161 | 162 | #: src/imconfigdialog.cpp:47 163 | #, kde-format 164 | msgid "Default" 165 | msgstr "기본값" 166 | 167 | #: src/module.cpp:83 168 | #, kde-format 169 | msgid "Fcitx Configuration Module" 170 | msgstr "Fcitx 구성 모듈" 171 | 172 | #: src/skinpage.cpp:217 173 | #, kde-format 174 | msgid "First candidate" 175 | msgstr "첫 후보" 176 | 177 | #. i18n: file: src/configpage.ui:14 178 | #. i18n: ectx: property (windowTitle), widget (QWidget, ConfigPage) 179 | #. i18n: file: src/fontbutton.ui:20 180 | #. i18n: ectx: property (windowTitle), widget (QWidget, FontButton) 181 | msgid "Form" 182 | msgstr "폼" 183 | 184 | #: src/module.cpp:113 185 | #, kde-format 186 | msgid "Global Config" 187 | msgstr "전역 구성" 188 | 189 | #: src/module.cpp:104 src/kcm_fcitx.desktop.in:11 190 | #, kde-format 191 | msgid "Input Method" 192 | msgstr "입력기" 193 | 194 | #: src/imconfigdialog.cpp:49 195 | #, kde-format 196 | msgid "Input Method Default" 197 | msgstr "입력기 기본값" 198 | 199 | #: layout/main.cpp:44 200 | #, kde-format 201 | msgid "Keyboard " 202 | msgstr "키보드 <자판>" 203 | 204 | #: layout/main.cpp:74 205 | #, kde-format 206 | msgid "Keyboard Layout viewer" 207 | msgstr "키보드 자판 보기도구" 208 | 209 | #: layout/main.cpp:41 210 | #, kde-format 211 | msgid "Keyboard layout (0-3)" 212 | msgstr "키보드 자판 <그룹> (0-3)" 213 | 214 | #: layout/main.cpp:47 215 | #, kde-format 216 | msgid "Keyboard layout " 217 | msgstr "키보드 자판 <변형>" 218 | 219 | #. i18n: file: src/impage.ui:38 220 | #. i18n: ectx: property (toolTip), widget (QPushButton, defaultLayoutButton) 221 | msgid "Keyboard layout to use when no input method active" 222 | msgstr "활성 입력기가 없을 때 사용할 키보드 자판" 223 | 224 | #: layout/kbd-layout-viewer.desktop.in:6 225 | msgid "Keyboard layout viewer" 226 | msgstr "키보드 자판 보기도구" 227 | 228 | #: src/module.cpp:178 229 | #, kde-format 230 | msgid "Manage Skin" 231 | msgstr "스킨 관리" 232 | 233 | #: src/impage.cpp:53 234 | #, kde-format 235 | msgid "Multilingual" 236 | msgstr "다국어" 237 | 238 | #: src/uipage.cpp:45 239 | #, kde-format 240 | msgid "No configuration options for %1." 241 | msgstr "%1에 대한 구성 옵션들이 없습니다." 242 | 243 | #. i18n: file: src/impage.ui:115 244 | #. i18n: ectx: property (text), widget (QCheckBox, onlyCurrentLanguageCheckBox) 245 | msgid "Only &Show Current Language" 246 | msgstr "현재 언어만 표시(&S)" 247 | 248 | #. i18n: file: src/configpage.ui:54 249 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 250 | msgid "" 251 | "Options listed here might be overridden by specific input method, usually " 252 | "including candidate number, hotkey of previous page and next page. You may " 253 | "need go to configuration of corresponding input method to change them." 254 | msgstr "" 255 | "표시된 옵션은 입력기에 의해 덮어씌워질 수 있습니다. 대체로 후보 개수, 이전 혹" 256 | "은 다음 페이지의 단축기 등이 해당됩니다. 그냥 당연한 거 같아요.해당 입력기의 " 257 | "구성 페이지에서 변경 가능합니다." 258 | 259 | #: src/configwidget.cpp:560 src/impage.cpp:69 260 | #, kde-format 261 | msgid "Other" 262 | msgstr "기타" 263 | 264 | #: src/skinpage.cpp:218 265 | #, kde-format 266 | msgid "Other candidate" 267 | msgstr "다른 후보" 268 | 269 | #: src/addonselector.cpp:375 270 | #, kde-format 271 | msgid "Search Addons" 272 | msgstr "애드온 검색" 273 | 274 | #: src/impage.cpp:481 275 | #, kde-format 276 | msgid "Search Input Method" 277 | msgstr "입력기 검색" 278 | 279 | #. i18n: file: src/fontbutton.ui:51 280 | #. i18n: ectx: property (text), widget (QPushButton, fontSelectButton) 281 | msgid "Select &Font..." 282 | msgstr "글꼴 선택...(&F)" 283 | 284 | #. i18n: file: src/impage.ui:41 285 | #. i18n: ectx: property (text), widget (QPushButton, defaultLayoutButton) 286 | msgid "Select default keyboard layout" 287 | msgstr "기본 키보드 자판 선택" 288 | 289 | #: src/addonselector.cpp:382 src/configwidget.cpp:606 290 | #, kde-format 291 | msgid "Show &Advance option" 292 | msgstr "고급 옵션 표시(&A)" 293 | 294 | #: src/skinpage.cpp:387 295 | #, kde-format 296 | msgid "Skin %1 Cannot be loaded" 297 | msgstr "스킨 %1 을 불러올 수 없음" 298 | 299 | #. i18n: file: src/impage.ui:277 300 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 301 | msgid "" 302 | "The first input method will be inactive state. Usually you need to put " 303 | "Keyboard or Keyboard - layout name in the first place." 304 | msgstr "" 305 | "첫번째 입력기가 비활성화 상태입니다. 대체로 키보드 또는 키보드 - " 306 | " 자판명 을 첫 항목으로 하여야 합니다." 307 | 308 | #: src/impage.cpp:50 309 | #, kde-format 310 | msgid "Unknown" 311 | msgstr "알 수 없음 " 312 | 313 | #: src/subconfigwidget.cpp:230 314 | #, kde-format 315 | msgid "" 316 | "User config doesn't exisits, do you want to open system file or copy system " 317 | "file to user file?" 318 | msgstr "" 319 | "사용자 구성이 존재하지 않습니다. 시스템 파일을 열거나 시스템 파일을 사용자 파" 320 | "일로 복사하시겠습니까?" 321 | 322 | #: layout/kbd-layout-viewer.desktop.in:7 323 | msgid "View keyboard layout" 324 | msgstr "키보드 자판 보기" 325 | 326 | #: src/subconfigwidget.cpp:233 327 | #, kde-format 328 | msgid "View system" 329 | msgstr "시스템 보기" 330 | 331 | #: src/subconfigwidget.cpp:231 332 | #, kde-format 333 | msgid "What to do" 334 | msgstr "어떡할까요?" 335 | 336 | #: src/module.cpp:91 337 | #, kde-format 338 | msgid "Xuetian Weng" 339 | msgstr "Xuetian Weng" 340 | 341 | msgctxt "EMAIL OF TRANSLATORS" 342 | msgid "Your emails" 343 | msgstr "당신의 이메일" 344 | 345 | msgctxt "NAME OF TRANSLATORS" 346 | msgid "Your names" 347 | msgstr "당신의 이름" 348 | 349 | #: layout/main.cpp:42 350 | #, kde-format 351 | msgid "group" 352 | msgstr "그룹" 353 | 354 | #: src/kcm_fcitx.desktop.in:14 355 | msgid "keyboard,input,im,fcitx" 356 | msgstr "keyboard,input,im,fcitx키보드;입력;입력기" 357 | 358 | #: layout/kbd-layout-viewer.desktop.in:9 359 | msgid "keyboard;input;im" 360 | msgstr "keyboard;input;im;키보드;입력;입력기" 361 | 362 | #: layout/main.cpp:45 363 | #, kde-format 364 | msgid "layout" 365 | msgstr "자판" 366 | 367 | #: layout/main.cpp:48 368 | #, kde-format 369 | msgid "variant" 370 | msgstr "변형" 371 | -------------------------------------------------------------------------------- /po/vi.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # 5 | # Translators: 6 | # csslayer , 2014 7 | # dinhdangkhoi , 2014 8 | # dinhdangkhoi , 2014 9 | # Lê Trường An , 2013 10 | # csslayer , 2014 11 | # csslayer , 2014 12 | msgid "" 13 | msgstr "" 14 | "Project-Id-Version: fcitx\n" 15 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" 16 | "POT-Creation-Date: 2022-06-02 20:30+0000\n" 17 | "PO-Revision-Date: 2011-11-16 06:53+0000\n" 18 | "Last-Translator: csslayer , 2014\n" 19 | "Language-Team: Vietnamese (http://www.transifex.com/fcitx/fcitx/language/" 20 | "vi/)\n" 21 | "Language: vi\n" 22 | "MIME-Version: 1.0\n" 23 | "Content-Type: text/plain; charset=UTF-8\n" 24 | "Content-Transfer-Encoding: 8bit\n" 25 | "Plural-Forms: nplurals=1; plural=0;\n" 26 | 27 | #: src/impage.cpp:84 28 | #, kde-format 29 | msgctxt "%1 is language name, %2 is country name" 30 | msgid "%1 (%2)" 31 | msgstr "" 32 | 33 | #. i18n: file: src/skinpage.ui:41 34 | #. i18n: ectx: property (text), widget (QPushButton, configureSkinButton) 35 | msgid "&Configure Skin" 36 | msgstr "&Cấu hình vỏ ngoài" 37 | 38 | #. i18n: file: src/skinpage.ui:51 39 | #. i18n: ectx: property (text), widget (QPushButton, deleteSkinButton) 40 | msgid "&Delete Skin" 41 | msgstr "&Xóa vỏ ngoài" 42 | 43 | #. i18n: file: src/skinpage.ui:65 44 | #. i18n: ectx: property (text), widget (QLabel, label) 45 | msgid "" 46 | "\n" 48 | "\n" 53 | "

Notice:

\n" 56 | "

You need to use Classic UI " 58 | "to use skin function.

" 59 | msgstr "" 60 | 61 | #. i18n: file: src/impage.ui:292 62 | #. i18n: ectx: property (text), widget (QLabel, label_3) 63 | msgid "Default keyboard layout:" 64 | msgstr "" 65 | 66 | #: src/imconfigdialog.cpp:98 67 | #, kde-format 68 | msgid "Input Method Setting:" 69 | msgstr "" 70 | 71 | #: src/imconfigdialog.cpp:42 72 | #, kde-format 73 | msgid "Keyboard Layout:" 74 | msgstr "" 75 | 76 | #: src/configwidget.cpp:450 77 | #, kde-format 78 | msgid "Other" 79 | msgstr "" 80 | 81 | #. i18n: file: src/impage.ui:302 82 | #. i18n: ectx: property (text), widget (QLabel, label_4) 83 | msgid "Select Input Method:" 84 | msgstr "" 85 | 86 | #: layout/main.cpp:37 87 | #, kde-format 88 | msgid "A general keyboard layout viewer" 89 | msgstr "" 90 | 91 | #: src/module.cpp:129 92 | #, kde-format 93 | msgid "Addon Config" 94 | msgstr "Cấu hình Addon" 95 | 96 | #: src/module.cpp:121 97 | #, kde-format 98 | msgid "Appearance" 99 | msgstr "Dáng vẻ bên ngoài" 100 | 101 | #: src/module.cpp:91 102 | #, kde-format 103 | msgid "Author" 104 | msgstr "" 105 | 106 | #. i18n: file: src/impage.ui:83 107 | #. i18n: ectx: property (text), widget (QLabel, label) 108 | msgid "Available Input Method:" 109 | msgstr "" 110 | 111 | #: src/erroroverlay.cpp:43 112 | #, kde-format 113 | msgid "Cannot connect to Fcitx by DBus, is Fcitx running?" 114 | msgstr "" 115 | 116 | #: src/uipage.cpp:16 117 | #, kde-format 118 | msgid "Cannot load currently used user interface info" 119 | msgstr "" 120 | 121 | #: src/module.cpp:85 122 | #, kde-format 123 | msgid "Configure Fcitx" 124 | msgstr "Cấu hình Fcitx" 125 | 126 | #: src/kcm_fcitx.desktop.in:12 127 | msgid "Configure Input Method" 128 | msgstr "" 129 | 130 | #: src/subconfigwidget.cpp:232 131 | #, kde-format 132 | msgid "Copy" 133 | msgstr "Sao chép" 134 | 135 | #: src/subconfigwidget.cpp:245 136 | #, kde-format 137 | msgid "Copy failed" 138 | msgstr "Sao chép thất bại" 139 | 140 | #: src/module.cpp:87 141 | #, kde-format 142 | msgid "Copyright 2012 Xuetian Weng" 143 | msgstr "Copyright 2012 Xuetian Weng" 144 | 145 | #. i18n: file: src/impage.ui:176 146 | #. i18n: ectx: property (text), widget (QLabel, label_2) 147 | msgid "Current Input Method:" 148 | msgstr "" 149 | 150 | #: src/imconfigdialog.cpp:47 151 | #, kde-format 152 | msgid "Default" 153 | msgstr "Mặc định" 154 | 155 | #: src/module.cpp:83 156 | #, kde-format 157 | msgid "Fcitx Configuration Module" 158 | msgstr "" 159 | 160 | #: src/skinpage.cpp:217 161 | #, kde-format 162 | msgid "First candidate" 163 | msgstr "Ứng cử viên đầu tiên" 164 | 165 | #. i18n: file: src/configpage.ui:14 166 | #. i18n: ectx: property (windowTitle), widget (QWidget, ConfigPage) 167 | #. i18n: file: src/fontbutton.ui:20 168 | #. i18n: ectx: property (windowTitle), widget (QWidget, FontButton) 169 | msgid "Form" 170 | msgstr "Mẫu" 171 | 172 | #: src/module.cpp:113 173 | #, kde-format 174 | msgid "Global Config" 175 | msgstr "Cấu hình chung" 176 | 177 | #: src/module.cpp:104 src/kcm_fcitx.desktop.in:11 178 | #, kde-format 179 | msgid "Input Method" 180 | msgstr "Kiểu gõ" 181 | 182 | #: src/imconfigdialog.cpp:49 183 | #, kde-format 184 | msgid "Input Method Default" 185 | msgstr "" 186 | 187 | #: layout/main.cpp:44 188 | #, kde-format 189 | msgid "Keyboard " 190 | msgstr "" 191 | 192 | #: layout/main.cpp:74 193 | #, kde-format 194 | msgid "Keyboard Layout viewer" 195 | msgstr "" 196 | 197 | #: layout/main.cpp:41 198 | #, kde-format 199 | msgid "Keyboard layout (0-3)" 200 | msgstr "" 201 | 202 | #: layout/main.cpp:47 203 | #, kde-format 204 | msgid "Keyboard layout " 205 | msgstr "" 206 | 207 | #. i18n: file: src/impage.ui:38 208 | #. i18n: ectx: property (toolTip), widget (QPushButton, defaultLayoutButton) 209 | msgid "Keyboard layout to use when no input method active" 210 | msgstr "" 211 | 212 | #: layout/kbd-layout-viewer.desktop.in:6 213 | msgid "Keyboard layout viewer" 214 | msgstr "" 215 | 216 | #: src/module.cpp:178 217 | #, kde-format 218 | msgid "Manage Skin" 219 | msgstr "Quản lý vỏ ngoài" 220 | 221 | #: src/impage.cpp:53 222 | #, kde-format 223 | msgid "Multilingual" 224 | msgstr "Đa ngôn ngữ" 225 | 226 | #: src/uipage.cpp:45 227 | #, kde-format 228 | msgid "No configuration options for %1." 229 | msgstr "" 230 | 231 | #. i18n: file: src/impage.ui:115 232 | #. i18n: ectx: property (text), widget (QCheckBox, onlyCurrentLanguageCheckBox) 233 | msgid "Only &Show Current Language" 234 | msgstr "" 235 | 236 | #. i18n: file: src/configpage.ui:54 237 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 238 | msgid "" 239 | "Options listed here might be overridden by specific input method, usually " 240 | "including candidate number, hotkey of previous page and next page. You may " 241 | "need go to configuration of corresponding input method to change them." 242 | msgstr "" 243 | 244 | #: src/configwidget.cpp:560 src/impage.cpp:69 245 | #, kde-format 246 | msgid "Other" 247 | msgstr "Khác" 248 | 249 | #: src/skinpage.cpp:218 250 | #, kde-format 251 | msgid "Other candidate" 252 | msgstr "Ứng cử viên khác" 253 | 254 | #: src/addonselector.cpp:375 255 | #, kde-format 256 | msgid "Search Addons" 257 | msgstr "Tìm kiếm Addons" 258 | 259 | #: src/impage.cpp:481 260 | #, kde-format 261 | msgid "Search Input Method" 262 | msgstr "" 263 | 264 | #. i18n: file: src/fontbutton.ui:51 265 | #. i18n: ectx: property (text), widget (QPushButton, fontSelectButton) 266 | msgid "Select &Font..." 267 | msgstr "Chọn &Font..." 268 | 269 | #. i18n: file: src/impage.ui:41 270 | #. i18n: ectx: property (text), widget (QPushButton, defaultLayoutButton) 271 | msgid "Select default keyboard layout" 272 | msgstr "" 273 | 274 | #: src/addonselector.cpp:382 src/configwidget.cpp:606 275 | #, kde-format 276 | msgid "Show &Advance option" 277 | msgstr "Hiện tùy c&họn nâng cao" 278 | 279 | #: src/skinpage.cpp:387 280 | #, kde-format 281 | msgid "Skin %1 Cannot be loaded" 282 | msgstr "Vỏ ngoài %1 không thể nạp" 283 | 284 | #. i18n: file: src/impage.ui:277 285 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 286 | msgid "" 287 | "The first input method will be inactive state. Usually you need to put " 288 | "Keyboard or Keyboard - layout name in the first place." 289 | msgstr "" 290 | 291 | #: src/impage.cpp:50 292 | #, kde-format 293 | msgid "Unknown" 294 | msgstr "Không rõ" 295 | 296 | #: src/subconfigwidget.cpp:230 297 | #, kde-format 298 | msgid "" 299 | "User config doesn't exisits, do you want to open system file or copy system " 300 | "file to user file?" 301 | msgstr "" 302 | 303 | #: layout/kbd-layout-viewer.desktop.in:7 304 | msgid "View keyboard layout" 305 | msgstr "" 306 | 307 | #: src/subconfigwidget.cpp:233 308 | #, kde-format 309 | msgid "View system" 310 | msgstr "Xem thông tin hệ thống" 311 | 312 | #: src/subconfigwidget.cpp:231 313 | #, kde-format 314 | msgid "What to do" 315 | msgstr "Phải làm gì" 316 | 317 | #: src/module.cpp:91 318 | #, kde-format 319 | msgid "Xuetian Weng" 320 | msgstr "Xuetian Weng" 321 | 322 | msgctxt "EMAIL OF TRANSLATORS" 323 | msgid "Your emails" 324 | msgstr "dinhdangkhoi.fs@gmail.com" 325 | 326 | msgctxt "NAME OF TRANSLATORS" 327 | msgid "Your names" 328 | msgstr "Đinh Đăng Khôi" 329 | 330 | #: layout/main.cpp:42 331 | #, kde-format 332 | msgid "group" 333 | msgstr "" 334 | 335 | #: src/kcm_fcitx.desktop.in:14 336 | msgid "keyboard,input,im,fcitx" 337 | msgstr "" 338 | 339 | #: layout/kbd-layout-viewer.desktop.in:9 340 | msgid "keyboard;input;im" 341 | msgstr "" 342 | 343 | #: layout/main.cpp:45 344 | #, kde-format 345 | msgid "layout" 346 | msgstr "" 347 | 348 | #: layout/main.cpp:48 349 | #, kde-format 350 | msgid "variant" 351 | msgstr "" 352 | -------------------------------------------------------------------------------- /po/zh_CN.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # 5 | # Translators: 6 | # Christopher Meng , 2012 7 | # csslayer , 2011,2014,2017 8 | # marguerite su , 2014 9 | # Ukyoi , 2011 10 | # csslayer , 2014,2017 11 | # csslayer , 2011 12 | # csslayer , 2010-2013 13 | # wwj402 , 2014 14 | # wwj402 , 2014 15 | # csslayer , 2011,2014 16 | # Xuetian Weng , 2012 17 | msgid "" 18 | msgstr "" 19 | "Project-Id-Version: fcitx\n" 20 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" 21 | "POT-Creation-Date: 2022-06-02 20:30+0000\n" 22 | "PO-Revision-Date: 2011-11-16 06:53+0000\n" 23 | "Last-Translator: Xuetian Weng , 2012\n" 24 | "Language-Team: Chinese (China) (http://www.transifex.com/fcitx/fcitx/" 25 | "language/zh_CN/)\n" 26 | "Language: zh_CN\n" 27 | "MIME-Version: 1.0\n" 28 | "Content-Type: text/plain; charset=UTF-8\n" 29 | "Content-Transfer-Encoding: 8bit\n" 30 | "Plural-Forms: nplurals=1; plural=0;\n" 31 | 32 | #: src/impage.cpp:84 33 | #, kde-format 34 | msgctxt "%1 is language name, %2 is country name" 35 | msgid "%1 (%2)" 36 | msgstr "%1 (%2)" 37 | 38 | #. i18n: file: src/skinpage.ui:41 39 | #. i18n: ectx: property (text), widget (QPushButton, configureSkinButton) 40 | msgid "&Configure Skin" 41 | msgstr "配置皮肤(&C)" 42 | 43 | #. i18n: file: src/skinpage.ui:51 44 | #. i18n: ectx: property (text), widget (QPushButton, deleteSkinButton) 45 | msgid "&Delete Skin" 46 | msgstr "删除皮肤(&D)" 47 | 48 | #. i18n: file: src/skinpage.ui:65 49 | #. i18n: ectx: property (text), widget (QLabel, label) 50 | msgid "" 51 | "\n" 53 | "\n" 58 | "

Notice:

\n" 61 | "

You need to use Classic UI " 63 | "to use skin function.

" 64 | msgstr "" 65 | "\n" 67 | "\n" 72 | "

注意:

\n" 75 | "

您需要使用经典界面才能使用" 77 | "皮肤功能。

" 78 | 79 | #. i18n: file: src/impage.ui:292 80 | #. i18n: ectx: property (text), widget (QLabel, label_3) 81 | msgid "Default keyboard layout:" 82 | msgstr "默认键盘布局:" 83 | 84 | #: src/imconfigdialog.cpp:98 85 | #, kde-format 86 | msgid "Input Method Setting:" 87 | msgstr "输入法设置:" 88 | 89 | #: src/imconfigdialog.cpp:42 90 | #, kde-format 91 | msgid "Keyboard Layout:" 92 | msgstr "键盘布局:" 93 | 94 | #: src/configwidget.cpp:450 95 | #, kde-format 96 | msgid "Other" 97 | msgstr "其它" 98 | 99 | #. i18n: file: src/impage.ui:302 100 | #. i18n: ectx: property (text), widget (QLabel, label_4) 101 | msgid "Select Input Method:" 102 | msgstr "选择输入法:" 103 | 104 | #: layout/main.cpp:37 105 | #, kde-format 106 | msgid "A general keyboard layout viewer" 107 | msgstr "通用键盘布局查看器" 108 | 109 | #: src/module.cpp:129 110 | #, kde-format 111 | msgid "Addon Config" 112 | msgstr "附加组件配置" 113 | 114 | #: src/module.cpp:121 115 | #, kde-format 116 | msgid "Appearance" 117 | msgstr "外观" 118 | 119 | #: src/module.cpp:91 120 | #, kde-format 121 | msgid "Author" 122 | msgstr "作者" 123 | 124 | #. i18n: file: src/impage.ui:83 125 | #. i18n: ectx: property (text), widget (QLabel, label) 126 | msgid "Available Input Method:" 127 | msgstr "可用输入法:" 128 | 129 | #: src/erroroverlay.cpp:43 130 | #, kde-format 131 | msgid "Cannot connect to Fcitx by DBus, is Fcitx running?" 132 | msgstr "无法通过 DBus 连接到 Fcitx,Fcitx 是否正在运行?" 133 | 134 | #: src/uipage.cpp:16 135 | #, kde-format 136 | msgid "Cannot load currently used user interface info" 137 | msgstr "无法加载当前所用用户界面信息" 138 | 139 | #: src/module.cpp:85 140 | #, kde-format 141 | msgid "Configure Fcitx" 142 | msgstr "配置 Fcitx" 143 | 144 | #: src/kcm_fcitx.desktop.in:12 145 | msgid "Configure Input Method" 146 | msgstr "配置输入法" 147 | 148 | #: src/subconfigwidget.cpp:232 149 | #, kde-format 150 | msgid "Copy" 151 | msgstr "复制" 152 | 153 | #: src/subconfigwidget.cpp:245 154 | #, kde-format 155 | msgid "Copy failed" 156 | msgstr "复制失败" 157 | 158 | #: src/module.cpp:87 159 | #, kde-format 160 | msgid "Copyright 2012 Xuetian Weng" 161 | msgstr "Copyright 2012 Xuetian Weng" 162 | 163 | #. i18n: file: src/impage.ui:176 164 | #. i18n: ectx: property (text), widget (QLabel, label_2) 165 | msgid "Current Input Method:" 166 | msgstr "当前输入法:" 167 | 168 | #: src/imconfigdialog.cpp:47 169 | #, kde-format 170 | msgid "Default" 171 | msgstr "默认" 172 | 173 | #: src/module.cpp:83 174 | #, kde-format 175 | msgid "Fcitx Configuration Module" 176 | msgstr "Fcitx 配置模块" 177 | 178 | #: src/skinpage.cpp:217 179 | #, kde-format 180 | msgid "First candidate" 181 | msgstr "第一候选词" 182 | 183 | #. i18n: file: src/configpage.ui:14 184 | #. i18n: ectx: property (windowTitle), widget (QWidget, ConfigPage) 185 | #. i18n: file: src/fontbutton.ui:20 186 | #. i18n: ectx: property (windowTitle), widget (QWidget, FontButton) 187 | msgid "Form" 188 | msgstr "表格" 189 | 190 | #: src/module.cpp:113 191 | #, kde-format 192 | msgid "Global Config" 193 | msgstr "全局配置" 194 | 195 | #: src/module.cpp:104 src/kcm_fcitx.desktop.in:11 196 | #, kde-format 197 | msgid "Input Method" 198 | msgstr "输入法" 199 | 200 | #: src/imconfigdialog.cpp:49 201 | #, kde-format 202 | msgid "Input Method Default" 203 | msgstr "输入法默认" 204 | 205 | #: layout/main.cpp:44 206 | #, kde-format 207 | msgid "Keyboard " 208 | msgstr "键盘 <布局>" 209 | 210 | #: layout/main.cpp:74 211 | #, kde-format 212 | msgid "Keyboard Layout viewer" 213 | msgstr "键盘布局查看器" 214 | 215 | #: layout/main.cpp:41 216 | #, kde-format 217 | msgid "Keyboard layout (0-3)" 218 | msgstr "键盘布局<分组号> (0-3)" 219 | 220 | #: layout/main.cpp:47 221 | #, kde-format 222 | msgid "Keyboard layout " 223 | msgstr "键盘布局<变体>" 224 | 225 | #. i18n: file: src/impage.ui:38 226 | #. i18n: ectx: property (toolTip), widget (QPushButton, defaultLayoutButton) 227 | msgid "Keyboard layout to use when no input method active" 228 | msgstr "无活动输入法时使用的键盘布局" 229 | 230 | #: layout/kbd-layout-viewer.desktop.in:6 231 | msgid "Keyboard layout viewer" 232 | msgstr "键盘布局查看器" 233 | 234 | #: src/module.cpp:178 235 | #, kde-format 236 | msgid "Manage Skin" 237 | msgstr "管理皮肤" 238 | 239 | #: src/impage.cpp:53 240 | #, kde-format 241 | msgid "Multilingual" 242 | msgstr "多语言" 243 | 244 | #: src/uipage.cpp:45 245 | #, kde-format 246 | msgid "No configuration options for %1." 247 | msgstr "%1 无配置选项。" 248 | 249 | #. i18n: file: src/impage.ui:115 250 | #. i18n: ectx: property (text), widget (QCheckBox, onlyCurrentLanguageCheckBox) 251 | msgid "Only &Show Current Language" 252 | msgstr "仅显示当前语言(&S)" 253 | 254 | #. i18n: file: src/configpage.ui:54 255 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 256 | msgid "" 257 | "Options listed here might be overridden by specific input method, usually " 258 | "including candidate number, hotkey of previous page and next page. You may " 259 | "need go to configuration of corresponding input method to change them." 260 | msgstr "" 261 | "这里列出的选项可能是由特定的输入法占用了,通常包括候选编号,上一页和下一页的" 262 | "热键。你可能需要去相应的输入法配置中更改。" 263 | 264 | #: src/configwidget.cpp:560 src/impage.cpp:69 265 | #, kde-format 266 | msgid "Other" 267 | msgstr "其它" 268 | 269 | #: src/skinpage.cpp:218 270 | #, kde-format 271 | msgid "Other candidate" 272 | msgstr "其它候选词" 273 | 274 | #: src/addonselector.cpp:375 275 | #, kde-format 276 | msgid "Search Addons" 277 | msgstr "搜索附加组件" 278 | 279 | #: src/impage.cpp:481 280 | #, kde-format 281 | msgid "Search Input Method" 282 | msgstr "搜索输入法" 283 | 284 | #. i18n: file: src/fontbutton.ui:51 285 | #. i18n: ectx: property (text), widget (QPushButton, fontSelectButton) 286 | msgid "Select &Font..." 287 | msgstr "选择字体(&F)..." 288 | 289 | #. i18n: file: src/impage.ui:41 290 | #. i18n: ectx: property (text), widget (QPushButton, defaultLayoutButton) 291 | msgid "Select default keyboard layout" 292 | msgstr "选择默认键盘布局" 293 | 294 | #: src/addonselector.cpp:382 src/configwidget.cpp:606 295 | #, kde-format 296 | msgid "Show &Advance option" 297 | msgstr "显示高级选项(&A)" 298 | 299 | #: src/skinpage.cpp:387 300 | #, kde-format 301 | msgid "Skin %1 Cannot be loaded" 302 | msgstr "无法加载皮肤 %1" 303 | 304 | #. i18n: file: src/impage.ui:277 305 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 306 | msgid "" 307 | "The first input method will be inactive state. Usually you need to put " 308 | "Keyboard or Keyboard - layout name in the first place." 309 | msgstr "" 310 | "第一个输入法将为非激活状态。通常您需要将键盘键盘 - 布局名称放在第一位。" 312 | 313 | #: src/impage.cpp:50 314 | #, kde-format 315 | msgid "Unknown" 316 | msgstr "未知" 317 | 318 | #: src/subconfigwidget.cpp:230 319 | #, kde-format 320 | msgid "" 321 | "User config doesn't exisits, do you want to open system file or copy system " 322 | "file to user file?" 323 | msgstr "用户配置不存在,您想要打开系统配置还是将系统配置复制为用户配置?" 324 | 325 | #: layout/kbd-layout-viewer.desktop.in:7 326 | msgid "View keyboard layout" 327 | msgstr "查看键盘布局" 328 | 329 | #: src/subconfigwidget.cpp:233 330 | #, kde-format 331 | msgid "View system" 332 | msgstr "查看系統配置" 333 | 334 | #: src/subconfigwidget.cpp:231 335 | #, kde-format 336 | msgid "What to do" 337 | msgstr "操作" 338 | 339 | #: src/module.cpp:91 340 | #, kde-format 341 | msgid "Xuetian Weng" 342 | msgstr "翁学天" 343 | 344 | msgctxt "EMAIL OF TRANSLATORS" 345 | msgid "Your emails" 346 | msgstr "wengxt@gmail.com" 347 | 348 | msgctxt "NAME OF TRANSLATORS" 349 | msgid "Your names" 350 | msgstr "翁学天" 351 | 352 | #: layout/main.cpp:42 353 | #, kde-format 354 | msgid "group" 355 | msgstr "分组" 356 | 357 | #: src/kcm_fcitx.desktop.in:14 358 | msgid "keyboard,input,im,fcitx" 359 | msgstr "keyboard,input,im,fcitx,输入法,小企鹅,键盘,输入" 360 | 361 | #: layout/kbd-layout-viewer.desktop.in:9 362 | msgid "keyboard;input;im" 363 | msgstr "keyboard;input;im;输入法;键盘;输入" 364 | 365 | #: layout/main.cpp:45 366 | #, kde-format 367 | msgid "layout" 368 | msgstr "布局" 369 | 370 | #: layout/main.cpp:48 371 | #, kde-format 372 | msgid "variant" 373 | msgstr "变体" 374 | -------------------------------------------------------------------------------- /po/zh_TW.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # 5 | # Translators: 6 | # Alisha , 2012 7 | # Alisha , 2011-2012 8 | # csslayer , 2014 9 | # PHLin , 2017 10 | # Gerald Du , 2015 11 | # Haowei Hsu , 2023 12 | # 黃柏諺 , 2015,2017 13 | # PHLin , 2017 14 | # csslayer , 2014,2024 15 | # csslayer , 2012-2013 16 | # 如月飛羽 , 2022 17 | # 黃柏諺 , 2015,2017 18 | msgid "" 19 | msgstr "" 20 | "Project-Id-Version: fcitx\n" 21 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" 22 | "POT-Creation-Date: 2024-02-27 20:35+0000\n" 23 | "PO-Revision-Date: 2011-11-16 06:53+0000\n" 24 | "Last-Translator: csslayer , 2014,2024\n" 25 | "Language-Team: Chinese (Taiwan) (http://app.transifex.com/fcitx/fcitx/" 26 | "language/zh_TW/)\n" 27 | "Language: zh_TW\n" 28 | "MIME-Version: 1.0\n" 29 | "Content-Type: text/plain; charset=UTF-8\n" 30 | "Content-Transfer-Encoding: 8bit\n" 31 | "Plural-Forms: nplurals=1; plural=0;\n" 32 | 33 | #: src/impage.cpp:84 34 | #, kde-format 35 | msgctxt "%1 is language name, %2 is country name" 36 | msgid "%1 (%2)" 37 | msgstr "%1 (%2)" 38 | 39 | #. i18n: file: src/skinpage.ui:41 40 | #. i18n: ectx: property (text), widget (QPushButton, configureSkinButton) 41 | msgid "&Configure Skin" 42 | msgstr "設定佈景(&C)" 43 | 44 | #. i18n: file: src/skinpage.ui:51 45 | #. i18n: ectx: property (text), widget (QPushButton, deleteSkinButton) 46 | msgid "&Delete Skin" 47 | msgstr "刪除佈景(&D)" 48 | 49 | #. i18n: file: src/skinpage.ui:65 50 | #. i18n: ectx: property (text), widget (QLabel, label) 51 | msgid "" 52 | "\n" 54 | "\n" 59 | "

Notice:

\n" 62 | "

You need to use Classic UI " 64 | "to use skin function.

" 65 | msgstr "" 66 | "\n" 68 | "\n" 73 | "

注意:

\n" 76 | "

需要經典介面來使用佈景功" 78 | "能。

" 79 | 80 | #. i18n: file: src/impage.ui:292 81 | #. i18n: ectx: property (text), widget (QLabel, label_3) 82 | msgid "Default keyboard layout:" 83 | msgstr "預設鍵盤佈局:" 84 | 85 | #: src/imconfigdialog.cpp:98 86 | #, kde-format 87 | msgid "Input Method Setting:" 88 | msgstr "輸入法設定:" 89 | 90 | #: src/imconfigdialog.cpp:42 91 | #, kde-format 92 | msgid "Keyboard Layout:" 93 | msgstr "鍵盤配置:" 94 | 95 | #: src/configwidget.cpp:450 96 | #, kde-format 97 | msgid "Other" 98 | msgstr "其他" 99 | 100 | #. i18n: file: src/impage.ui:302 101 | #. i18n: ectx: property (text), widget (QLabel, label_4) 102 | msgid "Select Input Method:" 103 | msgstr "選擇輸入法:" 104 | 105 | #: layout/main.cpp:37 106 | #, kde-format 107 | msgid "A general keyboard layout viewer" 108 | msgstr "一般鍵盤配置檢視器" 109 | 110 | #: src/module.cpp:129 111 | #, kde-format 112 | msgid "Addon Config" 113 | msgstr "附加元件設定" 114 | 115 | #: src/module.cpp:121 116 | #, kde-format 117 | msgid "Appearance" 118 | msgstr "外觀" 119 | 120 | #: src/module.cpp:91 121 | #, kde-format 122 | msgid "Author" 123 | msgstr "作者" 124 | 125 | #. i18n: file: src/impage.ui:83 126 | #. i18n: ectx: property (text), widget (QLabel, label) 127 | msgid "Available Input Method:" 128 | msgstr "可用輸入法:" 129 | 130 | #: src/erroroverlay.cpp:43 131 | #, kde-format 132 | msgid "Cannot connect to Fcitx by DBus, is Fcitx running?" 133 | msgstr "無法透過 DBus 連接到 Fcitx,Fcitx 是否正在運行?" 134 | 135 | #: src/uipage.cpp:16 136 | #, kde-format 137 | msgid "Cannot load currently used user interface info" 138 | msgstr "無法載入目前使用的使用者介面資訊" 139 | 140 | #: src/module.cpp:85 141 | #, kde-format 142 | msgid "Configure Fcitx" 143 | msgstr "設定 Fcitx" 144 | 145 | #: src/kcm_fcitx.desktop.in:12 146 | msgid "Configure Input Method" 147 | msgstr "設定輸入法" 148 | 149 | #: src/subconfigwidget.cpp:232 150 | #, kde-format 151 | msgid "Copy" 152 | msgstr "複製" 153 | 154 | #: src/subconfigwidget.cpp:245 155 | #, kde-format 156 | msgid "Copy failed" 157 | msgstr "複製失敗" 158 | 159 | #: src/module.cpp:87 160 | #, kde-format 161 | msgid "Copyright 2012 Xuetian Weng" 162 | msgstr "版權所有 2012 Xuetian Weng" 163 | 164 | #. i18n: file: src/impage.ui:176 165 | #. i18n: ectx: property (text), widget (QLabel, label_2) 166 | msgid "Current Input Method:" 167 | msgstr "目前輸入法:" 168 | 169 | #: src/imconfigdialog.cpp:47 170 | #, kde-format 171 | msgid "Default" 172 | msgstr "預設" 173 | 174 | #: src/module.cpp:83 175 | #, kde-format 176 | msgid "Fcitx Configuration Module" 177 | msgstr "Fcitx 設定模組" 178 | 179 | #: src/skinpage.cpp:217 180 | #, kde-format 181 | msgid "First candidate" 182 | msgstr "第一候選詞" 183 | 184 | #. i18n: file: src/configpage.ui:14 185 | #. i18n: ectx: property (windowTitle), widget (QWidget, ConfigPage) 186 | #. i18n: file: src/fontbutton.ui:20 187 | #. i18n: ectx: property (windowTitle), widget (QWidget, FontButton) 188 | msgid "Form" 189 | msgstr "Form" 190 | 191 | #: src/module.cpp:113 192 | #, kde-format 193 | msgid "Global Config" 194 | msgstr "全域設定" 195 | 196 | #: src/module.cpp:104 src/kcm_fcitx.desktop.in:11 197 | #, kde-format 198 | msgid "Input Method" 199 | msgstr "輸入法" 200 | 201 | #: src/imconfigdialog.cpp:49 202 | #, kde-format 203 | msgid "Input Method Default" 204 | msgstr "輸入法預設" 205 | 206 | #: layout/main.cpp:44 207 | #, kde-format 208 | msgid "Keyboard " 209 | msgstr "鍵盤 " 210 | 211 | #: layout/main.cpp:74 212 | #, kde-format 213 | msgid "Keyboard Layout viewer" 214 | msgstr "鍵盤配置檢視器" 215 | 216 | #: layout/main.cpp:41 217 | #, kde-format 218 | msgid "Keyboard layout (0-3)" 219 | msgstr "鍵盤配置 (0-3)" 220 | 221 | #: layout/main.cpp:47 222 | #, kde-format 223 | msgid "Keyboard layout " 224 | msgstr "鍵盤配置 " 225 | 226 | #. i18n: file: src/impage.ui:38 227 | #. i18n: ectx: property (toolTip), widget (QPushButton, defaultLayoutButton) 228 | msgid "Keyboard layout to use when no input method active" 229 | msgstr "無作用中輸入法時使用的鍵盤佈局" 230 | 231 | #: layout/kbd-layout-viewer.desktop.in:6 232 | msgid "Keyboard layout viewer" 233 | msgstr "鍵盤配置檢視器" 234 | 235 | #: src/module.cpp:178 236 | #, kde-format 237 | msgid "Manage Skin" 238 | msgstr "管理佈景" 239 | 240 | #: src/impage.cpp:53 241 | #, kde-format 242 | msgid "Multilingual" 243 | msgstr "多語言" 244 | 245 | #: src/uipage.cpp:45 246 | #, kde-format 247 | msgid "No configuration options for %1." 248 | msgstr "%1 無配置選項" 249 | 250 | #. i18n: file: src/impage.ui:115 251 | #. i18n: ectx: property (text), widget (QCheckBox, onlyCurrentLanguageCheckBox) 252 | msgid "Only &Show Current Language" 253 | msgstr "只顯示目前語言(&S)" 254 | 255 | #. i18n: file: src/configpage.ui:54 256 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 257 | msgid "" 258 | "Options listed here might be overridden by specific input method, usually " 259 | "including candidate number, hotkey of previous page and next page. You may " 260 | "need go to configuration of corresponding input method to change them." 261 | msgstr "" 262 | "在此列出的選項可能被特定的輸入法覆寫,通常包括候選字數,上一頁和下一頁翻頁" 263 | "鍵。您可能需要到對應輸入法的設定來修改這些選項。" 264 | 265 | #: src/configwidget.cpp:560 src/impage.cpp:69 266 | #, kde-format 267 | msgid "Other" 268 | msgstr "其他" 269 | 270 | #: src/skinpage.cpp:218 271 | #, kde-format 272 | msgid "Other candidate" 273 | msgstr "其他候選詞" 274 | 275 | #: src/addonselector.cpp:375 276 | #, kde-format 277 | msgid "Search Addons" 278 | msgstr "搜尋附加元件" 279 | 280 | #: src/impage.cpp:481 281 | #, kde-format 282 | msgid "Search Input Method" 283 | msgstr "搜尋輸入法" 284 | 285 | #. i18n: file: src/fontbutton.ui:51 286 | #. i18n: ectx: property (text), widget (QPushButton, fontSelectButton) 287 | msgid "Select &Font..." 288 | msgstr "選擇字體(&F)" 289 | 290 | #. i18n: file: src/impage.ui:41 291 | #. i18n: ectx: property (text), widget (QPushButton, defaultLayoutButton) 292 | msgid "Select default keyboard layout" 293 | msgstr "選擇預設鍵盤配置" 294 | 295 | #: src/addonselector.cpp:382 src/configwidget.cpp:606 296 | #, kde-format 297 | msgid "Show &Advance option" 298 | msgstr "顯示進階選項(&A)" 299 | 300 | #: src/skinpage.cpp:387 301 | #, kde-format 302 | msgid "Skin %1 Cannot be loaded" 303 | msgstr "無法載入佈景 %1" 304 | 305 | #. i18n: file: src/impage.ui:277 306 | #. i18n: ectx: property (text), widget (QLabel, infoLabel) 307 | msgid "" 308 | "The first input method will be inactive state. Usually you need to put " 309 | "Keyboard or Keyboard - layout name in the first place." 310 | msgstr "" 311 | "第一個輸入法將作爲非作用中狀態。通常您需要將鍵盤或者鍵盤 - 配置" 312 | "名稱放到第一個。" 313 | 314 | #: src/impage.cpp:50 315 | #, kde-format 316 | msgid "Unknown" 317 | msgstr "未知" 318 | 319 | #: src/subconfigwidget.cpp:230 320 | #, kde-format 321 | msgid "" 322 | "User config doesn't exisits, do you want to open system file or copy system " 323 | "file to user file?" 324 | msgstr "" 325 | "使用者設定不存在,您想要開啟系統設定文件,還是要將系統設定文件複製到使用者設" 326 | "定文件?" 327 | 328 | #: layout/kbd-layout-viewer.desktop.in:7 329 | msgid "View keyboard layout" 330 | msgstr "檢視鍵盤配置" 331 | 332 | #: src/subconfigwidget.cpp:233 333 | #, kde-format 334 | msgid "View system" 335 | msgstr "查看系統" 336 | 337 | #: src/subconfigwidget.cpp:231 338 | #, kde-format 339 | msgid "What to do" 340 | msgstr "要做什麼" 341 | 342 | #: src/module.cpp:91 343 | #, kde-format 344 | msgid "Xuetian Weng" 345 | msgstr "Xuetian Weng" 346 | 347 | msgctxt "EMAIL OF TRANSLATORS" 348 | msgid "Your emails" 349 | msgstr "alisha.4m@gmail.com" 350 | 351 | msgctxt "NAME OF TRANSLATORS" 352 | msgid "Your names" 353 | msgstr "Alisha" 354 | 355 | #: layout/main.cpp:42 356 | #, kde-format 357 | msgid "group" 358 | msgstr "群組" 359 | 360 | #: src/kcm_fcitx.desktop.in:14 361 | msgid "keyboard,input,im,fcitx" 362 | msgstr "keyboard,input,im,fcitx,輸入法,鍵盤,輸入" 363 | 364 | #: layout/kbd-layout-viewer.desktop.in:9 365 | msgid "keyboard;input;im" 366 | msgstr "keyboard;input;im;輸入法;鍵盤;輸入" 367 | 368 | #: layout/main.cpp:45 369 | #, kde-format 370 | msgid "layout" 371 | msgstr "配置" 372 | 373 | #: layout/main.cpp:48 374 | #, kde-format 375 | msgid "variant" 376 | msgstr "變體" 377 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${PROJECT_SOURCE_DIR}/layout) 2 | add_definitions(-DTRANSLATION_DOMAIN=\"kcm_fcitx\") 3 | 4 | set(kcm_SRCS 5 | main.cpp 6 | module.cpp 7 | addonselector.cpp 8 | configwidget.cpp 9 | global.cpp 10 | subconfigparser.cpp 11 | subconfigpattern.cpp 12 | subconfig.cpp 13 | subconfigwidget.cpp 14 | skinpage.cpp 15 | impage.cpp 16 | uipage.cpp 17 | imconfigdialog.cpp 18 | dummyconfig.cpp 19 | verticalscrollarea.cpp 20 | fontbutton.cpp 21 | configpage.cpp 22 | erroroverlay.cpp 23 | ../layout/keyboardlayoutwidget.cpp 24 | ) 25 | 26 | set(kcm_UIS module.ui skinpage.ui impage.ui fontbutton.ui configpage.ui) 27 | fcitx_translate_add_sources(${kcm_SRCS} ${kcm_UIS} kcm_fcitx.desktop.in) 28 | 29 | ki18n_wrap_ui(kcm_SRCS ${kcm_UIS}) 30 | 31 | add_library(kcm_fcitx MODULE ${kcm_SRCS}) 32 | 33 | target_link_libraries(kcm_fcitx 34 | Qt5::Widgets 35 | Qt5::X11Extras 36 | KF5::CoreAddons 37 | KF5::WidgetsAddons 38 | KF5::ConfigWidgets 39 | KF5::ItemViews 40 | KF5::I18n 41 | KF5::KIOCore 42 | KF5::KIOWidgets 43 | FcitxQt5::WidgetsAddons 44 | FcitxQt5::DBusAddons 45 | ${FCITX4_FCITX_UTILS_LIBRARIES} 46 | ${FCITX4_FCITX_CONFIG_LIBRARIES} 47 | ${FCITX4_FCITX_LIBRARIES} 48 | ${LIBINTL_LIBRARY} 49 | ${X11_X11_LIB} ${XKBFILE_LIBRARIES} ${X11_Xkblib_LIB} 50 | ) 51 | 52 | install(TARGETS kcm_fcitx DESTINATION ${CMAKE_INSTALL_PLUGINDIR}) 53 | fcitx_translate_add_apply_source( 54 | kcm_fcitx.desktop.in 55 | "${CMAKE_CURRENT_BINARY_DIR}/kcm_fcitx.desktop") 56 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kcm_fcitx.desktop" 57 | DESTINATION ${CMAKE_INSTALL_KSERVICES5DIR}) 58 | 59 | if(ENABLE_TEST) 60 | add_subdirectory(test) 61 | endif(ENABLE_TEST) 62 | -------------------------------------------------------------------------------- /src/addonselector.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __FCITX_ADDON_SELECTOR_H__ 21 | #define __FCITX_ADDON_SELECTOR_H__ 22 | 23 | // Qt 24 | #include 25 | 26 | struct _FcitxAddon; 27 | 28 | namespace Fcitx 29 | { 30 | 31 | class Module; 32 | 33 | class AddonSelector : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | AddonSelector(Module* parent); 39 | virtual ~AddonSelector(); 40 | void load(); 41 | void save(); 42 | void addAddon(struct _FcitxAddon* fcitxAddon); 43 | 44 | Q_SIGNALS: 45 | void changed(bool hasChanged); 46 | void configCommitted(const QByteArray& componentName); 47 | 48 | private: 49 | 50 | class Private; 51 | Private* d; 52 | Module* parent; 53 | }; 54 | 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/addonselector_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __FCITX_ADDON_SELECTOR_P_H__ 21 | #define __FCITX_ADDON_SELECTOR_P_H__ 22 | 23 | // Qt 24 | #include 25 | #include 26 | #include 27 | 28 | // KDE 29 | #include 30 | #include 31 | 32 | // Fcitx 33 | #include 34 | 35 | // self 36 | #include "addonselector.h" 37 | 38 | class KCategoryDrawer; 39 | 40 | class KCategorizedView; 41 | 42 | class QPushButton; 43 | 44 | class QCheckBox; 45 | 46 | namespace Fcitx 47 | { 48 | 49 | class AddonSelector::Private 50 | : public QObject 51 | { 52 | Q_OBJECT 53 | 54 | public: 55 | enum ExtraRoles { 56 | CommentRole = 0x19880209, 57 | ConfigurableRole = 0x20080331 58 | }; 59 | Private(AddonSelector* parent); 60 | virtual ~Private(); 61 | int dependantLayoutValue(int value, int width, int totalWidth) const; 62 | 63 | public: 64 | 65 | class AddonModel; 66 | 67 | class ProxyModel; 68 | 69 | class AddonDelegate; 70 | QLineEdit* lineEdit; 71 | KCategorizedView* listView; 72 | KCategoryDrawer *categoryDrawer; 73 | AddonModel *addonModel; 74 | ProxyModel *proxyModel; 75 | AddonDelegate *addonDelegate; 76 | QCheckBox* advanceCheckbox; 77 | 78 | private: 79 | AddonSelector* parent; 80 | }; 81 | 82 | class AddonSelector::Private::AddonModel : public QAbstractListModel 83 | { 84 | Q_OBJECT 85 | 86 | public: 87 | AddonModel(AddonSelector::Private *addonSelector_d, QObject* parent = 0); 88 | virtual ~AddonModel(); 89 | 90 | QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override; 91 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 92 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; 93 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; 94 | void addAddon(FcitxAddon* addon); 95 | 96 | private: 97 | QList addonEntryList; 98 | AddonSelector::Private *addonSelector_d; 99 | }; 100 | 101 | class AddonSelector::Private::ProxyModel 102 | : public KCategorizedSortFilterProxyModel 103 | { 104 | Q_OBJECT 105 | 106 | public: 107 | ProxyModel(AddonSelector::Private *addonSelector_d, QObject* parent = 0); 108 | virtual ~ProxyModel(); 109 | 110 | protected: 111 | bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; 112 | bool subSortLessThan(const QModelIndex& left, const QModelIndex& right) const override; 113 | 114 | private: 115 | AddonSelector::Private* addonSelector_d; 116 | }; 117 | 118 | class AddonSelector::Private::AddonDelegate 119 | : public KWidgetItemDelegate 120 | { 121 | Q_OBJECT 122 | 123 | public: 124 | AddonDelegate(AddonSelector::Private *addonSelector_d, QObject* parent = 0); 125 | virtual ~AddonDelegate(); 126 | 127 | void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 128 | QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; 129 | 130 | Q_SIGNALS: 131 | void changed(bool hasChanged); 132 | void configCommitted(const QByteArray& addonName); 133 | 134 | protected: 135 | QList< QWidget* > createItemWidgets(const QModelIndex &index) const override; 136 | void updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const override; 137 | 138 | private Q_SLOTS: 139 | void slotStateChanged(bool state); 140 | void emitChanged(); 141 | void slotConfigureClicked(); 142 | 143 | private: 144 | QFont titleFont(const QFont &baseFont) const; 145 | 146 | QCheckBox *checkBox; 147 | QPushButton *pushButton; 148 | QList moduleProxyList; 149 | AddonSelector::Private* addonSelector_d; 150 | }; 151 | 152 | } 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /src/configpage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2013~2013 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include "configpage.h" 21 | #include "global.h" 22 | #include "configwidget.h" 23 | #include "ui_configpage.h" 24 | 25 | namespace Fcitx { 26 | 27 | ConfigPage::ConfigPage(QWidget* parent): QWidget(parent) 28 | ,m_ui(new Ui::ConfigPage) 29 | { 30 | m_ui->setupUi(this); 31 | FcitxConfigFileDesc* configDesc = Global::instance()->GetConfigDesc("config.desc"); 32 | m_configWidget = new ConfigWidget(configDesc, "", "config", QString(), "global"); 33 | m_ui->layout->insertWidget(0, m_configWidget); 34 | // m_ui->infoIconLabel->setPixmap(KIcon("dialog-information").pixmap(KIconLoader::SizeSmallMedium)); 35 | 36 | connect(m_configWidget, SIGNAL(changed()), this, SIGNAL(changed())); 37 | } 38 | 39 | ConfigPage::~ConfigPage() 40 | { 41 | delete m_ui; 42 | } 43 | 44 | void ConfigPage::load() 45 | { 46 | m_configWidget->load(); 47 | } 48 | 49 | void ConfigPage::save() 50 | { 51 | m_configWidget->buttonClicked(QDialogButtonBox::Ok); 52 | } 53 | 54 | void ConfigPage::defaults() 55 | { 56 | m_configWidget->buttonClicked(QDialogButtonBox::RestoreDefaults); 57 | } 58 | 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/configpage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2013~2013 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef CONFIGPAGE_H 21 | #define CONFIGPAGE_H 22 | #include 23 | 24 | namespace Ui { 25 | class ConfigPage; 26 | } 27 | 28 | namespace Fcitx { 29 | 30 | class ConfigWidget; 31 | 32 | class ConfigPage : public QWidget { 33 | Q_OBJECT 34 | public: 35 | explicit ConfigPage(QWidget* parent = 0); 36 | virtual ~ConfigPage(); 37 | void load(); 38 | void save(); 39 | void defaults(); 40 | signals: 41 | void changed(); 42 | private: 43 | Ui::ConfigPage* m_ui; 44 | ConfigWidget* m_configWidget; 45 | }; 46 | 47 | } 48 | 49 | #endif // CONFIGPAGE_H 50 | -------------------------------------------------------------------------------- /src/configpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ConfigPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 659 10 | 405 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | Qt::Horizontal 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 0 31 | 0 32 | 33 | 34 | 35 | 36 | 22 37 | 22 38 | 39 | 40 | 41 | 42 | 22 43 | 22 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Options listed here might be overridden by specific input method, usually including candidate number, hotkey of previous page and next page. You may need go to configuration of corresponding input method to change them. 55 | 56 | 57 | true 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/configwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITXCONFIGPAGE_H 21 | #define FCITXCONFIGPAGE_H 22 | 23 | // Qt 24 | #include 25 | 26 | // KDE 27 | #include 28 | #include 29 | #include 30 | 31 | // Fcitx 32 | #include 33 | #include 34 | #include 35 | 36 | class QCheckBox; 37 | class QVBoxLayout; 38 | class QStandardItemModel; 39 | struct _FcitxConfigFileDesc; 40 | 41 | class QTabWidget; 42 | 43 | namespace Fcitx 44 | { 45 | 46 | class DummyConfig; 47 | 48 | class Global; 49 | 50 | class SubConfigParser; 51 | 52 | 53 | class ColorButton : public KColorButton { 54 | Q_OBJECT 55 | public: 56 | explicit ColorButton(QWidget* parent = 0) : KColorButton(parent) { } 57 | public slots: 58 | void setColor(const QColor& color) { 59 | KColorButton::setColor(color); 60 | } 61 | }; 62 | 63 | class ConfigWidget : public QWidget 64 | { 65 | Q_OBJECT 66 | 67 | enum UIType { 68 | CW_Simple = 0x1, 69 | CW_Full = 0x2, 70 | CW_NoShow = 0x0 71 | }; 72 | 73 | public: 74 | explicit ConfigWidget(struct _FcitxConfigFileDesc* cfdesc, const QString& prefix, const QString& name, const QString& subconfig = QString(), const QString& addonName = QString(), QWidget* parent = NULL); 75 | explicit ConfigWidget(FcitxAddon* addonEntry, QWidget* parent = 0); 76 | virtual ~ConfigWidget(); 77 | 78 | static QDialog* configDialog(QWidget* parent, _FcitxConfigFileDesc* cfdesc, const QString& prefix, const QString& name, const QString& subconfig = QString(), const QString& addonName = QString()); 79 | static QDialog* configDialog(QWidget* parent, FcitxAddon* addonEntry); 80 | 81 | DummyConfig* config() { return m_config; } 82 | 83 | Q_SIGNALS: 84 | void changed(); 85 | 86 | public Q_SLOTS: 87 | void buttonClicked(QDialogButtonBox::StandardButton); 88 | void load(); 89 | private Q_SLOTS: 90 | void toggleSimpleFull(); 91 | private: 92 | QWidget* createFullConfigUi(); 93 | QWidget* createSimpleConfigUi(bool skinAdvance); 94 | void setupConfigUi(); 95 | void createConfigOptionWidget(FcitxConfigGroupDesc* cgdesc, FcitxConfigOptionDesc* codesc, QString& label, QString& tooltip, QWidget*& inputWidget, void*& newarg); 96 | void checkCanUseSimple(); 97 | 98 | struct _FcitxConfigFileDesc* m_cfdesc; 99 | QString m_prefix; 100 | QString m_name; 101 | QString m_addonName; 102 | QVBoxLayout* m_switchLayout; 103 | QWidget* m_simpleWidget; 104 | QWidget* m_fullWidget; 105 | QCheckBox* m_advanceCheckBox; 106 | DummyConfig* m_config; 107 | SubConfigParser* m_parser; 108 | UIType m_simpleUiType; 109 | UIType m_fullUiType; 110 | QMap m_argMap; 111 | }; 112 | 113 | } 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /src/dummyconfig.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "dummyconfig.h" 25 | 26 | namespace Fcitx { 27 | 28 | DummyConfig::DummyConfig(FcitxConfigFileDesc* cfdesc) : 29 | m_cfdesc(cfdesc), 30 | m_cfile(NULL) 31 | { 32 | m_config.configFile = NULL; 33 | /* malloc necessary value */ 34 | HASH_FOREACH(cgdesc, m_cfdesc->groupsDesc, FcitxConfigGroupDesc) { 35 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { 36 | QString name("%1/%2"); 37 | name = name.arg(cgdesc->groupName, codesc->optionName); 38 | if (m_dummyValue.contains(name)) 39 | continue; 40 | void* value = NULL; 41 | switch (codesc->type) 42 | { 43 | #define OPTION_TYPE_CASE(NAME, TYPE) \ 44 | case T_##NAME: \ 45 | value = fcitx_utils_new(TYPE); \ 46 | break; 47 | OPTION_TYPE_CASE(Integer, int); 48 | OPTION_TYPE_CASE(Boolean, boolean); 49 | OPTION_TYPE_CASE(Char, char); 50 | OPTION_TYPE_CASE(Color, FcitxConfigColor); 51 | OPTION_TYPE_CASE(Enum, int); 52 | OPTION_TYPE_CASE(File, char*); 53 | OPTION_TYPE_CASE(Font, char*); 54 | OPTION_TYPE_CASE(Hotkey, FcitxHotkeys); 55 | OPTION_TYPE_CASE(String, char*); 56 | OPTION_TYPE_CASE(I18NString, char*); 57 | default: 58 | break; 59 | } 60 | if (value) 61 | m_dummyValue[name] = value; 62 | } 63 | } 64 | } 65 | 66 | DummyConfig::~DummyConfig() 67 | { 68 | FcitxConfigFree(&m_config); 69 | foreach(void* value, m_dummyValue) 70 | { 71 | free(value); 72 | } 73 | } 74 | 75 | FcitxGenericConfig* DummyConfig::genericConfig() 76 | { 77 | return &m_config; 78 | } 79 | 80 | void DummyConfig::load(FILE* fp) 81 | { 82 | if (!m_config.configFile) { 83 | m_config.configFile = FcitxConfigParseConfigFileFp(fp, m_cfdesc); 84 | 85 | HASH_FOREACH(cgdesc, m_cfdesc->groupsDesc, FcitxConfigGroupDesc) { 86 | HASH_FOREACH(codesc, cgdesc->optionsDesc, FcitxConfigOptionDesc) { 87 | QString name("%1/%2"); 88 | name = name.arg(cgdesc->groupName, codesc->optionName); 89 | if (!m_dummyValue.contains(name)) 90 | continue; 91 | // assert(m_dummyValue[name]); 92 | FcitxConfigBindValue(m_config.configFile, cgdesc->groupName, codesc->optionName, m_dummyValue[name], NULL, NULL); 93 | } 94 | } 95 | } 96 | else { 97 | m_config.configFile = FcitxConfigParseIniFp(fp, m_config.configFile); 98 | } 99 | } 100 | 101 | void DummyConfig::bind(char* group, char* option, FcitxSyncFilter filter, void* arg) 102 | { 103 | if (!m_config.configFile) 104 | return; 105 | QString name("%1/%2"); 106 | name = name.arg(group, option); 107 | 108 | if (!m_dummyValue.contains(name)) 109 | return; 110 | 111 | // assert(m_dummyValue[name]); 112 | FcitxConfigBindValue(m_config.configFile, group, option, m_dummyValue[name], filter, arg); 113 | } 114 | 115 | bool DummyConfig::isValid() 116 | { 117 | return (m_config.configFile != NULL); 118 | } 119 | 120 | void DummyConfig::sync() 121 | { 122 | FcitxConfigBindSync(&m_config); 123 | } 124 | 125 | 126 | 127 | 128 | } -------------------------------------------------------------------------------- /src/dummyconfig.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef DUMMYCONFIG_H 21 | #define DUMMYCONFIG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Fcitx { 29 | 30 | class DummyConfig 31 | { 32 | public: 33 | DummyConfig(FcitxConfigFileDesc* cfdesc); 34 | ~DummyConfig(); 35 | 36 | FcitxGenericConfig* genericConfig(); 37 | void load(FILE* fp); 38 | void bind(char* group, char* option, FcitxSyncFilter filter = NULL, void* arg = NULL); 39 | bool isValid(); 40 | void sync(); 41 | private: 42 | QMap m_dummyValue; 43 | FcitxConfigFileDesc* m_cfdesc; 44 | FcitxConfigFile* m_cfile; 45 | FcitxGenericConfig m_config; 46 | }; 47 | 48 | } 49 | 50 | #endif // DUMMYCONFIG_H -------------------------------------------------------------------------------- /src/erroroverlay.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011 by Dario Freddi * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | ***************************************************************************/ 19 | 20 | #include "erroroverlay.h" 21 | #include "global.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | ErrorOverlay::ErrorOverlay(QWidget *baseWidget, QWidget *parent) : 31 | QWidget(parent ? parent : baseWidget->window()), 32 | m_BaseWidget(baseWidget), 33 | m_enable(false) 34 | { 35 | setVisible(false); 36 | // Build the UI 37 | QVBoxLayout *layout = new QVBoxLayout; 38 | layout->setSpacing(10); 39 | 40 | QLabel *pixmap = new QLabel(); 41 | pixmap->setPixmap(QIcon::fromTheme("dialog-error").pixmap(64)); 42 | 43 | QLabel *message = new QLabel(i18n("Cannot connect to Fcitx by DBus, is Fcitx running?")); 44 | 45 | pixmap->setAlignment(Qt::AlignHCenter); 46 | message->setAlignment(Qt::AlignHCenter); 47 | 48 | layout->addStretch(); 49 | layout->addWidget(pixmap); 50 | layout->addWidget(message); 51 | layout->addStretch(); 52 | 53 | setLayout(layout); 54 | 55 | // Draw the transparent overlay background 56 | QPalette p = palette(); 57 | p.setColor(backgroundRole(), QColor(0, 0, 0, 128)); 58 | p.setColor(foregroundRole(), Qt::white); 59 | setPalette(p); 60 | setAutoFillBackground(true); 61 | 62 | m_BaseWidget->installEventFilter(this); 63 | // Destory overlay with the base widget. 64 | connect(m_BaseWidget, SIGNAL(destroyed()), this, SLOT(deleteLater())); 65 | connect(Fcitx::Global::instance(), SIGNAL(connectStatusChanged(bool)), this, SLOT(onConnectStatusChanged(bool))); 66 | onConnectStatusChanged(Fcitx::Global::instance()->inputMethodProxy() != 0); 67 | } 68 | 69 | ErrorOverlay::~ErrorOverlay() 70 | { 71 | } 72 | 73 | void ErrorOverlay::onConnectStatusChanged(bool connected) 74 | { 75 | if (m_enable != !connected) { 76 | m_enable = !connected; 77 | setVisible(!connected); 78 | if (!connected) 79 | reposition(); 80 | } 81 | } 82 | 83 | void ErrorOverlay::reposition() 84 | { 85 | if (!m_BaseWidget) { 86 | return; 87 | } 88 | 89 | // reparent to the current top level widget of the base widget if needed 90 | // needed eg. in dock widgets 91 | if (parentWidget() != m_BaseWidget->window()) { 92 | setParent(m_BaseWidget->window()); 93 | } 94 | 95 | // follow base widget visibility 96 | // needed eg. in tab widgets 97 | if (!m_BaseWidget->isVisible()) { 98 | hide(); 99 | return; 100 | } 101 | 102 | show(); 103 | 104 | // follow position changes 105 | const QPoint topLevelPos = m_BaseWidget->mapTo(window(), QPoint(0, 0)); 106 | const QPoint parentPos = parentWidget()->mapFrom(window(), topLevelPos); 107 | move(parentPos); 108 | 109 | // follow size changes 110 | // TODO: hide/scale icon if we don't have enough space 111 | resize(m_BaseWidget->size()); 112 | } 113 | 114 | bool ErrorOverlay::eventFilter(QObject * object, QEvent * event) 115 | { 116 | if (m_enable && object == m_BaseWidget && 117 | (event->type() == QEvent::Move || event->type() == QEvent::Resize || 118 | event->type() == QEvent::Show || event->type() == QEvent::Hide || 119 | event->type() == QEvent::ParentChange)) { 120 | reposition(); 121 | } 122 | return QWidget::eventFilter(object, event); 123 | } 124 | -------------------------------------------------------------------------------- /src/erroroverlay.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011 by Dario Freddi * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | ***************************************************************************/ 19 | 20 | #ifndef ERROROVERLAY_H 21 | #define ERROROVERLAY_H 22 | 23 | #include 24 | #include 25 | 26 | class ErrorOverlay : public QWidget 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit ErrorOverlay(QWidget *baseWidget, QWidget *parent = 0); 31 | virtual ~ErrorOverlay(); 32 | public slots: 33 | void onConnectStatusChanged(bool connected); 34 | 35 | protected: 36 | bool eventFilter(QObject *object, QEvent *event) override; 37 | 38 | private: 39 | void reposition(); 40 | 41 | private: 42 | QPointer m_BaseWidget; 43 | bool m_enable; 44 | }; 45 | 46 | #endif // ERROROVERLAY_H 47 | -------------------------------------------------------------------------------- /src/fcitx-skin.knsrc: -------------------------------------------------------------------------------- 1 | [KNewStuff3] 2 | Categories=Fcitx Theme 3 | InstallPath=.config/fcitx/skin 4 | Uncompress=archive 5 | -------------------------------------------------------------------------------- /src/fontbutton.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "fontbutton.h" 26 | #include "ui_fontbutton.h" 27 | 28 | FontButton::FontButton(QWidget* parent): QWidget(parent) 29 | ,m_ui(new Ui::FontButton) 30 | { 31 | m_ui->setupUi(this); 32 | connect(m_ui->fontSelectButton, SIGNAL(clicked(bool)), this, SLOT(selectFont())); 33 | } 34 | 35 | FontButton::~FontButton() 36 | { 37 | delete m_ui; 38 | } 39 | 40 | const QFont& FontButton::font() 41 | { 42 | return m_font; 43 | } 44 | 45 | QString FontButton::fontName() 46 | { 47 | return m_ui->fontPreviewLabel->text(); 48 | } 49 | 50 | QFont FontButton::parseFont(const QString& string) 51 | { 52 | QStringList list = string.split(" ", QString::SkipEmptyParts); 53 | bool bold = false; 54 | bool italic = false; 55 | while(!list.empty()) { 56 | if (list.last() == "Bold") { 57 | bold = true; 58 | list.pop_back(); 59 | } 60 | else if (list.last() == "Italic") { 61 | italic = true; 62 | list.pop_back(); 63 | } 64 | else 65 | break; 66 | } 67 | QString family = list.join(" "); 68 | QFont font; 69 | font.setFamily(family); 70 | font.setBold(bold); 71 | font.setItalic(italic); 72 | return font; 73 | } 74 | 75 | void FontButton::setFont(const QFont& font) 76 | { 77 | m_font = font; 78 | QString style; 79 | #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) 80 | if (!font.styleName().isEmpty()) { 81 | style = font.styleName(); 82 | } 83 | else 84 | #endif 85 | { 86 | QStringList styles; 87 | if (font.bold()) 88 | styles << "Bold"; 89 | if (font.italic()) 90 | styles << "Italic"; 91 | style = styles.join(" "); 92 | } 93 | m_ui->fontPreviewLabel->setText(QString("%1 %2").arg(m_font.family(), style)); 94 | m_ui->fontPreviewLabel->setFont(m_font); 95 | if (font.family() != m_font.family()) { 96 | emit fontChanged(m_font); 97 | } 98 | } 99 | 100 | void FontButton::selectFont() 101 | { 102 | QDialog dialog(NULL); 103 | KFontChooser* chooser = new KFontChooser(&dialog); 104 | chooser->enableColumn(KFontChooser::SizeList, false); 105 | chooser->setFont(m_font); 106 | QVBoxLayout* dialogLayout = new QVBoxLayout; 107 | dialog.setLayout(dialogLayout); 108 | QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); 109 | dialogLayout->addWidget(chooser); 110 | dialogLayout->addWidget(buttonBox); 111 | connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); 112 | connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); 113 | 114 | if (dialog.exec() == QDialog::Accepted) { 115 | setFont(chooser->font()); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/fontbutton.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FONTBUTTON_H 21 | #define FONTBUTTON_H 22 | 23 | #include 24 | 25 | namespace Ui { 26 | class FontButton; 27 | }; 28 | 29 | class FontButton : public QWidget { 30 | Q_OBJECT 31 | public: 32 | explicit FontButton(QWidget* parent = 0); 33 | virtual ~FontButton(); 34 | const QFont& font(); 35 | QString fontName(); 36 | static QFont parseFont(const QString& string); 37 | 38 | public slots: 39 | void setFont(const QFont& font); 40 | signals: 41 | void fontChanged(const QFont& font); 42 | private slots: 43 | void selectFont(); 44 | private: 45 | Ui::FontButton* m_ui; 46 | QFont m_font; 47 | }; 48 | 49 | #endif // FONTBUTTON_H -------------------------------------------------------------------------------- /src/fontbutton.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FontButton 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 186 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 28 | 29 | 30 | 0 31 | 0 32 | 33 | 34 | 35 | QFrame::StyledPanel 36 | 37 | 38 | QFrame::Sunken 39 | 40 | 41 | 42 | 43 | 44 | Qt::AlignCenter 45 | 46 | 47 | 48 | 49 | 50 | 51 | Select &Font... 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/global.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | // Fcitx 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | // self 27 | #include "global.h" 28 | 29 | 30 | namespace Fcitx 31 | { 32 | Global* Global::inst = NULL; 33 | 34 | Global* Global::instance() 35 | { 36 | if (!inst) 37 | inst = new Global; 38 | return inst; 39 | } 40 | 41 | void Global::deInit() 42 | { 43 | if (inst) { 44 | inst->deleteLater(); 45 | inst = 0; 46 | } 47 | } 48 | 49 | Global::Global() : 50 | m_hash(new QHash), 51 | m_connection(new FcitxQtConnection(this)), 52 | m_inputmethod(0), 53 | m_keyboard(0) 54 | { 55 | connect(m_connection, SIGNAL(connected()), this, SLOT(connected())); 56 | connect(m_connection, SIGNAL(disconnected()), this, SLOT(disconnected())); 57 | 58 | m_connection->startConnection(); 59 | } 60 | 61 | Global::~Global() 62 | { 63 | QHash::iterator iter; 64 | 65 | for (iter = m_hash->begin(); 66 | iter != m_hash->end(); 67 | iter ++) { 68 | FcitxConfigFreeConfigFileDesc(iter.value()); 69 | } 70 | 71 | delete m_hash; 72 | } 73 | 74 | void Global::connected() 75 | { 76 | if (m_inputmethod) 77 | delete m_inputmethod; 78 | 79 | if (m_keyboard) 80 | delete m_keyboard; 81 | 82 | m_inputmethod = new FcitxQtInputMethodProxy( 83 | m_connection->serviceName(), 84 | "/inputmethod", 85 | *m_connection->connection(), 86 | this 87 | ); 88 | 89 | m_keyboard = new FcitxQtKeyboardProxy( 90 | m_connection->serviceName(), 91 | "/keyboard", 92 | *m_connection->connection(), 93 | this 94 | ); 95 | 96 | #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) 97 | m_inputmethod->setTimeout(3000); 98 | m_keyboard->setTimeout(3000); 99 | #endif 100 | 101 | emit connectStatusChanged(true); 102 | } 103 | 104 | void Global::disconnected() 105 | { 106 | if (m_inputmethod) 107 | delete m_inputmethod; 108 | m_inputmethod = 0; 109 | if (m_keyboard) 110 | delete m_keyboard; 111 | m_keyboard = 0; 112 | 113 | emit connectStatusChanged(false); 114 | } 115 | 116 | FcitxConfigFileDesc* Global::GetConfigDesc(const QString& name) 117 | { 118 | if (m_hash->count(name) <= 0) { 119 | FILE* fp = FcitxXDGGetFileWithPrefix("configdesc", name.toLatin1().constData(), "r", NULL); 120 | FcitxConfigFileDesc* cfdesc = FcitxConfigParseConfigFileDescFp(fp); 121 | 122 | if (cfdesc) 123 | m_hash->insert(name, cfdesc); 124 | 125 | return cfdesc; 126 | } else 127 | return (*m_hash) [name]; 128 | } 129 | 130 | QString Global::testWrapper(const QString &path) const { 131 | char* qtguiwrapper[] = { 132 | fcitx_utils_get_fcitx_path_with_filename ("libdir", "fcitx/libexec/fcitx-qt5-gui-wrapper"), 133 | fcitx_utils_get_fcitx_path_with_filename ("libdir", "fcitx/libexec/fcitx-qt-gui-wrapper") 134 | }; 135 | QString wrapper; 136 | for (int i = 0; i < FCITX_ARRAY_SIZE(qtguiwrapper); i++) { 137 | if (qtguiwrapper[i]) { 138 | QStringList args; 139 | args << QLatin1String("--test"); 140 | args << path; 141 | int exit_status =QProcess::execute(QString::fromLocal8Bit(qtguiwrapper[i]), args); 142 | if (exit_status == 0) { 143 | wrapper = QString::fromLatin1(qtguiwrapper[i]); 144 | break; 145 | } 146 | } 147 | } 148 | 149 | return wrapper; 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/global.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef KCM_FCITX_GLOBAL_H 21 | #define KCM_FCITX_GLOBAL_H 22 | 23 | // Qt 24 | #include 25 | 26 | // Fcitx 27 | #include 28 | #include 29 | #include 30 | 31 | class FcitxQtKeyboardProxy; 32 | class FcitxQtInputMethodProxy; 33 | class FcitxQtConnection; 34 | namespace Fcitx 35 | { 36 | 37 | class Global : public QObject 38 | { 39 | Q_OBJECT 40 | public: 41 | static Global* instance(); 42 | static void deInit(); 43 | virtual ~Global(); 44 | FcitxConfigFileDesc* GetConfigDesc(const QString& name); 45 | FcitxQtConnection* connection() { return m_connection; } 46 | FcitxQtInputMethodProxy* inputMethodProxy() { return (m_inputmethod && m_inputmethod->isValid()) ? m_inputmethod : 0; } 47 | FcitxQtKeyboardProxy* keyboardProxy() { return (m_keyboard && m_keyboard->isValid()) ? m_keyboard : 0; } 48 | QString testWrapper(const QString &path) const; 49 | 50 | signals: 51 | void connectStatusChanged(bool connected); 52 | 53 | private slots: 54 | void connected(); 55 | void disconnected(); 56 | 57 | private: 58 | Global(); 59 | QHash* m_hash; 60 | FcitxQtConnection* m_connection; 61 | FcitxQtInputMethodProxy* m_inputmethod; 62 | FcitxQtKeyboardProxy* m_keyboard; 63 | static Global* inst; 64 | }; 65 | 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/imconfigdialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "imconfigdialog.h" 14 | #include "global.h" 15 | #include "configwidget.h" 16 | #include "keyboardlayoutwidget.h" 17 | 18 | Fcitx::IMConfigDialog::IMConfigDialog(const QString& imName, const FcitxAddon* addon, QWidget* parent): QDialog(parent) 19 | ,m_imName(imName) 20 | ,m_layoutCombobox(0) 21 | ,m_configPage(0) 22 | ,m_layoutWidget(nullptr) 23 | { 24 | QWidget* widget = new QWidget(this); 25 | QVBoxLayout* l = new QVBoxLayout(this); 26 | widget->setLayout(l); 27 | 28 | if (!imName.startsWith("fcitx-keyboard") && Global::instance()->keyboardProxy()) { 29 | QDBusPendingReply< FcitxQtKeyboardLayoutList > layoutList = Global::instance()->keyboardProxy()->GetLayouts(); 30 | layoutList.waitForFinished(); 31 | 32 | if (!layoutList.isError()) { 33 | m_layoutList = layoutList.value(); 34 | m_layoutCombobox = new QComboBox(this); 35 | 36 | QDBusPendingReply< QString, QString > res = Global::instance()->keyboardProxy()->GetLayoutForIM(imName); 37 | res.waitForFinished(); 38 | QString imLayout = qdbus_cast(res.argumentAt(0)); 39 | QString imVariant = qdbus_cast(res.argumentAt(1)); 40 | 41 | QLabel* label; 42 | label = new QLabel(i18n("Keyboard Layout:")); 43 | 44 | int idx = 1; 45 | int select = 0; 46 | if (imName == "default") 47 | m_layoutCombobox->addItem(i18n("Default")); 48 | else 49 | m_layoutCombobox->addItem(i18n("Input Method Default")); 50 | 51 | foreach (const FcitxQtKeyboardLayout& layout, layoutList.value()) { 52 | if (imLayout == layout.layout() && imVariant == layout.variant()) 53 | select = idx; 54 | m_layoutCombobox->addItem(layout.name()); 55 | idx ++; 56 | } 57 | m_layoutCombobox->setCurrentIndex(select); 58 | 59 | l->addWidget(label); 60 | l->addWidget(m_layoutCombobox); 61 | connect(m_layoutCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutComboBoxChanged())); 62 | if (QX11Info::isPlatformX11()) { 63 | m_layoutWidget = new KeyboardLayoutWidget(this); 64 | m_layoutWidget->setMinimumSize(QSize(400, 200)); 65 | m_layoutWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 66 | l->addWidget(m_layoutWidget); 67 | } 68 | layoutComboBoxChanged(); 69 | } 70 | } 71 | else { 72 | if (QX11Info::isPlatformX11()) { 73 | KeyboardLayoutWidget* layoutWidget = new KeyboardLayoutWidget(this); 74 | layoutWidget->setMinimumSize(QSize(400, 200)); 75 | layoutWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 76 | QString layoutstring = imName.mid(strlen("fcitx-keyboard-")); 77 | int p = layoutstring.indexOf("-"); 78 | QString layout, variant; 79 | if (p < 0) { 80 | layout = layoutstring; 81 | } 82 | else { 83 | layout = layoutstring.mid(0, p); 84 | variant = layoutstring.mid(p + 1); 85 | } 86 | layoutWidget->setKeyboardLayout(layout, variant); 87 | l->addWidget(layoutWidget); 88 | } 89 | } 90 | 91 | FcitxConfigFileDesc* cfdesc = NULL; 92 | 93 | if (addon) { 94 | cfdesc = Global::instance()->GetConfigDesc(QString::fromUtf8(addon->name).append(".desc")); 95 | 96 | if (cfdesc || strlen(addon->subconfig) != 0) { 97 | if (m_layoutCombobox) { 98 | QLabel* label = new QLabel(i18n("Input Method Setting:")); 99 | label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); 100 | l->addWidget(label); 101 | } 102 | m_configPage = new ConfigWidget( 103 | cfdesc, 104 | QString::fromUtf8("conf"), 105 | QString::fromUtf8(addon->name).append(".config") , 106 | QString::fromUtf8(addon->subconfig), 107 | QString::fromUtf8(addon->name), 108 | this 109 | ); 110 | l->addWidget(m_configPage); 111 | } 112 | } 113 | setWindowIcon(QIcon::fromTheme("fcitx")); 114 | auto dialogLayout = new QVBoxLayout; 115 | setLayout(dialogLayout); 116 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); 117 | dialogLayout->addWidget(widget); 118 | dialogLayout->addWidget(buttonBox); 119 | connect(buttonBox, &QDialogButtonBox::clicked, this, [this, buttonBox](QAbstractButton* button) { 120 | this->onButtonClicked(buttonBox->standardButton(button)); 121 | }); 122 | connect(buttonBox, &QDialogButtonBox::accepted, this, &Fcitx::IMConfigDialog::accept); 123 | connect(buttonBox, &QDialogButtonBox::rejected, this, &Fcitx::IMConfigDialog::reject); 124 | } 125 | 126 | void Fcitx::IMConfigDialog::onButtonClicked(QDialogButtonBox::StandardButton code) 127 | { 128 | if (m_layoutCombobox && Global::instance()->keyboardProxy()) { 129 | if (code == QDialogButtonBox::Ok) { 130 | int idx = m_layoutCombobox->currentIndex(); 131 | if (idx == 0) 132 | Global::instance()->keyboardProxy()->SetLayoutForIM(m_imName, "", ""); 133 | else 134 | Global::instance()->keyboardProxy()->SetLayoutForIM(m_imName, m_layoutList.at(idx - 1).layout(), m_layoutList.at(idx - 1).variant()); 135 | } 136 | else if (code == QDialogButtonBox::RestoreDefaults) 137 | m_layoutCombobox->setCurrentIndex(0); 138 | } 139 | 140 | if (m_configPage) 141 | m_configPage->buttonClicked(code); 142 | } 143 | 144 | void Fcitx::IMConfigDialog::layoutComboBoxChanged() 145 | { 146 | if (!m_layoutCombobox || !m_layoutWidget) { 147 | return; 148 | } 149 | 150 | int idx = m_layoutCombobox->currentIndex(); 151 | if (idx != 0) { 152 | m_layoutWidget->setKeyboardLayout(m_layoutList.at(idx - 1).layout(), m_layoutList.at(idx - 1).variant()); 153 | m_layoutWidget->show(); 154 | } 155 | else { 156 | m_layoutWidget->hide(); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/imconfigdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef IM_CONFIG_DIALOG_H 21 | #define IM_CONFIG_DIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class KeyboardLayoutWidget; 29 | class QComboBox; 30 | namespace Fcitx { 31 | 32 | class ConfigWidget; 33 | class IMConfigDialog: public QDialog 34 | { 35 | Q_OBJECT 36 | public: 37 | explicit IMConfigDialog(const QString& imName, const FcitxAddon* addon, QWidget* parent = 0); 38 | 39 | private slots: 40 | void onButtonClicked(QDialogButtonBox::StandardButton code); 41 | void layoutComboBoxChanged(); 42 | 43 | private: 44 | QString m_imName; 45 | QComboBox* m_layoutCombobox; 46 | ConfigWidget* m_configPage; 47 | FcitxQtKeyboardLayoutList m_layoutList; 48 | KeyboardLayoutWidget* m_layoutWidget; 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/impage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITX_IM_PAGE_H 21 | #define FCITX_IM_PAGE_H 22 | 23 | // Qt 24 | #include 25 | #include 26 | #include 27 | 28 | // self 29 | 30 | namespace Ui 31 | { 32 | class IMPage; 33 | } 34 | 35 | namespace Fcitx 36 | { 37 | 38 | class Module; 39 | class IMPage : public QWidget 40 | { 41 | Q_OBJECT 42 | public: 43 | IMPage(Module* parent = 0); 44 | virtual ~IMPage(); 45 | Q_SIGNALS: 46 | void changed(); 47 | public Q_SLOTS: 48 | void save(); 49 | void load(); 50 | void filterTextChanged(const QString& text); 51 | void onlyLanguageChanged(bool); 52 | void defaults(); 53 | private: 54 | Ui::IMPage* m_ui; 55 | 56 | class Private; 57 | Private* d; 58 | }; 59 | } 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/impage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1062 10 | 648 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | Qt::Horizontal 21 | 22 | 23 | QSizePolicy::Fixed 24 | 25 | 26 | 27 | 20 28 | 20 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Keyboard layout to use when no input method active 39 | 40 | 41 | Select default keyboard layout 42 | 43 | 44 | 45 | 46 | 47 | 48 | Qt::Horizontal 49 | 50 | 51 | 52 | 40 53 | 20 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Qt::Horizontal 64 | 65 | 66 | QSizePolicy::Fixed 67 | 68 | 69 | 70 | 20 71 | 20 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Available Input Method: 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 0 94 | 95 | 96 | false 97 | 98 | 99 | false 100 | 101 | 102 | true 103 | 104 | 105 | true 106 | 107 | 108 | false 109 | 110 | 111 | 112 | 113 | 114 | 115 | Only &Show Current Language 116 | 117 | 118 | true 119 | 120 | 121 | false 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | Qt::Vertical 133 | 134 | 135 | 136 | 20 137 | 40 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | false 146 | 147 | 148 | 149 | 150 | 151 | 152 | false 153 | 154 | 155 | 156 | 157 | 158 | 159 | Qt::Vertical 160 | 161 | 162 | 163 | 20 164 | 40 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | Current Input Method: 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | Qt::Vertical 191 | 192 | 193 | 194 | 20 195 | 40 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | false 204 | 205 | 206 | 207 | 208 | 209 | 210 | false 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | Qt::Vertical 221 | 222 | 223 | 224 | 20 225 | 40 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 0 239 | 0 240 | 241 | 242 | 243 | Qt::Horizontal 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 0 254 | 0 255 | 256 | 257 | 258 | 259 | 22 260 | 22 261 | 262 | 263 | 264 | 265 | 22 266 | 22 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | The first input method will be inactive state. Usually you need to put <b>Keyboard</b> or <b>Keyboard - <i>layout name</i></b> in the first place. 278 | 279 | 280 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 281 | 282 | 283 | true 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | <b>Default keyboard layout:</b> 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | <b>Select Input Method:</b> 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | -------------------------------------------------------------------------------- /src/impage_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __FCITX_IM_PAGE_P_H__ 21 | #define __FCITX_IM_PAGE_P_H__ 22 | 23 | // Qt 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | // Fcitx 31 | #include 32 | 33 | // self 34 | #include "impage.h" 35 | 36 | enum { 37 | FcitxRowTypeRole = 0x324da8fc, 38 | FcitxLanguageRole, 39 | FcitxIMUniqueNameRole 40 | }; 41 | 42 | enum { 43 | LanguageType, 44 | IMType 45 | }; 46 | 47 | class QTreeView; 48 | class QCheckBox; 49 | class QListView; 50 | class QPushButton; 51 | class QLineEdit; 52 | namespace Fcitx 53 | { 54 | 55 | class IMPage::Private 56 | : public QObject 57 | { 58 | Q_OBJECT 59 | public: 60 | Private(QObject* parent); 61 | virtual ~Private(); 62 | void fetchIMList(); 63 | const FcitxQtInputMethodItemList& getIMList(); 64 | int dependantLayoutValue(int value, int width, int totalWidth) const; 65 | 66 | class IMModel; 67 | class AvailIMModel; 68 | class IMProxyModel; 69 | 70 | class IMDelegate; 71 | 72 | QPushButton* addIMButton; 73 | QPushButton* removeIMButton; 74 | QPushButton* moveUpButton; 75 | QPushButton* moveDownButton; 76 | QPushButton* configureButton; 77 | QListView* currentIMView; 78 | QTreeView* availIMView; 79 | QLineEdit* filterTextEdit; 80 | 81 | AvailIMModel* availIMModel; 82 | IMProxyModel* availIMProxyModel; 83 | 84 | IMModel* currentIMModel; 85 | QCheckBox* onlyCurrentLanguageCheckBox; 86 | Module* module; 87 | QPushButton* defaultLayoutButton; 88 | 89 | Q_SIGNALS: 90 | void updateIMList(const FcitxQtInputMethodItemList& list, const QString& selection); 91 | void changed(); 92 | 93 | public Q_SLOTS: 94 | void availIMSelectionChanged(); 95 | void currentIMCurrentChanged(); 96 | void clickAddIM(); 97 | void clickRemoveIM(); 98 | void addIM(const QModelIndex& index); 99 | void removeIM(const QModelIndex& index); 100 | void moveUpIM(); 101 | void moveDownIM(); 102 | void configureIM(); 103 | void save(); 104 | void doubleClickCurrentIM(const QModelIndex& index); 105 | void doubleClickAvailIM(const QModelIndex& index); 106 | void selectCurrentIM(const QModelIndex& index); 107 | void selectAvailIM(const QModelIndex& index); 108 | void selectDefaultLayout(); 109 | void onConnectStatusChanged(bool connected); 110 | private: 111 | FcitxQtInputMethodItemList m_list; 112 | }; 113 | 114 | class IMDelegate : public QStyledItemDelegate 115 | { 116 | Q_OBJECT 117 | public: 118 | explicit IMDelegate(QObject* parent = 0); 119 | virtual ~IMDelegate(); 120 | 121 | virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; 122 | virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE; 123 | }; 124 | 125 | 126 | class IMPage::Private::IMProxyModel : public QSortFilterProxyModel 127 | { 128 | Q_OBJECT 129 | 130 | public: 131 | IMProxyModel(QAbstractItemModel* sourceModel); 132 | virtual ~IMProxyModel(); 133 | void setFilterText(const QString& text); 134 | void setShowOnlyCurrentLanguage(bool checked); 135 | public Q_SLOTS: 136 | void filterIMEntryList(const FcitxQtInputMethodItemList& imEntryList, const QString& selection = QString()); 137 | 138 | protected: 139 | virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const Q_DECL_OVERRIDE; 140 | virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const Q_DECL_OVERRIDE; 141 | int compareCategories(const QModelIndex& left, const QModelIndex& right) const; 142 | 143 | private: 144 | bool filterLanguage(const QModelIndex& index) const; 145 | bool filterIM(const QModelIndex& index) const; 146 | 147 | bool m_showOnlyCurrentLanguage; 148 | QString m_filterText; 149 | QSet< QString > m_languageSet; 150 | }; 151 | 152 | class IMPage::Private::AvailIMModel : public QAbstractItemModel 153 | { 154 | Q_OBJECT 155 | void m_languageSet(); 156 | 157 | public: 158 | AvailIMModel(QObject* parent = 0); 159 | virtual ~AvailIMModel(); 160 | virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; 161 | virtual QModelIndex parent(const QModelIndex& child) const Q_DECL_OVERRIDE; 162 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; 163 | virtual int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; 164 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 165 | Q_SIGNALS: 166 | void select(QModelIndex index); 167 | void updateIMListFinished(); 168 | public Q_SLOTS: 169 | void filterIMEntryList(const FcitxQtInputMethodItemList& imEntryList, const QString& selection = QString()); 170 | private: 171 | QList > filteredIMEntryList; 172 | }; 173 | 174 | class IMPage::Private::IMModel : public QAbstractListModel 175 | { 176 | Q_OBJECT 177 | public: 178 | 179 | IMModel(QObject* parent = 0); 180 | virtual ~IMModel(); 181 | 182 | QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override; 183 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 184 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; 185 | Q_SIGNALS: 186 | void select(QModelIndex index); 187 | public Q_SLOTS: 188 | void filterIMEntryList(const FcitxQtInputMethodItemList& imEntryList, const QString& selection = QString()); 189 | private: 190 | FcitxQtInputMethodItemList filteredIMEntryList; 191 | }; 192 | 193 | } 194 | 195 | #endif 196 | -------------------------------------------------------------------------------- /src/kcm_fcitx.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Exec=kcmshell5 kcm_fcitx 3 | Icon=fcitx 4 | Type=Service 5 | X-KDE-ServiceTypes=KCModule 6 | X-KDE-Library=kcm_fcitx 7 | X-KDE-ParentApp=kcontrol 8 | 9 | X-KDE-System-Settings-Parent-Category=regionalsettings 10 | 11 | _Name=Input Method 12 | _Comment=Configure Input Method 13 | 14 | _X-KDE-Keywords=keyboard,input,im,fcitx 15 | 16 | Categories=Qt;KDE;X-KDE-settings-fcitx; 17 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | // KDE 21 | #include 22 | 23 | // self 24 | #include "module.h" 25 | 26 | K_PLUGIN_FACTORY(KcmFcitxFactory, 27 | registerPlugin();) 28 | K_EXPORT_PLUGIN(KcmFcitxFactory("kcm_fcitx")) 29 | 30 | #include "main.moc" 31 | -------------------------------------------------------------------------------- /src/module.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2010~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | 21 | // Qt 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // KDE 28 | #include 29 | #include 30 | 31 | // system 32 | #include 33 | 34 | // Fcitx 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | // self 44 | #include "config.h" 45 | #include "ui_module.h" 46 | #include "module.h" 47 | #include "addonselector.h" 48 | #include "configwidget.h" 49 | #include "global.h" 50 | #include "subconfigparser.h" 51 | #include "skinpage.h" 52 | #include "impage.h" 53 | #include "imconfigdialog.h" 54 | #include "uipage.h" 55 | #include "configpage.h" 56 | #include "erroroverlay.h" 57 | 58 | K_PLUGIN_FACTORY_DECLARATION(KcmFcitxFactory); 59 | 60 | namespace Fcitx 61 | { 62 | 63 | const UT_icd addonicd = {sizeof(FcitxAddon), 0, 0, FcitxAddonFree}; 64 | 65 | Module::Module(QWidget *parent, const QVariantList &args) : 66 | KCModule(parent, args), 67 | ui(new Ui::Module), 68 | addonSelector(0), 69 | m_addons(0), 70 | m_configPage(0), 71 | m_skinPage(0), 72 | m_imPage(0), 73 | m_uiPage(0) 74 | { 75 | bindtextdomain("fcitx", LOCALEDIR); 76 | bind_textdomain_codeset("fcitx", "UTF-8"); 77 | FcitxLogSetLevel(FCITX_NONE); 78 | 79 | FcitxQtInputMethodItem::registerMetaType(); 80 | FcitxQtKeyboardLayout::registerMetaType(); 81 | 82 | KAboutData *about = new KAboutData("kcm_fcitx", 83 | i18n("Fcitx Configuration Module"), 84 | VERSION_STRING_FULL, 85 | i18n("Configure Fcitx"), 86 | KAboutLicense::GPL_V2, 87 | i18n("Copyright 2012 Xuetian Weng"), 88 | QString(), QString(), 89 | "wengxt@gmail.com"); 90 | 91 | about->addAuthor(i18n("Xuetian Weng"), i18n("Author"), "wengxt@gmail.com"); 92 | setAboutData(about); 93 | 94 | if (FcitxAddonGetConfigDesc() != NULL) { 95 | utarray_new(m_addons, &addonicd); 96 | FcitxAddonsLoad(m_addons); 97 | } 98 | 99 | Global::instance(); 100 | 101 | ui->setupUi(this); 102 | { 103 | m_imPage = new IMPage(this); 104 | ui->pageWidget->addTab(m_imPage, i18n("Input Method")); 105 | connect(m_imPage, SIGNAL(changed()), this, SLOT(changed())); 106 | } 107 | 108 | { 109 | FcitxConfigFileDesc* configDesc = Global::instance()->GetConfigDesc("config.desc"); 110 | 111 | if (configDesc) { 112 | m_configPage = new ConfigPage; 113 | ui->pageWidget->addTab(m_configPage, i18n("Global Config")); 114 | connect(m_configPage, SIGNAL(changed()), this, SLOT(changed())); 115 | } 116 | } 117 | 118 | { 119 | if (Global::instance()->inputMethodProxy()) { 120 | m_uiPage = new UIPage(this); 121 | ui->pageWidget->addTab(m_uiPage, i18n("Appearance")); 122 | connect(m_uiPage, SIGNAL(changed()), this, SLOT(changed())); 123 | } 124 | } 125 | 126 | { 127 | if (FcitxAddonGetConfigDesc() != NULL) { 128 | addonSelector = new AddonSelector(this); 129 | ui->pageWidget->addTab(addonSelector, i18n("Addon Config")); 130 | } 131 | } 132 | 133 | if (m_addons) { 134 | for (FcitxAddon* addon = (FcitxAddon *) utarray_front(m_addons); 135 | addon != NULL; 136 | addon = (FcitxAddon *) utarray_next(m_addons, addon)) { 137 | this->addonSelector->addAddon(addon); 138 | } 139 | } 140 | 141 | if (args.size() != 0) { 142 | m_arg = args[0].toString(); 143 | } 144 | } 145 | 146 | Module::~Module() 147 | { 148 | delete ui; 149 | if (addonSelector) { 150 | delete addonSelector; 151 | } 152 | if (m_addons) { 153 | utarray_free(m_addons); 154 | } 155 | Global::deInit(); 156 | } 157 | 158 | FcitxAddon* Module::findAddonByName(const QString& name) 159 | { 160 | if (!m_addons) { 161 | return NULL; 162 | } 163 | 164 | FcitxAddon* addon = NULL; 165 | for (addon = (FcitxAddon *) utarray_front(m_addons); 166 | addon != NULL; 167 | addon = (FcitxAddon *) utarray_next(m_addons, addon)) { 168 | if (QString::fromUtf8(addon->name) == name) 169 | break; 170 | } 171 | return addon; 172 | } 173 | 174 | SkinPage* Module::skinPage() { 175 | 176 | if (!m_skinPage) { 177 | m_skinPage = new SkinPage(this); 178 | ui->pageWidget->addTab(m_skinPage, i18n("Manage Skin")); 179 | connect(m_skinPage, SIGNAL(changed()), this, SLOT(changed())); 180 | } 181 | 182 | return m_skinPage; 183 | } 184 | 185 | void Module::load() 186 | { 187 | QDialog* configDialog = NULL; 188 | if (!m_arg.isEmpty()) { 189 | do { 190 | if (!Global::instance()->inputMethodProxy()) 191 | break; 192 | QDBusPendingReply< QString > result = Global::instance()->inputMethodProxy()->GetIMAddon(m_arg); 193 | result.waitForFinished(); 194 | if (!result.isValid() || result.value().isEmpty()) 195 | break; 196 | FcitxAddon* addonEntry = findAddonByName(result.value()); 197 | if (!addonEntry) 198 | break; 199 | configDialog = new IMConfigDialog(m_arg, addonEntry, 0); 200 | } while(0); 201 | if (!configDialog) { 202 | FcitxAddon* addonEntry = findAddonByName(m_arg); 203 | if (addonEntry) 204 | configDialog = ConfigWidget::configDialog(0, addonEntry); 205 | } 206 | if (configDialog) { 207 | configDialog->setAttribute(Qt::WA_DeleteOnClose); 208 | configDialog->open(); 209 | } 210 | m_arg = QString(); 211 | } 212 | 213 | if (m_imPage) 214 | m_imPage->load(); 215 | if (m_skinPage) 216 | m_skinPage->load(); 217 | if (m_configPage) 218 | m_configPage->load(); 219 | } 220 | 221 | void Module::save() 222 | { 223 | 224 | if (m_imPage) 225 | m_imPage->save(); 226 | if (m_skinPage) 227 | m_skinPage->save(); 228 | if (m_configPage) 229 | m_configPage->save(); 230 | if (m_uiPage) 231 | m_uiPage->save(); 232 | } 233 | 234 | void Module::defaults() 235 | { 236 | if (m_configPage) { 237 | m_configPage->defaults(); 238 | } 239 | if (m_imPage) { 240 | m_imPage->defaults(); 241 | } 242 | markAsChanged(); 243 | } 244 | 245 | } 246 | -------------------------------------------------------------------------------- /src/module.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef MODULE_H 21 | #define MODULE_H 22 | 23 | // KDE 24 | #include 25 | 26 | // Fcitx 27 | #include 28 | #include 29 | 30 | class QFile; 31 | 32 | namespace Ui 33 | { 34 | 35 | class Module; 36 | } 37 | 38 | namespace Fcitx 39 | { 40 | 41 | class ConfigPage; 42 | 43 | class UIPage; 44 | 45 | 46 | class IMPage; 47 | 48 | class SkinPage; 49 | 50 | class ConfigWidget; 51 | 52 | class AddonSelector; 53 | 54 | class Module : public KCModule 55 | { 56 | Q_OBJECT 57 | 58 | public: 59 | /** 60 | * Constructor. 61 | * 62 | * @param parent Parent widget of the module 63 | * @param args Arguments for the module 64 | */ 65 | Module(QWidget *parent, const QVariantList &args = QVariantList()); 66 | 67 | /** 68 | * Destructor. 69 | */ 70 | ~Module(); 71 | 72 | /** 73 | * Overloading the KCModule load() function. 74 | */ 75 | void load() override; 76 | 77 | /** 78 | * Overloading the KCModule save() function. 79 | */ 80 | void save() override; 81 | 82 | /** 83 | * Overloading the KCModule defaults() function. 84 | */ 85 | void defaults() override; 86 | 87 | FcitxAddon* findAddonByName(const QString& name); 88 | 89 | SkinPage* skinPage(); 90 | 91 | private: 92 | /** 93 | * UI 94 | */ 95 | Ui::Module *ui; 96 | 97 | /** 98 | * Addon Selector 99 | */ 100 | AddonSelector* addonSelector; 101 | 102 | /** 103 | * addon array 104 | */ 105 | UT_array* m_addons; 106 | 107 | ConfigPage* m_configPage; 108 | SkinPage* m_skinPage; 109 | IMPage* m_imPage; 110 | UIPage* m_uiPage; 111 | QString m_arg; 112 | }; 113 | 114 | } 115 | 116 | #endif // MODULE_H 117 | -------------------------------------------------------------------------------- /src/module.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Module 4 | 5 | 6 | 7 | 0 8 | 0 9 | 10 | 11 | 12 | Form 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/skinpage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITX_SKIN_PAGE_H 21 | #define FCITX_SKIN_PAGE_H 22 | 23 | // Qt 24 | #include 25 | 26 | // self 27 | #include "ui_skinpage.h" 28 | 29 | 30 | namespace Fcitx 31 | { 32 | class Module; 33 | 34 | class SkinPage : public QWidget 35 | { 36 | Q_OBJECT 37 | public: 38 | SkinPage(Module* module, QWidget* parent = 0); 39 | virtual ~SkinPage(); 40 | 41 | void setSkinField(QLineEdit* lineEdit); 42 | public Q_SLOTS: 43 | void load(); 44 | void save(); 45 | Q_SIGNALS: 46 | void changed(); 47 | private: 48 | class Private; 49 | Module* m_module; 50 | Private* d; 51 | Ui::SkinPage* m_ui; 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/skinpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SkinPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 663 10 | 451 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Qt::Horizontal 26 | 27 | 28 | 29 | 40 30 | 20 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | false 39 | 40 | 41 | &Configure Skin 42 | 43 | 44 | 45 | 46 | 47 | 48 | false 49 | 50 | 51 | &Delete Skin 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 61 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 62 | p, li { white-space: pre-wrap; } 63 | </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> 64 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Notice:</span></p> 65 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You need to use Classic UI to use skin function.</p></body></html> 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/skinpage_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | // Qt 21 | #include 22 | #include 23 | #include 24 | 25 | // Fcitx 26 | #include 27 | #include 28 | 29 | // self 30 | #include "subconfigparser.h" 31 | #include "skinpage.h" 32 | 33 | enum FillRule { 34 | F_COPY = 0, 35 | F_RESIZE = 1 36 | }; 37 | 38 | 39 | struct SkinPlacement { 40 | char *name; 41 | int x; 42 | int y; 43 | }; 44 | 45 | struct SkinMainBar { 46 | char* backImg; 47 | char* eng; 48 | char* logo; 49 | char* active; 50 | int marginTop; 51 | int marginBottom; 52 | int marginLeft; 53 | int marginRight; 54 | FillRule fillV; 55 | FillRule fillH; 56 | char* placement; 57 | }; 58 | 59 | struct SkinInputBar { 60 | int fontSize; 61 | FcitxConfigColor inputColor; 62 | FcitxConfigColor indexColor; 63 | FcitxConfigColor firstCandColor; 64 | FcitxConfigColor otherColor; 65 | boolean respectDPI; 66 | char* backImg; 67 | FcitxConfigColor cursorColor; 68 | int marginTop; 69 | int marginBottom; 70 | int marginLeft; 71 | int marginRight; 72 | char* backArrow; 73 | char* forwardArrow; 74 | int iBackArrowX; 75 | int iBackArrowY; 76 | int iForwardArrowX; 77 | int iForwardArrowY; 78 | int iInputPos; 79 | int iOutputPos; 80 | FillRule fillV; 81 | FillRule fillH; 82 | }; 83 | 84 | struct SkinData { 85 | FcitxGenericConfig config; 86 | SkinMainBar mainbar; 87 | SkinInputBar inputbar; 88 | }; 89 | 90 | namespace Fcitx 91 | { 92 | class SkinInfo 93 | { 94 | public: 95 | QString name; 96 | QString path; 97 | QPixmap pixmap; 98 | }; 99 | 100 | class SkinPage::Private : public QObject 101 | { 102 | enum { 103 | PixmapRole = 0x4532efd3, 104 | PathRole = 0x3F213873 105 | }; 106 | 107 | Q_OBJECT 108 | public: 109 | Private(QObject* parent = 0); 110 | virtual ~Private(); 111 | 112 | class SkinModel; 113 | class SkinDelegate; 114 | 115 | SkinModel* skinModel; 116 | QListView* skinView; 117 | QPushButton* configureSkinButton; 118 | QPushButton* deleteSkinButton; 119 | SkinDelegate* skinDelegate; 120 | Module* module; 121 | QLineEdit* skinField; 122 | public Q_SLOTS: 123 | void load(); 124 | void deleteSkin(); 125 | void configureSkin(); 126 | void save(); 127 | void currentSkinChanged(); 128 | Q_SIGNALS: 129 | void changed(); 130 | private: 131 | bool removeDir(const QString &dirName); 132 | SubConfigParser m_parser; 133 | SubConfig* m_subConfig; 134 | }; 135 | 136 | class SkinPage::Private::SkinModel : public QAbstractListModel 137 | { 138 | Q_OBJECT 139 | public: 140 | SkinModel(Private* d, QObject* parent = 0); 141 | QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override; 142 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 143 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; 144 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; 145 | void setSkinList(const QStringList& list); 146 | const QList& skinList() const; 147 | private: 148 | QPixmap drawSkinPreview(const QString& path); 149 | void DrawResizableBackground( 150 | QPixmap &destPixmap, 151 | QPixmap &backgroundPixmap, 152 | int marginLeft, 153 | int marginRight, 154 | int marginTop, 155 | int marginBottom, 156 | int resizeWidth, 157 | int resizeHeight, 158 | FillRule fillV, 159 | FillRule fillH 160 | ); 161 | void DrawWidget( 162 | QPixmap &destPixmap, QPixmap &widgetPixmap, 163 | int x, int y 164 | ); 165 | QPixmap LoadImage(const char* skinDir, const char* fileName); 166 | QColor ConvertColor(FcitxConfigColor floatColor); 167 | Private* d; 168 | QList m_skins; 169 | }; 170 | 171 | class SkinPage::Private::SkinDelegate : public QStyledItemDelegate 172 | { 173 | Q_OBJECT 174 | public: 175 | SkinDelegate(QObject* parent = 0); 176 | ~SkinDelegate(); 177 | 178 | void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 179 | QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; 180 | signals: 181 | void regeneratePreview(const QModelIndex& index, const QSize& size) const; 182 | }; 183 | } 184 | -------------------------------------------------------------------------------- /src/subconfig.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | // self 29 | #include "subconfig.h" 30 | #include "subconfigpattern.h" 31 | #include "global.h" 32 | 33 | namespace Fcitx 34 | { 35 | 36 | 37 | QStringList getFilesByPattern(QDir& currentdir, const QStringList& filePatternList, int index) 38 | { 39 | QStringList result; 40 | if (!currentdir.exists()) 41 | return result; 42 | 43 | const QString& filter = filePatternList.at(index); 44 | QStringList filters; 45 | filters << filter; 46 | QDir::Filters filterflag; 47 | 48 | if (index + 1 == filePatternList.size()) { 49 | filterflag = QDir::Files; 50 | } else { 51 | filterflag = QDir::Dirs | QDir::NoDotAndDotDot; 52 | } 53 | 54 | QStringList list = currentdir.entryList(filters, filterflag); 55 | if (index + 1 == filePatternList.size()) { 56 | Q_FOREACH(const QString & item, list) { 57 | result << currentdir.absoluteFilePath(item); 58 | } 59 | } else { 60 | Q_FOREACH(const QString & item, list) { 61 | QDir dir(currentdir.absoluteFilePath(item)); 62 | result << getFilesByPattern(dir, filePatternList, index + 1); 63 | } 64 | } 65 | return result; 66 | } 67 | 68 | QSet getFiles(const QStringList& filePatternList, bool user) 69 | { 70 | size_t size; 71 | char** xdgpath; 72 | 73 | if (user) 74 | xdgpath = FcitxXDGGetPathUserWithPrefix(&size, ""); 75 | else 76 | xdgpath = FcitxXDGGetPathWithPrefix(&size, ""); 77 | 78 | QSet result; 79 | for (size_t i = 0; i < size; i ++) { 80 | QDir dir(xdgpath[i]); 81 | QStringList list = getFilesByPattern(dir, filePatternList, 0); 82 | Q_FOREACH(const QString & str, list) { 83 | result.insert( 84 | dir.relativeFilePath(str)); 85 | } 86 | } 87 | 88 | FcitxXDGFreePath(xdgpath); 89 | 90 | return result; 91 | } 92 | 93 | void SubConfig::parseConfigFileSubConfig(const SubConfigPattern* pattern) 94 | { 95 | m_fileList = getFiles(pattern->filePatternList(), false); 96 | m_configdesc = pattern->configdesc(); 97 | } 98 | 99 | void SubConfig::parseNativeFileSubConfig(const SubConfigPattern* pattern) 100 | { 101 | m_mimetype = pattern->mimetype(); 102 | m_nativepath = pattern->nativepath(); 103 | m_filePatternList = pattern->filePatternList(); 104 | updateFileList(); 105 | } 106 | 107 | void SubConfig::parsePluginSubConfig(const SubConfigPattern* pattern) 108 | { 109 | m_nativepath = pattern->nativepath(); 110 | } 111 | 112 | void SubConfig::updateFileList() 113 | { 114 | if (m_type == SC_NativeFile) { 115 | m_fileList = getFiles(m_filePatternList, false); 116 | m_userFileList = getFiles(m_filePatternList, true); 117 | } 118 | } 119 | 120 | 121 | void SubConfig::parseProgramSubConfig(const SubConfigPattern* pattern) 122 | { 123 | QString program = pattern->program(); 124 | 125 | if (pattern->program()[0] != '/') { 126 | program = QStandardPaths::findExecutable(pattern->program()); 127 | if (program.isEmpty()) { 128 | char* path = fcitx_utils_get_fcitx_path_with_filename("bindir", program.toUtf8().constData()); 129 | if (path) { 130 | program = path; 131 | free(path); 132 | } 133 | } 134 | } 135 | else { 136 | program = pattern->program(); 137 | } 138 | QFileInfo info(program); 139 | if (!info.isExecutable()) 140 | program = QString(); 141 | 142 | m_progam = program; 143 | } 144 | 145 | SubConfig::SubConfig(const QString& name, SubConfigPattern* pattern) : 146 | m_name(name), 147 | m_type(pattern->type()) 148 | { 149 | switch (pattern->type()) { 150 | case SC_ConfigFile: 151 | parseConfigFileSubConfig(pattern); 152 | break; 153 | case SC_NativeFile: 154 | parseNativeFileSubConfig(pattern); 155 | break; 156 | case SC_Program: 157 | parseProgramSubConfig(pattern); 158 | break; 159 | case SC_Plugin: 160 | parsePluginSubConfig(pattern); 161 | break; 162 | default: 163 | break; 164 | } 165 | } 166 | 167 | SubConfigType SubConfig::type() 168 | { 169 | return m_type; 170 | } 171 | 172 | const QString& SubConfig::name() const 173 | { 174 | return m_name; 175 | } 176 | 177 | const QString& SubConfig::configdesc() const 178 | { 179 | return m_configdesc; 180 | } 181 | 182 | const QString& SubConfig::nativepath() const 183 | { 184 | return m_nativepath; 185 | } 186 | 187 | const QString& SubConfig::program() const 188 | { 189 | return m_progam; 190 | } 191 | 192 | QSet< QString >& SubConfig::fileList() 193 | { 194 | return m_fileList; 195 | } 196 | 197 | QSet< QString >& SubConfig::userFileList() 198 | { 199 | return m_userFileList; 200 | } 201 | 202 | const QString& SubConfig::mimetype() const 203 | { 204 | return m_mimetype; 205 | } 206 | 207 | bool SubConfig::isValid() const 208 | { 209 | switch (m_type) { 210 | case SC_ConfigFile: 211 | return true; 212 | case SC_NativeFile: 213 | return true; 214 | case SC_Program: 215 | return !m_progam.isEmpty(); 216 | case SC_Plugin: 217 | return !Global::instance()->testWrapper(m_nativepath).isEmpty(); 218 | default: 219 | break; 220 | } 221 | return false; 222 | } 223 | 224 | } 225 | -------------------------------------------------------------------------------- /src/subconfig.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITXSUBCONFIG_H 21 | #define FCITXSUBCONFIG_H 22 | 23 | // Qt 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Fcitx 30 | { 31 | 32 | class SubConfigPattern; 33 | enum SubConfigType { 34 | SC_None, 35 | SC_ConfigFile, 36 | SC_NativeFile, 37 | SC_Program, 38 | SC_Plugin 39 | }; 40 | 41 | class SubConfig 42 | { 43 | public: 44 | explicit SubConfig(const QString& name, SubConfigPattern* pattern); 45 | SubConfigType type(); 46 | QSet< QString >& fileList(); 47 | QSet< QString >& userFileList(); 48 | const QString& name() const; 49 | const QString& configdesc() const; 50 | const QString& nativepath() const; 51 | const QString& mimetype() const; 52 | const QString& program() const; 53 | bool isValid() const; 54 | 55 | void updateFileList(); 56 | private: 57 | void parseProgramSubConfig(const SubConfigPattern* pattern); 58 | void parseNativeFileSubConfig(const SubConfigPattern* pattern); 59 | void parseConfigFileSubConfig(const SubConfigPattern* pattern); 60 | void parsePluginSubConfig(const SubConfigPattern* pattern); 61 | QString m_name; 62 | SubConfigType m_type; 63 | QSet< QString > m_fileList; 64 | QSet< QString > m_userFileList; 65 | QString m_configdesc; 66 | QString m_nativepath; 67 | QString m_mimetype; 68 | QString m_progam; 69 | QStringList m_filePatternList; 70 | }; 71 | 72 | } 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /src/subconfigparser.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | // Qt 21 | #include 22 | #include 23 | 24 | // Fcitx 25 | #include 26 | 27 | // self 28 | #include "config.h" 29 | #include "subconfigpattern.h" 30 | #include "subconfigparser.h" 31 | 32 | namespace Fcitx 33 | { 34 | SubConfigParser::SubConfigParser(const QString& subConfigString, QObject* parent) : 35 | QObject(parent) 36 | { 37 | /* 38 | * format like: name:type:XXXXXXX,name:type:XXXXXXX 39 | * valid value contains: 40 | * :domain 41 | * :native:path 42 | * :configfile:path:configdesc 43 | * :program:path 44 | */ 45 | QStringList subConfigList = subConfigString.split(','); 46 | Q_FOREACH(const QString & str, subConfigList) { 47 | int i = str.indexOf(':'); 48 | if (i < 0) 49 | continue; 50 | QString namestr = str.section(':', 0, 0); 51 | if (namestr.length() == 0) 52 | continue; 53 | QString typestr = str.section(':', 1, 1); 54 | if (typestr == "domain") { 55 | m_domain = namestr; 56 | continue; 57 | } 58 | SubConfigType type = parseType(typestr); 59 | if (type == SC_None) 60 | continue; 61 | if (m_subConfigMap.count(namestr) > 0) 62 | continue; 63 | QString patternstr = str.section(':', 2, -1); 64 | SubConfigPattern* pattern = SubConfigPattern::parsePattern(type, patternstr, this); 65 | if (pattern == NULL) 66 | continue; 67 | m_subConfigMap[namestr] = pattern; 68 | } 69 | } 70 | 71 | SubConfigType SubConfigParser::parseType(const QString& str) 72 | { 73 | if (str == "native") { 74 | return SC_NativeFile; 75 | } 76 | if (str == "configfile") { 77 | return SC_ConfigFile; 78 | } 79 | if (str == "program") { 80 | return SC_Program; 81 | } 82 | if (str == "plugin") { 83 | return SC_Plugin; 84 | } 85 | return SC_None; 86 | } 87 | 88 | QStringList SubConfigParser::getSubConfigKeys() 89 | { 90 | return m_subConfigMap.keys(); 91 | } 92 | 93 | SubConfig* SubConfigParser::getSubConfig(const QString& key) 94 | { 95 | if (m_subConfigMap.count(key) != 1) 96 | return NULL; 97 | 98 | SubConfigPattern* pattern = m_subConfigMap[key]; 99 | 100 | SubConfig* subconfig = new SubConfig(key, pattern); 101 | 102 | return subconfig; 103 | } 104 | 105 | const QString& SubConfigParser::domain() const 106 | { 107 | return m_domain; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/subconfigparser.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITXSUBCONFIGPARSER_H 21 | #define FCITXSUBCONFIGPARSER_H 22 | 23 | // Qt 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | // self 32 | #include "subconfig.h" 33 | 34 | namespace Fcitx 35 | { 36 | class SubConfigPattern; 37 | class SubConfig; 38 | 39 | class SubConfigParser : public QObject 40 | { 41 | Q_OBJECT 42 | public: 43 | SubConfigParser(const QString& subConfigString, QObject* parent = NULL); 44 | SubConfig* getSubConfig(const QString& key); 45 | QStringList getSubConfigKeys(); 46 | const QString& domain() const; 47 | protected: 48 | SubConfigType parseType(const QString& str); 49 | QSet getFiles(const QString& key, bool user); 50 | QStringList getFilesByPattern(QDir& dir, SubConfigPattern* pattern, int index = 0); 51 | QMap m_subConfigMap; 52 | QString m_domain; 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/subconfigpattern.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | // Qt 21 | #include 22 | 23 | // self 24 | #include "subconfigpattern.h" 25 | 26 | namespace Fcitx 27 | { 28 | QStringList SubConfigPattern::parseFilePattern(const QString& pattern) 29 | { 30 | do { 31 | if (pattern.length() == 0 || pattern[0] == '/') 32 | break; 33 | QStringList filePatternlist = pattern.split('/'); 34 | if (filePatternlist.length() == 0) 35 | break; 36 | Q_FOREACH(const QString & str, filePatternlist) { 37 | if (str.length() == 0) 38 | break; 39 | if (str == ".") 40 | break; 41 | if (str == "..") 42 | break; 43 | } 44 | return filePatternlist; 45 | } while(0); 46 | 47 | return QStringList(); 48 | } 49 | 50 | SubConfigPattern* SubConfigPattern::parsePattern(Fcitx::SubConfigType type, const QString& p, QObject* parent) 51 | { 52 | switch (type) { 53 | case SC_ConfigFile: 54 | { 55 | QString pattern = p.section(':', 0, 0); 56 | QString configdesc = p.section(':', 1, 1); 57 | if (configdesc.isEmpty()) 58 | return NULL; 59 | QStringList filePatternlist = parseFilePattern(pattern); 60 | if (filePatternlist.length() == 0) 61 | return NULL; 62 | SubConfigPattern* result = new SubConfigPattern(type, parent); 63 | result->m_configdesc = configdesc; 64 | result->m_filePatternlist = filePatternlist; 65 | return result; 66 | } 67 | break; 68 | case SC_NativeFile: 69 | { 70 | QString pattern = p.section(':', 0, 0); 71 | if (pattern.indexOf('*') > 0) 72 | return NULL; 73 | QString mimetype = p.section(':', 1, 1); 74 | 75 | QStringList filePatternlist = parseFilePattern(pattern); 76 | if (filePatternlist.length() == 0) 77 | return NULL; 78 | SubConfigPattern* result = new SubConfigPattern(type, parent); 79 | if (!mimetype.isEmpty()) 80 | result->m_mimetype = mimetype; 81 | result->m_nativepath = pattern; 82 | result->m_filePatternlist = filePatternlist; 83 | return result; 84 | } 85 | break; 86 | case SC_Program: 87 | { 88 | QString pattern = p.section(':', 0, 0); 89 | if (pattern.isEmpty()) 90 | return NULL; 91 | SubConfigPattern* result = new SubConfigPattern(type, parent); 92 | result->m_progam = pattern; 93 | return result; 94 | } 95 | break; 96 | case SC_Plugin: 97 | { 98 | QString pattern = p.section(':', 0, 0); 99 | if (pattern.isEmpty()) 100 | return NULL; 101 | SubConfigPattern* result = new SubConfigPattern(type, parent); 102 | result->m_nativepath = pattern; 103 | return result; 104 | } 105 | break; 106 | default: 107 | return NULL; 108 | } 109 | return NULL; 110 | } 111 | 112 | SubConfigPattern::SubConfigPattern(Fcitx::SubConfigType type, QObject* parent) : QObject(parent) 113 | { 114 | m_type = type; 115 | } 116 | 117 | const QStringList& SubConfigPattern::filePatternList() const 118 | { 119 | return m_filePatternlist; 120 | } 121 | 122 | const QString& SubConfigPattern::configdesc() const 123 | { 124 | return m_configdesc; 125 | } 126 | 127 | const QString& SubConfigPattern::nativepath() const 128 | { 129 | return m_nativepath; 130 | } 131 | 132 | const QString& SubConfigPattern::program() const 133 | { 134 | return m_progam; 135 | } 136 | 137 | const QString& SubConfigPattern::mimetype() const 138 | { 139 | return m_mimetype; 140 | } 141 | 142 | SubConfigType SubConfigPattern::type() const 143 | { 144 | return m_type; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/subconfigpattern.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITXSUBCONFIGPATTERN_H 21 | #define FCITXSUBCONFIGPATTERN_H 22 | 23 | // Qt 24 | #include 25 | #include 26 | 27 | // self 28 | #include "subconfig.h" 29 | 30 | namespace Fcitx 31 | { 32 | class SubConfigPattern : public QObject 33 | { 34 | Q_OBJECT 35 | public: 36 | static SubConfigPattern* parsePattern(SubConfigType type, const QString& pattern, QObject* parent = NULL); 37 | 38 | const QStringList& filePatternList() const; 39 | const QString& configdesc() const; 40 | SubConfigType type() const; 41 | const QString& nativepath() const; 42 | const QString& program() const; 43 | const QString& mimetype() const; 44 | private: 45 | SubConfigPattern(Fcitx::SubConfigType type, QObject* parent = 0); 46 | static QStringList parseFilePattern(const QString& p); 47 | QStringList m_filePatternlist; 48 | QString m_configdesc; 49 | QString m_nativepath; 50 | QString m_mimetype; 51 | QString m_progam; 52 | SubConfigType m_type; 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /src/subconfigwidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | // Qt 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // KDE 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | // Fcitx 36 | #include 37 | 38 | // self 39 | #include "global.h" 40 | #include "configwidget.h" 41 | #include "subconfigparser.h" 42 | #include "subconfigwidget.h" 43 | #include "subconfigwidget_p.h" 44 | namespace Fcitx 45 | { 46 | 47 | ConfigFile::ConfigFile(const QString& path) : 48 | m_path(path) 49 | { 50 | } 51 | 52 | QString ConfigFile::name() 53 | { 54 | return m_path; 55 | } 56 | 57 | const QString& ConfigFile::path() const 58 | { 59 | return m_path; 60 | } 61 | 62 | ConfigFileItemModel::ConfigFileItemModel(QObject* parent): 63 | QAbstractListModel(parent) 64 | { 65 | } 66 | 67 | ConfigFileItemModel::~ConfigFileItemModel() 68 | { 69 | Q_FOREACH(ConfigFile * file, m_files) { 70 | delete file; 71 | } 72 | } 73 | 74 | QModelIndex ConfigFileItemModel::index(int row, int column, const QModelIndex& parent) const 75 | { 76 | Q_UNUSED(parent); 77 | 78 | return createIndex(row, column, (row < m_files.count()) ? (void*) m_files.at(row) : 0); 79 | } 80 | 81 | int ConfigFileItemModel::rowCount(const QModelIndex& parent) const 82 | { 83 | if (parent.isValid()) 84 | return 0; 85 | return m_files.size(); 86 | } 87 | 88 | QVariant ConfigFileItemModel::data(const QModelIndex& index, int role) const 89 | { 90 | if (!index.isValid() || !index.internalPointer()) { 91 | return QVariant(); 92 | } 93 | 94 | ConfigFile *configfile = static_cast(index.internalPointer()); 95 | 96 | if (role == Qt::DisplayRole) 97 | return configfile->name(); 98 | 99 | return QVariant(); 100 | } 101 | 102 | void ConfigFileItemModel::addConfigFile(ConfigFile* configfile) 103 | { 104 | beginInsertRows(QModelIndex(), m_files.count(), m_files.count()); 105 | m_files << configfile; 106 | endInsertRows(); 107 | } 108 | 109 | SubConfigWidget::SubConfigWidget(SubConfig* subconfig, QWidget* parent) : 110 | QWidget(parent), m_subConfig(subconfig) 111 | { 112 | switch (subconfig->type()) { 113 | case SC_ConfigFile: { 114 | QVBoxLayout* hbox = new QVBoxLayout; 115 | setLayout(hbox); 116 | m_listView = new QListView; 117 | m_listView->setSelectionMode(QAbstractItemView::SingleSelection); 118 | m_model = new ConfigFileItemModel(this); 119 | Q_FOREACH(const QString & file, subconfig->fileList()) { 120 | m_model->addConfigFile(new ConfigFile(file)); 121 | } 122 | m_listView->setModel(m_model); 123 | hbox->addWidget(m_listView); 124 | 125 | QPushButton* pushButton = new QPushButton; 126 | pushButton->setIcon(QIcon::fromTheme("configure")); 127 | connect(pushButton, SIGNAL(clicked()), this, SLOT(openSubConfig())); 128 | hbox->addWidget(pushButton); 129 | } 130 | break; 131 | case SC_NativeFile: { 132 | QVBoxLayout* hbox = new QVBoxLayout; 133 | setLayout(hbox); 134 | QPushButton* pushButton = new QPushButton; 135 | pushButton->setIcon(QIcon::fromTheme("document-open")); 136 | connect(pushButton, SIGNAL(clicked()), this, SLOT(openNativeFile())); 137 | hbox->addWidget(pushButton); 138 | } 139 | break; 140 | case SC_Program: { 141 | QVBoxLayout* hbox = new QVBoxLayout; 142 | setLayout(hbox); 143 | QPushButton* pushButton = new QPushButton; 144 | pushButton->setIcon(QIcon::fromTheme("system-run")); 145 | if (subconfig->program().isNull()) 146 | pushButton->setEnabled(false); 147 | else 148 | connect(pushButton, SIGNAL(clicked()), this, SLOT(openProgram())); 149 | hbox->addWidget(pushButton); 150 | } 151 | break; 152 | case SC_Plugin: { 153 | QVBoxLayout* hbox = new QVBoxLayout; 154 | setLayout(hbox); 155 | QPushButton* pushButton = new QPushButton; 156 | pushButton->setIcon(QIcon::fromTheme("configure")); 157 | connect(pushButton, SIGNAL(clicked()), this, SLOT(openPlugin())); 158 | hbox->addWidget(pushButton); 159 | } 160 | break; 161 | default: 162 | break; 163 | } 164 | } 165 | 166 | SubConfigWidget::~SubConfigWidget() 167 | { 168 | delete m_subConfig; 169 | } 170 | 171 | void SubConfigWidget::openSubConfig() 172 | { 173 | QItemSelectionModel* selectionModel = m_listView->selectionModel(); 174 | QModelIndex ind = selectionModel->currentIndex(); 175 | if (!ind.isValid()) 176 | return; 177 | ConfigFile* configfile = static_cast(ind.internalPointer()); 178 | FcitxConfigFileDesc* cfdesc = Global::instance()->GetConfigDesc(m_subConfig->configdesc()); 179 | 180 | if (cfdesc) { 181 | QPointer configDialog(ConfigWidget::configDialog( 182 | NULL, 183 | cfdesc, 184 | "", 185 | configfile->path() 186 | )); 187 | 188 | configDialog->exec(); 189 | delete configDialog; 190 | } 191 | } 192 | 193 | bool SubConfigWidget::launchGuiWrapper(const QString &path) { 194 | QString wrapper = Global::instance()->testWrapper(path); 195 | 196 | if (!wrapper.isEmpty()) { 197 | QStringList args; 198 | args << path; 199 | return QProcess::startDetached(wrapper, args); 200 | } 201 | return false; 202 | } 203 | 204 | void SubConfigWidget::openPlugin() 205 | { 206 | launchGuiWrapper(m_subConfig->nativepath()); 207 | } 208 | 209 | void SubConfigWidget::openNativeFile() 210 | { 211 | char *newpath = NULL; 212 | 213 | if (launchGuiWrapper(m_subConfig->nativepath())) { 214 | return; 215 | } 216 | 217 | /* this configuration file doesn't have user version */ 218 | if (m_subConfig->userFileList().size() == 0) { 219 | /* still if system version doesn't exit either, let's create an empty text file for user */ 220 | if (m_subConfig->fileList().size() == 0) { 221 | FILE* fp = FcitxXDGGetFileUserWithPrefix("", m_subConfig->nativepath().toLocal8Bit().constData(), "w", &newpath); 222 | if (fp) { 223 | fclose(fp); 224 | m_subConfig->updateFileList(); 225 | } 226 | } 227 | else { 228 | switch(KMessageBox::questionYesNoCancel( 229 | NULL, 230 | i18n("User config doesn't exisits, do you want to open system file or copy system file to user file?"), 231 | i18n("What to do"), 232 | KGuiItem(i18n("Copy")), 233 | KGuiItem(i18n("View system")))) 234 | { 235 | case KMessageBox::Yes: 236 | { 237 | char* src = NULL; 238 | FILE* fp = FcitxXDGGetFileWithPrefix("", m_subConfig->fileList().begin()->toLocal8Bit().constData(), "r", &src); 239 | if (fp) 240 | fclose(fp); 241 | FcitxXDGGetFileUserWithPrefix("", m_subConfig->nativepath().toLocal8Bit().constData(), NULL, &newpath); 242 | QFile file(src); 243 | free(src); 244 | if (!file.copy(newpath)) { 245 | KMessageBox::error(NULL, i18n("Copy failed"), i18n("Copy failed")); 246 | } 247 | m_subConfig->updateFileList(); 248 | } 249 | break; 250 | case KMessageBox::No: 251 | { 252 | FILE* fp = FcitxXDGGetFileWithPrefix("", m_subConfig->fileList().begin()->toLocal8Bit().constData(), "r", &newpath); 253 | if (fp) 254 | fclose(fp); 255 | } 256 | break; 257 | default: 258 | return; 259 | } 260 | } 261 | } 262 | else { 263 | FILE* fp = FcitxXDGGetFileWithPrefix("", m_subConfig->userFileList().begin()->toLocal8Bit().constData(), "r", &newpath); 264 | if (fp) 265 | fclose(fp); 266 | } 267 | 268 | if (newpath) { 269 | #if KIO_VERSION < QT_VERSION_CHECK(5, 31, 0) 270 | KRun::runUrl(QUrl(newpath), m_subConfig->mimetype().isEmpty() ? "text/plain" : m_subConfig->mimetype(), NULL); 271 | #else 272 | KRun::runUrl(QUrl(newpath), m_subConfig->mimetype().isEmpty() ? "text/plain" : m_subConfig->mimetype(), NULL, KRun::RunFlags()); 273 | #endif 274 | free(newpath); 275 | } 276 | } 277 | 278 | void SubConfigWidget::openProgram() 279 | { 280 | KRun::runCommand(m_subConfig->program(), NULL); 281 | } 282 | 283 | } 284 | -------------------------------------------------------------------------------- /src/subconfigwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITXCONFIGPAGE_P_H 21 | #define FCITXCONFIGPAGE_P_H 22 | 23 | // Qt 24 | #include 25 | 26 | class QListView; 27 | namespace Fcitx 28 | { 29 | 30 | class ConfigFileItemModel; 31 | class SubConfig; 32 | 33 | class SubConfigWidget : public QWidget 34 | { 35 | Q_OBJECT 36 | public: 37 | SubConfigWidget(SubConfig* subconfig, QWidget* parent = 0); 38 | virtual ~SubConfigWidget(); 39 | 40 | private slots: 41 | void openSubConfig(); 42 | void openNativeFile(); 43 | void openProgram(); 44 | void openPlugin(); 45 | 46 | private: 47 | bool launchGuiWrapper(const QString &path); 48 | SubConfig* m_subConfig; 49 | ConfigFileItemModel* m_model; 50 | QListView* m_listView; 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/subconfigwidget_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2011~2011 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITXSUBCONFIGWIDGET_P_H 21 | #define FCITXSUBCONFIGWIDGET_P_H 22 | 23 | // Qt 24 | #include 25 | 26 | namespace Fcitx 27 | { 28 | class ConfigFile 29 | { 30 | public: 31 | ConfigFile(const QString& path); 32 | QString name(); 33 | const QString& path() const; 34 | private: 35 | QString m_path; 36 | }; 37 | 38 | class ConfigFileItemModel : public QAbstractListModel 39 | { 40 | Q_OBJECT 41 | public: 42 | ConfigFileItemModel(QObject* parent = 0); 43 | virtual ~ConfigFileItemModel(); 44 | QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; 45 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; 46 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 47 | void addConfigFile(ConfigFile* configfile); 48 | private: 49 | QList m_files; 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${PROJECT_SOURCE_DIR}/src) 2 | include_directories(${PROJECT_BINARY_DIR}/src) 3 | 4 | kde4_add_executable(testconfigpage 5 | testconfigpage.cpp 6 | ../global.cpp 7 | ../configwidget.cpp 8 | ../subconfig.cpp 9 | ../subconfigparser.cpp 10 | ../subconfigpattern.cpp 11 | ../subconfigwidget.cpp 12 | ../dummyconfig.cpp 13 | ../verticalscrollarea.cpp 14 | ../fontbutton.cpp 15 | ../plugindialog.cpp 16 | ) 17 | 18 | target_link_libraries(testconfigpage 19 | ${KDE4_KDEUI_LIBRARY} 20 | ${KDE4_KIO_LIBS} 21 | ${FCITX4_FCITX_UTILS_LIBRARIES} 22 | ${FCITX4_FCITX_CONFIG_LIBRARIES} 23 | ${FCITX_QT_LIBRARIES} 24 | ) 25 | 26 | kde4_add_executable(testdummyconfig 27 | testdummyconfig.cpp 28 | ../global.cpp 29 | ../dummyconfig.cpp 30 | ../verticalscrollarea.cpp 31 | ) 32 | 33 | target_link_libraries(testdummyconfig 34 | ${KDE4_KDEUI_LIBRARY} 35 | ${KDE4_KIO_LIBS} 36 | ${FCITX4_FCITX_UTILS_LIBRARIES} 37 | ${FCITX4_FCITX_CONFIG_LIBRARIES} 38 | ${FCITX_QT_LIBRARIES} 39 | ) 40 | 41 | kde4_add_executable(testfontbutton 42 | testfontbutton.cpp 43 | ../fontbutton.cpp 44 | ) 45 | 46 | target_link_libraries(testfontbutton 47 | ${KDE4_KDEUI_LIBRARY} 48 | ) 49 | -------------------------------------------------------------------------------- /src/test/testconfigpage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "configwidget.h" 4 | #include "global.h" 5 | 6 | int main(int argc, char* argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | FcitxConfigFileDesc* cfdesc = Fcitx::Global::instance()->GetConfigDesc("config.desc"); 11 | 12 | Fcitx::ConfigWidget configPage(cfdesc, "", "config"); 13 | configPage.load(); 14 | configPage.show(); 15 | a.exec(); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /src/test/testdummyconfig.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "dummyconfig.h" 5 | #include "global.h" 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | QCoreApplication a(argc, argv); 10 | 11 | FcitxConfigFileDesc* cfdesc = Fcitx::Global::instance()->GetConfigDesc("config.desc"); 12 | Fcitx::DummyConfig* dummyConfig = new Fcitx::DummyConfig(cfdesc); 13 | dummyConfig->load(NULL); 14 | delete dummyConfig; 15 | 16 | Fcitx::Global::deInit(); 17 | 18 | QTimer::singleShot(0, &a, SLOT(quit())); 19 | a.exec(); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/test/testfontbutton.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include 21 | 22 | #include "fontbutton.h" 23 | 24 | int main(int argc, char* argv[]) 25 | { 26 | QApplication a(argc, argv); 27 | 28 | FontButton button; 29 | button.show(); 30 | 31 | a.exec(); 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /src/uipage.cpp: -------------------------------------------------------------------------------- 1 | #include "uipage.h" 2 | #include "module.h" 3 | #include "configwidget.h" 4 | #include "global.h" 5 | #include "skinpage.h" 6 | #include "dummyconfig.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | Fcitx::UIPage::UIPage(Fcitx::Module* parent) : QWidget(parent) 14 | ,m_module(parent) 15 | ,m_layout(new QVBoxLayout(this)) 16 | ,m_label(new QLabel(i18n("Cannot load currently used user interface info"), this)) 17 | ,m_widget(0) 18 | { 19 | setLayout(m_layout); 20 | m_layout->addWidget(m_label); 21 | if (Global::instance()->inputMethodProxy()) { 22 | QDBusPendingReply< QString > reply = Global::instance()->inputMethodProxy()->GetCurrentUI(); 23 | QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(reply, this); 24 | connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(getUIFinished(QDBusPendingCallWatcher*))); 25 | } 26 | } 27 | 28 | void Fcitx::UIPage::getUIFinished(QDBusPendingCallWatcher* watcher) 29 | { 30 | QDBusPendingReply reply(*watcher); 31 | if (!reply.isValid()) 32 | return; 33 | QString name = reply.value(); 34 | FcitxAddon* addon = m_module->findAddonByName(name); 35 | if (addon) { 36 | FcitxConfigFileDesc* cfdesc = Global::instance()->GetConfigDesc(QString::fromUtf8(addon->name).append(".desc")); 37 | bool configurable = (bool)(cfdesc != NULL || strlen(addon->subconfig) != 0); 38 | if (configurable) { 39 | m_label->hide(); 40 | m_widget = new ConfigWidget(addon, this); 41 | m_layout->addWidget(m_widget); 42 | connect(m_widget, SIGNAL(changed()), this, SIGNAL(changed())); 43 | } 44 | else { 45 | m_label->setText(i18n("No configuration options for %1.").arg(QString::fromUtf8(addon->generalname))); 46 | } 47 | 48 | if (name == "fcitx-classic-ui") { 49 | do { 50 | FcitxConfigOption* option = FcitxConfigFileGetOption(m_widget->config()->genericConfig()->configFile, "ClassicUI", "SkinType"); 51 | // this should not happen, but ,we just protect it 52 | if (!option) 53 | break; 54 | 55 | // this should not happen, but ,we just protect it 56 | QLineEdit* lineEdit = static_cast(option->filterArg); 57 | if (!lineEdit) 58 | break; 59 | 60 | m_module->skinPage()->setSkinField(lineEdit); 61 | } while(0); 62 | } 63 | } 64 | } 65 | 66 | void Fcitx::UIPage::load() 67 | { 68 | if (m_widget) 69 | m_widget->load(); 70 | } 71 | 72 | 73 | void Fcitx::UIPage::save() 74 | { 75 | if (m_widget) 76 | m_widget->buttonClicked(QDialogButtonBox::Ok); 77 | } 78 | 79 | Fcitx::UIPage::~UIPage() 80 | { 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/uipage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef FCITX_UI_PAGE_H 21 | #define FCITX_UI_PAGE_H 22 | 23 | // Qt 24 | #include 25 | #include 26 | 27 | // self 28 | #include 29 | 30 | class QLabel; 31 | class QVBoxLayout; 32 | namespace Fcitx 33 | { 34 | 35 | class ConfigWidget; 36 | 37 | class Module; 38 | class UIPage : public QWidget 39 | { 40 | Q_OBJECT 41 | public: 42 | UIPage(Module* parent = 0); 43 | virtual ~UIPage(); 44 | Q_SIGNALS: 45 | void changed(); 46 | public Q_SLOTS: 47 | void save(); 48 | void load(); 49 | void getUIFinished(QDBusPendingCallWatcher* watcher); 50 | private: 51 | Module* m_module; 52 | QVBoxLayout* m_layout; 53 | QLabel* m_label; 54 | ConfigWidget* m_widget; 55 | }; 56 | } 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /src/verticalscrollarea.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "verticalscrollarea.h" 25 | 26 | namespace Fcitx { 27 | VerticalScrollArea::VerticalScrollArea(QWidget *parent) 28 | : QScrollArea(parent) 29 | { 30 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 31 | } 32 | 33 | void VerticalScrollArea::setWidget(QWidget* widget) 34 | { 35 | QScrollArea::setWidget(widget); 36 | widget->installEventFilter(this); 37 | } 38 | 39 | bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e) 40 | { 41 | if(o == widget() && e->type() == QEvent::Resize) 42 | setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width()); 43 | 44 | return false; 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/verticalscrollarea.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2012~2012 by CSSlayer * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef VERTICALSCROLLAREA_H 21 | #define VERTICALSCROLLAREA_H 22 | 23 | #include 24 | namespace Fcitx 25 | { 26 | class VerticalScrollArea : public QScrollArea { 27 | Q_OBJECT 28 | public: 29 | explicit VerticalScrollArea(QWidget* parent = 0); 30 | void setWidget(QWidget *widget); 31 | protected: 32 | bool eventFilter(QObject* o, QEvent* e) override; 33 | }; 34 | } 35 | 36 | #endif // VERTICALSCROLLAREA_H 37 | --------------------------------------------------------------------------------