From b5b873c2b346d45d858f6a610e24b726d7de5d57 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 3 Sep 2023 21:48:19 +0300 Subject: [PATCH] generic: keyboard layout applet and kayboard KCM reimplementation lots of changes with this commit - on the plasma applet side: + the applet now handles mouse wheel events * the applet itself sets its global global shortcut key + the applet itself has configuration interface for the text and flag options * ported to the new KKeyboardLayout class - no per-window or per-application keyboard layout on the overall keyboard configuration: * no KDED module required + keyboard layout descriptions (model, layout, variant, etc.) are actually translated - no keyboard configuration will be shown when a keyboard is plugged-in (see bellow) - keyboard layout options are not configurable, not via GUI interface anyway the hotplug plasma data engine, device notifications and solid actions have to be either reimplemented or extended to handle more device types (currently the above mentioned handle only removable devices by default such as cameras, not input devices such as keyboard) overall - from reimplemented one thing to another and the keyboard configuration is not done yet (adding and editing keyboard layout not implemented yet) but in a working state on a side note the changes here affect kvkbd as it uses D-Bus interface for keyboard layout change that is no more and has to be ported or (most likely) replaced with a handler for QEvent::RequestSoftwareInputPanel event that shows a keyboard on demand there is also the double-keyboard layout applet thing - applet for the keyboard layout could be added and the daemon (KDED module) was showing its own keyboard layout indicator automatically (by default) the X11 keyboard bell options are next to useless btw - there is KNotification::beep() for such things so the X11 bell options are simply dropped Signed-off-by: Ivailo Monev --- CMakeLists.txt | 84 +- ConfigureChecks.cmake | 4 +- config-X11.h.cmake | 6 - kcontrol/keyboard/CMakeLists.txt | 152 +-- kcontrol/keyboard/Messages.sh | 5 +- kcontrol/keyboard/README | 44 - kcontrol/keyboard/bindings.cpp | 146 --- kcontrol/keyboard/bindings.h | 54 -- kcontrol/keyboard/flags.cpp | 299 ------ kcontrol/keyboard/flags.h | 72 -- kcontrol/keyboard/iso_codes.cpp | 151 --- kcontrol/keyboard/iso_codes.h | 72 -- kcontrol/keyboard/kcm_add_layout_dialog.cpp | 165 ---- kcontrol/keyboard/kcm_add_layout_dialog.h | 61 -- kcontrol/keyboard/kcm_add_layout_dialog.ui | 148 --- kcontrol/keyboard/kcm_keyboard.cpp | 109 --- kcontrol/keyboard/kcm_keyboard.desktop | 5 +- kcontrol/keyboard/kcm_keyboard.h | 47 - kcontrol/keyboard/kcm_keyboard.ui | 477 ---------- kcontrol/keyboard/kcm_keyboard_widget.cpp | 692 -------------- kcontrol/keyboard/kcm_keyboard_widget.h | 102 -- kcontrol/keyboard/kcm_view_models.cpp | 504 ---------- kcontrol/keyboard/kcm_view_models.h | 170 ---- kcontrol/keyboard/kcmmisc.cpp | 237 ----- kcontrol/keyboard/kcmmisc.h | 93 -- kcontrol/keyboard/kcmmiscwidget.ui | 334 ------- kcontrol/keyboard/keyboard.desktop | 75 -- kcontrol/keyboard/keyboard_applet.cpp | 221 ----- kcontrol/keyboard/keyboard_applet.h | 81 -- kcontrol/keyboard/keyboard_config.cpp | 208 ----- kcontrol/keyboard/keyboard_config.h | 93 -- kcontrol/keyboard/keyboard_daemon.cpp | 243 ----- kcontrol/keyboard/keyboard_daemon.h | 81 -- kcontrol/keyboard/keyboard_dbus.h | 27 - kcontrol/keyboard/keyboard_hardware.cpp | 119 --- kcontrol/keyboard/keyboard_hardware.h | 25 - kcontrol/keyboard/keyboardconfig.cpp | 470 ++++++++++ kcontrol/keyboard/keyboardconfig.h | 85 ++ kcontrol/keyboard/layout_memory.cpp | 211 ----- kcontrol/keyboard/layout_memory.h | 66 -- kcontrol/keyboard/layout_memory_persister.cpp | 260 ------ kcontrol/keyboard/layout_memory_persister.h | 52 -- kcontrol/keyboard/layout_tray_icon.cpp | 125 --- kcontrol/keyboard/layout_tray_icon.h | 69 -- kcontrol/keyboard/layout_widget.cpp | 114 --- kcontrol/keyboard/layout_widget.h | 59 -- kcontrol/keyboard/layouts_menu.cpp | 142 --- kcontrol/keyboard/layouts_menu.h | 56 -- kcontrol/keyboard/numlockx.c | 303 ------ kcontrol/keyboard/pics/CMakeLists.txt | 1 - kcontrol/keyboard/pics/epo.png | Bin 154 -> 0 bytes kcontrol/keyboard/preview/kbpreviewframe.cpp | 367 -------- kcontrol/keyboard/preview/kbpreviewframe.h | 55 -- kcontrol/keyboard/preview/keyaliases.cpp | 127 --- kcontrol/keyboard/preview/keyaliases.h | 35 - kcontrol/keyboard/preview/keyboardlayout.cpp | 186 ---- kcontrol/keyboard/preview/keyboardlayout.h | 50 - kcontrol/keyboard/preview/keyboardpainter.cpp | 53 -- kcontrol/keyboard/preview/keyboardpainter.h | 44 - kcontrol/keyboard/preview/keysym2ucs.cpp | 878 ------------------ kcontrol/keyboard/preview/keysym2ucs.h | 27 - kcontrol/keyboard/preview/keysymbols.cpp | 60 -- kcontrol/keyboard/preview/keysymbols.h | 37 - kcontrol/keyboard/preview/keysymhelper.cpp | 78 -- kcontrol/keyboard/preview/keysymhelper.h | 40 - kcontrol/keyboard/tests/CMakeLists.txt | 82 -- kcontrol/keyboard/tests/config/base.1.1.xml | 68 -- kcontrol/keyboard/tests/config/base.bad.xml | 5 - kcontrol/keyboard/tests/config/base.xml | 48 - kcontrol/keyboard/tests/flags_test.cpp | 103 -- kcontrol/keyboard/tests/iso_codes_test.cpp | 78 -- .../keyboard/tests/keyboard_daemon_test.cpp | 101 -- .../tests/layout_memory_persister_test.cpp | 160 ---- kcontrol/keyboard/tests/xkb_rules_test.cpp | 240 ----- kcontrol/keyboard/x11_helper.cpp | 402 -------- kcontrol/keyboard/x11_helper.h | 185 ---- kcontrol/keyboard/xinput_helper.cpp | 160 ---- kcontrol/keyboard/xinput_helper.h | 50 - kcontrol/keyboard/xkb_helper.cpp | 190 ---- kcontrol/keyboard/xkb_helper.h | 35 - kcontrol/keyboard/xkb_rules.cpp | 384 -------- kcontrol/keyboard/xkb_rules.h | 120 --- plasma/applets/CMakeLists.txt | 7 +- plasma/applets/keyboard/CMakeLists.txt | 21 + plasma/applets/keyboard/keyboard.cpp | 202 ++++ plasma/applets/keyboard/keyboard.h | 62 ++ .../keyboard/plasma-applet-keyboard.desktop | 8 +- 87 files changed, 907 insertions(+), 11260 deletions(-) delete mode 100644 kcontrol/keyboard/README delete mode 100644 kcontrol/keyboard/bindings.cpp delete mode 100644 kcontrol/keyboard/bindings.h delete mode 100644 kcontrol/keyboard/flags.cpp delete mode 100644 kcontrol/keyboard/flags.h delete mode 100644 kcontrol/keyboard/iso_codes.cpp delete mode 100644 kcontrol/keyboard/iso_codes.h delete mode 100644 kcontrol/keyboard/kcm_add_layout_dialog.cpp delete mode 100644 kcontrol/keyboard/kcm_add_layout_dialog.h delete mode 100644 kcontrol/keyboard/kcm_add_layout_dialog.ui delete mode 100644 kcontrol/keyboard/kcm_keyboard.cpp delete mode 100644 kcontrol/keyboard/kcm_keyboard.h delete mode 100644 kcontrol/keyboard/kcm_keyboard.ui delete mode 100644 kcontrol/keyboard/kcm_keyboard_widget.cpp delete mode 100644 kcontrol/keyboard/kcm_keyboard_widget.h delete mode 100644 kcontrol/keyboard/kcm_view_models.cpp delete mode 100644 kcontrol/keyboard/kcm_view_models.h delete mode 100644 kcontrol/keyboard/kcmmisc.cpp delete mode 100644 kcontrol/keyboard/kcmmisc.h delete mode 100644 kcontrol/keyboard/kcmmiscwidget.ui delete mode 100644 kcontrol/keyboard/keyboard.desktop delete mode 100644 kcontrol/keyboard/keyboard_applet.cpp delete mode 100644 kcontrol/keyboard/keyboard_applet.h delete mode 100644 kcontrol/keyboard/keyboard_config.cpp delete mode 100644 kcontrol/keyboard/keyboard_config.h delete mode 100644 kcontrol/keyboard/keyboard_daemon.cpp delete mode 100644 kcontrol/keyboard/keyboard_daemon.h delete mode 100644 kcontrol/keyboard/keyboard_dbus.h delete mode 100644 kcontrol/keyboard/keyboard_hardware.cpp delete mode 100644 kcontrol/keyboard/keyboard_hardware.h create mode 100644 kcontrol/keyboard/keyboardconfig.cpp create mode 100644 kcontrol/keyboard/keyboardconfig.h delete mode 100644 kcontrol/keyboard/layout_memory.cpp delete mode 100644 kcontrol/keyboard/layout_memory.h delete mode 100644 kcontrol/keyboard/layout_memory_persister.cpp delete mode 100644 kcontrol/keyboard/layout_memory_persister.h delete mode 100644 kcontrol/keyboard/layout_tray_icon.cpp delete mode 100644 kcontrol/keyboard/layout_tray_icon.h delete mode 100644 kcontrol/keyboard/layout_widget.cpp delete mode 100644 kcontrol/keyboard/layout_widget.h delete mode 100644 kcontrol/keyboard/layouts_menu.cpp delete mode 100644 kcontrol/keyboard/layouts_menu.h delete mode 100644 kcontrol/keyboard/numlockx.c delete mode 100644 kcontrol/keyboard/pics/CMakeLists.txt delete mode 100644 kcontrol/keyboard/pics/epo.png delete mode 100644 kcontrol/keyboard/preview/kbpreviewframe.cpp delete mode 100644 kcontrol/keyboard/preview/kbpreviewframe.h delete mode 100644 kcontrol/keyboard/preview/keyaliases.cpp delete mode 100644 kcontrol/keyboard/preview/keyaliases.h delete mode 100644 kcontrol/keyboard/preview/keyboardlayout.cpp delete mode 100644 kcontrol/keyboard/preview/keyboardlayout.h delete mode 100644 kcontrol/keyboard/preview/keyboardpainter.cpp delete mode 100644 kcontrol/keyboard/preview/keyboardpainter.h delete mode 100644 kcontrol/keyboard/preview/keysym2ucs.cpp delete mode 100644 kcontrol/keyboard/preview/keysym2ucs.h delete mode 100644 kcontrol/keyboard/preview/keysymbols.cpp delete mode 100644 kcontrol/keyboard/preview/keysymbols.h delete mode 100644 kcontrol/keyboard/preview/keysymhelper.cpp delete mode 100644 kcontrol/keyboard/preview/keysymhelper.h delete mode 100644 kcontrol/keyboard/tests/CMakeLists.txt delete mode 100644 kcontrol/keyboard/tests/config/base.1.1.xml delete mode 100644 kcontrol/keyboard/tests/config/base.bad.xml delete mode 100644 kcontrol/keyboard/tests/config/base.xml delete mode 100644 kcontrol/keyboard/tests/flags_test.cpp delete mode 100644 kcontrol/keyboard/tests/iso_codes_test.cpp delete mode 100644 kcontrol/keyboard/tests/keyboard_daemon_test.cpp delete mode 100644 kcontrol/keyboard/tests/layout_memory_persister_test.cpp delete mode 100644 kcontrol/keyboard/tests/xkb_rules_test.cpp delete mode 100644 kcontrol/keyboard/x11_helper.cpp delete mode 100644 kcontrol/keyboard/x11_helper.h delete mode 100644 kcontrol/keyboard/xinput_helper.cpp delete mode 100644 kcontrol/keyboard/xinput_helper.h delete mode 100644 kcontrol/keyboard/xkb_helper.cpp delete mode 100644 kcontrol/keyboard/xkb_helper.h delete mode 100644 kcontrol/keyboard/xkb_rules.cpp delete mode 100644 kcontrol/keyboard/xkb_rules.h create mode 100644 plasma/applets/keyboard/CMakeLists.txt create mode 100644 plasma/applets/keyboard/keyboard.cpp create mode 100644 plasma/applets/keyboard/keyboard.h rename kcontrol/keyboard/plasma_applet_keyboard.desktop => plasma/applets/keyboard/plasma-applet-keyboard.desktop (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f559440..3e64d08d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,54 +24,50 @@ set_package_properties(Sudo PROPERTIES PURPOSE "Needed for kdesudo to operate" ) -if(Q_WS_X11) - find_package(XCB REQUIRED) - set_package_properties(XCB PROPERTIES - DESCRIPTION "X protocol C-language Binding" - URL "http://xcb.freedesktop.org" - TYPE REQUIRED - ) +find_package(XCB) +set_package_properties(XCB PROPERTIES + DESCRIPTION "X protocol C-language Binding" + URL "http://xcb.freedesktop.org" + TYPE REQUIRED +) - find_package(X11_XCB) - set_package_properties(X11_XCB - PROPERTIES DESCRIPTION "XCB X11 protocol client library" - TYPE REQUIRED - ) +find_package(X11_XCB) +set_package_properties(X11_XCB + PROPERTIES DESCRIPTION "XCB X11 protocol client library" + TYPE REQUIRED +) - find_package(X11) - set_package_properties(X11 PROPERTIES - DESCRIPTION "X11 libraries" - URL "http://www.x.org" - TYPE REQUIRED - ) +find_package(X11) +set_package_properties(X11 PROPERTIES + DESCRIPTION "X11 libraries" + URL "http://www.x.org" + TYPE REQUIRED +) - add_feature_info("libXTest" X11_XTest_FOUND "The X11 Testing Resource extension library is useful for automated testing of X clients") - add_feature_info("libXcomposite" X11_Xcomposite_FOUND "The X11 Composite extension library may be used by Plasma and KWin") - add_feature_info("libxf86misc" X11_xf86misc_FOUND "The X11 miscellaneous library may be used by keyboard KCM") # TODO: unused? - add_feature_info("libXSync" X11_XSync_FOUND "The X11 synchronization may be used by KWin") - add_feature_info("libXinput" X11_Xinput_FOUND "The X11 XINPUT extension library may be used by keyboard KCM") - add_feature_info("libXRes" X11_XRes_FOUND "The X Resource library may be used by ksysguard") - add_feature_info("libXext" X11_dpms_FOUND "The X extensions library may be used by kscreensaver") +add_feature_info("libXcomposite" X11_Xcomposite_FOUND "The X11 Composite extension library may be used by Plasma and KWin") +add_feature_info("libXSync" X11_XSync_FOUND "The X11 synchronization may be used by KWin") +add_feature_info("libXinput" X11_Xinput_FOUND "The X11 XINPUT extension library may be used by touchpad handler") +add_feature_info("libXRes" X11_XRes_FOUND "The X Resource library may be used by ksysguard") +add_feature_info("libXext" X11_dpms_FOUND "The X extensions library may be used by kscreensaver") - if(NOT X11_Xau_FOUND) - message(FATAL_ERROR "The X11 authorization extension library was not found. Required for authorization in kworkspace library") - endif() - if(NOT X11_Xdamage_FOUND) - message(FATAL_ERROR "The X11 damaged region extension library was not found. Required for compositing support in KWin") - endif() - if(NOT X11_Xrender_FOUND) - message(FATAL_ERROR " The X Rendering extension client library was not found. Required for XRender Compositing backend in KWin") - endif() - if(NOT X11_Xfixes_FOUND) - message(FATAL_ERROR "The X11 miscellaneous 'fixes' extension library was not found. Required for XRender Compositing backend in KWin") - endif() - if(NOT X11_Xrandr_FOUND) - message(FATAL_ERROR "The X11 RandR extension library was not found. Required for Multi Screen Support") - endif() - if(NOT X11_Xcursor_FOUND) - message(FATAL_ERROR "The X11 cursor management library was not found. Required for desktop effects support in KWin") - endif() -endif(Q_WS_X11) +if(NOT X11_Xau_FOUND) + message(FATAL_ERROR "The X11 authorization extension library was not found. Required for authorization in kworkspace library") +endif() +if(NOT X11_Xdamage_FOUND) + message(FATAL_ERROR "The X11 damaged region extension library was not found. Required for compositing support in KWin") +endif() +if(NOT X11_Xrender_FOUND) + message(FATAL_ERROR " The X Rendering extension client library was not found. Required for XRender Compositing backend in KWin") +endif() +if(NOT X11_Xfixes_FOUND) + message(FATAL_ERROR "The X11 miscellaneous 'fixes' extension library was not found. Required for XRender Compositing backend in KWin") +endif() +if(NOT X11_Xrandr_FOUND) + message(FATAL_ERROR "The X11 RandR extension library was not found. Required for Multi Screen Support") +endif() +if(NOT X11_Xcursor_FOUND) + message(FATAL_ERROR "The X11 cursor management library was not found. Required for desktop effects support in KWin") +endif() kde4_optional_find_package(OpenGL) set_package_properties(OpenGL PROPERTIES diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 39d93b7b..aa3d79b3 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -18,14 +18,12 @@ check_function_exists(nice HAVE_NICE) check_include_files(malloc.h HAVE_MALLOC_H) kde4_bool_to_01(FONTCONFIG_FOUND HAVE_FONTCONFIG) # kcontrol/fonts kde4_bool_to_01(FREETYPE_FOUND HAVE_FREETYPE) # kcontrol/fonts -kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kcontrol/keyboard kde4_bool_to_01(X11_Xcomposite_FOUND HAVE_XCOMPOSITE) # plasma, kwin kde4_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR) # many uses kde4_bool_to_01(X11_Xdamage_FOUND HAVE_XDAMAGE) # kwin kde4_bool_to_01(X11_Xfixes_FOUND HAVE_XFIXES) # klipper, kicker, kwin -kde4_bool_to_01(X11_Xkb_FOUND HAVE_XKB) # kglobalaccel, kcontrol/keyboard +kde4_bool_to_01(X11_Xkb_FOUND HAVE_XKB) # kglobalaccel kde4_bool_to_01(X11_Xrandr_FOUND HAVE_XRANDR) # kwin -kde4_bool_to_01(X11_xf86misc_FOUND HAVE_XF86MISC) # kcontrol/keyboard kde4_bool_to_01(X11_XSync_FOUND HAVE_XSYNC) # kwin kde4_bool_to_01(X11_XRes_FOUND HAVE_XRES) # ksysguard kde4_bool_to_01(X11_dpms_FOUND HAVE_DPMS) # kscreensaver diff --git a/config-X11.h.cmake b/config-X11.h.cmake index fc8d030b..07aa92b4 100644 --- a/config-X11.h.cmake +++ b/config-X11.h.cmake @@ -13,15 +13,9 @@ /* Define to 1 if you have Xcursor */ #cmakedefine HAVE_XCURSOR 1 -/* Define if you have the xf86misc extension */ -#cmakedefine HAVE_XF86MISC 1 - /* Define if you have the XFixes extension */ #cmakedefine HAVE_XFIXES 1 -/* Define if you have the XTest extension */ -#cmakedefine HAVE_XTEST 1 - /* Define if you have the XSync extension */ #cmakedefine HAVE_XSYNC 1 diff --git a/kcontrol/keyboard/CMakeLists.txt b/kcontrol/keyboard/CMakeLists.txt index b7b218e6..712bd65e 100644 --- a/kcontrol/keyboard/CMakeLists.txt +++ b/kcontrol/keyboard/CMakeLists.txt @@ -1,146 +1,24 @@ -if( X11_Xinput_FOUND ) - ADD_DEFINITIONS(-DHAVE_XINPUT_AND_DEVICE_NOTIFY=1) -else() - MESSAGE(STATUS "libXi version 1.2.0 or later is required to keep layouts with keyboard hotplugging") -endif() +########### next target ############### -### kded daemon ### - -set(kded_keyboard_SRCS - keyboard_daemon.cpp - layout_memory.cpp - layout_memory_persister.cpp - x11_helper.cpp - xinput_helper.cpp - xkb_helper.cpp - keyboard_config.cpp - keyboard_hardware.cpp - numlockx.c - bindings.cpp - # next are temporary for sys tray UI - layout_tray_icon.cpp - layouts_menu.cpp - flags.cpp - xkb_rules.cpp +set(keyboardconfig_SRCS + keyboardconfig.cpp ) -kde4_add_plugin(kded_keyboard ${kded_keyboard_SRCS}) - -target_link_libraries(kded_keyboard - KDE4::kdecore - KDE4::kdeui - KDE4::plasma - ${QT_QTXML_LIBRARY} - ${X11_LIBRARIES} - ${X11_Xkbfile_LIB} - ) - -if(X11_XTest_FOUND) - target_link_libraries(kded_keyboard ${X11_XTest_LIB}) -endif(X11_XTest_FOUND) - -if(X11_Xinput_FOUND) - target_link_libraries(kded_keyboard ${X11_Xinput_LIB}) -endif(X11_Xinput_FOUND) - -install( TARGETS kded_keyboard DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} ) -install( FILES keyboard.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR}/kded ) - - -### plasma applet ### - -set( plasma_applet_keyboard_SRCS - keyboard_applet.cpp - flags.cpp - keyboard_config.cpp - xkb_rules.cpp - x11_helper.cpp - xkb_helper.cpp - layouts_menu.cpp -) - -kde4_add_plugin(plasma_applet_keyboard ${plasma_applet_keyboard_SRCS}) - -target_link_libraries(plasma_applet_keyboard - KDE4::kdeui - KDE4::plasma - ${QT_QTXML_LIBRARY} - ${X11_Xkbfile_LIB} - ${X11_LIBRARIES} -) - -install( TARGETS plasma_applet_keyboard DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} ) -install( FILES plasma_applet_keyboard.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} ) - - -### widget lib ### - -set( keyboard_layout_widget_SRCS - layout_widget.cpp - keyboard_config.cpp - flags.cpp - x11_helper.cpp - xkb_helper.cpp -) - -# MODULE? -kde4_add_plugin(keyboard_layout_widget ${keyboard_layout_widget_SRCS}) - -target_link_libraries(keyboard_layout_widget - KDE4::kdeui - KDE4::plasma - ${QT_QTXML_LIBRARY} - ${X11_LIBRARIES} - ${X11_Xkbfile_LIB} -) - -install( TARGETS keyboard_layout_widget DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} ) - - -### kcm keyboard ### -include_directories("preview") - -set(kcm_keyboard_PART_SRCS - kcm_keyboard.cpp - kcm_keyboard_widget.cpp - kcm_view_models.cpp - kcm_add_layout_dialog.cpp - keyboard_config.cpp - x11_helper.cpp - xkb_helper.cpp - xkb_rules.cpp - flags.cpp - iso_codes.cpp - kcmmisc.cpp - bindings.cpp - preview/keyaliases.cpp - preview/keyboardlayout.cpp - preview/keyboardpainter.cpp - preview/keysymbols.cpp - preview/keysymhelper.cpp - preview/kbpreviewframe.cpp - preview/keysym2ucs.cpp - kcm_keyboard.ui - kcm_add_layout_dialog.ui - kcmmiscwidget.ui -) - -kde4_add_plugin(kcm_keyboard ${kcm_keyboard_PART_SRCS}) +kde4_add_plugin(kcm_keyboard ${keyboardconfig_SRCS}) target_link_libraries(kcm_keyboard - KDE4::plasma - KDE4::kio - ${X11_Xkbfile_LIB} + KDE4::kdeui + KDE4::kcmutils ${X11_LIBRARIES} + ${X11_Xkbfile_LIB} ) -install(TARGETS kcm_keyboard DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}) +install( + TARGETS kcm_keyboard + DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} +) -install(FILES kcm_keyboard.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR}) - -add_subdirectory( pics ) - - -if(ENABLE_TESTING) - add_subdirectory(tests) -endif() +install( + FILES kcm_keyboard.desktop + DESTINATION ${KDE4_SERVICES_INSTALL_DIR} +) diff --git a/kcontrol/keyboard/Messages.sh b/kcontrol/keyboard/Messages.sh index 9005d695..57394875 100755 --- a/kcontrol/keyboard/Messages.sh +++ b/kcontrol/keyboard/Messages.sh @@ -1,5 +1,4 @@ #!/bin/bash $EXTRACTRC kcm*.ui >> rc.cpp -$XGETTEXT rc.cpp kcmmisc.cpp preview/*.cpp -o $podir/kcmkeyboard.pot -$XGETTEXT kcm_*.cpp keyboard_*.cpp layout_*.cpp flags.cpp layouts_menu.cpp bindings.cpp -o $podir/kxkb.pot -rm -f rc.cpp +$XGETTEXT rc.cpp *.cpp -o $podir/kcmkeyboard.pot +rm -f rc.cpp diff --git a/kcontrol/keyboard/README b/kcontrol/keyboard/README deleted file mode 100644 index 25c50b47..00000000 --- a/kcontrol/keyboard/README +++ /dev/null @@ -1,44 +0,0 @@ -This is new project to replace keyboard (kcmmisc) and kxkb -to manage keyboard harware configuration and layouts. - -Components: - -kcm_init: -* no kcm_init - all initialization (including after keyboard hot-plug) is done by kded daemon - -Keyboard daemon: -* configures keyboard layouts on start -* provides DBUS API "org.kde.KXKB/kxkb" -* listens to window/desktop switching if layout switch mode is not global -* listens to new keyboard devices and reinitializes keyboard layouts and hardware settings -* listens to Global KDE Shortcut to switch layouts -* listens to Global Shortcut settings change -* listens to keyboard configuration changes -* provides systray icon for layout - -Keyboard applet: -* displays current layout with text and (optionally flag) -* allows to toggle layouts by click or set them with context menu - -Layout widget: -* displays current layout with text embedded in another widget (e.g. lock dialog) -* currently only short text (no flag or long text) -* dynamically loaded as a plugin - -KCM Module: -* allows to configure keyboard hardware, layouts and xkb options (advanced) - -Advantages (over old code): -* One UI module to configure keyboard layouts and hardware -* Allows to configure keyboard model/xkb options without configuring layouts -* Less cluttered layout configuration control (add layout is separate) -* Layout control/DBus interface is separate from the indicator -* Does not require libxklvier -* Takes language names from iso-codes project -* Takes country names/translations from xkeyboard-config project -* Information about current layouts is always taken from X server, so should be more robust -* Cleaner code (rewritten from scratch) -* Due to many points above should start faster (though no benchmarks performed) - -New features: -* Allow selection of keyboard layout by language diff --git a/kcontrol/keyboard/bindings.cpp b/kcontrol/keyboard/bindings.cpp deleted file mode 100644 index 1e5cbe87..00000000 --- a/kcontrol/keyboard/bindings.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "bindings.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include "x11_helper.h" -#include "flags.h" - - -static const char* actionName = I18N_NOOP("Switch to Next Keyboard Layout"); -static const char* COMPONENT_NAME = I18N_NOOP("KDE Keyboard Layout Switcher"); - - -KeyboardLayoutActionCollection::KeyboardLayoutActionCollection(QObject* parent, bool configAction_): - KActionCollection(parent, KComponentData(KAboutData(COMPONENT_NAME, 0, ki18n(COMPONENT_NAME), 0))), - configAction(configAction_) -{ - KAction* toggleAction = addAction( actionName ); - toggleAction->setText( i18n(actionName) ); - toggleAction->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_K)); - if( configAction ) { - toggleAction->setProperty("isConfigurationAction", true); - } - kDebug() << "Keyboard layout toggle shortcut" << toggleAction->globalShortcut().toString(); -} - -KeyboardLayoutActionCollection::~KeyboardLayoutActionCollection() -{ - clear(); -} - -KAction* KeyboardLayoutActionCollection::getToggeAction() -{ - return static_cast(action(0)); -} - -KAction* KeyboardLayoutActionCollection::createLayoutShortcutActon(const LayoutUnit& layoutUnit, const Rules* rules, bool autoload) -{ - QString longLayoutName = Flags::getLongText( layoutUnit, rules ); - QString actionName = "Switch keyboard layout to "; - actionName += longLayoutName; - KAction* action = addAction( actionName ); - action->setText( i18n("Switch keyboard layout to %1", longLayoutName) ); - KAction::GlobalShortcutLoading loading = autoload ? KAction::Autoloading : KAction::NoAutoloading; - KShortcut shortcut = autoload ? KShortcut() : KShortcut(layoutUnit.getShortcut()); - action->setGlobalShortcut(shortcut, KAction::ShortcutTypes(KAction::ActiveShortcut /*| KAction::DefaultShortcut*/), loading); - action->setData(layoutUnit.toString()); - if( configAction ) { - action->setProperty("isConfigurationAction", true); - } - kDebug() << "Registered layout shortcut" << action->globalShortcut(KAction::ActiveShortcut).primary().toString() << "for" << action->text() << "lu.shortcut" << layoutUnit.getShortcut().toString(); - return action; -} - -void KeyboardLayoutActionCollection::setToggleShortcut(const QKeySequence& keySequence) -{ - KShortcut shortcut(keySequence); - getToggeAction()->setGlobalShortcut(shortcut, KAction::ActiveShortcut, KAction::NoAutoloading); - kDebug() << "Saving keyboard layout KDE shortcut" << shortcut.toString(); -} - -//KAction* KeyboardLayoutActionCollection::setShortcut(LayoutUnit& layoutUnit, const QKeySequence& keySequence, const Rules* rules) -//{ -// KAction* action = getAction(layoutUnit); -// if( action == NULL && ! keySequence.isEmpty() ) { -// action = createLayoutShortcutActon(layoutUnit, rules, false); -// } -// else if( action != NULL && keySequence.isEmpty() ){ -//// action->setGlobalShortcut(KShortcut(keySequence), KAction::ActiveShortcut, KAction::NoAutoloading); // do we need this? -// removeAction(action); -// action = NULL; -// } -//// if( configAction ) { -//// layoutUnit.setShortcut(keySequence); // shortcut was restored -//// } -// return action; -//} - -void KeyboardLayoutActionCollection::setLayoutShortcuts(QList& layoutUnits, const Rules* rules) -{ - for (QList::iterator i = layoutUnits.begin(); i != layoutUnits.end(); ++i) { - LayoutUnit& layoutUnit = *i; - if( ! layoutUnit.getShortcut().isEmpty() ) { - createLayoutShortcutActon(layoutUnit, rules, false); - } - } - kDebug() << "Cleaning component shortcuts on save" << KGlobalAccel::cleanComponent(COMPONENT_NAME); -} - -void KeyboardLayoutActionCollection::loadLayoutShortcuts(QList& layoutUnits, const Rules* rules) -{ - for (QList::iterator i = layoutUnits.begin(); i != layoutUnits.end(); ++i) { - LayoutUnit& layoutUnit = *i; - KAction* action = createLayoutShortcutActon(layoutUnit, rules, true); - QKeySequence shortcut = action->globalShortcut(KAction::ActiveShortcut).primary(); // shortcut was restored - if( ! shortcut.isEmpty() ) { - kDebug() << "Restored shortcut for" << layoutUnit.toString() << shortcut; - layoutUnit.setShortcut(shortcut); - } - else { - kDebug() << "Skipping empty shortcut for" << layoutUnit.toString(); - removeAction(action); - } - } - kDebug() << "Cleaning component shortcuts on load" << KGlobalAccel::cleanComponent(COMPONENT_NAME); -} - -//KAction* KeyboardLayoutActionCollection::getAction(const LayoutUnit& layoutUnit) -//{ -// for(int i=1; idata() == layoutUnit.toString() ) -// return static_cast(action(i)); -// } -// return NULL; -//} - -void KeyboardLayoutActionCollection::resetLayoutShortcuts() -{ - for(int i=1; i(action(i))->setGlobalShortcut(KShortcut(), KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut), KAction::NoAutoloading); - } -} diff --git a/kcontrol/keyboard/bindings.h b/kcontrol/keyboard/bindings.h deleted file mode 100644 index 6b60c9e0..00000000 --- a/kcontrol/keyboard/bindings.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef BINDINGS_H_ -#define BINDINGS_H_ - -#include - - -//#include -class KAction; -class Rules; -class LayoutUnit; -#include - - -class KeyboardLayoutActionCollection : public KActionCollection { -public: - KeyboardLayoutActionCollection(QObject* parent, bool configAction); - virtual ~KeyboardLayoutActionCollection(); - - KAction* getToggeAction(); -// KAction* getAction(const LayoutUnit& layoutUnit); - KAction* createLayoutShortcutActon(const LayoutUnit& layoutUnit, const Rules* rules, bool autoload); -// KAction* setShortcut(LayoutUnit& layoutUnit, const QKeySequence& keySequence, const Rules* rules); - void setLayoutShortcuts(QList& layoutUnits, const Rules* rules); - void setToggleShortcut(const QKeySequence& keySequence); - void loadLayoutShortcuts(QList& layoutUnits, const Rules* rules); - void resetLayoutShortcuts(); - -private: - bool configAction; -}; - -//KActionCollection* createGlobalActionCollection(QObject *parent, KAction** mainAction); -//KAction* createLayoutShortcutActon(KActionCollection* actionCollection, const LayoutUnit& layoutUnit, const Rules* rules); - -#endif /* BINDINGS_H_ */ diff --git a/kcontrol/keyboard/flags.cpp b/kcontrol/keyboard/flags.cpp deleted file mode 100644 index 582e376d..00000000 --- a/kcontrol/keyboard/flags.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "flags.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "x11_helper.h" - -//for text handling -#include "keyboard_config.h" -#include "xkb_rules.h" - - -static const int FLAG_MAX_WIDTH = 21; -static const int FLAG_MAX_HEIGHT = 14; -static const char flagTemplate[] = "l10n/%1/flag.png"; - -Flags::Flags(): - svg(NULL) -{ - transparentPixmap = new QPixmap(FLAG_MAX_WIDTH, FLAG_MAX_HEIGHT); - transparentPixmap->fill(Qt::transparent); -} - -Flags::~Flags() -{ - if( svg != NULL ) { - disconnect(svg, SIGNAL(repaintNeeded()), this, SLOT(themeChanged())); - delete svg; - } - delete transparentPixmap; -} - -const QIcon Flags::getIcon(const QString& layout) -{ - if( ! iconMap.contains(layout) ) { - iconMap[ layout ] = createIcon(layout); - } - return iconMap[ layout ]; -} - -QIcon Flags::createIcon(const QString& layout) -{ - QIcon icon; - if( ! layout.isEmpty() ) { - if( layout == "epo" ) { - QString file = KStandardDirs::locate("data", "kcmkeyboard/pics/epo.png"); - icon.addFile(file); - } - else { - QString countryCode = getCountryFromLayoutName( layout ); - if( ! countryCode.isEmpty() ) { - QString file = KStandardDirs::locate("locale", QString(flagTemplate).arg(countryCode)); - // kDebug() << "Creating icon for" << layout << "with" << file; - icon.addFile(file); - } - } - } - return icon; -} - - -//static -//const QStringList NON_COUNTRY_LAYOUTS = QString("ara,brai,epo,latam,mao").split(","); - -QString Flags::getCountryFromLayoutName(const QString& layout) const -{ - QString countryCode = layout; - - if( countryCode == "nec_vndr/jp" ) - return "jp"; - -// if( NON_COUNTRY_LAYOUTS.contain(layout) ) - if( countryCode.length() > 2 ) - return ""; - - return countryCode; -} - -//TODO: move this to some other class? - -QString Flags::getShortText(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig) -{ - if( layoutUnit.isEmpty() ) - return QString("--"); - - QString layoutText = layoutUnit.layout; - - foreach(const LayoutUnit& lu, keyboardConfig.layouts) { - if( layoutUnit.layout == lu.layout && layoutUnit.variant == lu.variant ) { - layoutText = lu.getDisplayName(); - break; - } - } - -//TODO: good autolabel -// if( layoutText == layoutUnit.layout && layoutUnit.getDisplayName() != layoutUnit.layout ) { -// layoutText = layoutUnit.getDisplayName(); -// } - - return layoutText; -} - -QString Flags::getFullText(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig, const Rules* rules) -{ - QString shortText = Flags::getShortText(layoutUnit, keyboardConfig); - QString longText = Flags::getLongText(layoutUnit, rules); - return i18nc("short layout label - full layout name", "%1 - %2", shortText, longText); -} - -static QString getDisplayText(const QString& layout, const QString& variant, const Rules* rules) -{ - if( variant.isEmpty() ) - return layout; - if( rules == NULL || rules->version == "1.0" ) - return i18nc("layout - variant", "%1 - %2", layout, variant); - return variant; -} - -QString Flags::getLongText(const LayoutUnit& layoutUnit, const Rules* rules) -{ - if( rules == NULL ) { - return getDisplayText(layoutUnit.layout, layoutUnit.variant, rules); - } - - QString layoutText = layoutUnit.layout; - const LayoutInfo* layoutInfo = rules->getLayoutInfo(layoutUnit.layout); - if( layoutInfo != NULL ) { - layoutText = layoutInfo->description; - - if( ! layoutUnit.variant.isEmpty() ) { - const VariantInfo* variantInfo = layoutInfo->getVariantInfo(layoutUnit.variant); - QString variantText = variantInfo != NULL ? variantInfo->description : layoutUnit.variant; - - layoutText = getDisplayText(layoutText, variantText, rules); - } - } - - return layoutText; -} - -static -QString getPixmapKey(const KeyboardConfig& keyboardConfig) -{ - switch(keyboardConfig.indicatorType) { - case KeyboardConfig::SHOW_FLAG: - return "_fl"; - case KeyboardConfig::SHOW_LABEL_ON_FLAG: - return "_bt"; - case KeyboardConfig::SHOW_LABEL: - return "_lb"; - } - return "_"; // should not happen -} - -void Flags::drawLabel(QPainter& painter, const QString& layoutText, bool flagShown) -{ - QFont font = painter.font(); - - QRect rect = painter.window(); -// int fontSize = layoutText.length() == 2 -// ? height * 7 / 10 -// : height * 5 / 10; - - int fontSize = rect.height();// * 7 /10; - - font.setPixelSize(fontSize); - font.setWeight(QFont::DemiBold); - - QFontMetrics fm = painter.fontMetrics(); - int width = fm.width(layoutText); - - if( width > rect.width() * 2 / 3 ) { - fontSize = round( (double)fontSize * ((double)rect.width()*2/3) / width ); - } - - int smallestReadableSize = KGlobalSettings::smallestReadableFont().pixelSize(); - if( fontSize < smallestReadableSize ) { - fontSize = smallestReadableSize; - } - font.setPixelSize(fontSize); - -#ifdef DONT_USE_PLASMA - painter.setFont(font); - painter.setPen(Qt::white); - painter.drawText(QRect(rect).adust(1,1,0,0), Qt::AlignCenter | Qt::AlignHCenter, layoutText); - painter.setPen(Qt::black); - painter.drawText(rect, Qt::AlignCenter | Qt::AlignHCenter, layoutText); -#else - // we init svg so that we get notification about theme change - getSvg(); - - QColor textColor = flagShown ? Qt::black : Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor); - QColor shadowColor = flagShown ? Qt::white : Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor); - QPoint offset = QPoint(0, 0); - - // QPixmap pixmap = Plasma::PaintUtils::texturedText(layoutText, font, svg); - QPixmap labelPixmap = Plasma::PaintUtils::shadowText(layoutText, font, textColor, shadowColor, offset, 3); - - int y = round((rect.height() - labelPixmap.height()) / 2.0); - int x = round((rect.width() - labelPixmap.width()) / 2.0); - painter.drawPixmap(QPoint(x, y), labelPixmap); -#endif -} - -const QIcon Flags::getIconWithText(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig) -{ - QString keySuffix(getPixmapKey(keyboardConfig)); - QString key(layoutUnit.toString() + keySuffix); - if( iconOrTextMap.contains(key) ) { - return iconOrTextMap[ key ]; - } - - if( keyboardConfig.indicatorType == KeyboardConfig::SHOW_FLAG ) { - QIcon icon = getIcon(layoutUnit.layout); - if( ! icon.isNull() ) { - iconOrTextMap[ key ] = icon; - return icon; - } - } - - QString layoutText = Flags::getShortText(layoutUnit, keyboardConfig); - - const QSize TRAY_ICON_SIZE(21, 14); - QPixmap pixmap = QPixmap(TRAY_ICON_SIZE); - pixmap.fill(Qt::transparent); - - QPainter painter(&pixmap); -// p.setRenderHint(QPainter::SmoothPixmapTransform); -// p.setRenderHint(QPainter::Antialiasing); - - if( keyboardConfig.indicatorType == KeyboardConfig::SHOW_LABEL_ON_FLAG ) { - QIcon iconf = createIcon(layoutUnit.layout); - iconf.paint(&painter, painter.window(), Qt::AlignCenter); - } - - drawLabel(painter, layoutText, keyboardConfig.isFlagShown()); - - painter.end(); - - QIcon icon(pixmap); - iconOrTextMap[ key ] = icon; - - return icon; -} - -Plasma::Svg* Flags::getSvg() -{ - if( svg == NULL ) { - svg = new Plasma::Svg; - svg->setImagePath("widgets/labeltexture"); - svg->setContainsMultipleImages(true); - connect(svg, SIGNAL(repaintNeeded()), this, SLOT(themeChanged())); - } - return svg; -} - -void Flags::themeChanged() -{ -// kDebug() << "Theme changed, new text color" << Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor); - clearCache(); - emit pixmapChanged(); -} - -void Flags::clearCache() -{ -// kDebug() << "Clearing flag pixmap cache"; - iconOrTextMap.clear(); -} diff --git a/kcontrol/keyboard/flags.h b/kcontrol/keyboard/flags.h deleted file mode 100644 index 1a3b09d5..00000000 --- a/kcontrol/keyboard/flags.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef FLAGS_H_ -#define FLAGS_H_ - -#include -#include -#include - -#include -#include -class LayoutUnit; -class KeyboardConfig; -class Rules; -#include -namespace Plasma { - class Svg; -} - -class Flags : public QObject -{ - Q_OBJECT - -public: - Flags(); - virtual ~Flags(); - - const QIcon getIcon(const QString& layout); - const QIcon getIconWithText(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig); - const QPixmap& getTransparentPixmap() const { return *transparentPixmap; } - - static QString getLongText(const LayoutUnit& layoutUnit, const Rules* rules); - static QString getShortText(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig); - static QString getFullText(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig, const Rules* rules); - -public Q_SLOTS: - void themeChanged(); - void clearCache(); - -Q_SIGNALS: - void pixmapChanged(); - -private: - QIcon createIcon(const QString& layout); - QString getCountryFromLayoutName(const QString& fullLayoutName) const; - void drawLabel(QPainter& painter, const QString& layoutText, bool flagShown); - Plasma::Svg* getSvg(); - - QMap iconMap; - QMap iconOrTextMap; - QPixmap* transparentPixmap; - Plasma::Svg* svg; -}; - -#endif /* FLAGS_H_ */ diff --git a/kcontrol/keyboard/iso_codes.cpp b/kcontrol/keyboard/iso_codes.cpp deleted file mode 100644 index 5ea0cb88..00000000 --- a/kcontrol/keyboard/iso_codes.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "iso_codes.h" - -#include -#include -#include - -#include -#include - - -class IsoCodesPrivate { -public: - IsoCodesPrivate(const QString& isoCode_): - isoCode(isoCode_), - isoCodesXmlDir(QLatin1String("/usr/share/xml/iso-codes")), - loaded(false) - { - static const QStringList additionalCodesDirs = QStringList() - << QLatin1String("/usr/local/share/xml/iso-codes") - << QLatin1String("/usr/pkg/share/xml/iso-codes"); // NetBSD - foreach (const QString &dir, additionalCodesDirs) { - if (QDir(dir).exists()) { - isoCodesXmlDir = dir; - } - } - } - void buildIsoEntryList(); - - const QString isoCode; - QString isoCodesXmlDir; - QList isoEntryList; - bool loaded; -}; - -class XmlHandler : public QXmlDefaultHandler -{ -public: - XmlHandler(const QString& isoCode_, QList& isoEntryList_): - isoCode(isoCode_), - qName("iso_"+isoCode+"_entry"), - isoEntryList(isoEntryList_) {} - - bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &attributes); -// bool fatalError(const QXmlParseException &exception); -// QString errorString() const; - -private: - const QString isoCode; - const QString qName; - QList& isoEntryList; -}; - -bool XmlHandler::startElement(const QString &/*namespaceURI*/, const QString &/*localName*/, - const QString &qName, const QXmlAttributes &attributes) -{ - if( qName == this->qName ) { - IsoCodeEntry entry; - for(int i=0; iinsertCatalog(QString("iso_")+d->isoCode); -} - -IsoCodes::~IsoCodes() -{ - KGlobal::locale()->removeCatalog(QString("iso_")+d->isoCode); - delete d; -} - -QList IsoCodes::getEntryList() -{ - if( ! d->loaded ) { - d->buildIsoEntryList(); - } - return d->isoEntryList; -} - -//const char* IsoCodes::iso_639="639"; -const char* IsoCodes::iso_639_3="639_3"; -const char* IsoCodes::attr_name="name"; -//const char* IsoCodes::attr_iso_639_2B_code="iso_639_2B_code"; -//const char* IsoCodes::attr_iso_639_2T_code="iso_639_2T_code"; -//const char* IsoCodes::attr_iso_639_1_code="iso_639_1_code"; -const char* IsoCodes::attr_iso_639_3_id="id"; - -const IsoCodeEntry* IsoCodes::getEntry(const QString& attributeName, const QString& attributeValue) -{ - if( ! d->loaded ) { - d->buildIsoEntryList(); - } - for(QList::Iterator it = d->isoEntryList.begin(); it != d->isoEntryList.end(); ++it) { - const IsoCodeEntry* isoCodeEntry = &(*it); - if( isoCodeEntry->value(attributeName) == attributeValue ) - return isoCodeEntry; - } - return NULL; -} - -void IsoCodesPrivate::buildIsoEntryList() -{ - loaded = true; - - QFile file(QString("%1/iso_%2.xml").arg(isoCodesXmlDir, isoCode)); - if( !file.open(QFile::ReadOnly | QFile::Text) ) { - kError() << "Can't open the xml file" << file.fileName(); - return; - } - - XmlHandler xmlHandler(isoCode, isoEntryList); - - QXmlSimpleReader reader; - reader.setContentHandler(&xmlHandler); - reader.setErrorHandler(&xmlHandler); - - QXmlInputSource xmlInputSource(&file); - - if( ! reader.parse(xmlInputSource) ) { - kError() << "Failed to parse the xml file" << file.fileName(); - return; - } - - kDebug() << "Loaded" << isoEntryList.count() << ("iso entry definitions for iso"+isoCode) << "from" << file.fileName(); -} diff --git a/kcontrol/keyboard/iso_codes.h b/kcontrol/keyboard/iso_codes.h deleted file mode 100644 index 669d2c5f..00000000 --- a/kcontrol/keyboard/iso_codes.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef ISO_CODES_H_ -#define ISO_CODES_H_ - -#include -#include -#include - - -/** - * Represents an item for iso-* standards which consists of attributes and their values - */ -struct IsoCodeEntry: public QMap -{ -}; - -class IsoCodesPrivate; - -/** - * Represents a set of codes for iso-* standards. - * Uses iso-codes project to read and localize the values. - */ -class IsoCodes -{ -public: -// static const char* iso_639; - static const char* iso_639_3; - - static const char* attr_name; -// static const char* attr_iso_639_2B_code; -// static const char* attr_iso_639_2T_code; -// static const char* attr_iso_639_1_code; - static const char* attr_iso_639_3_id; - - /** - * @param isoCode Code for iso standard, i.e. "639", for convenience there's iso_* constants defined - */ - explicit IsoCodes(const QString& isoCode); - ~IsoCodes(); - - /** - * @return Returns the list of items for this iso-* standard - */ - QList getEntryList(); - /** - * @return Returns the item for which given attribute has specified value - */ - const IsoCodeEntry* getEntry(const QString& attributeName, const QString& attributeValue); - -private: - IsoCodesPrivate* const d; -}; - -#endif /* ISO_CODES_H_ */ diff --git a/kcontrol/keyboard/kcm_add_layout_dialog.cpp b/kcontrol/keyboard/kcm_add_layout_dialog.cpp deleted file mode 100644 index 444da8ea..00000000 --- a/kcontrol/keyboard/kcm_add_layout_dialog.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kcm_add_layout_dialog.h" -#include -#include - -#include "xkb_rules.h" -#include "flags.h" -#include "iso_codes.h" - -#include "ui_kcm_add_layout_dialog.h" - - -AddLayoutDialog::AddLayoutDialog(const Rules* rules_, Flags* flags_, bool showLabel, QWidget* parent): - QDialog(parent), - rules(rules_), - flags(flags_), - selectedLanguage("no_language") -{ - layoutDialogUi = new Ui_AddLayoutDialog(); - layoutDialogUi->setupUi(this); - - QSet languages; - foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { - QSet langs = QSet::fromList(layoutInfo->languages); - languages.unite( langs ); - } - IsoCodes isoCodes(IsoCodes::iso_639_3); - foreach(const QString& lang, languages) { - const IsoCodeEntry* isoCodeEntry = isoCodes.getEntry(IsoCodes::attr_iso_639_3_id, lang); -// const IsoCodeEntry* isoCodeEntry = isoCodes.getEntry(IsoCodes::attr_iso_639_2B_code, lang); -// if( isoCodeEntry == NULL ) { -// isoCodeEntry = isoCodes.getEntry(IsoCodes::attr_iso_639_2T_code, lang); -// } - QString name = isoCodeEntry != NULL ? i18n(isoCodeEntry->value(IsoCodes::attr_name).toUtf8()) : lang; - layoutDialogUi->languageComboBox->addItem(name, lang); - } - layoutDialogUi->languageComboBox->model()->sort(0); - layoutDialogUi->languageComboBox->insertItem(0, i18n("Any language"), ""); - layoutDialogUi->languageComboBox->setCurrentIndex(0); - - if( showLabel ) { - layoutDialogUi->labelEdit->setMaxLength(LayoutUnit::MAX_LABEL_LENGTH); - } - else { - layoutDialogUi->labelLabel->setVisible(false); - layoutDialogUi->labelEdit->setVisible(false); - } - - languageChanged(0); - connect(layoutDialogUi->languageComboBox, SIGNAL(activated(int)), this, SLOT(languageChanged(int))); - connect(layoutDialogUi->layoutComboBox, SIGNAL(activated(int)), this, SLOT(layoutChanged(int))); - connect(layoutDialogUi->prevbutton,SIGNAL(clicked()),this,SLOT(preview())); -} - -void AddLayoutDialog::languageChanged(int langIdx) -{ - QString lang = layoutDialogUi->languageComboBox->itemData(langIdx).toString(); - if( lang == selectedLanguage ) - return; - - QPixmap emptyPixmap(layoutDialogUi->layoutComboBox->iconSize()); - emptyPixmap.fill(Qt::transparent); - - layoutDialogUi->layoutComboBox->clear(); - int defaultIndex = -1; - int i = 0; - foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { - if( lang.isEmpty() || layoutInfo->isLanguageSupportedByLayout(lang) ) { - if( flags ) { - QIcon icon(flags->getIcon(layoutInfo->name)); - if( icon.isNull() ) { - icon = QIcon(emptyPixmap); // align text with no icons - } - layoutDialogUi->layoutComboBox->addItem(icon, layoutInfo->description, layoutInfo->name); - } - else { - layoutDialogUi->layoutComboBox->addItem(layoutInfo->description, layoutInfo->name); - } - - // try to guess best default layout selection for given language - if( ! lang.isEmpty() && defaultIndex == -1 && layoutInfo->isLanguageSupportedByDefaultVariant(lang) ) { - defaultIndex = i; - } - i++; - } - } - if( defaultIndex == -1 ) { - defaultIndex = 0; - } - - layoutDialogUi->layoutComboBox->model()->sort(0); - layoutDialogUi->layoutComboBox->setCurrentIndex(defaultIndex); - layoutChanged(defaultIndex); - - selectedLanguage = lang; -} - -void AddLayoutDialog::layoutChanged(int layoutIdx) -{ - QString layoutName = layoutDialogUi->layoutComboBox->itemData(layoutIdx).toString(); - if( layoutName == selectedLayout ) - return; - - QString lang = layoutDialogUi->languageComboBox->itemData(layoutDialogUi->languageComboBox->currentIndex()).toString(); - - layoutDialogUi->variantComboBox->clear(); - const LayoutInfo* layoutInfo = rules->getLayoutInfo(layoutName); - foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) { - if( lang.isEmpty() || layoutInfo->isLanguageSupportedByVariant(variantInfo, lang) ) { - layoutDialogUi->variantComboBox->addItem(variantInfo->description, variantInfo->name); - } - } - - layoutDialogUi->variantComboBox->model()->sort(0); - - if( lang.isEmpty() || layoutInfo->isLanguageSupportedByDefaultVariant(lang) ) { - layoutDialogUi->variantComboBox->insertItem(0, i18nc("variant", "Default"), ""); - } - layoutDialogUi->variantComboBox->setCurrentIndex(0); - - layoutDialogUi->labelEdit->setText(layoutName); - - selectedLayout = layoutName; -} - -void AddLayoutDialog::accept() -{ - selectedLayoutUnit.layout = layoutDialogUi->layoutComboBox->itemData(layoutDialogUi->layoutComboBox->currentIndex()).toString(); - selectedLayoutUnit.variant = layoutDialogUi->variantComboBox->itemData(layoutDialogUi->variantComboBox->currentIndex()).toString(); - QString label = layoutDialogUi->labelEdit->text(); - if( label == selectedLayoutUnit.layout ) { - label = ""; - } - selectedLayoutUnit.setDisplayName( label ); - selectedLayoutUnit.setShortcut(layoutDialogUi->kkeysequencewidget->keySequence()); - QDialog::accept(); -} - - -void AddLayoutDialog::preview(){ - int index = layoutDialogUi->variantComboBox->currentIndex(); - QString variant = layoutDialogUi->variantComboBox->itemData(index).toString(); - KeyboardPainter* layoutPreview = new KeyboardPainter(); - layoutPreview->generateKeyboardLayout(selectedLayout, variant); - layoutPreview->setModal(true); - layoutPreview->exec(); - delete layoutPreview; -} diff --git a/kcontrol/keyboard/kcm_add_layout_dialog.h b/kcontrol/keyboard/kcm_add_layout_dialog.h deleted file mode 100644 index 54857559..00000000 --- a/kcontrol/keyboard/kcm_add_layout_dialog.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KCM_ADD_LAYOUT_DIALOG_H_ -#define KCM_ADD_LAYOUT_DIALOG_H_ - -#include - -#include "keyboard_config.h" -#include "preview/keyboardpainter.h" - -class Rules; -class Flags; - -QT_BEGIN_NAMESPACE -class Ui_AddLayoutDialog; -QT_END_NAMESPACE - -class AddLayoutDialog: public QDialog -{ - Q_OBJECT - -public: - AddLayoutDialog(const Rules* rules, Flags* flags, bool showLabel, QWidget* parent=NULL); - - LayoutUnit getSelectedLayoutUnit() { return selectedLayoutUnit; } - QString getvariant(QString variant); - void accept(); - -public Q_SLOTS: - void languageChanged(int langIdx); - void layoutChanged(int layoutIdx); - void preview(); - -private: - const Rules* rules; - Flags* flags; - Ui_AddLayoutDialog* layoutDialogUi; - QString selectedLanguage; - QString selectedLayout; - LayoutUnit selectedLayoutUnit; -}; - - -#endif /* KCM_ADD_LAYOUT_DIALOG_H_ */ diff --git a/kcontrol/keyboard/kcm_add_layout_dialog.ui b/kcontrol/keyboard/kcm_add_layout_dialog.ui deleted file mode 100644 index 4d851be3..00000000 --- a/kcontrol/keyboard/kcm_add_layout_dialog.ui +++ /dev/null @@ -1,148 +0,0 @@ - - - AddLayoutDialog - - - - 0 - 0 - 525 - 270 - - - - Add Layout - - - - - - - 0 - 0 - - - - - - - - Layout: - - - - - - - - 0 - 0 - - - - - - - - Shortcut: - - - - - - - Variant: - - - - - - - - - - Label: - - - - - - - Limit selection by language: - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - Preview - - - - - - - - KKeySequenceWidget - QWidget -
kkeysequencewidget.h
-
-
- - - buttonBox - accepted() - AddLayoutDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AddLayoutDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/kcontrol/keyboard/kcm_keyboard.cpp b/kcontrol/keyboard/kcm_keyboard.cpp deleted file mode 100644 index 2dad22d9..00000000 --- a/kcontrol/keyboard/kcm_keyboard.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include "kcm_keyboard.h" - -#include -#include -#include -#include -#include - -#include -#include -//#include - -#include "kcm_keyboard_widget.h" -#include "x11_helper.h" -#include "keyboard_config.h" -#include "xkb_rules.h" -#include "keyboard_dbus.h" - -#include "xkb_helper.h" - -//temp hack -#include "kcmmisc.h" - - -K_PLUGIN_FACTORY(KeyboardModuleFactory, registerPlugin();) -K_EXPORT_PLUGIN(KeyboardModuleFactory("kcmkeyboard")) - -KCMKeyboard::KCMKeyboard(QWidget *parent, const QVariantList &args) - : KCModule(KeyboardModuleFactory::componentData(), parent/*, name*/) -{ - KGlobal::locale()->insertCatalog("kxkb"); - KGlobal::locale()->insertCatalog("kcmmisc"); - - KAboutData *about = - new KAboutData("kcmkeyboard", 0, ki18n("KDE Keyboard Control Module"), - 0, KLocalizedString(), KAboutData::License_GPL, - ki18n("(c) 2010 Andriy Rysin")); - - setAboutData( about ); - setQuickHelp( i18n("

Keyboard

This control module can be used to configure keyboard" - " parameters and layouts.")); - - - rules = Rules::readRules(Rules::READ_EXTRAS); - - keyboardConfig = new KeyboardConfig(); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(KDialog::spacingHint()); - - widget = new KCMKeyboardWidget(rules, keyboardConfig, componentData(), args, parent); - layout->addWidget(widget); - - connect(widget, SIGNAL(changed(bool)), this, SIGNAL(changed(bool))); - - setButtons(Help|Default|Apply); -} - -KCMKeyboard::~KCMKeyboard() -{ - delete keyboardConfig; - delete rules; -} - -void KCMKeyboard::defaults() -{ - keyboardConfig->setDefaults(); - widget->updateUI(); - widget->getKcmMiscWidget()->defaults(); - emit changed(true); -} - -void KCMKeyboard::load() -{ - keyboardConfig->load(); - widget->updateUI(); - widget->getKcmMiscWidget()->load(); -} - -//static void initializeKeyboardSettings(); -void KCMKeyboard::save() -{ - keyboardConfig->save(); - widget->save(); - widget->getKcmMiscWidget()->save(); - - QDBusMessage message = QDBusMessage::createSignal(KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE); - QDBusConnection::sessionBus().send(message); -} diff --git a/kcontrol/keyboard/kcm_keyboard.desktop b/kcontrol/keyboard/kcm_keyboard.desktop index 258cc28f..02624ab1 100644 --- a/kcontrol/keyboard/kcm_keyboard.desktop +++ b/kcontrol/keyboard/kcm_keyboard.desktop @@ -2,12 +2,13 @@ Exec=kcmshell4 kcm_keyboard Icon=preferences-desktop-keyboard Type=Service -X-KDE-ServiceTypes=KCModule +X-KDE-ServiceTypes=KCModule,KCModuleInit X-DocPath=kcontrol/keyboard/index.html Categories=Qt;KDE;X-KDE-settings-hardware; X-KDE-Library=kcm_keyboard -X-KDE-Init-Symbol=keyboard +X-KDE-Init-Symbol=kcminit_keyboard +X-KDE-Init-Phase=0 X-KDE-ParentApp=kcontrol X-KDE-System-Settings-Parent-Category=input-devices diff --git a/kcontrol/keyboard/kcm_keyboard.h b/kcontrol/keyboard/kcm_keyboard.h deleted file mode 100644 index c88fe3dd..00000000 --- a/kcontrol/keyboard/kcm_keyboard.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KCM_KEYBOARD_H_ -#define KCM_KEYBOARD_H_ - -#include - -class KCMKeyboardWidget; -class KeyboardConfig; -class Rules; - -class KCMKeyboard: public KCModule -{ -Q_OBJECT - -public: - KCMKeyboard(QWidget *parent, const QVariantList &); - virtual ~KCMKeyboard(); - - void save(); - void load(); - void defaults(); - -private: - Rules* rules; - KeyboardConfig* keyboardConfig; - KCMKeyboardWidget *widget; -}; - -#endif /* KCM_KEYBOARD_H_ */ diff --git a/kcontrol/keyboard/kcm_keyboard.ui b/kcontrol/keyboard/kcm_keyboard.ui deleted file mode 100644 index 509c7b23..00000000 --- a/kcontrol/keyboard/kcm_keyboard.ui +++ /dev/null @@ -1,477 +0,0 @@ - - - TabWidget - - - - 0 - 0 - 677 - 485 - - - - 1 - - - - Hardware - - - - - - - 1 - 0 - - - - Keyboard &model: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - keyboardModelComboBox - - - - - - - - 2 - 0 - - - - Here you can choose a keyboard model. This setting is independent of your keyboard layout and refers to the "hardware" model, i.e. the way your keyboard is manufactured. Modern keyboards that come with your computer usually have two extra keys and are referred to as "104-key" models, which is probably what you want if you do not know what kind of keyboard you have. - - - - 15 - - - QComboBox::AdjustToContentsOnFirstShow - - - - - - - - 1 - 1 - - - - - 0 - 100 - - - - - 0 - 0 - - - - - 0 - - - - - - - - - Layouts - - - - - - - - Layout Indicator - - - - - - Show layout indicator - - - - - - - Show for single layout - - - - - - - Show flag - - - - - - - Show label - - - - - - - Show label on flag - - - - - - - - - - If you select "Application" or "Window" switching policy, changing the keyboard layout will only affect the current application or window. - - - Switching Policy - - - - - - &Global - - - true - - - - - - - &Desktop - - - - - - - &Application - - - - - - - &Window - - - - - - - - - - Shortcuts for Switching Layout - - - - - - Main shortcuts: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - xkbGrpShortcutBtn - - - - - - - This is a shortcut for switching layouts which is handled by X.org. It allows modifier-only shortcuts. - - - None - - - - - - - ... - - - - - - - 3rd level shortcuts: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - xkb3rdLevelShortcutBtn - - - - - - - This is a shortcut for switching to a third level of the active layout (if it has one) which is handled by X.org. It allows modifier-only shortcuts. - - - None - - - - - - - ... - - - - - - - Alternative shortcut: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - kdeKeySequence - - - - - - - This is a shortcut for switching layouts which is handled by KDE. It does not support modifier-only shortcuts and also may not work in some situations (e.g. if popup is active or from screensaver). - - - false - - - - - - - - - - - - true - - - Configure layouts - - - false - - - true - - - - - - - - Add - - - - - - - false - - - Remove - - - - - - - false - - - Move Up - - - - - - - false - - - Move Down - - - - - - - false - - - Preview - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - QAbstractItemView::SelectRows - - - false - - - false - - - - - - - Spare layouts - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 15 - 20 - - - - - - - - - - - true - - - - - - Main layout count: - - - - - - - - - - Qt::Horizontal - - - - 431 - 20 - - - - - - - - - - - - - - - Advanced - - - - - - &Configure keyboard options - - - - - - - false - - - QAbstractItemView::NoSelection - - - true - - - - - - - - - KButtonGroup - QGroupBox -
kbuttongroup.h
- 1 -
- - KKeySequenceWidget - QWidget -
kkeysequencewidget.h
-
-
- - - changed(bool) - -
diff --git a/kcontrol/keyboard/kcm_keyboard_widget.cpp b/kcontrol/keyboard/kcm_keyboard_widget.cpp deleted file mode 100644 index 82b0941f..00000000 --- a/kcontrol/keyboard/kcm_keyboard_widget.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kcm_keyboard_widget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "keyboard_config.h" -#include "preview/keyboardpainter.h" -#include "xkb_rules.h" -#include "flags.h" -#include "x11_helper.h" -#include "kcm_view_models.h" -#include "kcm_add_layout_dialog.h" -#include "bindings.h" - -#include "kcmmisc.h" - -#include "ui_kcm_add_layout_dialog.h" - - -static const QString GROUP_SWITCH_GROUP_NAME("grp"); -static const QString LV3_SWITCH_GROUP_NAME("lv3"); -//static const QString RESET_XKB_OPTIONS("-option"); - -static const int TAB_HARDWARE = 0; -static const int TAB_LAYOUTS = 1; -static const int TAB_ADVANCED = 2; - -static const int MIN_LOOPING_COUNT = 2; - - -KCMKeyboardWidget::KCMKeyboardWidget(Rules* rules_, KeyboardConfig* keyboardConfig_, - const KComponentData componentData_, const QVariantList &args, QWidget* /*parent*/): - rules(rules_), - componentData(componentData_), - actionCollection(NULL), - uiUpdating(false) -{ - flags = new Flags(); - keyboardConfig = keyboardConfig_; - - uiWidget = new Ui::TabWidget; - uiWidget->setupUi(this); - - kcmMiscWidget = new KCMiscKeyboardWidget(uiWidget->lowerHardwareWidget); - uiWidget->lowerHardwareWidget->layout()->addWidget( kcmMiscWidget ); - connect(kcmMiscWidget, SIGNAL(changed(bool)), this, SIGNAL(changed(bool))); - - if( rules != NULL ) { - initializeKeyboardModelUI(); - initializeXkbOptionsUI(); - initializeLayoutsUI(); - } - else { - uiWidget->tabLayouts->setEnabled(false); - uiWidget->tabAdvanced->setEnabled(false); - uiWidget->keyboardModelComboBox->setEnabled(false); - } - - handleParameters(args); -} - -KCMKeyboardWidget::~KCMKeyboardWidget() -{ - delete flags; -} - -void KCMKeyboardWidget::handleParameters(const QVariantList &args) -{ - // TODO: improve parameter handling - setCurrentIndex(TAB_HARDWARE); - foreach(const QVariant& arg, args) { - if( arg.type() == QVariant::String ) { - QString str = arg.toString(); - if( str == "--tab=layouts" ) { - setCurrentIndex(TAB_LAYOUTS); - } - else if( str == "--tab=advanced" ) { - setCurrentIndex(TAB_ADVANCED); - } - } - } -} - -void KCMKeyboardWidget::save() -{ - if( rules == NULL ) - return; - - if( actionCollection != NULL ) { - actionCollection->resetLayoutShortcuts(); - actionCollection->clear(); - delete actionCollection; - } - actionCollection = new KeyboardLayoutActionCollection(this, true); - actionCollection->setToggleShortcut(uiWidget->kdeKeySequence->keySequence()); - actionCollection->setLayoutShortcuts(keyboardConfig->layouts, rules); - - //TODO: skip if no change in shortcuts? - KGlobalSettings::emitChange(KGlobalSettings::ShortcutsChanged); -} - -void KCMKeyboardWidget::updateUI() -{ - if( rules == NULL ) - return; - - uiWidget->layoutsTableView->setModel(uiWidget->layoutsTableView->model()); - layoutsTableModel->refresh(); - uiWidget->layoutsTableView->resizeRowsToContents(); - - uiUpdating = true; - updateHardwareUI(); - updateXkbOptionsUI(); - updateSwitcingPolicyUI(); - updateLayoutsUI(); - updateShortcutsUI(); - uiUpdating = false; -} - -void KCMKeyboardWidget::uiChanged() -{ - if( rules == NULL ) - return; - - ((LayoutsTableModel*)uiWidget->layoutsTableView->model())->refresh(); -// this collapses the tree so use more fine-grained updates -// ((LayoutsTableModel*)uiWidget->xkbOptionsTreeView->model())->refresh(); - - if( uiUpdating ) - return; - - keyboardConfig->showIndicator = uiWidget->showIndicatorChk->isChecked(); - keyboardConfig->showSingle = uiWidget->showSingleChk->isChecked(); - - keyboardConfig->configureLayouts = uiWidget->layoutsGroupBox->isChecked(); - keyboardConfig->keyboardModel = uiWidget->keyboardModelComboBox->itemData(uiWidget->keyboardModelComboBox->currentIndex()).toString(); - - if( uiWidget->showFlagRadioBtn->isChecked() ) { - keyboardConfig->indicatorType = KeyboardConfig::SHOW_FLAG; - } - else - if( uiWidget->showLabelRadioBtn->isChecked() ) { - keyboardConfig->indicatorType = KeyboardConfig::SHOW_LABEL; - } - else { -// if( uiWidget->showFlagRadioBtn->isChecked() ) { - keyboardConfig->indicatorType = KeyboardConfig::SHOW_LABEL_ON_FLAG; - } - - keyboardConfig->resetOldXkbOptions = uiWidget->configureKeyboardOptionsChk->isChecked(); - - if( uiWidget->switchByDesktopRadioBtn->isChecked() ) { - keyboardConfig->switchingPolicy = KeyboardConfig::SWITCH_POLICY_DESKTOP; - } - else - if( uiWidget->switchByApplicationRadioBtn->isChecked() ) { - keyboardConfig->switchingPolicy = KeyboardConfig::SWITCH_POLICY_APPLICATION; - } - else - if( uiWidget->switchByWindowRadioBtn->isChecked() ) { - keyboardConfig->switchingPolicy = KeyboardConfig::SWITCH_POLICY_WINDOW; - } - else { - keyboardConfig->switchingPolicy = KeyboardConfig::SWITCH_POLICY_GLOBAL; - } - - updateXkbShortcutsButtons(); - - updateLoopCount(); - int loop = uiWidget->layoutLoopCountSpinBox->text().isEmpty() - ? KeyboardConfig::NO_LOOPING - : uiWidget->layoutLoopCountSpinBox->value(); - keyboardConfig->layoutLoopCount = loop; - - layoutsTableModel->refresh(); - - emit changed(true); -} - -void KCMKeyboardWidget::initializeKeyboardModelUI() -{ - foreach(ModelInfo* modelInfo, rules->modelInfos) { - QString vendor = modelInfo->vendor; - if( vendor.isEmpty() ) { - vendor = i18nc("unknown keyboard model vendor", "Unknown"); - } - uiWidget->keyboardModelComboBox->addItem(i18nc("vendor | keyboard model", "%1 | %2", vendor, modelInfo->description), modelInfo->name); - } - uiWidget->keyboardModelComboBox->model()->sort(0); - connect(uiWidget->keyboardModelComboBox, SIGNAL(activated(int)), this, SLOT(uiChanged())); -} - -void KCMKeyboardWidget::addLayout() -{ - if( keyboardConfig->layouts.count() >= X11Helper::ARTIFICIAL_GROUP_LIMIT_COUNT ) { // artificial limit now - QMessageBox msgBox; - msgBox.setText(i18np("Only up to %1 keyboard layout is supported", "Only up to %1 keyboard layouts are supported", X11Helper::ARTIFICIAL_GROUP_LIMIT_COUNT)); - // more information https://bugs.freedesktop.org/show_bug.cgi?id=19501 - msgBox.exec(); - return; - } - - AddLayoutDialog dialog(rules, keyboardConfig->isFlagShown() ? flags : NULL, keyboardConfig->isLabelShown(), this); - dialog.setModal(true); - if( dialog.exec() == QDialog::Accepted ) { - keyboardConfig->layouts.append( dialog.getSelectedLayoutUnit() ); - layoutsTableModel->refresh(); - uiWidget->layoutsTableView->resizeRowsToContents(); - uiChanged(); - } - - updateLoopCount(); -} - -static -inline int min(int x, int y) { return x < y ? x : y; } - -void KCMKeyboardWidget::updateLoopCount() -{ - int maxLoop = min(X11Helper::MAX_GROUP_COUNT, keyboardConfig->layouts.count() - 1); - uiWidget->layoutLoopCountSpinBox->setMaximum(maxLoop); - - bool layoutsConfigured = uiWidget->layoutsGroupBox->isChecked(); - - if( maxLoop < MIN_LOOPING_COUNT ) { - uiWidget->layoutLoopingCheckBox->setEnabled(false); - uiWidget->layoutLoopingCheckBox->setChecked(false); - } - else if( maxLoop >= X11Helper::MAX_GROUP_COUNT ) { - uiWidget->layoutLoopingCheckBox->setEnabled(false); - uiWidget->layoutLoopingCheckBox->setChecked(true); - } - else { - uiWidget->layoutLoopingCheckBox->setEnabled(layoutsConfigured); - } - - uiWidget->layoutLoopingGroupBox->setEnabled( - layoutsConfigured && uiWidget->layoutLoopingCheckBox->isChecked()); - - if( uiWidget->layoutLoopingCheckBox->isChecked() ) { - if( uiWidget->layoutLoopCountSpinBox->text().isEmpty() ) { - uiWidget->layoutLoopCountSpinBox->setValue(maxLoop); -// keyboardConfig->layoutLoopCount = maxLoop; - } - } - else { - uiWidget->layoutLoopCountSpinBox->clear(); -// keyboardConfig->layoutLoopCount = KeyboardConfig::NO_LOOPING; - } -} - -void KCMKeyboardWidget::initializeLayoutsUI() -{ - layoutsTableModel = new LayoutsTableModel(rules, flags, keyboardConfig, uiWidget->layoutsTableView); - uiWidget->layoutsTableView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed); - uiWidget->layoutsTableView->setModel(layoutsTableModel); - uiWidget->layoutsTableView->setIconSize( flags->getTransparentPixmap().size() ); - - //TODO: do we need to delete this delegate or parent will take care of it? - VariantComboDelegate* variantDelegate = new VariantComboDelegate(keyboardConfig, rules, uiWidget->layoutsTableView); - uiWidget->layoutsTableView->setItemDelegateForColumn(LayoutsTableModel::VARIANT_COLUMN, variantDelegate); - - LabelEditDelegate* labelDelegate = new LabelEditDelegate(keyboardConfig, uiWidget->layoutsTableView); - uiWidget->layoutsTableView->setItemDelegateForColumn(LayoutsTableModel::DISPLAY_NAME_COLUMN, labelDelegate); - - KKeySequenceWidgetDelegate* shortcutDelegate = new KKeySequenceWidgetDelegate(keyboardConfig, uiWidget->layoutsTableView); - uiWidget->layoutsTableView->setItemDelegateForColumn(LayoutsTableModel::SHORTCUT_COLUMN, shortcutDelegate); - - //TODO: is it ok to hardcode sizes? any better approach? - uiWidget->layoutsTableView->setColumnWidth(LayoutsTableModel::MAP_COLUMN, 70); - uiWidget->layoutsTableView->setColumnWidth(LayoutsTableModel::LAYOUT_COLUMN, 200); - uiWidget->layoutsTableView->setColumnWidth(LayoutsTableModel::VARIANT_COLUMN, 200); - uiWidget->layoutsTableView->setColumnWidth(LayoutsTableModel::DISPLAY_NAME_COLUMN, 50); - uiWidget->layoutsTableView->setColumnWidth(LayoutsTableModel::SHORTCUT_COLUMN, 130); - - connect(layoutsTableModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(uiChanged())); - - uiWidget->layoutLoopCountSpinBox->setMinimum(MIN_LOOPING_COUNT); - -#ifdef DRAG_ENABLED - uiWidget->layoutsTableView->setDragEnabled(true); - uiWidget->layoutsTableView->setAcceptDrops(true); -#endif - - uiWidget->moveUpBtn->setIcon(KIcon("arrow-up")); - uiWidget->moveDownBtn->setIcon(KIcon("arrow-down")); - uiWidget->addLayoutBtn->setIcon(KIcon("list-add")); - uiWidget->removeLayoutBtn->setIcon(KIcon("list-remove")); - - KIcon clearIcon = qApp->isLeftToRight() ? KIcon("edit-clear-locationbar-rtl") : KIcon("edit-clear-locationbar-ltr"); - uiWidget->xkbGrpClearBtn->setIcon(clearIcon); - uiWidget->xkb3rdLevelClearBtn->setIcon(clearIcon); - - KIcon configIcon = KIcon("configure"); - uiWidget->xkbGrpShortcutBtn->setIcon(configIcon); - uiWidget->xkb3rdLevelShortcutBtn->setIcon(configIcon); - - uiWidget->kdeKeySequence->setModifierlessAllowed(false); - - connect(uiWidget->addLayoutBtn, SIGNAL(clicked(bool)), this, SLOT(addLayout())); - connect(uiWidget->removeLayoutBtn, SIGNAL(clicked(bool)), this, SLOT(removeLayout())); -// connect(uiWidget->layoutsTable, SIGNAL(itemSelectionChanged()), this, SLOT(layoutSelectionChanged())); - connect(uiWidget->layoutsTableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(layoutSelectionChanged())); - -// connect(uiWidget->moveUpBtn, SIGNAL(triggered(QAction*)), this, SLOT(moveUp())); -// connect(uiWidget->moveDownBtn, SIGNAL(triggered(QAction*)), this, SLOT(moveDown())); - connect(uiWidget->moveUpBtn, SIGNAL(clicked(bool)), this, SLOT(moveUp())); - connect(uiWidget->moveDownBtn, SIGNAL(clicked(bool)), this, SLOT(moveDown())); - - connect(uiWidget->previewbutton,SIGNAL(clicked(bool)),this,SLOT(previewLayout())); - - connect(uiWidget->xkbGrpClearBtn, SIGNAL(clicked(bool)), this, SLOT(clearGroupShortcuts())); - connect(uiWidget->xkb3rdLevelClearBtn, SIGNAL(clicked(bool)), this, SLOT(clear3rdLevelShortcuts())); - -// connect(uiWidget->xkbGrpClearBtn, SIGNAL(triggered(QAction*)), this, SLOT(uiChanged())); -// connect(uiWidget->xkb3rdLevelClearBtn, SIGNAL(triggered(QAction*)), this, SLOT(uiChanged())); - connect(uiWidget->kdeKeySequence, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(uiChanged())); - connect(uiWidget->switchingPolicyButtonGroup, SIGNAL(clicked(int)), this, SLOT(uiChanged())); - - connect(uiWidget->xkbGrpShortcutBtn, SIGNAL(clicked(bool)), this, SLOT(scrollToGroupShortcut())); - connect(uiWidget->xkb3rdLevelShortcutBtn, SIGNAL(clicked(bool)), this, SLOT(scrollTo3rdLevelShortcut())); - - // connect(uiWidget->configureLayoutsChk, SIGNAL(toggled(bool)), uiWidget->layoutsGroupBox, SLOT(setEnabled(bool))); - connect(uiWidget->layoutsGroupBox, SIGNAL(toggled(bool)), this, SLOT(configureLayoutsChanged())); - - connect(uiWidget->showIndicatorChk, SIGNAL(clicked(bool)), this, SLOT(uiChanged())); - connect(uiWidget->showIndicatorChk, SIGNAL(toggled(bool)), uiWidget->showSingleChk, SLOT(setEnabled(bool))); - connect(uiWidget->showFlagRadioBtn, SIGNAL(clicked(bool)), this, SLOT(uiChanged())); - connect(uiWidget->showLabelRadioBtn, SIGNAL(clicked(bool)), this, SLOT(uiChanged())); - connect(uiWidget->showLabelOnFlagRadioBtn, SIGNAL(clicked(bool)), this, SLOT(uiChanged())); - connect(uiWidget->showSingleChk, SIGNAL(toggled(bool)), this, SLOT(uiChanged())); - - connect(uiWidget->layoutLoopingCheckBox, SIGNAL(clicked(bool)), this, SLOT(uiChanged())); - connect(uiWidget->layoutLoopCountSpinBox, SIGNAL(valueChanged(int)), this, SLOT(uiChanged())); -} - -void KCMKeyboardWidget::previewLayout(){ - QMessageBox q; - QModelIndex index = uiWidget->layoutsTableView->currentIndex() ; - QModelIndex idcountry = index.sibling(index.row(),0) ; - QString country=uiWidget->layoutsTableView->model()->data(idcountry).toString(); - QModelIndex idvariant = index.sibling(index.row(),2) ; - QString variant=uiWidget->layoutsTableView->model()->data(idvariant).toString(); - if(index.row()==-1 || index.column()==-1){ - q.setText(i18n("No layout selected ")); - q.exec(); - } - else{ - KeyboardPainter* layoutPreview = new KeyboardPainter(); - const LayoutInfo* layoutInfo = rules->getLayoutInfo(country); - foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) { - if(variant==variantInfo->description){ - variant=variantInfo->name; - break; - } - } - layoutPreview->generateKeyboardLayout(country,variant); - layoutPreview->exec(); - layoutPreview->setModal(true); - } -} - -void KCMKeyboardWidget::configureLayoutsChanged() -{ - if( uiWidget->layoutsGroupBox->isChecked() && keyboardConfig->layouts.isEmpty() ) { - populateWithCurrentLayouts(); - } - uiChanged(); -} - -static QPair getSelectedRowRange(const QModelIndexList& selected) -{ - if( selected.isEmpty() ) { - return QPair(-1, -1); - } - - QList rows; - foreach(const QModelIndex& index, selected) { - rows << index.row(); - } - qSort(rows); - return QPair(rows[0], rows[rows.size()-1]); -} - -void KCMKeyboardWidget::layoutSelectionChanged() -{ - QModelIndexList selected = uiWidget->layoutsTableView->selectionModel()->selectedIndexes(); - uiWidget->removeLayoutBtn->setEnabled( ! selected.isEmpty() ); - QPair rowsRange( getSelectedRowRange(selected) ); - uiWidget->moveUpBtn->setEnabled( ! selected.isEmpty() && rowsRange.first > 0); - uiWidget->previewbutton->setEnabled(! selected.isEmpty()); - uiWidget->moveDownBtn->setEnabled( ! selected.isEmpty() && rowsRange.second < keyboardConfig->layouts.size()-1 ); -} - -void KCMKeyboardWidget::removeLayout() -{ - if( ! uiWidget->layoutsTableView->selectionModel()->hasSelection() ) - return; - - QModelIndexList selected = uiWidget->layoutsTableView->selectionModel()->selectedIndexes(); - QPair rowsRange( getSelectedRowRange(selected) ); - foreach(const QModelIndex& idx, selected) { - if( idx.column() == 0 ) { - keyboardConfig->layouts.removeAt(rowsRange.first); - } - } - layoutsTableModel->refresh(); - uiChanged(); - - if( keyboardConfig->layouts.size() > 0 ) { - int rowToSelect = rowsRange.first; - if( rowToSelect >= keyboardConfig->layouts.size() ) { - rowToSelect--; - } - - QModelIndex topLeft = layoutsTableModel->index(rowToSelect, 0, QModelIndex()); - QModelIndex bottomRight = layoutsTableModel->index(rowToSelect, layoutsTableModel->columnCount(topLeft)-1, QModelIndex()); - QItemSelection selection(topLeft, bottomRight); - uiWidget->layoutsTableView->selectionModel()->select(selection, QItemSelectionModel::SelectCurrent); - uiWidget->layoutsTableView->setFocus(); - } - - layoutSelectionChanged(); - - updateLoopCount(); -} - -void KCMKeyboardWidget::moveUp() -{ - moveSelectedLayouts(-1); -} - -void KCMKeyboardWidget::moveDown() -{ - moveSelectedLayouts(1); -} - -void KCMKeyboardWidget::moveSelectedLayouts(int shift) -{ - QItemSelectionModel* selectionModel = uiWidget->layoutsTableView->selectionModel(); - if( selectionModel == NULL || !selectionModel->hasSelection() ) - return; - - QModelIndexList selected = selectionModel->selectedRows(); - if( selected.count() < 1 ) - return; - - int newFirstRow = selected[0].row() + shift; - int newLastRow = selected[ selected.size()-1 ].row() + shift; - - if( newFirstRow >= 0 && newLastRow <= keyboardConfig->layouts.size() - 1 ) { - QList selectionRows; - foreach(const QModelIndex& index, selected) { - int newRowIndex = index.row() + shift; - keyboardConfig->layouts.move(index.row(), newRowIndex); - selectionRows << newRowIndex; - } - uiChanged(); - - QItemSelection selection; - foreach(int row, selectionRows) { - QModelIndex topLeft = layoutsTableModel->index(row, 0, QModelIndex()); - QModelIndex bottomRight = layoutsTableModel->index(row, layoutsTableModel->columnCount(topLeft)-1, QModelIndex()); - selection << QItemSelectionRange(topLeft, bottomRight); - } - uiWidget->layoutsTableView->selectionModel()->select(selection, QItemSelectionModel::SelectCurrent); - uiWidget->layoutsTableView->setFocus(); - } -} - -void KCMKeyboardWidget::scrollToGroupShortcut() -{ - this->setCurrentIndex(TAB_ADVANCED); - if( ! uiWidget->configureKeyboardOptionsChk->isChecked() ) { - uiWidget->configureKeyboardOptionsChk->setChecked(true); - } - ((XkbOptionsTreeModel*)uiWidget->xkbOptionsTreeView->model())->gotoGroup(GROUP_SWITCH_GROUP_NAME, uiWidget->xkbOptionsTreeView); -} - -void KCMKeyboardWidget::scrollTo3rdLevelShortcut() -{ - this->setCurrentIndex(TAB_ADVANCED); - if( ! uiWidget->configureKeyboardOptionsChk->isChecked() ) { - uiWidget->configureKeyboardOptionsChk->setChecked(true); - } - ((XkbOptionsTreeModel*)uiWidget->xkbOptionsTreeView->model())->gotoGroup(LV3_SWITCH_GROUP_NAME, uiWidget->xkbOptionsTreeView); -} - -void KCMKeyboardWidget::clearGroupShortcuts() -{ - clearXkbGroup(GROUP_SWITCH_GROUP_NAME); -} - -void KCMKeyboardWidget::clear3rdLevelShortcuts() -{ - clearXkbGroup(LV3_SWITCH_GROUP_NAME); -} - -void KCMKeyboardWidget::clearXkbGroup(const QString& groupName) -{ - for(int ii=keyboardConfig->xkbOptions.count()-1; ii>=0; ii--) { - if( keyboardConfig->xkbOptions[ii].startsWith(groupName + Rules::XKB_OPTION_GROUP_SEPARATOR) ) { - keyboardConfig->xkbOptions.removeAt(ii); - } - } - ((XkbOptionsTreeModel*)uiWidget->xkbOptionsTreeView->model())->reset(); - uiWidget->xkbOptionsTreeView->update(); - updateXkbShortcutsButtons(); - emit changed(true); -} - -static -bool xkbOptionGroupLessThan(const OptionGroupInfo* og1, const OptionGroupInfo* og2) -{ - return og1->description.toLower() < og2->description.toLower(); -} -static -bool xkbOptionLessThan(const OptionInfo* o1, const OptionInfo* o2) -{ - return o1->description.toLower() < o2->description.toLower(); -} - -void KCMKeyboardWidget::initializeXkbOptionsUI() -{ - qSort(rules->optionGroupInfos.begin(), rules->optionGroupInfos.end(), xkbOptionGroupLessThan); - foreach(OptionGroupInfo* optionGroupInfo, rules->optionGroupInfos) { - qSort(optionGroupInfo->optionInfos.begin(), optionGroupInfo->optionInfos.end(), xkbOptionLessThan); - } - - XkbOptionsTreeModel* model = new XkbOptionsTreeModel(rules, keyboardConfig, uiWidget->xkbOptionsTreeView); - uiWidget->xkbOptionsTreeView->setModel(model); - connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(uiChanged())); - - connect(uiWidget->configureKeyboardOptionsChk, SIGNAL(toggled(bool)), this, SLOT(configureXkbOptionsChanged())); - // connect(uiWidget->configureKeyboardOptionsChk, SIGNAL(toggled(bool)), this, SLOT(uiChanged())); - connect(uiWidget->configureKeyboardOptionsChk, SIGNAL(toggled(bool)), uiWidget->xkbOptionsTreeView, SLOT(setEnabled(bool))); -} - -void KCMKeyboardWidget::configureXkbOptionsChanged() -{ - if( uiWidget->configureKeyboardOptionsChk->isChecked() && keyboardConfig->xkbOptions.isEmpty() ) { - populateWithCurrentXkbOptions(); - } - ((LayoutsTableModel*)uiWidget->xkbOptionsTreeView->model())->refresh(); - uiChanged(); -} - -void KCMKeyboardWidget::updateSwitcingPolicyUI() -{ - switch (keyboardConfig->switchingPolicy){ - case KeyboardConfig::SWITCH_POLICY_DESKTOP: - uiWidget->switchByDesktopRadioBtn->setChecked(true); - break; - case KeyboardConfig::SWITCH_POLICY_APPLICATION: - uiWidget->switchByApplicationRadioBtn->setChecked(true); - break; - case KeyboardConfig::SWITCH_POLICY_WINDOW: - uiWidget->switchByWindowRadioBtn->setChecked(true); - break; - default: - case KeyboardConfig::SWITCH_POLICY_GLOBAL: - uiWidget->switchByGlobalRadioBtn->setChecked(true); - } -} - -void KCMKeyboardWidget::updateXkbShortcutButton(const QString& groupName, QPushButton* button) -{ - QStringList grpOptions; - if( keyboardConfig->resetOldXkbOptions ) { - QRegExp regexp = QRegExp("^" + groupName + Rules::XKB_OPTION_GROUP_SEPARATOR); - grpOptions = keyboardConfig->xkbOptions.filter(regexp); - } - switch( grpOptions.size() ) { - case 0: - button->setText(i18nc("no shortcuts defined", "None")); - break; - case 1: { - const QString& option = grpOptions.first(); - const OptionGroupInfo* optionGroupInfo = rules->getOptionGroupInfo(groupName); - const OptionInfo* optionInfo = optionGroupInfo->getOptionInfo(option); - if( optionInfo == NULL || optionInfo->description == NULL ) { - kError() << "Could not find option info for " << option; - button->setText(grpOptions.first()); - } - else { - button->setText(optionInfo->description); - } - } - break; - default: - button->setText(i18np("%1 shortcut", "%1 shortcuts", grpOptions.size())); - } -} - -void KCMKeyboardWidget::updateXkbShortcutsButtons() -{ - updateXkbShortcutButton(GROUP_SWITCH_GROUP_NAME, uiWidget->xkbGrpShortcutBtn); - updateXkbShortcutButton(LV3_SWITCH_GROUP_NAME, uiWidget->xkb3rdLevelShortcutBtn); -} - -void KCMKeyboardWidget::updateShortcutsUI() -{ - updateXkbShortcutsButtons(); - - delete actionCollection; - actionCollection = new KeyboardLayoutActionCollection(this, true); - KAction* toggleAction = actionCollection->getToggeAction(); - uiWidget->kdeKeySequence->setKeySequence(toggleAction->globalShortcut().primary()); - actionCollection->loadLayoutShortcuts(keyboardConfig->layouts, rules); - layoutsTableModel->refresh(); -} - -void KCMKeyboardWidget::updateXkbOptionsUI() -{ - uiWidget->configureKeyboardOptionsChk->setChecked(keyboardConfig->resetOldXkbOptions); -} - -void KCMKeyboardWidget::updateLayoutsUI() { - uiWidget->layoutsGroupBox->setChecked(keyboardConfig->configureLayouts); - uiWidget->showIndicatorChk->setChecked(keyboardConfig->showIndicator); - uiWidget->showSingleChk->setChecked(keyboardConfig->showSingle); - uiWidget->showFlagRadioBtn->setChecked(keyboardConfig->indicatorType == KeyboardConfig::SHOW_FLAG); - uiWidget->showLabelRadioBtn->setChecked(keyboardConfig->indicatorType == KeyboardConfig::SHOW_LABEL); - uiWidget->showLabelOnFlagRadioBtn->setChecked(keyboardConfig->indicatorType == KeyboardConfig::SHOW_LABEL_ON_FLAG); - - bool loopingOn = keyboardConfig->configureLayouts && keyboardConfig->layoutLoopCount - != KeyboardConfig::NO_LOOPING; - uiWidget->layoutLoopingCheckBox->setChecked(loopingOn); - uiWidget->layoutLoopingGroupBox->setEnabled(loopingOn); - if( loopingOn ) { - uiWidget->layoutLoopCountSpinBox->setValue(keyboardConfig->layoutLoopCount); - } - else { - uiWidget->layoutLoopCountSpinBox->clear(); - } -} - -void KCMKeyboardWidget::updateHardwareUI() -{ - int idx = uiWidget->keyboardModelComboBox->findData(keyboardConfig->keyboardModel); - if( idx != -1 ) { - uiWidget->keyboardModelComboBox->setCurrentIndex(idx); - } -} - -void KCMKeyboardWidget::populateWithCurrentLayouts() -{ - QList layouts = X11Helper::getLayoutsList(); - foreach(LayoutUnit layoutUnit, layouts) { - keyboardConfig->layouts.append(layoutUnit); - } -} - -void KCMKeyboardWidget::populateWithCurrentXkbOptions() -{ - XkbConfig xkbConfig; - if( X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::ALL) ) { - foreach(QString xkbOption, xkbConfig.options) { - keyboardConfig->xkbOptions.append(xkbOption); - } - } -} diff --git a/kcontrol/keyboard/kcm_keyboard_widget.h b/kcontrol/keyboard/kcm_keyboard_widget.h deleted file mode 100644 index 39b77f2a..00000000 --- a/kcontrol/keyboard/kcm_keyboard_widget.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KCM_KEYBOARD_WIDGET_H_ -#define KCM_KEYBOARD_WIDGET_H_ - -#include "ui_kcm_keyboard.h" - -#include -#include - -#include -class KeyboardConfig; -class Rules; -class Flags; -class KComponentData; -#include -#include -class LayoutsTableModel; -class KCMiscKeyboardWidget; -class KeyboardLayoutActionCollection; - -class KCMKeyboardWidget: public QTabWidget -{ - Q_OBJECT - -public: - KCMKeyboardWidget(Rules* rules, KeyboardConfig* keyboardConfig, - const KComponentData componentData, const QVariantList &args, QWidget* parent=0); - virtual ~KCMKeyboardWidget(); - - void updateUI(); - void save(); - - //temp hack - KCMiscKeyboardWidget* getKcmMiscWidget() const { return kcmMiscWidget; } - -Q_SIGNALS: - void changed(bool state); - -private Q_SLOTS: - void addLayout(); - void removeLayout(); - void layoutSelectionChanged(); - void uiChanged(); - void scrollToGroupShortcut(); - void scrollTo3rdLevelShortcut(); - void clearGroupShortcuts(); - void clear3rdLevelShortcuts(); - void updateXkbShortcutsButtons(); - void moveUp(); - void moveDown(); - void configureLayoutsChanged(); - void configureXkbOptionsChanged(); - void previewLayout(); - -private: - Rules *rules; - Flags *flags; - Ui::TabWidget *uiWidget; - KeyboardConfig *keyboardConfig; - const KComponentData componentData; - KeyboardLayoutActionCollection* actionCollection; - LayoutsTableModel* layoutsTableModel; - KCMiscKeyboardWidget* kcmMiscWidget; - bool uiUpdating; - - void initializeLayoutsUI(); - void initializeXkbOptionsUI(); - void initializeKeyboardModelUI(); - void updateHardwareUI(); - void updateLayoutsUI(); - void updateShortcutsUI(); - void updateXkbOptionsUI(); - void updateSwitcingPolicyUI(); - void updateXkbShortcutButton(const QString& groupName, QPushButton* button); - void clearXkbGroup(const QString& groupName); - void moveSelectedLayouts(int shift); - void populateWithCurrentLayouts(); - void populateWithCurrentXkbOptions(); - void updateLoopCount(); - void handleParameters(const QVariantList &args); -}; - - -#endif /* KCM_KEYBOARD_WIDGET_H_ */ diff --git a/kcontrol/keyboard/kcm_view_models.cpp b/kcontrol/keyboard/kcm_view_models.cpp deleted file mode 100644 index ad2aeb66..00000000 --- a/kcontrol/keyboard/kcm_view_models.cpp +++ /dev/null @@ -1,504 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kcm_view_models.h" - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef DRAG_ENABLED -#include -#endif - -#include "keyboard_config.h" -#include "xkb_rules.h" -#include "flags.h" -#include "x11_helper.h" -#include "bindings.h" - -const int LayoutsTableModel::MAP_COLUMN = 0; -const int LayoutsTableModel::LAYOUT_COLUMN = 1; -const int LayoutsTableModel::VARIANT_COLUMN = 2; -const int LayoutsTableModel::DISPLAY_NAME_COLUMN = 3; -const int LayoutsTableModel::SHORTCUT_COLUMN = 4; -static const int COLUMN_COUNT = 5; - -LayoutsTableModel::LayoutsTableModel(Rules* rules_, Flags *flags_, KeyboardConfig* keyboardConfig_, QObject* parent): - QAbstractTableModel(parent), - keyboardConfig(keyboardConfig_), - rules(rules_), - countryFlags(flags_) -{ -} - -void LayoutsTableModel::refresh() -{ - beginResetModel(); - endResetModel(); -} - -int LayoutsTableModel::rowCount(const QModelIndex &/*parent*/) const -{ - return keyboardConfig->layouts.count(); -} - -int LayoutsTableModel::columnCount(const QModelIndex&) const -{ - return COLUMN_COUNT; -} - -Qt::ItemFlags LayoutsTableModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return 0; - - Qt::ItemFlags flags = QAbstractTableModel::flags(index); - - if( index.column() == DISPLAY_NAME_COLUMN - || index.column() == VARIANT_COLUMN - || index.column() == SHORTCUT_COLUMN ) { - flags |= Qt::ItemIsEditable; - } - -#ifdef DRAG_ENABLED - flags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; -#endif - - return flags; -} - -#ifdef DRAG_ENABLED -QStringList LayoutsTableModel::mimeTypes() const -{ - QStringList types; - types << "application/keyboard-layout-item"; - return types; -} - -QMimeData *LayoutsTableModel::mimeData(const QModelIndexList &indexes) const - { - QMimeData *mimeData = new QMimeData(); - QByteArray encodedData; - - QDataStream stream(&encodedData, QIODevice::WriteOnly); - - QSet rows; - foreach (const QModelIndex& index, indexes) { - if (index.isValid()) { - rows << index.row(); - } - } - foreach (int row, rows) { - stream << row; - } - - mimeData->setData("application/keyboard-layout-item", encodedData); - return mimeData; -} -#endif - -QVariant LayoutsTableModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() >= keyboardConfig->layouts.size()) - return QVariant(); - - const LayoutUnit& layoutUnit = keyboardConfig->layouts.at(index.row()); - - if (role == Qt::DecorationRole) { - switch( index.column() ) { - case DISPLAY_NAME_COLUMN: { -// if( keyboardConfig->isFlagShown() ) { - QIcon icon = countryFlags->getIconWithText(layoutUnit, *keyboardConfig); - return icon.isNull() ? countryFlags->getTransparentPixmap() : icon; -// } - } -//TODO: show the cells are editable -// case VARIANT_COLUMN: { -// case DISPLAY_NAME_COLUMN: { -// int sz = 5; -// QPixmap pm = QPixmap(sz, sz+5); -// pm.fill(Qt::transparent); -// QPainter p(&pm); -// QPoint points[] = { QPoint(0, 0), QPoint(0, sz), QPoint(sz, 0) }; -// p.drawPolygon(points, 3); -// return pm; -// } - break; - } - } - else - if( role == Qt::BackgroundRole ) { - if( keyboardConfig->layoutLoopCount != KeyboardConfig::NO_LOOPING - && index.row() >= keyboardConfig->layoutLoopCount ) { - return QBrush(Qt::lightGray); - } - } - else - if (role == Qt::DisplayRole) { - switch( index.column() ) { - case MAP_COLUMN: - return layoutUnit.layout; - break; - case LAYOUT_COLUMN: { - const LayoutInfo* layoutInfo = rules->getLayoutInfo(layoutUnit.layout); - return layoutInfo != NULL ? layoutInfo->description : layoutUnit.layout; - } - case VARIANT_COLUMN: { - if( layoutUnit.variant.isEmpty() ) - return QVariant(); - const LayoutInfo* layoutInfo = rules->getLayoutInfo(layoutUnit.layout); - if( layoutInfo == NULL ) - return QVariant(); - const VariantInfo* variantInfo = layoutInfo->getVariantInfo(layoutUnit.variant); - return variantInfo != NULL ? variantInfo->description : layoutUnit.variant; - } - break; - case DISPLAY_NAME_COLUMN: -// if( keyboardConfig->indicatorType == KeyboardConfig::SHOW_LABEL ) { -// return layoutUnit.getDisplayName(); -// } - break; - case SHORTCUT_COLUMN: { - return layoutUnit.getShortcut().toString(); - } - break; - } - } - else if (role==Qt::EditRole ) { - switch( index.column() ) { - case DISPLAY_NAME_COLUMN: - return layoutUnit.getDisplayName(); - break; - case VARIANT_COLUMN: - return layoutUnit.variant; - break; - case SHORTCUT_COLUMN: - return layoutUnit.getShortcut().toString(); - break; - default:; - } - } - else if( role == Qt::TextAlignmentRole ) { - switch( index.column() ) { - case MAP_COLUMN: - case DISPLAY_NAME_COLUMN: - case SHORTCUT_COLUMN: - return Qt::AlignCenter; - break; - default:; - } - } - return QVariant(); -} - -QVariant LayoutsTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Horizontal) { - const QString headers[] = {i18nc("layout map name", "Map"), i18n("Layout"), i18n("Variant"), i18n("Label"), i18n("Shortcut")}; - return headers[section]; - } - - return QVariant(); -} - -bool LayoutsTableModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (role != Qt::EditRole - || (index.column() != DISPLAY_NAME_COLUMN && index.column() != VARIANT_COLUMN && index.column() != SHORTCUT_COLUMN) ) - return false; - - if (index.row() >= keyboardConfig->layouts.size()) - return false; - - LayoutUnit& layoutUnit = keyboardConfig->layouts[index.row()]; - - switch( index.column() ) { - case DISPLAY_NAME_COLUMN: { - QString displayText = value.toString().left(3); - layoutUnit.setDisplayName(displayText); - countryFlags->clearCache(); // regenerate the label - } - break; - case VARIANT_COLUMN: { - QString variant = value.toString(); - layoutUnit.variant = variant; - } - break; - case SHORTCUT_COLUMN: { - QString shortcut = value.toString(); - layoutUnit.setShortcut(QKeySequence(shortcut)); - } - break; - } - emit dataChanged(index, index); - - return true; -} - -// -// LabelEditDelegate -// -LabelEditDelegate::LabelEditDelegate(const KeyboardConfig* keyboardConfig_, QObject *parent): - QStyledItemDelegate(parent), - keyboardConfig(keyboardConfig_) -{} - -QWidget *LabelEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & option , - const QModelIndex & index ) const -{ - if( keyboardConfig->indicatorType == KeyboardConfig::SHOW_FLAG ) - return NULL; - - QWidget* widget = QStyledItemDelegate::createEditor(parent, option, index); - QLineEdit* lineEdit = static_cast(widget); - if( lineEdit != NULL ) { - lineEdit->setMaxLength(LayoutUnit::MAX_LABEL_LENGTH); - } - return widget; -} - -//void LabelEditDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const -//{ -// QStyleOptionViewItem option2(option); -//// option2.decorationPosition = QStyleOptionViewItem::Right; -// option2.decorationAlignment = Qt::AlignHCenter | Qt::AlignVCenter; -// QStyledItemDelegate::paint(painter, option2, index); -//} - - -// -// VariantComboDelegate -// -//TODO: reuse this function in kcm_add_layout_dialog.cpp -static void populateComboWithVariants(QComboBox* combo, const QString& layout, const Rules* rules) -{ - combo->clear(); - const LayoutInfo* layoutInfo = rules->getLayoutInfo(layout); - foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) { - combo->addItem(variantInfo->description, variantInfo->name); - } - combo->model()->sort(0); - combo->insertItem(0, i18nc("variant", "Default"), ""); - combo->setCurrentIndex(0); -} - -VariantComboDelegate::VariantComboDelegate(const KeyboardConfig* keyboardConfig_, const Rules* rules_, QObject *parent): - QStyledItemDelegate(parent), - keyboardConfig(keyboardConfig_), - rules(rules_) -{} - -QWidget *VariantComboDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, - const QModelIndex & index ) const -{ - QComboBox *editor = new QComboBox(parent); - const LayoutUnit& layoutUnit = keyboardConfig->layouts[index.row()]; - populateComboWithVariants(editor, layoutUnit.layout, rules); - return editor; -} - -void VariantComboDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const -{ - QComboBox *combo = static_cast(editor); - QString variant = index.model()->data(index, Qt::EditRole).toString(); - int itemIndex = combo->findData(variant); - if( itemIndex == -1 ) { - itemIndex = 0; - } - combo->setCurrentIndex(itemIndex); -} - -void VariantComboDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - QComboBox *combo = static_cast(editor); - QString variant = combo->itemData(combo->currentIndex()).toString(); - model->setData(index, variant, Qt::EditRole); -} - -void VariantComboDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &/* index */) const -{ - editor->setGeometry(option.rect); -} - -// -// KKeySequenceWidgetDelegate -// -KKeySequenceWidgetDelegate::KKeySequenceWidgetDelegate(const KeyboardConfig* keyboardConfig_, QObject *parent): - QStyledItemDelegate(parent), - keyboardConfig(keyboardConfig_) -{} - -QWidget *KKeySequenceWidgetDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /*option*/, - const QModelIndex & index ) const -{ - itemsBeingEdited.insert(index); - - KKeySequenceWidget *editor = new KKeySequenceWidget(parent); - editor->setFocusPolicy(Qt::StrongFocus); - editor->setModifierlessAllowed(false); - - const LayoutUnit& layoutUnit = keyboardConfig->layouts[index.row()]; - editor->setKeySequence(layoutUnit.getShortcut()); - - editor->captureKeySequence(); - - return editor; -} - -//void KKeySequenceWidgetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const -//{ -// KKeySequenceWidget *kkeysequencewidget = static_cast(editor); -// QString shortcut = index.model()->data(index, Qt::EditRole).toString(); -// kkeysequencewidget->setKeySequence(QKeySequence(shortcut)); -// kkeysequencewidget->captureKeySequence(); -//// kDebug() << "set editor data"; -//} - -void KKeySequenceWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - KKeySequenceWidget *kkeysequencewidget = static_cast(editor); - QString shortcut = kkeysequencewidget->keySequence().toString(); - model->setData(index, shortcut, Qt::EditRole); - itemsBeingEdited.remove(index); -} - -void KKeySequenceWidgetDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ - if (itemsBeingEdited.contains(index)) { -// StyledBackgroundPainter::drawBackground(painter,option,index); - } - else { - QStyledItemDelegate::paint(painter,option,index); - } -} -// -// Xkb Options Tree View -// - -int XkbOptionsTreeModel::rowCount(const QModelIndex& parent) const { - if( ! parent.isValid() ) - return rules->optionGroupInfos.count(); - if( ! parent.parent().isValid() ) - return rules->optionGroupInfos[parent.row()]->optionInfos.count(); - return 0; -} - -QVariant XkbOptionsTreeModel::data(const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - int row = index.row(); - - if (role == Qt::DisplayRole) { - if( ! index.parent().isValid() ) { - return rules->optionGroupInfos[row]->description; - } - else { - int groupRow = index.parent().row(); - const OptionGroupInfo* xkbGroup = rules->optionGroupInfos[groupRow]; - return xkbGroup->optionInfos[row]->description; - } - } - else if (role==Qt::CheckStateRole ) { - if( index.parent().isValid() ) { - int groupRow = index.parent().row(); - const OptionGroupInfo* xkbGroup = rules->optionGroupInfos[groupRow]; - const QString& xkbOptionName = xkbGroup->optionInfos[row]->name; - return keyboardConfig->xkbOptions.indexOf(xkbOptionName) == -1 - ? Qt::Unchecked : Qt::Checked; - } - else { - int groupRow = index.row(); - const OptionGroupInfo* xkbGroup = rules->optionGroupInfos[groupRow]; - foreach(const OptionInfo* optionInfo, xkbGroup->optionInfos) { - if( keyboardConfig->xkbOptions.indexOf(optionInfo->name) != -1 ) - return Qt::PartiallyChecked; - } - return Qt::Unchecked; - } - } - return QVariant(); -} - -bool XkbOptionsTreeModel::setData(const QModelIndex & index, const QVariant & value, int role) { - int groupRow = index.parent().row(); - if( groupRow < 0 ) return false; - - const OptionGroupInfo* xkbGroup = rules->optionGroupInfos[groupRow]; - const OptionInfo* option = xkbGroup->optionInfos[index.row()]; - - if( value.toInt() == Qt::Checked ) { - if( xkbGroup->exclusive ) { - // clear if exclusive (TODO: radiobutton) - int idx = keyboardConfig->xkbOptions.indexOf(QRegExp(xkbGroup->name + ".*")); - if( idx >= 0 ) { - for(int i=0; ioptionInfos.count(); i++) - if( xkbGroup->optionInfos[i]->name == keyboardConfig->xkbOptions[idx] ) { - setData(createIndex(i, index.column(), (quint32)index.internalId()-index.row()+i), Qt::Unchecked, role); - break; - } - // m_kxkbConfig->m_options.removeAt(idx); - // idx = m_kxkbConfig->m_options.indexOf(QRegExp(xkbGroupNm+".*")); - } - } - if( keyboardConfig->xkbOptions.indexOf(option->name) < 0 ) { - keyboardConfig->xkbOptions.append(option->name); - } - } - else { - keyboardConfig->xkbOptions.removeAll(option->name); - } - - emit dataChanged(index, index); - emit dataChanged(index.parent(), index.parent()); - return true; -} - -void XkbOptionsTreeModel::gotoGroup(const QString& groupName, QTreeView* view) { - const OptionGroupInfo* optionGroupInfo = rules->getOptionGroupInfo(groupName); - int index = rules->optionGroupInfos.indexOf((OptionGroupInfo*)optionGroupInfo); - if( index != -1 ) { - QModelIndex modelIdx = createIndex(index,0); -// view->selectionModel()->setCurrentIndex(createIndex(index,0), QItemSelectionModel::NoUpdate); - view->setExpanded(modelIdx, true); - view->scrollTo(modelIdx, QAbstractItemView::PositionAtTop); - view->selectionModel()->setCurrentIndex(modelIdx, QItemSelectionModel::Current); - view->setFocus(Qt::OtherFocusReason); - } -// else { -// kDebug() << "can't scroll to group" << group; -// } -} - diff --git a/kcontrol/keyboard/kcm_view_models.h b/kcontrol/keyboard/kcm_view_models.h deleted file mode 100644 index d30c7a01..00000000 --- a/kcontrol/keyboard/kcm_view_models.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KCM_VIEW_MODELS_H_ -#define KCM_VIEW_MODELS_H_ - -#include -#include -#include -#include - -#include -class KeyboardConfig; -class Rules; -class Flags; -class KeyboardLayoutActionCollection; - -class LayoutsTableModel : public QAbstractTableModel -{ - Q_OBJECT - - public: - LayoutsTableModel(Rules* rules, Flags *flags, KeyboardConfig* keyboardConfig, QObject *parent = 0); - - int columnCount(const QModelIndex&) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); -#ifdef DRAG_ENABLED - Qt::DropActions supportedDropActions() const { - return Qt::MoveAction; - } - QStringList mimeTypes() const; - QMimeData *mimeData(const QModelIndexList &indexes) const; -#endif - void refresh(); - - static const int MAP_COLUMN; - static const int LAYOUT_COLUMN; - static const int VARIANT_COLUMN; - static const int DISPLAY_NAME_COLUMN; - static const int SHORTCUT_COLUMN; - - private: - KeyboardConfig* keyboardConfig; - const Rules *rules; - Flags *countryFlags; -}; - -class LabelEditDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - explicit LabelEditDelegate(const KeyboardConfig* keyboardConfig, QObject *parent = 0); - - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - -// void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - const KeyboardConfig* keyboardConfig; -}; - -class VariantComboDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - VariantComboDelegate(const KeyboardConfig* keyboardConfig, const Rules* rules, QObject *parent = 0); - - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; - - void updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - const KeyboardConfig* keyboardConfig; - const Rules* rules; -}; - -class KKeySequenceWidgetDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - KKeySequenceWidgetDelegate(const KeyboardConfig* keyboardConfig_, QObject *parent = 0); - - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; -// void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; - void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - -private: - const KeyboardConfig* keyboardConfig; - mutable QSet itemsBeingEdited; -}; - - -class XkbOptionsTreeModel: public QAbstractItemModel -{ -public: - XkbOptionsTreeModel(Rules* rules_, KeyboardConfig* keyboardConfig_, QObject *parent) - : QAbstractItemModel(parent), - keyboardConfig(keyboardConfig_), - rules(rules_) { } - - int columnCount(const QModelIndex& /*parent*/) const { return 1; } - int rowCount(const QModelIndex& parent) const; - QModelIndex parent(const QModelIndex& index) const { - if (!index.isValid() ) - return QModelIndex(); - if( index.internalId() < 100 ) - return QModelIndex(); - return createIndex(((index.internalId() - index.row())/100) - 1, index.column()); - } - QModelIndex index(int row, int column, const QModelIndex& parent) const { - if(!parent.isValid()) return createIndex(row, column); - return createIndex(row, column, (100 * (parent.row()+1)) + row); - } - Qt::ItemFlags flags ( const QModelIndex & index ) const { - if( ! index.isValid() ) - return 0; - - if( !index.parent().isValid() ) - return Qt::ItemIsEnabled; - - return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; - } - - bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); - QVariant data(const QModelIndex& index, int role) const; - void reset() { QAbstractItemModel::reset(); } - void gotoGroup(const QString& group, QTreeView* view); - -private: - KeyboardConfig* keyboardConfig; - Rules *rules; -}; - -#endif /* KCM_VIEW_MODELS_H_ */ diff --git a/kcontrol/keyboard/kcmmisc.cpp b/kcontrol/keyboard/kcmmisc.cpp deleted file mode 100644 index ffba3bb9..00000000 --- a/kcontrol/keyboard/kcmmisc.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * kcmmisc.cpp - * - * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca - * - * Layout management, cleanups: - * Copyright (c) 1999 Dirk A. Mueller - * - * Requires the Qt widget libraries, available at no cost at - * http://www.troll.no/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kcmmisc.h" -#include "ui_kcmmiscwidget.h" - -#include - -#include -#include -#include - -#include -#include -#include - -#include - - -KCMiscKeyboardWidget::KCMiscKeyboardWidget(QWidget *parent) - : QWidget(parent), - ui(*new Ui_KeyboardConfigWidget) -{ - ui.setupUi(this); - - ui.delay->setRange(100, 5000, 50); - ui.delay->setSliderEnabled(false); - ui.rate->setRange(0.2, 50, 5, false); - - sliderMax = (int)floor (0.5 + 2*(log(5000.0L)-log(100.0L)) / (log(5000.0L)-log(4999.0L))); - ui.delaySlider->setRange(0, sliderMax); - ui.delaySlider->setSingleStep(sliderMax/100); - ui.delaySlider->setPageStep(sliderMax/10); - ui.delaySlider->setTickInterval(sliderMax/10); - - ui.rateSlider->setRange(20, 5000); - ui.rateSlider->setSingleStep(30); - ui.rateSlider->setPageStep(500); - ui.rateSlider->setTickInterval(498); - - connect(ui.keyboardRepeatButtonGroup, SIGNAL(clicked()), this, SLOT(changed())); - connect(ui.keyboardRepeatButtonGroup, SIGNAL(changed(int)), this, SLOT(keyboardRepeatStateChanged(int))); - connect(ui.delay, SIGNAL(valueChanged(int)), this, SLOT(delaySpinboxChanged(int))); - connect(ui.delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delaySliderChanged(int))); - connect(ui.rate, SIGNAL(valueChanged(double)), this, SLOT(rateSpinboxChanged(double))); - connect(ui.rateSlider, SIGNAL(valueChanged(int)), this, SLOT(rateSliderChanged(int))); - - connect(ui.click, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(ui.numlockButtonGroup, SIGNAL(released(int)), this, SLOT(changed())); - -// Not sure why we need this - if XKB is not found the whole keyboard module won't be compiled -//#if !defined(HAVE_XTEST) && !defined(HAVE_XKB) -// ui.numlockButtonGroup->setDisabled( true ); -//#endif -//#if !defined(HAVE_XKB) && !defined(HAVE_XF86MISC) -// ui.delay->setDisabled( true ); -// ui.rate->setDisabled( true ); -//#endif -} - -KCMiscKeyboardWidget::~KCMiscKeyboardWidget() -{ - delete &ui; -} - -int KCMiscKeyboardWidget::getClick() -{ - return ui.click->value(); -} - -// set the slider and LCD values -void KCMiscKeyboardWidget::setRepeat(TriState keyboardRepeat, int delay_, double rate_) -{ - TriStateHelper::setTriState( ui.keyboardRepeatButtonGroup, keyboardRepeat ); -// ui.repeatBox->setChecked(r == AutoRepeatModeOn); - ui.delay->setValue(delay_); - ui.rate->setValue(rate_); - delaySpinboxChanged(delay_); - rateSpinboxChanged(rate_); -} - -void KCMiscKeyboardWidget::setClickVolume(int v) -{ - ui.click->setValue(v); -} - -TriState TriStateHelper::getTriState(const KButtonGroup* group) -{ - int selected = group->selected(); - return selected < 0 ? STATE_UNCHANGED : getTriState(selected); -} - -void TriStateHelper::setTriState(KButtonGroup* group, TriState state) -{ - group->setSelected( getInt(state) ); -} - -void KCMiscKeyboardWidget::load() -{ - KConfigGroup config(KSharedConfig::openConfig("kcminputrc", KConfig::NoGlobals), "Keyboard"); - - ui.delay->blockSignals(true); - ui.rate->blockSignals(true); - ui.click->blockSignals(true); - - // need to read as string to support old "true/false" parameter - QString key = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON)); - if( key == "true" || key == TriStateHelper::getString(STATE_ON)) { - keyboardRepeat = STATE_ON; - } - else if( key == "false" || key == TriStateHelper::getString(STATE_OFF)) { - keyboardRepeat = STATE_OFF; - } - else { - keyboardRepeat = STATE_UNCHANGED; - } - -// keyboardRepeat = (key ? AutoRepeatModeOn : AutoRepeatModeOff); - float delay = config.readEntry( "RepeatDelay", 660 ); - float rate = config.readEntry( "RepeatRate", 25. ); - setRepeat(keyboardRepeat, delay, rate); - - XKeyboardState kbd; - XGetKeyboardControl(QX11Info::display(), &kbd); - - clickVolume = config.readEntry("ClickVolume", kbd.key_click_percent); - setClickVolume(clickVolume); - // setRepeat(kbd.global_auto_repeat, ui.delay->value(), ui.rate->value()); - - numlockState = TriStateHelper::getTriState(config.readEntry( "NumLock", TriStateHelper::getInt(STATE_UNCHANGED) )); - TriStateHelper::setTriState( ui.numlockButtonGroup, numlockState ); - - ui.delay->blockSignals(false); - ui.rate->blockSignals(false); - ui.click->blockSignals(false); -} - -void KCMiscKeyboardWidget::save() -{ - KConfigGroup config(KSharedConfig::openConfig("kcminputrc", KConfig::NoGlobals), "Keyboard"); - - clickVolume = getClick(); - keyboardRepeat = TriStateHelper::getTriState(ui.keyboardRepeatButtonGroup); - numlockState = TriStateHelper::getTriState(ui.numlockButtonGroup); - - config.writeEntry("ClickVolume",clickVolume); - config.writeEntry("KeyboardRepeating", TriStateHelper::getInt(keyboardRepeat)); - config.writeEntry("RepeatRate", ui.rate->value() ); - config.writeEntry("RepeatDelay", ui.delay->value() ); - config.writeEntry("NumLock", TriStateHelper::getInt(numlockState) ); - config.sync(); -} - -void KCMiscKeyboardWidget::defaults() -{ - setClickVolume(50); - setRepeat(STATE_ON, 660, 25); - TriStateHelper::setTriState( ui.numlockButtonGroup, STATE_UNCHANGED ); - emit changed(true); -} - -QString KCMiscKeyboardWidget::quickHelp() const -{ - return QString(); - - /* "

Keyboard

This module allows you to choose options" - " for the way in which your keyboard works. The actual effect of" - " setting these options depends upon the features provided by your" - " keyboard hardware and the X server on which KDE is running.

" - " For example, you may find that changing the key click volume" - " has no effect because this feature is not available on your system." */ -} - -void KCMiscKeyboardWidget::delaySliderChanged (int value) { - double alpha = sliderMax / (log(5000.0L) - log(100.0L)); - double linearValue = exp (value/alpha + log(100.0L)); - - ui.delay->setValue((int)floor(0.5 + linearValue)); - - emit changed(true); -} - -void KCMiscKeyboardWidget::delaySpinboxChanged (int value) { - double alpha = sliderMax / (log(5000.0L) - log(100.0L)); - double logVal = alpha * (log((double)value)-log(100.0L)); - - ui.delaySlider->setValue ((int)floor (0.5 + logVal)); - - emit changed(true); -} - -void KCMiscKeyboardWidget::rateSliderChanged (int value) { - ui.rate->setValue(value/100.0); - - emit changed(true); -} - -void KCMiscKeyboardWidget::rateSpinboxChanged (double value) { - ui.rateSlider->setValue ((int)(value*100)); - - emit changed(true); -} - -void KCMiscKeyboardWidget::changed() -{ - emit changed(true); -} - -void KCMiscKeyboardWidget::keyboardRepeatStateChanged(int selection) -{ - bool enabled = selection == TriStateHelper::getInt(STATE_ON); - ui.keyboardRepeatParamsGroupBox->setEnabled(enabled); - changed(); -} diff --git a/kcontrol/keyboard/kcmmisc.h b/kcontrol/keyboard/kcmmisc.h deleted file mode 100644 index 2973b460..00000000 --- a/kcontrol/keyboard/kcmmisc.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * keyboard.h - * - * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca - * - * Requires the Qt widget libraries, available at no cost at - * http://www.troll.no/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __KCMMISC_H__ -#define __KCMMISC_H__ - -#include -#include - -QT_BEGIN_NAMESPACE -class Ui_KeyboardConfigWidget; -QT_END_NAMESPACE - -enum TriState { - STATE_ON = 0, STATE_OFF = 1, STATE_UNCHANGED = 2 -}; - -class KButtonGroup; -class TriStateHelper { -public: - static void setTriState(KButtonGroup* group, TriState state); - static TriState getTriState(const KButtonGroup* group); - - static TriState getTriState(int state) { return static_cast(state); } - static int getInt(TriState state) { return static_cast(state); } - static const char* getString(TriState state) { - return state == STATE_ON ? "0" : state == STATE_OFF ? "1" : "2"; - } -}; - -class KCMiscKeyboardWidget : public QWidget -{ - Q_OBJECT -public: - KCMiscKeyboardWidget(QWidget *parent); - ~KCMiscKeyboardWidget(); - - void save(); - void load(); - void defaults(); - - QString quickHelp() const; - -private slots: - void changed(); - - void delaySliderChanged (int value); - void delaySpinboxChanged (int value); - void rateSliderChanged (int value); - void rateSpinboxChanged (double value); - void keyboardRepeatStateChanged(int selection); - -Q_SIGNALS: - void changed(bool state); - -private: - void setClickVolume( int ); - void setRepeat( TriState flag, int delay, double rate); - void setRepeatRate( int ); - - int getClick(); - int getRepeatRate(); - - int sliderMax; - int clickVolume; - enum TriState keyboardRepeat; - enum TriState numlockState; - - Ui_KeyboardConfigWidget& ui; -}; - -#endif - diff --git a/kcontrol/keyboard/kcmmiscwidget.ui b/kcontrol/keyboard/kcmmiscwidget.ui deleted file mode 100644 index 6e036e57..00000000 --- a/kcontrol/keyboard/kcmmiscwidget.ui +++ /dev/null @@ -1,334 +0,0 @@ - - - KeyboardConfigWidget - - - - 0 - 0 - 577 - 361 - - - - - - - If supported, this option allows you to setup the state of NumLock after KDE startup.<p>You can configure NumLock to be turned on or off, or configure KDE not to set NumLock state. - - - NumLock on KDE Startup - - - - - - true - - - - - - T&urn on - - - - - - - Turn o&ff - - - - - - - Leave unchan&ged - - - - - - - - - - - - - Keyboard Repeat - - - - - - true - - - - - - T&urn on - - - - - - - Turn o&ff - - - - - - - Leave unchan&ged - - - - - - - - - - Qt::Horizontal - - - - 159 - 20 - - - - - - - - - - - false - - - - - - - 0 - 0 - - - - &Delay: - - - delay - - - - - - - If supported, this option allows you to set the delay after which a pressed key will start generating keycodes. The 'Repeat rate' option controls the frequency of these keycodes. - - - 0 - - - 10000 - - - 1000 - - - 1000 - - - 5000 - - - Qt::Horizontal - - - 1000 - - - - - - - If supported, this option allows you to set the delay after which a pressed key will start generating keycodes. The 'Repeat rate' option controls the frequency of these keycodes. - - - ms - - - - - - - - 0 - 0 - - - - &Rate: - - - rate - - - - - - - If supported, this option allows you to set the rate at which keycodes are generated while a key is pressed. - - - 0 - - - 10000 - - - 1000 - - - 1000 - - - 5000 - - - Qt::Horizontal - - - 1000 - - - - - - - If supported, this option allows you to set the rate at which keycodes are generated while a key is pressed. - - - repeats/s - - - - - - - - - - - - - - - - - - Test area: - - - - - - - Allows to test keyboard repeat and click volume (just don't forget to apply the changes). - - - - - - - - - Key Click - - - - - - - - If supported, this option allows you to hear audible clicks from your computer's speakers when you press the keys on your keyboard. This might be useful if your keyboard does not have mechanical keys, or if the sound that the keys make is very soft.<p>You can change the loudness of the key click feedback by dragging the slider button or by clicking the up/down arrows on the spin box. Setting the volume to 0% turns off the key click. - - - Key click &volume: - - - click - - - - - - - 100 - - - 10 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - KDoubleNumInput - QWidget -

knuminput.h
- 1 - - - KButtonGroup - QGroupBox -
kbuttongroup.h
- 1 -
- - KIntNumInput - QWidget -
knuminput.h
- 1 -
- - - diff --git a/kcontrol/keyboard/keyboard.desktop b/kcontrol/keyboard/keyboard.desktop deleted file mode 100644 index a2a4654c..00000000 --- a/kcontrol/keyboard/keyboard.desktop +++ /dev/null @@ -1,75 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=preferences-desktop-keyboard -X-KDE-ServiceTypes=KDEDModule -X-KDE-Library=keyboard -X-KDE-DBus-ModuleName=keyboard -X-KDE-Kded-autoload=true -X-KDE-Kded-load-on-demand=false -X-KDE-Kded-phase=1 -OnlyShowIn=KDE; - -Name=Keyboard Daemon -Name[ar]=مراقب لوحة المفاتيح -Name[ast]=Degorriu de tecláu -Name[bg]=Демон на клавиатурата -Name[bn]=কীবোর্ড ডীমন -Name[bs]=Demon tastature -Name[ca]=Dimoni del teclat -Name[ca@valencia]=Dimoni del teclat -Name[cs]=Démon klávesnice -Name[da]=Tastatur-dæmon -Name[de]=Tastatur-Dienst -Name[el]=Δαίμονας Πληκτρολογίου -Name[en_GB]=Keyboard Dæmon -Name[es]=Demonio de teclado -Name[et]=Klaviatuurideemon -Name[eu]=Teklatuaren daimona -Name[fi]=Näppäimistötaustaprosessi -Name[fr]=Démon du clavier -Name[ga]=Deamhan Méarchláir -Name[gl]=Daemon do teclado -Name[gu]=કીબોર્ડ ડિમન -Name[he]=תהליך רקע של המקלדת -Name[hi]=कुंजीपट डेमन -Name[hr]=Tipkovnički servis -Name[hu]=Billentyűzetszolgáltatás -Name[ia]=Demone de claviero -Name[id]=Jurik Papan Ketik -Name[is]=Lyklaborðspúki -Name[it]=Demone della tastiera -Name[ja]=キーボードデーモン -Name[kk]=Перенетақта қызметі -Name[km]=ដេមិន​​ក្ដារចុច -Name[kn]=ಕೀಲಿಮಣೆ ನೇಪಥಿಕ -Name[ko]=키보드 데몬 -Name[lt]=Klaviatūros tarnyba -Name[lv]=Tastatūras dēmons -Name[mr]=कळफलक डीमन -Name[nb]=Tastatur-daemon -Name[nds]=Tastatuur-Dämoon -Name[nl]=Toetsenbord-daemon -Name[nn]=Tastaturteneste -Name[pa]=ਕੀ-ਬੋਰਡ ਡੈਮਨ -Name[pl]=Demon klawiatury -Name[pt]=Servidor do Teclado -Name[pt_BR]=Daemon de teclado -Name[ro]=Demon de tastatură -Name[ru]=Фоновая служба клавиатуры -Name[si]=යතුරුපුවරු ඩීමනය -Name[sk]=Démon klávesnice -Name[sl]=Ozadnji program za tipkovnico -Name[sr]=Демон тастатуре -Name[sr@ijekavian]=Демон тастатуре -Name[sr@ijekavianlatin]=Demon tastature -Name[sr@latin]=Demon tastature -Name[sv]=Tangentbordsdemon -Name[th]=ดีมอนแป้นพิมพ์ -Name[tr]=Klavye Servisi -Name[ug]=ھەرپتاختا نازارەتچى -Name[uk]=Фонова служба клавіатури -Name[vi]=Trình nền bàn phím -Name[wa]=Démon del taprece -Name[x-test]=xxKeyboard Daemonxx -Name[zh_CN]=键盘守护进程 -Name[zh_TW]=鍵盤伺服程式 diff --git a/kcontrol/keyboard/keyboard_applet.cpp b/kcontrol/keyboard/keyboard_applet.cpp deleted file mode 100644 index 39584039..00000000 --- a/kcontrol/keyboard/keyboard_applet.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "keyboard_applet.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "x11_helper.h" -#include "xkb_rules.h" -#include "keyboard_config.h" -#include "keyboard_dbus.h" -#include "layouts_menu.h" -//#include "utils.h" - - -K_EXPORT_PLASMA_APPLET(keyboard, KeyboardApplet) - -KeyboardApplet::KeyboardApplet(QObject *parent, const QVariantList &args): - Plasma::Applet(parent, args), - xEventNotifier(), - rules(Rules::readRules(Rules::READ_EXTRAS)), - keyboardConfig(new KeyboardConfig()), - layoutsMenu(new LayoutsMenu(*keyboardConfig, *rules, flags)) -{ - if( ! X11Helper::xkbSupported(NULL) ) { - setFailedToLaunch(true, i18n("XKB extension failed to initialize")); - return; - } - - m_svg = new Plasma::Svg(this); - m_svg->setImagePath("widgets/labeltexture"); - m_svg->setContainsMultipleImages(true); - resize(48,48); - - setHasConfigurationInterface(false); - - setAspectRatioMode(Plasma::KeepAspectRatio); - //setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); - setBackgroundHints(DefaultBackground); - connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged())); - - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.connect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configChanged())); -} - -KeyboardApplet::~KeyboardApplet() -{ - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.disconnect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configChanged())); - - delete layoutsMenu; - delete rules; -} - -void KeyboardApplet::keyboardConfigChanged() -{ - readConfig(); - update(); -} - -void KeyboardApplet::readConfig() -{ -// KConfigGroup config = Plasma::Applet::config("KeyboardLayout"); - keyboardConfig->load(); -// drawFlag = keyboardConfig->readEntry("ShowFlag", true); -} - -void KeyboardApplet::configChanged() -{ - Applet::configChanged(); - readConfig(); -} - -void KeyboardApplet::init() -{ - Applet::init(); - - readConfig(); - connect(&xEventNotifier, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); - connect(&xEventNotifier, SIGNAL(layoutMapChanged()), this, SLOT(layoutChanged())); - xEventNotifier.start(); - - layoutChanged(); -} - -void KeyboardApplet::destroy() -{ - xEventNotifier.stop(); - disconnect(&xEventNotifier, SIGNAL(layoutMapChanged()), this, SLOT(layoutChanged())); - disconnect(&xEventNotifier, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); - Applet::destroy(); -} - -void KeyboardApplet::layoutChanged() -{ - generatePixmap(); - updateTooltip(); - update(); -} - -void KeyboardApplet::updateTooltip() -{ - LayoutUnit layoutUnit = X11Helper::getCurrentLayout(); - if( layoutUnit.isEmpty() ) - return; - - const QIcon icon(getFlag(layoutUnit.layout)); - Plasma::ToolTipContent data(name(), flags.getLongText(layoutUnit, rules), icon); - Plasma::ToolTipManager::self()->setContent(this, data); -} - -const QIcon KeyboardApplet::getFlag(const QString& layout) -{ - return keyboardConfig->isFlagShown() ? flags.getIcon(layout) : QIcon(); -} - -void KeyboardApplet::paintInterface(QPainter *p, const QStyleOptionGraphicsItem */*option*/, const QRect &contentsRect) -{ - LayoutUnit layoutUnit = X11Helper::getCurrentLayout(); - if( layoutUnit.isEmpty() ) - return; - - const QIcon icon(getFlag(layoutUnit.layout)); - if( ! icon.isNull() ) { - p->save(); - p->setRenderHint(QPainter::SmoothPixmapTransform); - p->setRenderHint(QPainter::Antialiasing); - QPixmap pixmap = icon.pixmap(contentsRect.size()); - p->drawPixmap(contentsRect, pixmap); - p->restore(); - } - if( icon.isNull() || keyboardConfig->isLabelShown() ) { - QRect finalRect(m_pixmap.rect()); - finalRect.moveCenter(contentsRect.center()); - p->drawPixmap(finalRect, m_pixmap); - } -} - -void KeyboardApplet::mousePressEvent ( QGraphicsSceneMouseEvent * event ) -{ - if( event->button() == Qt::LeftButton ) { - X11Helper::switchToNextLayout(); - } - event->ignore(); -} - -void KeyboardApplet::constraintsEvent(Plasma::Constraints constraints) -{ - if (constraints & Plasma::FormFactorConstraint) { - int iconSize; - if (formFactor() == Plasma::Planar || - formFactor() == Plasma::MediaCenter) { - iconSize = IconSize(KIconLoader::Desktop); - } else { - iconSize = IconSize(KIconLoader::Small); - } - setMinimumSize(iconSize, iconSize); - } - if (constraints & Plasma::SizeConstraint) { - generatePixmap(); - } -} - -void KeyboardApplet::generatePixmap() -{ - LayoutUnit layoutUnit = X11Helper::getCurrentLayout(); - QRect contentsRect = KeyboardApplet::contentsRect().toRect(); - QString shortText = Flags::getShortText(layoutUnit, *keyboardConfig); - - QPixmap pixmap(contentsRect.size()); - pixmap.fill(Qt::transparent); - - QFont font = Plasma::Theme::defaultTheme()->font(Plasma::Theme::DesktopFont); - int height = qMin(contentsRect.height(), contentsRect.width()); - int fontSize = shortText.length() == 2 - ? height * 13 / 15 - : height * 5 / 15; - - int smallestReadableSize = KGlobalSettings::smallestReadableFont().pixelSize(); - if( fontSize < smallestReadableSize ) { - fontSize = smallestReadableSize; - } - font.setPixelSize(fontSize); - if( keyboardConfig->isFlagShown() ) { - m_pixmap = Plasma::PaintUtils::shadowText(shortText, font, Qt::black, Qt::white, QPoint(), 3); - } - else { - m_pixmap = Plasma::PaintUtils::texturedText(shortText, font, m_svg); - } -} - -QList KeyboardApplet::contextualActions() -{ - return layoutsMenu->contextualActions(); -} diff --git a/kcontrol/keyboard/keyboard_applet.h b/kcontrol/keyboard/keyboard_applet.h deleted file mode 100644 index bfc80e0f..00000000 --- a/kcontrol/keyboard/keyboard_applet.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KEYBOARD_APPLET_H_ -#define KEYBOARD_APPLET_H_ - -#include - -#include - -#include "x11_helper.h" -#include "flags.h" - -#include -#include -class KConfigDialog; -#include -class Rules; -class KeyboardConfig; -class LayoutsMenu; - -class KeyboardApplet : public Plasma::Applet -{ - Q_OBJECT - -public Q_SLOTS: - void init(); - void destroy(); - -private Q_SLOTS: - void configChanged(); - void layoutChanged(); - -public: - KeyboardApplet(QObject *parent, const QVariantList &args); - virtual ~KeyboardApplet(); - - void constraintsEvent(Plasma::Constraints constraints); - void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect); - -protected: - void mousePressEvent ( QGraphicsSceneMouseEvent *event ); - QList contextualActions(); - void generatePixmap(); -// void createConfigurationInterface(KConfigDialog *parent); - -private Q_SLOTS: - void keyboardConfigChanged(); - -private: - void readConfig(); - const QIcon getFlag(const QString& layout); - void updateTooltip(); - -// bool drawFlag; - Flags flags; - XEventNotifier xEventNotifier; - const Rules* rules; - KeyboardConfig* keyboardConfig; - LayoutsMenu* layoutsMenu; - Plasma::Svg *m_svg; - QPixmap m_pixmap; -}; - -#endif /* KEYBOARD_APPLET_H_ */ diff --git a/kcontrol/keyboard/keyboard_config.cpp b/kcontrol/keyboard/keyboard_config.cpp deleted file mode 100644 index f3ff97ca..00000000 --- a/kcontrol/keyboard/keyboard_config.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "keyboard_config.h" - -#include -#include -#include - - -static const char* SWITCHING_POLICIES[] = {"Global", "Desktop", "WinClass", "Window", NULL }; -static const char* LIST_SEPARATOR = ","; -//static const char* DEFAULT_LAYOUT = "us"; -static const char* DEFAULT_MODEL = "pc104"; - -static const QString CONFIG_FILENAME("kxkbrc"); -static const QString CONFIG_GROUPNAME("Layout"); - -const int KeyboardConfig::NO_LOOPING = -1; - -KeyboardConfig::KeyboardConfig() -{ - setDefaults(); -} - -QString KeyboardConfig::getSwitchingPolicyString(SwitchingPolicy switchingPolicy) { - return SWITCHING_POLICIES[switchingPolicy]; -} - -static int findStringIndex(const char* strings[], const QString& toFind, int defaultIndex) -{ - for(int i=0; strings[i] != NULL; i++) { - if( toFind == strings[i] ) { - return i; - } - } - return defaultIndex; -} - -void KeyboardConfig::setDefaults() -{ - keyboardModel = DEFAULT_MODEL; - resetOldXkbOptions = false; - xkbOptions.clear(); - - // init layouts options - configureLayouts = false; - layouts.clear(); -// layouts.append(LayoutUnit(DEFAULT_LAYOUT)); - layoutLoopCount = NO_LOOPING; - - // switch cotrol options - switchingPolicy = SWITCH_POLICY_GLOBAL; -// stickySwitching = false; -// stickySwitchingDepth = 2; - - // display options - showIndicator = true; - indicatorType = SHOW_LABEL; - showSingle = false; -} - -static -KeyboardConfig::IndicatorType getIndicatorType(bool showFlag, bool showLabel) -{ - if( showFlag ) { - if( showLabel ) - return KeyboardConfig::SHOW_LABEL_ON_FLAG; - else - return KeyboardConfig::SHOW_FLAG; - } - else { - return KeyboardConfig::SHOW_LABEL; - } -} - - -void KeyboardConfig::load() -{ - KConfigGroup config(KSharedConfig::openConfig( CONFIG_FILENAME, KConfig::NoGlobals ), CONFIG_GROUPNAME); - - keyboardModel = config.readEntry("Model", ""); - - resetOldXkbOptions = config.readEntry("ResetOldOptions", false); - QString options = config.readEntry("Options", ""); - xkbOptions = options.split(LIST_SEPARATOR, QString::SkipEmptyParts); - - configureLayouts = config.readEntry("Use", false); - QString layoutsString = config.readEntry("LayoutList", ""); - QStringList layoutStrings = layoutsString.split(LIST_SEPARATOR, QString::SkipEmptyParts); -// if( layoutStrings.isEmpty() ) { -// layoutStrings.append(DEFAULT_LAYOUT); -// } - layouts.clear(); - foreach(const QString& layoutString, layoutStrings) { - layouts.append(LayoutUnit(layoutString)); - } - if( layouts.isEmpty() ) { - configureLayouts = false; - } - - layoutLoopCount = config.readEntry("LayoutLoopCount", NO_LOOPING); - - QString layoutMode = config.readEntry("SwitchMode", "Global"); - switchingPolicy = static_cast(findStringIndex(SWITCHING_POLICIES, layoutMode, SWITCH_POLICY_GLOBAL)); - - showIndicator = config.readEntry("ShowLayoutIndicator", true); - - bool showFlag = config.readEntry("ShowFlag", false); - bool showLabel = config.readEntry("ShowLabel", true); - indicatorType = getIndicatorType(showFlag, showLabel); - - showSingle = config.readEntry("ShowSingle", false); - - QString labelsStr = config.readEntry("DisplayNames", ""); - QStringList labels = labelsStr.split(LIST_SEPARATOR, QString::KeepEmptyParts); - for(int i=0; i KeyboardConfig::getDefaultLayouts() const -{ - QList defaultLayoutList; - int i = 0; - foreach(const LayoutUnit& layoutUnit, layouts) { - defaultLayoutList.append(layoutUnit); - if( layoutLoopCount != KeyboardConfig::NO_LOOPING && i >= layoutLoopCount-1 ) - break; - i++; - } - return defaultLayoutList; -} - -QList KeyboardConfig::getExtraLayouts() const -{ - if( layoutLoopCount == KeyboardConfig::NO_LOOPING ) - return QList(); - - return layouts.mid(layoutLoopCount, layouts.size()); -} diff --git a/kcontrol/keyboard/keyboard_config.h b/kcontrol/keyboard/keyboard_config.h deleted file mode 100644 index b86418de..00000000 --- a/kcontrol/keyboard/keyboard_config.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KEYBOARD_CONFIG_H_ -#define KEYBOARD_CONFIG_H_ - -#include "x11_helper.h" - -#include -#include -#include -#include -#include - -/** - * This class provides configuration options for keyboard module - */ -class KeyboardConfig -{ -public: - static const int MAX_LABEL_LEN = 3; - static const int NO_LOOPING; // = -1; - - enum SwitchingPolicy { - SWITCH_POLICY_GLOBAL = 0, - SWITCH_POLICY_DESKTOP = 1, - SWITCH_POLICY_APPLICATION = 2, - SWITCH_POLICY_WINDOW = 3 - }; - - enum IndicatorType { - SHOW_LABEL = 0, - SHOW_FLAG = 1, - SHOW_LABEL_ON_FLAG = 2 - }; - - QString keyboardModel; - // resetOldXkbOptions is now also "set xkb options" - bool resetOldXkbOptions; - QStringList xkbOptions; - - // init layouts options - bool configureLayouts; - QList layouts; - int layoutLoopCount; - - // switch cotrol options - SwitchingPolicy switchingPolicy; -// bool stickySwitching; -// int stickySwitchingDepth; - - // display options - bool showIndicator; - IndicatorType indicatorType; - bool showSingle; - - KeyboardConfig(); - bool isSpareLayoutsEnabled() const { - return layoutLoopCount != KeyboardConfig::NO_LOOPING; - } - QList getDefaultLayouts() const; - QList getExtraLayouts() const; - bool isFlagShown() const { - return indicatorType == SHOW_FLAG || indicatorType == SHOW_LABEL_ON_FLAG; - } - bool isLabelShown() const { - return indicatorType == SHOW_LABEL || indicatorType == SHOW_LABEL_ON_FLAG; - } - - void setDefaults(); - void load(); - void save(); - - static QString getSwitchingPolicyString(SwitchingPolicy switchingPolicy); -}; - -#endif /* KEYBOARD_CONFIG_H_ */ diff --git a/kcontrol/keyboard/keyboard_daemon.cpp b/kcontrol/keyboard/keyboard_daemon.cpp deleted file mode 100644 index 089e2dfc..00000000 --- a/kcontrol/keyboard/keyboard_daemon.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "keyboard_daemon.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "x11_helper.h" -#include "xinput_helper.h" -#include "xkb_helper.h" -#include "keyboard_dbus.h" -#include "xkb_rules.h" -#include "bindings.h" -#include "keyboard_hardware.h" -#include "layout_tray_icon.h" -#include "layout_memory_persister.h" -#include "layouts_menu.h" - - -K_PLUGIN_FACTORY(KeyboardFactory, registerPlugin();) -K_EXPORT_PLUGIN(KeyboardFactory("keyboard", "kxkb")) - -KeyboardDaemon::KeyboardDaemon(QObject *parent, const QList&) - : KDEDModule(parent), - actionCollection(NULL), - xEventNotifier(NULL), - layoutTrayIcon(NULL), - layoutMemory(keyboardConfig), - rules(Rules::readRules(Rules::READ_EXTRAS)) -{ - if( ! X11Helper::xkbSupported(NULL) ) - return; //TODO: shut down the daemon? - - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerService(KEYBOARD_DBUS_SERVICE_NAME); - dbus.registerObject(KEYBOARD_DBUS_OBJECT_PATH, this, QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportScriptableSignals); - dbus.connect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configureKeyboard())); - - configureKeyboard(); - registerListeners(); - - LayoutMemoryPersister layoutMemoryPersister(layoutMemory); - if( layoutMemoryPersister.restore(KGlobal::mainComponent().componentName()) ) { - if( layoutMemoryPersister.getGlobalLayout().isValid() ) { - X11Helper::setLayout(layoutMemoryPersister.getGlobalLayout()); - } - } -} - -KeyboardDaemon::~KeyboardDaemon() -{ - LayoutMemoryPersister layoutMemoryPersister(layoutMemory); - layoutMemoryPersister.setGlobalLayout(X11Helper::getCurrentLayout()); - layoutMemoryPersister.save(KGlobal::mainComponent().componentName()); - - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.disconnect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configureKeyboard())); - dbus.unregisterObject(KEYBOARD_DBUS_OBJECT_PATH); - dbus.unregisterService(KEYBOARD_DBUS_SERVICE_NAME); - - unregisterListeners(); - unregisterShortcut(); - - delete xEventNotifier; - delete layoutTrayIcon; - delete rules; -} - -void KeyboardDaemon::configureKeyboard() -{ - kDebug() << "Configuring keyboard"; - init_keyboard_hardware(); - - keyboardConfig.load(); - XkbHelper::initializeKeyboardLayouts(keyboardConfig); - layoutMemory.configChanged(); - - setupTrayIcon(); - - unregisterShortcut(); - registerShortcut(); -} - -void KeyboardDaemon::configureMouse() -{ - QStringList modules; - modules << "mouse"; - QProcess::startDetached("kcminit", modules); -} - -void KeyboardDaemon::setupTrayIcon() -{ - bool show = keyboardConfig.showIndicator - && ( keyboardConfig.showSingle || X11Helper::getLayoutsList().size() > 1 ); - - if( show && ! layoutTrayIcon ) { - layoutTrayIcon = new LayoutTrayIcon(rules, keyboardConfig); - } - else if( ! show && layoutTrayIcon ) { - delete layoutTrayIcon; - layoutTrayIcon = NULL; - } -} - -void KeyboardDaemon::registerShortcut() -{ - if( actionCollection == NULL ) { - actionCollection = new KeyboardLayoutActionCollection(this, false); - - KAction* toggleLayoutAction = actionCollection->getToggeAction(); - connect(toggleLayoutAction, SIGNAL(triggered()), this, SLOT(switchToNextLayout())); - actionCollection->loadLayoutShortcuts(keyboardConfig.layouts, rules); - connect(actionCollection, SIGNAL(actionTriggered(QAction*)), this, SLOT(setLayout(QAction*))); - - connect(KGlobalSettings::self(), SIGNAL(shortcutsChanged()), this, SLOT(globalShortcutsChanged())); - } -} - -void KeyboardDaemon::unregisterShortcut() -{ - // register KDE keyboard shortcut for switching layouts - if( actionCollection != NULL ) { - disconnect(KGlobalSettings::self(), SIGNAL(shortcutsChanged()), this, SLOT(globalShortcutsChanged())); - - disconnect(actionCollection, SIGNAL(actionTriggered(QAction*)), this, SLOT(setLayout(QAction*))); - disconnect(actionCollection->getToggeAction(), SIGNAL(triggered()), this, SLOT(switchToNextLayout())); - - delete actionCollection; - actionCollection = NULL; - } -} - -void KeyboardDaemon::registerListeners() -{ - if( xEventNotifier == NULL ) { - xEventNotifier = new XInputEventNotifier(); - } - connect(xEventNotifier, SIGNAL(newPointerDevice()), this, SLOT(configureMouse())); - connect(xEventNotifier, SIGNAL(newKeyboardDevice()), this, SLOT(configureKeyboard())); - connect(xEventNotifier, SIGNAL(layoutMapChanged()), this, SLOT(layoutMapChanged())); - connect(xEventNotifier, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); - xEventNotifier->start(); -} - -void KeyboardDaemon::unregisterListeners() -{ - if( xEventNotifier != NULL ) { - xEventNotifier->stop(); - disconnect(xEventNotifier, SIGNAL(newPointerDevice()), this, SLOT(configureMouse())); - disconnect(xEventNotifier, SIGNAL(newKeyboardDevice()), this, SLOT(configureKeyboard())); - disconnect(xEventNotifier, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); - disconnect(xEventNotifier, SIGNAL(layoutMapChanged()), this, SLOT(layoutMapChanged())); - } -} - -void KeyboardDaemon::globalShortcutsChanged() -{ -//TODO: optimize this? seems like we'll get configReload and globalShortcuts from kcm so we'll reconfigure twice - unregisterShortcut(); - registerShortcut(); -} - -void KeyboardDaemon::layoutChanged() -{ - //TODO: pass newLayout into layoutTrayIcon? - LayoutUnit newLayout = X11Helper::getCurrentLayout(); - - layoutMemory.layoutChanged(); - if( layoutTrayIcon != NULL ) { - layoutTrayIcon->layoutChanged(); - } - - if( newLayout != currentLayout ) { - currentLayout = newLayout; - emit currentLayoutChanged(newLayout.toString()); - } -} - -void KeyboardDaemon::layoutMapChanged() -{ - keyboardConfig.load(); - layoutMemory.layoutMapChanged(); - emit layoutListChanged(); - if( layoutTrayIcon != NULL ) { - layoutTrayIcon->layoutMapChanged(); - } -} - -void KeyboardDaemon::switchToNextLayout() -{ - kDebug() << "Toggling layout"; - X11Helper::switchToNextLayout(); -} - -bool KeyboardDaemon::setLayout(QAction* action) -{ - if( action == actionCollection->getToggeAction() ) - return false; - - LayoutUnit layoutUnit(action->data().toString()); - return LayoutsMenu::switchToLayout(layoutUnit, keyboardConfig); // need this to be able to switch to spare layouts -// return X11Helper::setLayout(LayoutUnit(action->data().toString())); -} - -bool KeyboardDaemon::setLayout(const QString& layout) -{ - return X11Helper::setLayout(LayoutUnit(layout)); -} - -QString KeyboardDaemon::getCurrentLayout() -{ - return X11Helper::getCurrentLayout().toString(); -} - -QStringList KeyboardDaemon::getLayoutsList() -{ - return X11Helper::getLayoutsListAsString( X11Helper::getLayoutsList() ); -} diff --git a/kcontrol/keyboard/keyboard_daemon.h b/kcontrol/keyboard/keyboard_daemon.h deleted file mode 100644 index 57fe1a24..00000000 --- a/kcontrol/keyboard/keyboard_daemon.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KEYBOARD_DAEMON_H_ -#define KEYBOARD_DAEMON_H_ - -#include -#include -#include - -#include "layout_memory.h" -#include "keyboard_dbus.h" -#include "bindings.h" - - -class KActionCollection; -class XInputEventNotifier; -class LayoutTrayIcon; -class KeyboardConfig; -class KAction; -class Rules; - -class KDE_EXPORT KeyboardDaemon : public KDEDModule -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.KeyboardLayouts") - - KeyboardConfig keyboardConfig; - KeyboardLayoutActionCollection *actionCollection; - XInputEventNotifier* xEventNotifier; - LayoutTrayIcon* layoutTrayIcon; - LayoutMemory layoutMemory; - LayoutUnit currentLayout; - const Rules* rules; - - void registerListeners(); - void registerShortcut(); - void unregisterListeners(); - void unregisterShortcut(); - void setupTrayIcon(); - -private Q_SLOTS: - void switchToNextLayout(); - void globalShortcutsChanged(); - void configureKeyboard(); - void configureMouse(); - void layoutChanged(); - void layoutMapChanged(); - bool setLayout(QAction* action); - -public Q_SLOTS: - Q_SCRIPTABLE bool setLayout(const QString& layout); - Q_SCRIPTABLE QString getCurrentLayout(); - Q_SCRIPTABLE QStringList getLayoutsList(); - -Q_SIGNALS: - Q_SCRIPTABLE void currentLayoutChanged(QString layout); - Q_SCRIPTABLE void layoutListChanged(); - -public: - KeyboardDaemon(QObject *parent, const QList&); - virtual ~KeyboardDaemon(); -}; - -#endif /* KEYBOARD_DAEMON_H_ */ diff --git a/kcontrol/keyboard/keyboard_dbus.h b/kcontrol/keyboard/keyboard_dbus.h deleted file mode 100644 index 4ea39668..00000000 --- a/kcontrol/keyboard/keyboard_dbus.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KEYBOARD_DBUS_H_ -#define KEYBOARD_DBUS_H_ - -#define KEYBOARD_DBUS_SERVICE_NAME "org.kde.keyboard" -#define KEYBOARD_DBUS_OBJECT_PATH "/Layouts" -#define KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE "reloadConfig" - -#endif /* KEYBOARD_DBUS_H_ */ diff --git a/kcontrol/keyboard/keyboard_hardware.cpp b/kcontrol/keyboard/keyboard_hardware.cpp deleted file mode 100644 index 9dcdd126..00000000 --- a/kcontrol/keyboard/keyboard_hardware.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include -#include // WTF? - otherwise compiler complains - -#include - -#include - -#include "x11_helper.h" -#include "kcmmisc.h" - -// from numlockx.c -extern "C" void numlockx_change_numlock_state(Display* dpy, int state); - -#include -#include - - -// This code is taken from xset utility from XFree 4.3 (http://www.xfree86.org/) - -static -void set_repeatrate(int delay, double rate) -{ - if( !X11Helper::xkbSupported(NULL) ) { - kError() << "Failed to set keyboard repeat rate: xkb is not supported"; - return; - } - - XkbDescPtr xkb = XkbAllocKeyboard(); - if (xkb) { - Display* dpy = QX11Info::display(); - Status res = XkbGetControls(dpy, XkbRepeatKeysMask, xkb); - if (res != Success) { - kError() << "Failed to get keyboard repeat controls"; - XkbFreeKeyboard(xkb, 0, true); - return; - } - xkb->ctrls->repeat_delay = delay; - xkb->ctrls->repeat_interval = (int)floor(1000/rate + 0.5); - Bool res2 = XkbSetControls(dpy, XkbRepeatKeysMask, xkb); - if (res2 != True) { - kError() << "Failed to set keyboard repeat controls"; - } - XkbFreeKeyboard(xkb, 0, true); - } -} - -static -int set_volume(int clickVolumePercent, TriState keyboardRepeatMode) -{ - XKeyboardState kbd; - XKeyboardControl kbdc; - - XGetKeyboardControl(QX11Info::display(), &kbd); - - int flags = 0; - if( clickVolumePercent != -1 ) { - flags |= KBKeyClickPercent; - kbdc.key_click_percent = clickVolumePercent; - } - if( keyboardRepeatMode != STATE_UNCHANGED ) { - flags |= KBAutoRepeatMode; - kbdc.auto_repeat_mode = (keyboardRepeatMode==STATE_ON ? AutoRepeatModeOn : AutoRepeatModeOff); - } - - return XChangeKeyboardControl(QX11Info::display(), flags, &kbdc); -} - -void init_keyboard_hardware() -{ - KConfigGroup config(KSharedConfig::openConfig( "kcminputrc" ), "Keyboard"); - - QString keyRepeatStr = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON)); - TriState keyRepeat = STATE_UNCHANGED; - if( keyRepeatStr == "true" || keyRepeatStr == TriStateHelper::getString(STATE_ON) ) { - keyRepeat = STATE_ON; - } - else if( keyRepeatStr == "false" || keyRepeatStr == TriStateHelper::getString(STATE_OFF) ) { - keyRepeat = STATE_OFF; - } - - int clickVolumePercent = config.readEntry("ClickVolume", -1); - if( clickVolumePercent != -1 && keyRepeat != STATE_UNCHANGED ) { - set_volume(clickVolumePercent, keyRepeat); - } - - if( keyRepeat == STATE_ON ) { - int delay_ = config.readEntry("RepeatDelay", 250); - double rate_ = config.readEntry("RepeatRate", 30.); - set_repeatrate(delay_, rate_); - } - - - TriState numlockState = TriStateHelper::getTriState( config.readEntry( "NumLock", TriStateHelper::getInt(STATE_UNCHANGED) ) ); - if( numlockState != STATE_UNCHANGED ) { - numlockx_change_numlock_state(QX11Info::display(), numlockState == STATE_ON ); - } -} diff --git a/kcontrol/keyboard/keyboard_hardware.h b/kcontrol/keyboard/keyboard_hardware.h deleted file mode 100644 index e3daa80b..00000000 --- a/kcontrol/keyboard/keyboard_hardware.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KEYBOARD_HARDWARE_H_ -#define KEYBOARD_HARDWARE_H_ - -void init_keyboard_hardware(); - -#endif /* KEYBOARD_HARDWARE_H_ */ diff --git a/kcontrol/keyboard/keyboardconfig.cpp b/kcontrol/keyboard/keyboardconfig.cpp new file mode 100644 index 00000000..cd61d832 --- /dev/null +++ b/kcontrol/keyboard/keyboardconfig.cpp @@ -0,0 +1,470 @@ +/* This file is part of the KDE project + Copyright (C) 2023 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "keyboardconfig.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static const float s_defaultrepeatdelay = 660.0; +static const float s_defaultrepeatrate = 25.0; + +static QList kLayoutsFromConfig() +{ + KConfig kconfig("kcminputrc", KConfig::NoGlobals); + KConfigGroup kconfiggroup(&kconfig, "Keyboard"); + const KKeyboardType defaultlayout = KKeyboardLayout::defaultLayout(); + const QByteArray layoutsmodel = kconfiggroup.readEntry("LayoutsModel", defaultlayout.model); + const QStringList layoutslayouts = kconfiggroup.readEntry( + "LayoutsLayouts", + QStringList() << QString::fromLatin1(defaultlayout.layout.constData(), defaultlayout.layout.size()) + ); + const QStringList layoutsvariants = kconfiggroup.readEntry( + "LayoutsVariants", + QStringList() << QString::fromLatin1(defaultlayout.variant.constData(), defaultlayout.variant.size()) + ); + QList result; + for (int i = 0; i < layoutslayouts.size(); i++) { + KKeyboardType kkeyboardtype; + kkeyboardtype.model = layoutsmodel; + kkeyboardtype.layout = layoutslayouts.at(i).toLatin1(); + if (i < layoutsvariants.size()) { + kkeyboardtype.variant = layoutsvariants.at(i).toLatin1(); + } + result.append(kkeyboardtype); + } + return result; +} + +void kFillTreeFromLayouts(QTreeWidget *treewidget, const QList &layouts) +{ + treewidget->clear(); + int itemcounter = 0; + foreach (const KKeyboardType &layout, layouts) { + QTreeWidgetItem* layoutitem = new QTreeWidgetItem(); + layoutitem->setData(0, Qt::UserRole, layout.layout); + layoutitem->setData(0, Qt::UserRole + 1, itemcounter); + layoutitem->setText(0, KKeyboardLayout::layoutDescription(layout.layout)); + layoutitem->setData(1, Qt::UserRole, layout.variant); + layoutitem->setText(1, KKeyboardLayout::variantDescription(layout.layout, layout.variant)); + treewidget->addTopLevelItem(layoutitem); + itemcounter++; + } +} + +QList kGetLayoutsFromTree(QTreeWidget *treewidget, const QByteArray &model) +{ + QList result; + for (int i = 0; i < treewidget->topLevelItemCount(); i++) { + QTreeWidgetItem* layoutitem = treewidget->topLevelItem(i); + KKeyboardType kkeyboardtype; + kkeyboardtype.model = model; + kkeyboardtype.layout = layoutitem->data(0, Qt::UserRole).toByteArray(); + kkeyboardtype.variant = layoutitem->data(1, Qt::UserRole).toByteArray(); + result.append(kkeyboardtype); + } + return result; +} + +void kcm_keyboard_apply_config() +{ + KConfig kconfig("kcminputrc", KConfig::NoGlobals); + KConfigGroup kconfiggroup(&kconfig, "Keyboard"); + const float repeatdelay = kconfiggroup.readEntry("RepeatDelay", s_defaultrepeatdelay); + const float repeatrate = kconfiggroup.readEntry("RepeatRate", s_defaultrepeatrate); + + XkbDescPtr xkbkeyboard = XkbAllocKeyboard(); + if (!xkbkeyboard) { + kError() << "Failed to allocate keyboard"; + return; + } + Status xkbgetresult = XkbGetControls(QX11Info::display(), XkbRepeatKeysMask, xkbkeyboard); + if (xkbgetresult != Success) { + kError() << "Failed to get keyboard repeat controls"; + XkbFreeKeyboard(xkbkeyboard, 0, true); + return; + } + xkbkeyboard->ctrls->repeat_delay = repeatdelay; + xkbkeyboard->ctrls->repeat_interval = qFloor(1000 / repeatrate + 0.5); + const Bool xkbsetresult = XkbSetControls(QX11Info::display(), XkbRepeatKeysMask, xkbkeyboard); + if (xkbsetresult != True) { + kError() << "Failed to set keyboard repeat controls"; + } + XkbFreeKeyboard(xkbkeyboard, 0, true); + + const QList layouts = kLayoutsFromConfig(); + if (layouts.size() > 0) { + KKeyboardLayout().setLayouts(layouts); + } +} + +extern "C" +{ + Q_DECL_EXPORT void kcminit_keyboard() + { + kcm_keyboard_apply_config(); + } +} + +K_PLUGIN_FACTORY(KCMKeyboardFactory, registerPlugin();) +K_EXPORT_PLUGIN(KCMKeyboardFactory("kcmkeyboard", "kcm_keyboard")) + +KCMKeyboard::KCMKeyboard(QWidget *parent, const QVariantList &args) + : KCModule(KCMKeyboardFactory::componentData(), parent), + m_layout(nullptr), + m_repeatgroup(nullptr), + m_repeatdelaylabel(nullptr), + m_repeatdelayinput(nullptr), + m_repeatratelabel(nullptr), + m_repeatrateinput(nullptr), + m_layoutsgroup(nullptr), + m_layoutsmodellabel(nullptr), + m_layoutsmodelbox(nullptr), + m_layoutstree(nullptr), + m_layoutbuttonsbox(nullptr), + m_layoutsbuttonsspacer(nullptr), + m_layoutsaddbutton(nullptr), + m_layoutseditbutton(nullptr), + m_layoutsremovebutton(nullptr), + m_layoutsupbutton(nullptr), + m_layoutsdownbutton(nullptr), + m_layoutsbuttonsspacer2(nullptr) +{ + Q_UNUSED(args); + + KGlobal::locale()->insertCatalog("kxkb"); + + setButtons(KCModule::Default | KCModule::Apply); + setQuickHelp(i18n("

Keyboard

This control module can be used to configure keyboard parameters and layouts.")); + + KAboutData *about = new KAboutData( + I18N_NOOP("kcmkeyboard"), 0, + ki18n("KDE Keyboard Control Module"), + 0, KLocalizedString(), KAboutData::License_GPL, + ki18n("Copyright 2023, Ivailo Monev xakepa10@gmail.com") + ); + about->addAuthor(ki18n("Ivailo Monev"), KLocalizedString(), "xakepa10@gmail.com"); + setAboutData(about); + + m_layout = new QVBoxLayout(this); + setLayout(m_layout); + + m_repeatgroup = new QGroupBox(this); + m_repeatgroup->setTitle(i18n("Repeat")); + QGridLayout* repeatgrouplayout = new QGridLayout(m_repeatgroup); + m_repeatgroup->setLayout(repeatgrouplayout); + m_layout->addWidget(m_repeatgroup); + + m_repeatdelaylabel = new QLabel(m_repeatgroup); + m_repeatdelaylabel->setText(i18n("Repeat delay:")); + repeatgrouplayout->addWidget(m_repeatdelaylabel, 0, 0); + m_repeatdelayinput = new KIntNumInput(m_repeatgroup); + m_repeatdelayinput->setSliderEnabled(true); + m_repeatdelayinput->setSuffix(i18n(" ms")); + const QString repeatdelayhelp = i18n("The delay after which a pressed key will start generating keycodes."); + m_repeatdelayinput->setToolTip(repeatdelayhelp); + m_repeatdelayinput->setWhatsThis(repeatdelayhelp); + m_repeatdelayinput->setRange(10, 10000); + m_repeatdelayinput->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + connect( + m_repeatdelayinput, SIGNAL(valueChanged(int)), + this, SLOT(slotEmitChanged()) + ); + repeatgrouplayout->addWidget(m_repeatdelayinput, 0, 1); + + m_repeatratelabel = new QLabel(m_repeatgroup); + m_repeatratelabel->setText(i18n("Repeat rate:")); + repeatgrouplayout->addWidget(m_repeatratelabel, 1, 0); + m_repeatrateinput = new KIntNumInput(m_repeatgroup); + m_repeatrateinput->setSliderEnabled(true); + m_repeatrateinput->setSuffix(i18n(" ms")); + const QString repeatratehelp = i18n("The rate at which keycodes are generated while a key is pressed."); + m_repeatrateinput->setToolTip(repeatratehelp); + m_repeatrateinput->setWhatsThis(repeatratehelp); + m_repeatrateinput->setRange(10, 5000); + m_repeatrateinput->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + connect( + m_repeatrateinput, SIGNAL(valueChanged(int)), + this, SLOT(slotEmitChanged()) + ); + repeatgrouplayout->addWidget(m_repeatrateinput, 1, 1); + + m_layoutsgroup = new QGroupBox(this); + m_layoutsgroup->setTitle(i18n("Layouts")); + QGridLayout* layoutgrouplayout = new QGridLayout(m_layoutsgroup); + m_layoutsgroup->setLayout(layoutgrouplayout); + m_layout->addWidget(m_layoutsgroup); + + m_layoutsmodellabel = new QLabel(m_layoutsgroup); + m_layoutsmodellabel->setText(i18n("Model:")); + layoutgrouplayout->addWidget(m_layoutsmodellabel, 0, 0); + m_layoutsmodelbox = new QComboBox(m_layoutsgroup); + m_layoutsmodelbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + foreach (const QByteArray &layoutmodel, KKeyboardLayout::modelNames()) { + m_layoutsmodelbox->addItem(KKeyboardLayout::modelDescription(layoutmodel), layoutmodel); + } + connect( + m_layoutsmodelbox, SIGNAL(currentIndexChanged(int)), + this, SLOT(slotEmitChanged()) + ); + layoutgrouplayout->addWidget(m_layoutsmodelbox, 0, 1); + + m_layoutstree = new QTreeWidget(m_layoutsgroup); + m_layoutstree->setColumnCount(2); + QStringList treeheaders = QStringList() + << i18n("Layout") + << i18n("Variant"); + m_layoutstree->setHeaderLabels(treeheaders); + m_layoutstree->setRootIsDecorated(false); + m_layoutstree->header()->setStretchLastSection(false); + m_layoutstree->header()->setResizeMode(0, QHeaderView::Stretch); + m_layoutstree->header()->setResizeMode(1, QHeaderView::Stretch); + connect( + m_layoutstree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), + this, SLOT(slotEmitChanged()) + ); + connect( + m_layoutstree, SIGNAL(itemSelectionChanged()), + this, SLOT(slotItemSelectionChanged()) + ); + layoutgrouplayout->addWidget(m_layoutstree, 1, 0, 1, 2); + + m_layoutbuttonsbox = new KHBox(m_layoutsgroup); + layoutgrouplayout->addWidget(m_layoutbuttonsbox, 2, 0, 1, 2); + + m_layoutsbuttonsspacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_layoutbuttonsbox->layout()->addItem(m_layoutsbuttonsspacer); + + m_layoutsaddbutton = new QPushButton(m_layoutbuttonsbox); + m_layoutsaddbutton->setText(i18n("Add")); + m_layoutsaddbutton->setIcon(KIcon("list-add")); + connect( + m_layoutsaddbutton, SIGNAL(pressed()), + this, SLOT(slotAddPressed()) + ); + + m_layoutseditbutton = new QPushButton(m_layoutbuttonsbox); + m_layoutseditbutton->setText(i18n("Edit")); + m_layoutseditbutton->setIcon(KIcon("document-edit")); + m_layoutseditbutton->setEnabled(false); + connect( + m_layoutseditbutton, SIGNAL(pressed()), + this, SLOT(slotEditPressed()) + ); + + m_layoutsremovebutton = new QPushButton(m_layoutbuttonsbox); + m_layoutsremovebutton->setText(i18n("Remove")); + m_layoutsremovebutton->setIcon(KIcon("list-remove")); + m_layoutsremovebutton->setEnabled(false); + connect( + m_layoutsremovebutton, SIGNAL(pressed()), + this, SLOT(slotRemovePressed()) + ); + + m_layoutsupbutton = new QPushButton(m_layoutbuttonsbox); + m_layoutsupbutton->setText(i18n("Move Up")); + m_layoutsupbutton->setIcon(KIcon("go-up")); + m_layoutsupbutton->setEnabled(false); + connect( + m_layoutsupbutton, SIGNAL(pressed()), + this, SLOT(slotUpPressed()) + ); + + m_layoutsdownbutton = new QPushButton(m_layoutbuttonsbox); + m_layoutsdownbutton->setText(i18n("Move Down")); + m_layoutsdownbutton->setIcon(KIcon("go-down")); + m_layoutsdownbutton->setEnabled(false); + connect( + m_layoutsdownbutton, SIGNAL(pressed()), + this, SLOT(slotDownPressed()) + ); + + m_layoutsbuttonsspacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_layoutbuttonsbox->layout()->addItem(m_layoutsbuttonsspacer2); +} + +KCMKeyboard::~KCMKeyboard() +{ +} + +void KCMKeyboard::load() +{ + KConfig kconfig("kcminputrc", KConfig::NoGlobals); + KConfigGroup kconfiggroup(&kconfig, "Keyboard"); + const float repeatdelay = kconfiggroup.readEntry("RepeatDelay", s_defaultrepeatdelay); + const float repeatrate = kconfiggroup.readEntry("RepeatRate", s_defaultrepeatrate); + m_repeatdelayinput->setValue(qRound(repeatdelay)); + m_repeatrateinput->setValue(qRound(repeatrate)); + + const QList layouts = kLayoutsFromConfig(); + const KKeyboardType modellayout = (layouts.size() > 0 ? layouts.first() : KKeyboardLayout::defaultLayout()); + m_layoutmodel = modellayout.model; + const int layoutsmodelindex = m_layoutsmodelbox->findData(m_layoutmodel); + if (layoutsmodelindex >= 0) { + m_layoutsmodelbox->setCurrentIndex(layoutsmodelindex); + } else { + kWarning() << "Could not find the keyboard layout model" << m_layoutmodel; + } + + kFillTreeFromLayouts(m_layoutstree, layouts); + + emit changed(false); +} + +void KCMKeyboard::save() +{ + KConfig kconfig("kcminputrc", KConfig::NoGlobals); + KConfigGroup kconfiggroup(&kconfig, "Keyboard"); + kconfiggroup.writeEntry("RepeatDelay", m_repeatdelayinput->value()); + kconfiggroup.writeEntry("RepeatRate", m_repeatrateinput->value()); + m_layoutmodel = m_layoutsmodelbox->itemData(m_layoutsmodelbox->currentIndex()).toByteArray(); + QStringList layoutslayouts; + QStringList layoutsvariants; + for (int i = 0; i < m_layoutstree->topLevelItemCount(); i++) { + QTreeWidgetItem* layoutitem = m_layoutstree->topLevelItem(i); + layoutslayouts.append(layoutitem->data(0, Qt::UserRole).toString()); + layoutsvariants.append(layoutitem->data(1, Qt::UserRole).toString()); + } + kconfiggroup.writeEntry("LayoutsModel", m_layoutmodel); + kconfiggroup.writeEntry("LayoutsLayouts", layoutslayouts); + kconfiggroup.writeEntry("LayoutsVariants", layoutsvariants); + kconfig.sync(); + + kcm_keyboard_apply_config(); + + emit changed(false); +} + +void KCMKeyboard::defaults() +{ + m_repeatdelayinput->setValue(qRound(s_defaultrepeatdelay)); + m_repeatrateinput->setValue(qRound(s_defaultrepeatrate)); + + const KKeyboardType defaultlayout = KKeyboardLayout::defaultLayout(); + const int defaultmodelindex = m_layoutsmodelbox->findData(defaultlayout.model); + if (defaultmodelindex >= 0) { + m_layoutsmodelbox->setCurrentIndex(defaultmodelindex); + } else { + kWarning() << "Could not find the default keyboard layout model" << defaultlayout.model; + } + + const QList layouts = QList() + << defaultlayout; + kFillTreeFromLayouts(m_layoutstree, layouts); + + emit changed(true); +} + +void KCMKeyboard::slotEmitChanged() +{ + emit changed(true); +} + +void KCMKeyboard::slotItemSelectionChanged() +{ + QList selectedlayouts = m_layoutstree->selectedItems(); + if (selectedlayouts.size() == 0) { + m_layoutseditbutton->setEnabled(false); + m_layoutsremovebutton->setEnabled(false); + m_layoutsupbutton->setEnabled(false); + m_layoutsdownbutton->setEnabled(false); + return; + } + + m_layoutseditbutton->setEnabled(true); + m_layoutsremovebutton->setEnabled(true); + if (m_layoutstree->topLevelItemCount() == 1) { + m_layoutsupbutton->setEnabled(false); + m_layoutsdownbutton->setEnabled(false); + return; + } + + const int selectedrow = selectedlayouts.at(0)->data(0, Qt::UserRole + 1).toInt(); + if (selectedrow > 0) { + m_layoutsupbutton->setEnabled(true); + } + if (selectedrow != m_layoutstree->topLevelItemCount()) { + m_layoutsdownbutton->setEnabled(true); + } +} + +void KCMKeyboard::slotAddPressed() +{ + // TODO: + KMessageBox::error(nullptr, "NOT IMPLEMENTED"); +} + +void KCMKeyboard::slotEditPressed() +{ + // TODO: + KMessageBox::error(nullptr, "NOT IMPLEMENTED"); +} + +void KCMKeyboard::slotRemovePressed() +{ + QList selectedlayouts = m_layoutstree->selectedItems(); + if (selectedlayouts.size() == 0) { + return; + } + const int selectedrow = selectedlayouts.at(0)->data(0, Qt::UserRole + 1).toInt(); + QList layouts = kGetLayoutsFromTree(m_layoutstree, m_layoutmodel); + layouts.removeAt(selectedrow); + kFillTreeFromLayouts(m_layoutstree, layouts); + emit changed(true); +} + +void KCMKeyboard::slotUpPressed() +{ + QList selectedlayouts = m_layoutstree->selectedItems(); + if (selectedlayouts.size() == 0) { + return; + } + const int selectedrow = selectedlayouts.at(0)->data(0, Qt::UserRole + 1).toInt(); + QList layouts = kGetLayoutsFromTree(m_layoutstree, m_layoutmodel); + layouts.move(selectedrow, selectedrow - 1); + kFillTreeFromLayouts(m_layoutstree, layouts); + emit changed(true); +} + +void KCMKeyboard::slotDownPressed() +{ + QList selectedlayouts = m_layoutstree->selectedItems(); + if (selectedlayouts.size() == 0) { + return; + } + const int selectedrow = selectedlayouts.at(0)->data(0, Qt::UserRole + 1).toInt(); + QList layouts = kGetLayoutsFromTree(m_layoutstree, m_layoutmodel); + layouts.move(selectedrow, selectedrow + 1); + kFillTreeFromLayouts(m_layoutstree, layouts); + emit changed(true); +} + +#include "moc_keyboardconfig.cpp" diff --git a/kcontrol/keyboard/keyboardconfig.h b/kcontrol/keyboard/keyboardconfig.h new file mode 100644 index 00000000..d9ad9294 --- /dev/null +++ b/kcontrol/keyboard/keyboardconfig.h @@ -0,0 +1,85 @@ +/* This file is part of the KDE project + Copyright (C) 2023 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KEYBOARDCONFIG_H +#define KEYBOARDCONFIG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * Control KDE keyboard + * + * @author Ivailo Monev (xakepa10@gmail.com) + */ +class KCMKeyboard : public KCModule +{ + Q_OBJECT +public: + KCMKeyboard(QWidget *parent, const QVariantList &args); + ~KCMKeyboard(); + + // KCModule reimplementations +public Q_SLOTS: + void load() final; + void save() final; + void defaults() final; + +private Q_SLOTS: + void slotEmitChanged(); + void slotItemSelectionChanged(); + void slotAddPressed(); + void slotEditPressed(); + void slotRemovePressed(); + void slotUpPressed(); + void slotDownPressed(); + +private: + QByteArray m_layoutmodel; + QVBoxLayout* m_layout; + + QGroupBox* m_repeatgroup; + QLabel* m_repeatdelaylabel; + KIntNumInput* m_repeatdelayinput; + QLabel* m_repeatratelabel; + KIntNumInput* m_repeatrateinput; + + QGroupBox* m_layoutsgroup; + QLabel* m_layoutsmodellabel; + QComboBox* m_layoutsmodelbox; + QTreeWidget* m_layoutstree; + KHBox* m_layoutbuttonsbox; + QSpacerItem* m_layoutsbuttonsspacer; + QPushButton* m_layoutsaddbutton; + QPushButton* m_layoutseditbutton; + QPushButton* m_layoutsremovebutton; + QPushButton* m_layoutsupbutton; + QPushButton* m_layoutsdownbutton; + QSpacerItem* m_layoutsbuttonsspacer2; +}; + +#endif // kkeyboardconfig diff --git a/kcontrol/keyboard/layout_memory.cpp b/kcontrol/keyboard/layout_memory.cpp deleted file mode 100644 index a73688bd..00000000 --- a/kcontrol/keyboard/layout_memory.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "layout_memory.h" - -#include -#include - -#include -#include - -#include "x11_helper.h" -#include "xkb_helper.h" - - -LayoutMemory::LayoutMemory(const KeyboardConfig& keyboardConfig_): - prevLayoutList(X11Helper::getLayoutsList()), - keyboardConfig(keyboardConfig_) -{ - registerListeners(); -} - -LayoutMemory::~LayoutMemory() -{ - unregisterListeners(); -} - -void LayoutMemory::configChanged() -{ -// this->layoutMap.clear(); // if needed this will be done on layoutMapChanged event - unregisterListeners(); - registerListeners(); -} - -void LayoutMemory::registerListeners() -{ - if( keyboardConfig.switchingPolicy == KeyboardConfig::SWITCH_POLICY_WINDOW - || keyboardConfig.switchingPolicy == KeyboardConfig::SWITCH_POLICY_APPLICATION ) { - connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(windowChanged(WId))); -// connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, SLOT(windowRemoved(WId))); - } - if( keyboardConfig.switchingPolicy == KeyboardConfig::SWITCH_POLICY_DESKTOP ) { - connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SLOT(desktopChanged(int))); - } -} - -void LayoutMemory::unregisterListeners() -{ - disconnect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(windowChanged(WId))); - disconnect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SLOT(desktopChanged(int))); -// disconnect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, SLOT(windowRemoved(WId))); -} - -QString LayoutMemory::getCurrentMapKey() { - switch(keyboardConfig.switchingPolicy) { - case KeyboardConfig::SWITCH_POLICY_WINDOW: { - WId wid = KWindowSystem::self()->activeWindow(); - KWindowInfo winInfo = KWindowSystem::windowInfo(wid, NET::WMWindowType); - NET::WindowType windowType = winInfo.windowType( NET::NormalMask | NET::DesktopMask | NET::DialogMask ); - kDebug() << "window type" << windowType; - - // we ignore desktop type so that our keybaord layout applet on desktop could change layout properly - if( windowType == NET::Desktop ) - return previousLayoutMapKey; - if( windowType != NET::Unknown && windowType != NET::Normal && windowType != NET::Dialog ) - return QString(); - - return QString::number(wid); - } - case KeyboardConfig::SWITCH_POLICY_APPLICATION: { - WId wid = KWindowSystem::self()->activeWindow(); - KWindowInfo winInfo = KWindowSystem::windowInfo(wid, NET::WMWindowType, NET::WM2WindowClass); - NET::WindowType windowType = winInfo.windowType( NET::NormalMask | NET::DesktopMask | NET::DialogMask ); - kDebug() << "window type" << windowType; - - // we ignore desktop type so that our keybaord layout applet on desktop could change layout properly - if( windowType == NET::Desktop ) - return previousLayoutMapKey; - if( windowType != NET::Unknown && windowType != NET::Normal && windowType != NET::Dialog ) - return QString(); - - // shall we use pid or window class ??? - class seems better (see e.g. https://bugs.kde.org/show_bug.cgi?id=245507) - // for window class shall we use class.class or class.name? (seem class.class is a bit better - more app-oriented) - kDebug() << "New active window with class.class: " << winInfo.windowClassClass(); - return QString(winInfo.windowClassClass()); -// NETWinInfo winInfoForPid( QX11Info::display(), wid, QX11Info::appRootWindow(), NET::WMPid); -// return QString::number(winInfoForPid.pid()); - } - case KeyboardConfig::SWITCH_POLICY_DESKTOP: - return QString::number(KWindowSystem::self()->currentDesktop()); - default: - return QString(); - } -} - -static -bool isExtraSubset(const QList& allLayouts, const QList& newList) -{ - if( allLayouts.first() != newList.first() ) - return false; - foreach(const LayoutUnit& layoutUnit, newList) { - if( ! allLayouts.contains(layoutUnit) ) - return false; - } - return true; -} - -void LayoutMemory::layoutMapChanged() -{ - QList newLayoutList(X11Helper::getLayoutsList()); - - if( prevLayoutList == newLayoutList ) - return; - - kDebug() << "Layout map change: " << LayoutSet::toString(prevLayoutList) << "-->" << LayoutSet::toString(newLayoutList); - prevLayoutList = newLayoutList; - - //TODO: need more thinking here on how to support external map resetting - if( keyboardConfig.configureLayouts - && keyboardConfig.isSpareLayoutsEnabled() - && isExtraSubset(keyboardConfig.layouts, newLayoutList) ) { - kDebug() << "Layout map change for extra layout"; - layoutChanged(); // to remember new map for active "window" - } - else { -// if( newLayoutList != keyboardConfig.getDefaultLayouts() ) { - // layoutList = newLayoutList; - kDebug() << "Layout map change from external source: clearing layout memory"; - layoutMap.clear(); -// } - } -} - -void LayoutMemory::layoutChanged() -{ - QString layoutMapKey = getCurrentMapKey(); - if( layoutMapKey.isEmpty() ) - return; - - layoutMap[ layoutMapKey ] = X11Helper::getCurrentLayouts(); -} - -void LayoutMemory::setCurrentLayoutFromMap() -{ - QString layoutMapKey = getCurrentMapKey(); - if( layoutMapKey.isEmpty() ) - return; - - if( ! layoutMap.contains(layoutMapKey) ) { -// kDebug() << "new key for layout map" << layoutMapKey; - - if( ! X11Helper::isDefaultLayout() ) { -// kDebug() << "setting default layout for container key" << layoutMapKey; - if( keyboardConfig.configureLayouts && keyboardConfig.isSpareLayoutsEnabled() - && X11Helper::getLayoutsList() != keyboardConfig.getDefaultLayouts() ) { - XkbHelper::initializeKeyboardLayouts(keyboardConfig.getDefaultLayouts()); - } - X11Helper::setDefaultLayout(); - } - } - else { - LayoutSet layoutFromMap = layoutMap[layoutMapKey]; - kDebug() << "Setting layout map item" << layoutFromMap.currentLayout.toString() - << "for container key" << layoutMapKey; - - LayoutSet currentLayouts = X11Helper::getCurrentLayouts(); - if( layoutFromMap.layouts != currentLayouts.layouts ) { - if( keyboardConfig.configureLayouts && keyboardConfig.isSpareLayoutsEnabled() ) { - XkbHelper::initializeKeyboardLayouts(layoutFromMap.layouts); - } - X11Helper::setLayout( layoutFromMap.currentLayout ); - } - else if( layoutFromMap.currentLayout != currentLayouts.currentLayout ) { - X11Helper::setLayout( layoutFromMap.currentLayout ); - } - } - - previousLayoutMapKey = layoutMapKey; -} - -//#include -//#include - -void LayoutMemory::windowChanged(WId /*wId*/) -{ -// KPluginInfo::List plugins = Plasma::Containment::listContainments(); -// foreach(KPluginInfo info, plugins) { -// kDebug() << "applets" << info.name(); -// } - setCurrentLayoutFromMap(); -} - -void LayoutMemory::desktopChanged(int /*desktop*/) -{ - setCurrentLayoutFromMap(); -} diff --git a/kcontrol/keyboard/layout_memory.h b/kcontrol/keyboard/layout_memory.h deleted file mode 100644 index 04c25a43..00000000 --- a/kcontrol/keyboard/layout_memory.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef LAYOUT_MEMORY_H_ -#define LAYOUT_MEMORY_H_ - -#include -#include -#include //For WId - -#include "x11_helper.h" -#include "keyboard_config.h" - -class LayoutMemoryPersister; - -class LayoutMemory : public QObject -{ - Q_OBJECT - - // if there's some transient windows coming up we'll need to either ignore it - // or in case of layout switcher popup menu to apply new layout to previous key - QString previousLayoutMapKey; - QList prevLayoutList; - const KeyboardConfig& keyboardConfig; - - void registerListeners(); - void unregisterListeners(); - QString getCurrentMapKey(); - void setCurrentLayoutFromMap(); - -public Q_SLOTS: - void layoutMapChanged(); - void layoutChanged(); - void windowChanged(WId wId); - void desktopChanged(int desktop); - -public: - LayoutMemory(const KeyboardConfig& keyboardConfig); - virtual ~LayoutMemory(); - - void configChanged(); - -protected: - //QVariant does not support long for WId so we'll use QString for key instead - QMap layoutMap; - - friend class LayoutMemoryPersister; -}; - -#endif /* LAYOUT_MEMORY_H_ */ diff --git a/kcontrol/keyboard/layout_memory_persister.cpp b/kcontrol/keyboard/layout_memory_persister.cpp deleted file mode 100644 index 8a6118aa..00000000 --- a/kcontrol/keyboard/layout_memory_persister.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "layout_memory_persister.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include "keyboard_config.h" -#include "layout_memory.h" - - -static const char* VERSION = "1.0"; -static const char* DOC_NAME = "LayoutMap"; -static const char* ROOT_NODE = "LayoutMap"; -static const char* VERSION_ATTRIBUTE = "version"; -static const char* SWITCH_MODE_ATTRIBUTE = "SwitchMode"; -static const char* ITEM_NODE = "item"; -static const QString CURRENT_LAYOUT_ATTRIBUTE("currentLayout"); -static const char* OWNER_KEY_ATTRIBUTE = "ownerKey"; -static const char* LAYOUTS_ATTRIBUTE = "layouts"; - -static const char* LIST_SEPARATOR_LM = ","; - -static const char* REL_SESSION_FILE_PATH = "/session/keyboard/layout_memory.xml"; - -QString LayoutMemoryPersister::getLayoutMapAsString() -{ - if( ! canPersist() ) - return ""; - - QDomDocument doc(DOC_NAME); - QDomElement root = doc.createElement(ROOT_NODE); - root.setAttribute(VERSION_ATTRIBUTE, VERSION); - root.setAttribute(SWITCH_MODE_ATTRIBUTE, KeyboardConfig::getSwitchingPolicyString(layoutMemory.keyboardConfig.switchingPolicy)); - doc.appendChild(root); - - if( layoutMemory.keyboardConfig.switchingPolicy == KeyboardConfig::SWITCH_POLICY_GLOBAL ) { - if( ! globalLayout.isValid() ) - return ""; - - QDomElement item = doc.createElement(ITEM_NODE); - item.setAttribute(CURRENT_LAYOUT_ATTRIBUTE, globalLayout.toString()); - root.appendChild(item); - } - else { - foreach(const QString& key , layoutMemory.layoutMap.keys()) { - QDomElement item = doc.createElement(ITEM_NODE); - item.setAttribute(OWNER_KEY_ATTRIBUTE, key); - item.setAttribute(CURRENT_LAYOUT_ATTRIBUTE, layoutMemory.layoutMap[key].currentLayout.toString()); - - QString layoutSetString; - foreach(const LayoutUnit& layoutUnit, layoutMemory.layoutMap[key].layouts) { - if( ! layoutSetString.isEmpty() ) { - layoutSetString += LIST_SEPARATOR_LM; - } - layoutSetString += layoutUnit.toString(); - } - item.setAttribute(LAYOUTS_ATTRIBUTE, layoutSetString); - root.appendChild(item); - } - } - - return doc.toString(); -} - -static bool isRestoreSession() -{ - KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General"); - kDebug() << "loginMode:" << c.readEntry("loginMode"); - QString loginMode = c.readEntry("loginMode"); - return loginMode != "default" && loginMode != "restoreSavedSession"; // we don't know how to restore saved session - only previous one -} - -bool LayoutMemoryPersister::save(const QString& moduleName) -{ - if( isRestoreSession() ) { - QString relPath = moduleName + REL_SESSION_FILE_PATH; - QFile file(KStandardDirs::locateLocal("data", relPath)); - return saveToFile(file); - } - return false; -} - -bool LayoutMemoryPersister::restore(const QString& moduleName) -{ - if( isRestoreSession() ) { - QString relPath = moduleName + REL_SESSION_FILE_PATH; - QFile file(KStandardDirs::locateLocal("data", relPath)); - return restoreFromFile(file); - } - return false; -} - - -bool LayoutMemoryPersister::saveToFile(const QFile& file_) -{ - QString xml = getLayoutMapAsString(); - if( xml.isEmpty() ) - return false; - - QFile file(file_.fileName()); // so we don't expose the file we open/close to the caller - if( ! file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text) ) { - kWarning() << "Failed to open layout memory xml file for writing" << file.fileName(); - return false; - } - - QTextStream out(&file); - out << xml; - out.flush(); - - if( file.error() != QFile::NoError ) { - kWarning() << "Failed to store keyboard layout memory, error" << file.error(); - file.close(); - file.remove(); - return false; - } - else { - kDebug() << "Keyboard layout memory stored into" << file.fileName() << "written" << file.pos(); - return true; - } -} - - -class MapHandler : public QXmlDefaultHandler -{ -public: - MapHandler(const KeyboardConfig::SwitchingPolicy& switchingPolicy_): - verified(false), - switchingPolicy(switchingPolicy_) {} - - bool startElement(const QString &/*namespaceURI*/, const QString &/*localName*/, - const QString &qName, const QXmlAttributes &attributes) { - - if( qName == ROOT_NODE ) { - if( attributes.value(VERSION_ATTRIBUTE) != VERSION ) - return false; - if( attributes.value(SWITCH_MODE_ATTRIBUTE) != KeyboardConfig::getSwitchingPolicyString(switchingPolicy) ) - return false; - - verified = true; - } - if( qName == ITEM_NODE ) { - if( ! verified ) - return false; - - if( switchingPolicy == KeyboardConfig::SWITCH_POLICY_GLOBAL ) { - globalLayout = LayoutUnit(attributes.value(CURRENT_LAYOUT_ATTRIBUTE)); - } - else { - QStringList layoutStrings = attributes.value(LAYOUTS_ATTRIBUTE).split(LIST_SEPARATOR_LM); - LayoutSet layoutSet; - foreach(const QString& layoutString, layoutStrings) { - layoutSet.layouts.append(LayoutUnit(layoutString)); - } - layoutSet.currentLayout = LayoutUnit(attributes.value(CURRENT_LAYOUT_ATTRIBUTE)); - QString ownerKey = attributes.value(OWNER_KEY_ATTRIBUTE); - - if( ownerKey.trimmed().isEmpty() || ! layoutSet.isValid() ) - return false; - - layoutMap[ownerKey] = layoutSet; - } - } - return verified; - } - - bool verified; - QMap layoutMap; - LayoutUnit globalLayout; - -private: - const KeyboardConfig::SwitchingPolicy& switchingPolicy; -}; - -template -static -bool containsAll(QList set1, QList set2) -{ - foreach(const T& t, set2) { - if( ! set1.contains(t) ) - return false; - } - return true; -} - -bool LayoutMemoryPersister::restoreFromFile(const QFile& file_) -{ - globalLayout = LayoutUnit(); - - if( ! canPersist() ) - return false; - - QFile file(file_.fileName()); // so we don't expose the file we open/close to the caller - if( ! file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { - kWarning() << "Failed to open layout memory xml file for reading" << file.fileName() << "error:" << file.error(); - return false; - } - - MapHandler mapHandler(layoutMemory.keyboardConfig.switchingPolicy); - - QXmlSimpleReader reader; - reader.setContentHandler(&mapHandler); - reader.setErrorHandler(&mapHandler); - - QXmlInputSource xmlInputSource(&file); - kDebug() << "Restoring keyboard layout map from" << file.fileName(); - - if( ! reader.parse(xmlInputSource) ) { - kWarning() << "Failed to parse the layout memory file" << file.fileName(); - return false; - } - - if( layoutMemory.keyboardConfig.switchingPolicy == KeyboardConfig::SWITCH_POLICY_GLOBAL ) { - if( mapHandler.globalLayout.isValid() && layoutMemory.keyboardConfig.layouts.contains(mapHandler.globalLayout)) { - globalLayout = mapHandler.globalLayout; - kDebug() << "Restored global layout" << globalLayout.toString(); - } - } - else { - layoutMemory.layoutMap.clear(); - foreach(const QString& key, mapHandler.layoutMap.keys()) { - if( containsAll(layoutMemory.keyboardConfig.layouts, mapHandler.layoutMap[key].layouts) ) { - layoutMemory.layoutMap.insert(key, mapHandler.layoutMap[key]); - } - } - kDebug() << "Restored layouts for" << layoutMemory.layoutMap.size() << "containers"; - } - return true; -} - -bool LayoutMemoryPersister::canPersist() { - // we can't persist per window - as we're using window id which is not preserved between sessions - bool windowMode = layoutMemory.keyboardConfig.switchingPolicy == KeyboardConfig::SWITCH_POLICY_WINDOW; - if( windowMode ) { - kDebug() << "Not saving session for window mode"; - } - return !windowMode; -} diff --git a/kcontrol/keyboard/layout_memory_persister.h b/kcontrol/keyboard/layout_memory_persister.h deleted file mode 100644 index 93ac8c45..00000000 --- a/kcontrol/keyboard/layout_memory_persister.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef LAYOUT_MEMORY_PERSISTER_H_ -#define LAYOUT_MEMORY_PERSISTER_H_ - -#include - -#include "x11_helper.h" - -class LayoutMemory; -#include - -class LayoutMemoryPersister { -public: - LayoutMemoryPersister(LayoutMemory& layoutMemory_): - layoutMemory(layoutMemory_) {} - - bool saveToFile(const QFile& file); - bool restoreFromFile(const QFile& file); - - bool save(const QString& moduleName); - bool restore(const QString& moduleName); - - LayoutUnit getGlobalLayout() const { return globalLayout; } - void setGlobalLayout(const LayoutUnit& layout) { globalLayout = layout; } - -private: - LayoutMemory& layoutMemory; - LayoutUnit globalLayout; - - QString getLayoutMapAsString(); - - bool canPersist(); -}; - -#endif /* LAYOUT_MEMORY_PERSISTER_H_ */ diff --git a/kcontrol/keyboard/layout_tray_icon.cpp b/kcontrol/keyboard/layout_tray_icon.cpp deleted file mode 100644 index 85eac9e4..00000000 --- a/kcontrol/keyboard/layout_tray_icon.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "layout_tray_icon.h" - -//#include -#include -#include -#include - -#include "xkb_rules.h" -#include "x11_helper.h" -#include "xkb_helper.h" -#include "keyboard_config.h" -#include "flags.h" -#include "layouts_menu.h" - - -// -// Layout Tray Icon -// -LayoutTrayIcon::LayoutTrayIcon(const Rules* rules_, const KeyboardConfig& keyboardConfig_): - keyboardConfig(keyboardConfig_), - rules(rules_), - flags(new Flags()), - layoutsMenu(new LayoutsMenu(keyboardConfig_, *rules, *flags)) -{ - m_notifierItem = new KStatusNotifierItem(this); - m_notifierItem->setCategory(KStatusNotifierItem::SystemServices); - m_notifierItem->setStatus(KStatusNotifierItem::Active); - m_notifierItem->setToolTipTitle(i18nc("tooltip title", "Keyboard Layout")); - m_notifierItem->setTitle(i18nc("tooltip title", "Keyboard Layout")); - - KMenu* menu = new KMenu(""); - m_notifierItem->setContextMenu(menu); - m_notifierItem->setStandardActionsEnabled(false); - - layoutMapChanged(); - - m_notifierItem->setStatus(KStatusNotifierItem::Active); - - init(); -} - -LayoutTrayIcon::~LayoutTrayIcon() -{ - destroy(); - delete flags; - delete layoutsMenu; -} - -void LayoutTrayIcon::init() -{ - connect(m_notifierItem, SIGNAL(activateRequested(bool,QPoint)), this, SLOT(toggleLayout())); - connect(m_notifierItem, SIGNAL(scrollRequested(int,Qt::Orientation)), this, SLOT(scrollRequested(int,Qt::Orientation))); - connect(flags, SIGNAL(pixmapChanged()), this, SLOT(layoutChanged())); -} - -void LayoutTrayIcon::destroy() -{ - disconnect(flags, SIGNAL(pixmapChanged()), this, SLOT(layoutChanged())); - disconnect(m_notifierItem, SIGNAL(scrollRequested(int,Qt::Orientation)), this, SLOT(scrollRequested(int,Qt::Orientation))); - disconnect(m_notifierItem, SIGNAL(activateRequested(bool,QPoint)), this, SLOT(toggleLayout())); -} - -void LayoutTrayIcon::layoutMapChanged() -{ - flags->clearCache(); - - KMenu* menu = m_notifierItem->contextMenu(); - menu->clear(); - QList actions = layoutsMenu->contextualActions(); - menu->addActions(actions); - - layoutChanged(); -} - -void LayoutTrayIcon::layoutChanged() -{ - LayoutUnit layoutUnit = X11Helper::getCurrentLayout(); - if( layoutUnit.isEmpty() ) - return; - -// QString shortText = Flags::getShortText(layoutUnit, *keyboardConfig); -// kDebug() << "systray: LayoutChanged" << layoutUnit.toString() << shortText; - QString longText = Flags::getLongText(layoutUnit, rules); - - m_notifierItem->setToolTipSubTitle(longText); - - const QIcon icon(getFlag(layoutUnit.layout)); - m_notifierItem->setToolTipIconByPixmap(icon); - - QIcon textOrIcon = flags->getIconWithText(layoutUnit, keyboardConfig); - m_notifierItem->setIconByPixmap( textOrIcon ); -} - -void LayoutTrayIcon::toggleLayout() -{ - X11Helper::switchToNextLayout(); -} - -void LayoutTrayIcon::scrollRequested(int delta, Qt::Orientation /*orientation*/) -{ - X11Helper::scrollLayouts(delta > 0 ? 1 : -1); -} - -const QIcon LayoutTrayIcon::getFlag(const QString& layout) const -{ - return keyboardConfig.isFlagShown() ? flags->getIcon(layout) : QIcon(); -} diff --git a/kcontrol/keyboard/layout_tray_icon.h b/kcontrol/keyboard/layout_tray_icon.h deleted file mode 100644 index 91131f28..00000000 --- a/kcontrol/keyboard/layout_tray_icon.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef LAYOUT_TRAY_ICON_H_ -#define LAYOUT_TRAY_ICON_H_ - -#include -#include - -#include "flags.h" -#include "x11_helper.h" - -class KeyboardConfig; -class LayoutsMenu; - -/** - * System tray icon to show layouts - */ -class KStatusNotifierItem; -#include -class Rules; -class Flags; -class LayoutTrayIcon : public QObject -{ - Q_OBJECT - -public: - LayoutTrayIcon(const Rules* rules, const KeyboardConfig& keyboardConfig); - ~LayoutTrayIcon(); - - void layoutMapChanged(); - -public Q_SLOTS: - void layoutChanged(); - -private Q_SLOTS: - void toggleLayout(); - void scrollRequested(int, Qt::Orientation); - -private: - void init(); - void destroy(); - const QIcon getFlag(const QString& layout) const; - - const KeyboardConfig& keyboardConfig; - const Rules* rules; - Flags* flags; - KStatusNotifierItem *m_notifierItem; - LayoutsMenu* layoutsMenu; -}; - - -#endif /* LAYOUT_WIDGET_H_ */ diff --git a/kcontrol/keyboard/layout_widget.cpp b/kcontrol/keyboard/layout_widget.cpp deleted file mode 100644 index 07ef0a56..00000000 --- a/kcontrol/keyboard/layout_widget.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "layout_widget.h" - -//#include -#include - -#include - -#include "xkb_rules.h" -#include "x11_helper.h" -#include "xkb_helper.h" -#include "keyboard_config.h" -#include "flags.h" - - -K_PLUGIN_FACTORY(LayoutWidgetFactory, registerPlugin();) -K_EXPORT_PLUGIN(LayoutWidgetFactory("keyboard_layout_widget")) - - -LayoutWidget::LayoutWidget(QWidget* parent, const QList& /*args*/): - QWidget(parent), - xEventNotifier(), - keyboardConfig(new KeyboardConfig()), - flags(new Flags()) -{ - if( ! X11Helper::xkbSupported(NULL) ) { -// setFailedToLaunch(true, "XKB extension failed to initialize"); - hide(); - return; - } - - keyboardConfig->load(); - bool show = // keyboardConfig->showIndicator && - ( keyboardConfig->showSingle || X11Helper::getLayoutsList().size() > 1 ); - if( ! show ) { - hide(); - return; - } - - widget = new QPushButton(this); - widget->setFlat(true); - - layoutChanged(); - init(); -} - -LayoutWidget::~LayoutWidget() -{ - destroy(); -} - -void LayoutWidget::init() -{ - connect(widget, SIGNAL(clicked(bool)), this, SLOT(toggleLayout())); - connect(&xEventNotifier, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); - connect(&xEventNotifier, SIGNAL(layoutMapChanged()), this, SLOT(layoutChanged())); - xEventNotifier.start(); -} - -void LayoutWidget::destroy() -{ - xEventNotifier.stop(); - disconnect(&xEventNotifier, SIGNAL(layoutMapChanged()), this, SLOT(layoutChanged())); - disconnect(&xEventNotifier, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); -} - -void LayoutWidget::toggleLayout() -{ - X11Helper::switchToNextLayout(); -} - -void LayoutWidget::layoutChanged() -{ - LayoutUnit layoutUnit = X11Helper::getCurrentLayout(); - if( layoutUnit.isEmpty() ) - return; - - QIcon icon; - if( keyboardConfig->isFlagShown() ) { - icon = flags->getIcon(layoutUnit.layout); - } - - QString longText = Flags::getLongText(layoutUnit, NULL); - if( ! icon.isNull() ) { - widget->setIcon(icon); - widget->setText(""); - widget->setToolTip(longText); - } - else { - QString shortText = Flags::getShortText(layoutUnit, *keyboardConfig); - widget->setIcon(icon); - widget->setText(shortText); - widget->setToolTip(longText); -// widget->setShortcut(QKeySequence()); - } -} - diff --git a/kcontrol/keyboard/layout_widget.h b/kcontrol/keyboard/layout_widget.h deleted file mode 100644 index ca7a057b..00000000 --- a/kcontrol/keyboard/layout_widget.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef LAYOUT_WIDGET_H_ -#define LAYOUT_WIDGET_H_ - -#include -#include - -#include "flags.h" -#include "x11_helper.h" - -#include -class KeyboardConfig; -class LayoutsMenu; - -/** - * Note: does not listen to configuration changes as currently we only use it in screen lock dialog - */ -class LayoutWidget : public QWidget -{ - Q_OBJECT - -public: - explicit LayoutWidget(QWidget* parent = 0, const QList& args = QList()); - virtual ~LayoutWidget(); - -private Q_SLOTS: - void toggleLayout(); - void layoutChanged(); - // void configChanged(); - -private: - void init(); - void destroy(); - - XEventNotifier xEventNotifier; - QPushButton* widget; - KeyboardConfig* keyboardConfig; - Flags* flags; -}; - -#endif /* LAYOUT_WIDGET_H_ */ diff --git a/kcontrol/keyboard/layouts_menu.cpp b/kcontrol/keyboard/layouts_menu.cpp deleted file mode 100644 index 5b9a62e5..00000000 --- a/kcontrol/keyboard/layouts_menu.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "layouts_menu.h" - -#include -#include -#include -#include - -#include -#include - -#include "keyboard_config.h" -#include "x11_helper.h" -#include "xkb_helper.h" -#include "flags.h" - - -LayoutsMenu::LayoutsMenu(const KeyboardConfig& keyboardConfig_, const Rules& rules_, Flags& flags_): - keyboardConfig(keyboardConfig_), - rules(rules_), - flags(flags_), - actionGroup(NULL) -{ -} - -LayoutsMenu::~LayoutsMenu() -{ - delete actionGroup; -} - -const QIcon LayoutsMenu::getFlag(const QString& layout) const -{ - return keyboardConfig.isFlagShown() ? flags.getIcon(layout) : QIcon(); -} - -void LayoutsMenu::actionTriggered(QAction* action) -{ - QString data = action->data().toString(); - if( data == "config" ) { - QStringList args; - args << "--args=--tab=layouts"; - args << "kcm_keyboard"; - KToolInvocation::kdeinitExec("kcmshell4", args); - } - else { - LayoutUnit layoutUnit(LayoutUnit(action->data().toString())); - switchToLayout(layoutUnit, keyboardConfig); - } -} - -int LayoutsMenu::switchToLayout(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig) -{ - QList layouts = X11Helper::getCurrentLayouts().layouts; - - bool res; - if( layouts.contains(layoutUnit) ) { - res = X11Helper::setLayout(layoutUnit); - } - else if ( keyboardConfig.isSpareLayoutsEnabled() && keyboardConfig.layouts.contains(layoutUnit) ) { - QList layouts(keyboardConfig.getDefaultLayouts()); - layouts.removeLast(); - layouts.append(layoutUnit); - XkbHelper::initializeKeyboardLayouts(layouts); - res = X11Helper::setLayout(layoutUnit); - } - else { - kWarning() << "switchToLayout with unknown layout" << layoutUnit.toString(); - res = -1; - } - return res; -} - -QAction* LayoutsMenu::createAction(const LayoutUnit& layoutUnit) const -{ - QString menuText = Flags::getFullText(layoutUnit, keyboardConfig, &rules); - QAction* action = new QAction(getFlag(layoutUnit.layout), menuText, actionGroup); - action->setData(layoutUnit.toString()); - //FIXME: tooltips don't work on dbusmenus??? -// if( ! layoutUnit.getShortcut().isEmpty() ) { -// action->setToolTip(layoutUnit.getShortcut().toString()); -// } - return action; -} - -QList LayoutsMenu::contextualActions() -{ - if( actionGroup ) { - disconnect(actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); - delete actionGroup; - } - actionGroup = new QActionGroup(this); - - X11Helper::getLayoutsList(); //UGLY: seems to be more reliable with extra call - QList currentLayouts = X11Helper::getLayoutsList(); - foreach(const LayoutUnit& layoutUnit, currentLayouts) { - QAction* action = createAction(layoutUnit); - actionGroup->addAction(action); - } - - if( keyboardConfig.configureLayouts ) { - QList extraLayouts = keyboardConfig.layouts; - foreach(const LayoutUnit& layoutUnit, currentLayouts) { - extraLayouts.removeOne(layoutUnit); - } - if( extraLayouts.size() > 0 ) { - QAction* separator = new QAction(actionGroup); - separator->setSeparator(true); - actionGroup->addAction(separator); - - foreach(const LayoutUnit& layoutUnit, extraLayouts) { - QAction* action = createAction(layoutUnit); - actionGroup->addAction(action); - } - } - } - - QAction* separator = new QAction(actionGroup); - separator->setSeparator(true); - actionGroup->addAction(separator); - QAction* configAction = new QAction(i18n("Configure..."), actionGroup); - actionGroup->addAction(configAction); - configAction->setData("config"); - connect(actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); - return actionGroup->actions(); -} diff --git a/kcontrol/keyboard/layouts_menu.h b/kcontrol/keyboard/layouts_menu.h deleted file mode 100644 index 3316d029..00000000 --- a/kcontrol/keyboard/layouts_menu.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef LAYOUTS_MENU_H_ -#define LAYOUTS_MENU_H_ - -#include -#include - -#include -class KeyboardConfig; -class Flags; -class Rules; -#include -class LayoutUnit; - -class LayoutsMenu : public QObject -{ - Q_OBJECT - -public: - LayoutsMenu(const KeyboardConfig& keyboardConfig, const Rules& rules, Flags& flags); - virtual ~LayoutsMenu(); - - QList contextualActions(); - static int switchToLayout(const LayoutUnit& layoutUnit, const KeyboardConfig& keyboardConfig); - -private Q_SLOTS: - void actionTriggered(QAction* action); - -private: - const QIcon getFlag(const QString& layout) const; - QAction* createAction(const LayoutUnit& layoutUnit) const; - - const KeyboardConfig& keyboardConfig; - const Rules& rules; - Flags& flags; - QActionGroup* actionGroup; -}; - -#endif /* LAYOUTS_MENU_H_ */ diff --git a/kcontrol/keyboard/numlockx.c b/kcontrol/keyboard/numlockx.c deleted file mode 100644 index e3599fe6..00000000 --- a/kcontrol/keyboard/numlockx.c +++ /dev/null @@ -1,303 +0,0 @@ -/**************************************************************************** - - NumLockX - - $Id: main.c,v 1.10 2001/04/30 20:55:20 seli Exp $ - - Copyright (C) 2000-2001 Lubos Lunak - Copyright (C) 2001 Oswald Buddenhagen - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -****************************************************************************/ - -#include - -#include - -#include - -#ifdef HAVE_XTEST -#include -#endif - -#ifdef HAVE_XKB -#include -#endif - -#include - -static -Display* dpy; - -/* the XKB stuff is based on code created by Oswald Buddenhagen */ -#ifdef HAVE_XKB -static -int xkb_init() - { - int xkb_opcode, xkb_event, xkb_error; - int xkb_lmaj = XkbMajorVersion; - int xkb_lmin = XkbMinorVersion; - return XkbLibraryVersion( &xkb_lmaj, &xkb_lmin ) - && XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error, - &xkb_lmaj, &xkb_lmin ); - } - -static -unsigned int xkb_mask_modifier( XkbDescPtr xkb, const char *name ) - { - int i; - if( !xkb || !xkb->names ) - return 0; - for( i = 0; - i < XkbNumVirtualMods; - i++ ) - { - char* modStr = XGetAtomName( xkb->dpy, xkb->names->vmods[i] ); - if( modStr != NULL && strcmp(name, modStr) == 0 ) - { - unsigned int mask; - XkbVirtualModsToReal( xkb, 1 << i, &mask ); - return mask; - } - } - return 0; - } - -static -unsigned int xkb_numlock_mask() - { - XkbDescPtr xkb; - if(( xkb = XkbGetKeyboard( dpy, XkbAllComponentsMask, XkbUseCoreKbd )) != NULL ) - { - unsigned int mask = xkb_mask_modifier( xkb, "NumLock" ); - XkbFreeKeyboard( xkb, 0, True ); - return mask; - } - return 0; - } - -static -int xkb_set_on() - { - unsigned int mask; - if( !xkb_init()) - return 0; - mask = xkb_numlock_mask(); - if( mask == 0 ) - return 0; - XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, mask); - return 1; - } - -static -int xkb_set_off() - { - unsigned int mask; - if( !xkb_init()) - return 0; - mask = xkb_numlock_mask(); - if( mask == 0 ) - return 0; - XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, 0); - return 1; - } - -#ifdef NUMLOCKX_STANDALONE -static -int xkb_toggle() - { - unsigned int mask; - unsigned int numlockState; - XkbStateRec xkbState; - if( !xkb_init()) - return 0; - mask = xkb_numlock_mask(); - if( mask == 0 ) - return 0; - XkbGetState( dpy, XkbUseCoreKbd, &xkbState); - numlockState = xkbState.locked_mods & mask; - if (numlockState) - XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, 0); - else - XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, mask); - return 1; - } -#endif - -#endif - -#ifdef HAVE_XTEST -static -int xtest_get_numlock_state() - { - int i; - int numlock_mask = 0; - Window dummy1, dummy2; - int dummy3, dummy4, dummy5, dummy6; - unsigned int mask; - XModifierKeymap* map = XGetModifierMapping( dpy ); - KeyCode numlock_keycode = XKeysymToKeycode( dpy, XK_Num_Lock ); - if( numlock_keycode == NoSymbol ) - return 0; - for( i = 0; - i < 8; - ++i ) - { - if( map->modifiermap[ map->max_keypermod * i ] == numlock_keycode ) - numlock_mask = 1 << i; - } - XQueryPointer( dpy, DefaultRootWindow( dpy ), &dummy1, &dummy2, - &dummy3, &dummy4, &dummy5, &dummy6, &mask ); - XFreeModifiermap( map ); - return mask & numlock_mask; - } - -static -void xtest_change_numlock() - { - XTestFakeKeyEvent( dpy, XKeysymToKeycode( dpy, XK_Num_Lock ), True, CurrentTime ); - XTestFakeKeyEvent( dpy, XKeysymToKeycode( dpy, XK_Num_Lock ), False, CurrentTime ); - } - -static -void xtest_set_on() - { - if( !xtest_get_numlock_state()) - xtest_change_numlock(); - } - -static -void xtest_set_off() - { - if( xtest_get_numlock_state()) - xtest_change_numlock(); - } - -#ifdef NUMLOCKX_STANDALONE -static -void xtest_toggle() - { - xtest_change_numlock(); - } -#endif - -#endif - -static -void numlock_set_on() - { -#ifdef HAVE_XKB - if( xkb_set_on()) - return; -#endif -#ifdef HAVE_XTEST - xtest_set_on(); -#endif - } - -static -void numlock_set_off() - { -#ifdef HAVE_XKB - if( xkb_set_off()) - return; -#endif -#ifdef HAVE_XTEST - xtest_set_off(); -#endif - } - - -#ifndef NUMLOCKX_STANDALONE - -void numlockx_change_numlock_state(Display* dpy_, int state) -{ -#ifndef HAVE_XTEST - #warning "XTEST extension not found - numlock setting may not work reliably" -#endif - - dpy = dpy_; - if( state ) { - numlock_set_on(); - } - else { - numlock_set_off(); - } -} - -#else - -static -void numlock_toggle() - { -#ifdef HAVE_XKB - if( xkb_toggle()) - return; -#endif -#ifdef HAVE_XTEST - xtest_toggle(); -#endif - } - -void usage( const char* argv0 ) - { - printf( "NumLockX " VERSION "\n" - "(C) 2000-2001 Lubos Lunak \n" - "(C) 2001 Oswald Buddenhagen \n\n" - "Usage : %s [on|off]\n" - "on - turns NumLock on in X ( default )\n" - "off - turns NumLock off in X\n" - "toggle - toggles the NumLock on and off in X\n" - "\n" - , argv0 ); - } - -int main( int argc, char* argv[] ) - { - if( argc > 2 ) - { - usage( argv[ 0 ] ); - return 1; - } - dpy = XOpenDisplay( NULL ); - if( dpy == NULL ) - { - fprintf( stderr, "Error opening display!\n" ); - return 1; - } - if( argc == 1 ) - numlock_set_on(); - else if( strcmp( argv[ 1 ], "on" ) == 0 ) - numlock_set_on(); - else if( strcmp( argv[ 1 ], "off" ) == 0 ) - numlock_set_off(); - else if( strcmp( argv[ 1 ], "toggle" ) == 0 ) - numlock_toggle(); - else - { - usage( argv[ 0 ] ); - XCloseDisplay( dpy ); - return 2; - } - XCloseDisplay( dpy ); - return 0; - } - -#endif diff --git a/kcontrol/keyboard/pics/CMakeLists.txt b/kcontrol/keyboard/pics/CMakeLists.txt deleted file mode 100644 index e87e7e74..00000000 --- a/kcontrol/keyboard/pics/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -install( FILES epo.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/kcmkeyboard/pics ) diff --git a/kcontrol/keyboard/pics/epo.png b/kcontrol/keyboard/pics/epo.png deleted file mode 100644 index aa04ef295e74532e86386574014c739b9c97d436..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^qCm{Y!VDyhG`#)-DXjpX5Lbqo3<}E>95*}0?TgDe zl(G52=3S3>U3q)u%DXG~KHYoq^~H;CFaG`e_y7O@iCeStfx5IkT^vI=t|#xP{{D`Y zO=Cy3=)rySW-zAT54zyCqVQYm=J#jjHVe2LwX-oWuyY7+UB1KWCQuuLr>mdKI;Vst E0DnY3*#H0l diff --git a/kcontrol/keyboard/preview/kbpreviewframe.cpp b/kcontrol/keyboard/preview/kbpreviewframe.cpp deleted file mode 100644 index 8ecc4f24..00000000 --- a/kcontrol/keyboard/preview/kbpreviewframe.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include "kbpreviewframe.h" - -#include -#include - -#include -#include - - -static const QColor keyBorderColor("#d4d4d4"); -static const QColor lev12color("#d4d4d4"); -static const QColor lev34color("#FF3300"); -static const int sz=20, kszx=70, kszy=70; - -static const int xOffset[] = {15, 15, 40, 40 }; -static const int yOffset[] = {10, 40, 10, 40 }; -static const QColor color[] = { lev12color, lev12color, lev34color, lev34color }; - - -// TODO: parse geometry files and display keyboard according to current keyboard model - -KbPreviewFrame::KbPreviewFrame(QWidget *parent) : - QFrame(parent) -{ - setFrameStyle( QFrame::Box ); - setFrameShadow(QFrame::Sunken); -} - -void KbPreviewFrame::paintTLDE(QPainter &painter,int &x,int &y) -{ - painter.setPen(keyBorderColor); - painter.drawRect(x, y, kszx, kszy); - - const QList symbols = keyboardLayout.TLDE.symbols; - - for(int level=0; level symbols = keyboardLayout.AE[i].symbols; - - for(int level=0; level")); - x+=tabszx; - - - for(int i=0; i symbols = keyboardLayout.AD[i].symbols; - - painter.setPen(keyBorderColor); - painter.drawRect(x, y,kszx,kszy); - - for(int level=0; level symbols = keyboardLayout.BKSL.symbols; - - for(int level=0; level symbols = keyboardLayout.AC[i].symbols; - - for(int level=0; level symbols = keyboardLayout.AB[i].symbols; - - for(int level=0; level symstr = content.split("xkb_symbols "); - - if( layoutVariant.isEmpty() ) { - keyboardLayout.generateLayout(symstr.at(1), layout); - } - else { - for(int i=1;i -#include - -class KbPreviewFrame : public QFrame -{ - Q_OBJECT - -private: - void paintTLDE(QPainter &painter, int &x, int &y); - void paintAERow(QPainter &painter, int &x, int &y); - void paintADRow(QPainter &painter, int &x, int &y); - void paintACRow(QPainter &painter, int &x, int &y); - void paintABRow(QPainter &painter, int &x, int &y); - void paintBottomRow(QPainter &painter, int &x, int &y); - void paintFnKeys(QPainter &painter, int &x, int &y); - - KeySymHelper symbol; - Aliases alias; - KeyboardLayout keyboardLayout; - -public: - explicit KbPreviewFrame(QWidget *parent = 0); - - void paintEvent(QPaintEvent * event); - void generateKeyboardLayout(const QString &country, const QString &layoutVariant); - QString getLayoutName() const { - return keyboardLayout.getLayoutName(); - } -}; - -#endif // KBPREVIEWFRAME_H diff --git a/kcontrol/keyboard/preview/keyaliases.cpp b/kcontrol/keyboard/preview/keyaliases.cpp deleted file mode 100644 index fdf2f123..00000000 --- a/kcontrol/keyboard/preview/keyaliases.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "keyaliases.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - - -Aliases::Aliases() -{ - QString filename=findaliasdir(); - QFile file(filename); - file.open(QIODevice::ReadOnly | QIODevice::Text); - QString content = file.readAll(); - file.close(); - QListals; - als=content.split("xkb_keycodes"); - for(int i=1;i"); - temp=temp.remove("<"); - temp=temp.remove(";"); - temp=temp.remove("}"); - temp=temp.remove("{"); - QListalskeys; - alskeys=temp.split("alias"); - if(temp.startsWith("qwerty")){ - for(int k=1;k= 3 ) { - // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb - QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11"; - QDir baseDir(base + delta); - if( baseDir.exists() ) { - xkbParentDir = baseDir.absolutePath(); - } - else { - QDir baseDir(base + "/X11"); // .../usr/X11/lib/X11/xkb (old XFree) - if( baseDir.exists() ) { - xkbParentDir = baseDir.absolutePath(); - } - } - } - - if( xkbParentDir.isEmpty() ) { - xkbParentDir = "/usr/share/X11"; - } - aliasdir=QString("%1/xkb/keycodes/aliases").arg(xkbParentDir); - return(aliasdir); -} diff --git a/kcontrol/keyboard/preview/keyaliases.h b/kcontrol/keyboard/preview/keyaliases.h deleted file mode 100644 index 3769e4eb..00000000 --- a/kcontrol/keyboard/preview/keyaliases.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef ALIASES_H -#define ALIASES_H - -#include - -class Aliases -{ -private: - QMapqwerty; - QMapazerty; - QMapqwertz; - QString findaliasdir(); -public: - Aliases(); - QString getAlias(const QString &type, const QString &name); -}; - -#endif // ALIASES_H diff --git a/kcontrol/keyboard/preview/keyboardlayout.cpp b/kcontrol/keyboard/preview/keyboardlayout.cpp deleted file mode 100644 index 5d607b0a..00000000 --- a/kcontrol/keyboard/preview/keyboardlayout.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include "keyboardlayout.h" -#include "keysymbols.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -//TODO: replace this with grammar parser (e.g. antlr) - - -KeyboardLayout::KeyboardLayout() -{ -} - -void KeyboardLayout::generateLayout(QString a,const QString& cname) -{ - includeSymbol(a,cname); - int i=a.indexOf("name[Group1]="); - i+=13; - - QString n=a.mid(i); - n=n.simplified(); - i=n.indexOf("\"",1); - layoutName=n.left(i); - layoutName.remove("\""); - layoutName.simplified(); - i=n.indexOf("key"); - n=n.mid(i); - - QList st; - st=n.split("key"); - - KeySymbols dum; - QString r,y; - - for(int k=0;ktobeinclude; - tobeinclude=a.split("include"); - - QString r; - for(int o=1;o incfile; - incfile=incsym.split("("); - for(int i=0;i symstrlist; - - symstrlist=content.split("xkb_symbols "); - for(int u=1;u= 3 ) { - // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb - QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11"; - QDir baseDir(base + delta); - if( baseDir.exists() ) { - xkbParentDir = baseDir.absolutePath(); - } - else { - QDir baseDir(base + "/X11"); // .../usr/X11/lib/X11/xkb (old XFree) - if( baseDir.exists() ) { - xkbParentDir = baseDir.absolutePath(); - } - } - } - - if( xkbParentDir.isEmpty() ) { - xkbParentDir = "/usr/share/X11"; - } - - return QString("%1/xkb/symbols/").arg(xkbParentDir); -} diff --git a/kcontrol/keyboard/preview/keyboardlayout.h b/kcontrol/keyboard/preview/keyboardlayout.h deleted file mode 100644 index 4844382e..00000000 --- a/kcontrol/keyboard/preview/keyboardlayout.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef KEYBOARDLAYOUT_H -#define KEYBOARDLAYOUT_H - -#include "keysymbols.h" -#include "keyaliases.h" - -#include - -class KeyboardLayout -{ - QString layoutName; - Aliases alias; - -public: - KeyboardLayout(); - - KeySymbols TLDE; - KeySymbols BKSL; - KeySymbols AE[12]; - KeySymbols AD[12]; - KeySymbols AC[11]; - KeySymbols AB[11]; - - void generateLayout(QString a, const QString &cname); - QString findSymbolBaseDir(); - void includeSymbol(QString a, const QString &cname); - QString getLayoutName() const { - return layoutName; - } -}; - -#endif // KEYBOARDLAYOUT_H diff --git a/kcontrol/keyboard/preview/keyboardpainter.cpp b/kcontrol/keyboard/preview/keyboardpainter.cpp deleted file mode 100644 index b9fbf242..00000000 --- a/kcontrol/keyboard/preview/keyboardpainter.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "keyboardpainter.h" - -#include -#include -#include - -#include - - -KeyboardPainter::KeyboardPainter(): - kbframe(new KbPreviewFrame(this)), - exitButton(new QPushButton(i18n("Close"),this)) -{ - kbframe->setFixedSize( 1030, 490 ); - exitButton->setFixedSize(120, 30); - - QVBoxLayout* vLayout = new QVBoxLayout( this ); - vLayout->addWidget(kbframe); - vLayout->addWidget(exitButton); - - connect(exitButton, SIGNAL(clicked()), this, SLOT(close())); - - setWindowTitle(kbframe->getLayoutName()); -} - -void KeyboardPainter::generateKeyboardLayout(const QString& layout, const QString& variant) -{ - kbframe->generateKeyboardLayout(layout, variant); -} - -KeyboardPainter::~KeyboardPainter() -{ - delete kbframe; - delete exitButton; -} diff --git a/kcontrol/keyboard/preview/keyboardpainter.h b/kcontrol/keyboard/preview/keyboardpainter.h deleted file mode 100644 index f666c996..00000000 --- a/kcontrol/keyboard/preview/keyboardpainter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef KEYBOARDPAINTER_H -#define KEYBOARDPAINTER_H - -#include "kbpreviewframe.h" - -#include - -#include - -class KeyboardPainter : public QDialog -{ - Q_OBJECT - -public: - explicit KeyboardPainter(); - ~KeyboardPainter(); - - void generateKeyboardLayout(const QString& layout, const QString& variant); - -private: - KbPreviewFrame *kbframe; - QPushButton *exitButton; -}; - -#endif // KEYBOARDPAINTER_H diff --git a/kcontrol/keyboard/preview/keysym2ucs.cpp b/kcontrol/keyboard/preview/keysym2ucs.cpp deleted file mode 100644 index 1822582b..00000000 --- a/kcontrol/keyboard/preview/keysym2ucs.cpp +++ /dev/null @@ -1,878 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/* $XFree86$ - * This module converts keysym values into the corresponding ISO 10646-1 - * (UCS, Unicode) values. - * - * The array keysymtab[] contains pairs of X11 keysym values for graphical - * characters and the corresponding Unicode value. The function - * keysym2ucs() maps a keysym onto a Unicode value using a binary search, - * therefore keysymtab[] must remain SORTED by keysym value. - * - * The keysym -> UTF-8 conversion will hopefully one day be provided - * by Xlib via XmbLookupString() and should ideally not have to be - * done in X applications. But we are not there yet. - * - * We allow to represent any UCS character in the range U+00000000 to - * U+00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff. - * This admittedly does not cover the entire 31-bit space of UCS, but - * it does cover all of the characters up to U+10FFFF, which can be - * represented by UTF-16, and more, and it is very unlikely that higher - * UCS codes will ever be assigned by ISO. So to get Unicode character - * U+ABCD you can directly use keysym 0x1000abcd. - * - * NOTE: The comments in the table below contain the actual character - * encoded in UTF-8, so for viewing and editing best use an editor in - * UTF-8 mode. - * - * Author: Markus G. Kuhn , University of Cambridge, June 1999 - * - * Special thanks to Richard Verhoeven for preparing - * an initial draft of the mapping table. - */ - -#include - -struct codepair { - unsigned short keysym; - unsigned short ucs; -} keysymtab[] = { - { 0x01a1, 0x0104 }, /* Aogonek Ą LATIN CAPITAL LETTER A WITH OGONEK */ - { 0x01a2, 0x02d8 }, /* breve ˘ BREVE */ - { 0x01a3, 0x0141 }, /* Lstroke Ł LATIN CAPITAL LETTER L WITH STROKE */ - { 0x01a5, 0x013d }, /* Lcaron Ľ LATIN CAPITAL LETTER L WITH CARON */ - { 0x01a6, 0x015a }, /* Sacute Ś LATIN CAPITAL LETTER S WITH ACUTE */ - { 0x01a9, 0x0160 }, /* Scaron Š LATIN CAPITAL LETTER S WITH CARON */ - { 0x01aa, 0x015e }, /* Scedilla Ş LATIN CAPITAL LETTER S WITH CEDILLA */ - { 0x01ab, 0x0164 }, /* Tcaron Ť LATIN CAPITAL LETTER T WITH CARON */ - { 0x01ac, 0x0179 }, /* Zacute Ź LATIN CAPITAL LETTER Z WITH ACUTE */ - { 0x01ae, 0x017d }, /* Zcaron Ž LATIN CAPITAL LETTER Z WITH CARON */ - { 0x01af, 0x017b }, /* Zabovedot Ż LATIN CAPITAL LETTER Z WITH DOT ABOVE */ - { 0x01b1, 0x0105 }, /* aogonek ą LATIN SMALL LETTER A WITH OGONEK */ - { 0x01b2, 0x02db }, /* ogonek ˛ OGONEK */ - { 0x01b3, 0x0142 }, /* lstroke ł LATIN SMALL LETTER L WITH STROKE */ - { 0x01b5, 0x013e }, /* lcaron ľ LATIN SMALL LETTER L WITH CARON */ - { 0x01b6, 0x015b }, /* sacute ś LATIN SMALL LETTER S WITH ACUTE */ - { 0x01b7, 0x02c7 }, /* caron ˇ CARON */ - { 0x01b9, 0x0161 }, /* scaron š LATIN SMALL LETTER S WITH CARON */ - { 0x01ba, 0x015f }, /* scedilla ş LATIN SMALL LETTER S WITH CEDILLA */ - { 0x01bb, 0x0165 }, /* tcaron ť LATIN SMALL LETTER T WITH CARON */ - { 0x01bc, 0x017a }, /* zacute ź LATIN SMALL LETTER Z WITH ACUTE */ - { 0x01bd, 0x02dd }, /* doubleacute ˝ DOUBLE ACUTE ACCENT */ - { 0x01be, 0x017e }, /* zcaron ž LATIN SMALL LETTER Z WITH CARON */ - { 0x01bf, 0x017c }, /* zabovedot ż LATIN SMALL LETTER Z WITH DOT ABOVE */ - { 0x01c0, 0x0154 }, /* Racute Ŕ LATIN CAPITAL LETTER R WITH ACUTE */ - { 0x01c3, 0x0102 }, /* Abreve Ă LATIN CAPITAL LETTER A WITH BREVE */ - { 0x01c5, 0x0139 }, /* Lacute Ĺ LATIN CAPITAL LETTER L WITH ACUTE */ - { 0x01c6, 0x0106 }, /* Cacute Ć LATIN CAPITAL LETTER C WITH ACUTE */ - { 0x01c8, 0x010c }, /* Ccaron Č LATIN CAPITAL LETTER C WITH CARON */ - { 0x01ca, 0x0118 }, /* Eogonek Ę LATIN CAPITAL LETTER E WITH OGONEK */ - { 0x01cc, 0x011a }, /* Ecaron Ě LATIN CAPITAL LETTER E WITH CARON */ - { 0x01cf, 0x010e }, /* Dcaron Ď LATIN CAPITAL LETTER D WITH CARON */ - { 0x01d0, 0x0110 }, /* Dstroke Đ LATIN CAPITAL LETTER D WITH STROKE */ - { 0x01d1, 0x0143 }, /* Nacute Ń LATIN CAPITAL LETTER N WITH ACUTE */ - { 0x01d2, 0x0147 }, /* Ncaron Ň LATIN CAPITAL LETTER N WITH CARON */ - { 0x01d5, 0x0150 }, /* Odoubleacute Ő LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */ - { 0x01d8, 0x0158 }, /* Rcaron Ř LATIN CAPITAL LETTER R WITH CARON */ - { 0x01d9, 0x016e }, /* Uring Ů LATIN CAPITAL LETTER U WITH RING ABOVE */ - { 0x01db, 0x0170 }, /* Udoubleacute Ű LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ - { 0x01de, 0x0162 }, /* Tcedilla Ţ LATIN CAPITAL LETTER T WITH CEDILLA */ - { 0x01e0, 0x0155 }, /* racute ŕ LATIN SMALL LETTER R WITH ACUTE */ - { 0x01e3, 0x0103 }, /* abreve ă LATIN SMALL LETTER A WITH BREVE */ - { 0x01e5, 0x013a }, /* lacute ĺ LATIN SMALL LETTER L WITH ACUTE */ - { 0x01e6, 0x0107 }, /* cacute ć LATIN SMALL LETTER C WITH ACUTE */ - { 0x01e8, 0x010d }, /* ccaron č LATIN SMALL LETTER C WITH CARON */ - { 0x01ea, 0x0119 }, /* eogonek ę LATIN SMALL LETTER E WITH OGONEK */ - { 0x01ec, 0x011b }, /* ecaron ě LATIN SMALL LETTER E WITH CARON */ - { 0x01ef, 0x010f }, /* dcaron ď LATIN SMALL LETTER D WITH CARON */ - { 0x01f0, 0x0111 }, /* dstroke đ LATIN SMALL LETTER D WITH STROKE */ - { 0x01f1, 0x0144 }, /* nacute ń LATIN SMALL LETTER N WITH ACUTE */ - { 0x01f2, 0x0148 }, /* ncaron ň LATIN SMALL LETTER N WITH CARON */ - { 0x01f5, 0x0151 }, /* odoubleacute ő LATIN SMALL LETTER O WITH DOUBLE ACUTE */ - { 0x01f8, 0x0159 }, /* rcaron ř LATIN SMALL LETTER R WITH CARON */ - { 0x01f9, 0x016f }, /* uring ů LATIN SMALL LETTER U WITH RING ABOVE */ - { 0x01fb, 0x0171 }, /* udoubleacute ű LATIN SMALL LETTER U WITH DOUBLE ACUTE */ - { 0x01fe, 0x0163 }, /* tcedilla ţ LATIN SMALL LETTER T WITH CEDILLA */ - { 0x01ff, 0x02d9 }, /* abovedot ˙ DOT ABOVE */ - { 0x02a1, 0x0126 }, /* Hstroke Ħ LATIN CAPITAL LETTER H WITH STROKE */ - { 0x02a6, 0x0124 }, /* Hcircumflex Ĥ LATIN CAPITAL LETTER H WITH CIRCUMFLEX */ - { 0x02a9, 0x0130 }, /* Iabovedot İ LATIN CAPITAL LETTER I WITH DOT ABOVE */ - { 0x02ab, 0x011e }, /* Gbreve Ğ LATIN CAPITAL LETTER G WITH BREVE */ - { 0x02ac, 0x0134 }, /* Jcircumflex Ĵ LATIN CAPITAL LETTER J WITH CIRCUMFLEX */ - { 0x02b1, 0x0127 }, /* hstroke ħ LATIN SMALL LETTER H WITH STROKE */ - { 0x02b6, 0x0125 }, /* hcircumflex ĥ LATIN SMALL LETTER H WITH CIRCUMFLEX */ - { 0x02b9, 0x0131 }, /* idotless ı LATIN SMALL LETTER DOTLESS I */ - { 0x02bb, 0x011f }, /* gbreve ğ LATIN SMALL LETTER G WITH BREVE */ - { 0x02bc, 0x0135 }, /* jcircumflex ĵ LATIN SMALL LETTER J WITH CIRCUMFLEX */ - { 0x02c5, 0x010a }, /* Cabovedot Ċ LATIN CAPITAL LETTER C WITH DOT ABOVE */ - { 0x02c6, 0x0108 }, /* Ccircumflex Ĉ LATIN CAPITAL LETTER C WITH CIRCUMFLEX */ - { 0x02d5, 0x0120 }, /* Gabovedot Ġ LATIN CAPITAL LETTER G WITH DOT ABOVE */ - { 0x02d8, 0x011c }, /* Gcircumflex Ĝ LATIN CAPITAL LETTER G WITH CIRCUMFLEX */ - { 0x02dd, 0x016c }, /* Ubreve Ŭ LATIN CAPITAL LETTER U WITH BREVE */ - { 0x02de, 0x015c }, /* Scircumflex Ŝ LATIN CAPITAL LETTER S WITH CIRCUMFLEX */ - { 0x02e5, 0x010b }, /* cabovedot ċ LATIN SMALL LETTER C WITH DOT ABOVE */ - { 0x02e6, 0x0109 }, /* ccircumflex ĉ LATIN SMALL LETTER C WITH CIRCUMFLEX */ - { 0x02f5, 0x0121 }, /* gabovedot ġ LATIN SMALL LETTER G WITH DOT ABOVE */ - { 0x02f8, 0x011d }, /* gcircumflex ĝ LATIN SMALL LETTER G WITH CIRCUMFLEX */ - { 0x02fd, 0x016d }, /* ubreve ŭ LATIN SMALL LETTER U WITH BREVE */ - { 0x02fe, 0x015d }, /* scircumflex ŝ LATIN SMALL LETTER S WITH CIRCUMFLEX */ - { 0x03a2, 0x0138 }, /* kra ĸ LATIN SMALL LETTER KRA */ - { 0x03a3, 0x0156 }, /* Rcedilla Ŗ LATIN CAPITAL LETTER R WITH CEDILLA */ - { 0x03a5, 0x0128 }, /* Itilde Ĩ LATIN CAPITAL LETTER I WITH TILDE */ - { 0x03a6, 0x013b }, /* Lcedilla Ļ LATIN CAPITAL LETTER L WITH CEDILLA */ - { 0x03aa, 0x0112 }, /* Emacron Ē LATIN CAPITAL LETTER E WITH MACRON */ - { 0x03ab, 0x0122 }, /* Gcedilla Ģ LATIN CAPITAL LETTER G WITH CEDILLA */ - { 0x03ac, 0x0166 }, /* Tslash Ŧ LATIN CAPITAL LETTER T WITH STROKE */ - { 0x03b3, 0x0157 }, /* rcedilla ŗ LATIN SMALL LETTER R WITH CEDILLA */ - { 0x03b5, 0x0129 }, /* itilde ĩ LATIN SMALL LETTER I WITH TILDE */ - { 0x03b6, 0x013c }, /* lcedilla ļ LATIN SMALL LETTER L WITH CEDILLA */ - { 0x03ba, 0x0113 }, /* emacron ē LATIN SMALL LETTER E WITH MACRON */ - { 0x03bb, 0x0123 }, /* gcedilla ģ LATIN SMALL LETTER G WITH CEDILLA */ - { 0x03bc, 0x0167 }, /* tslash ŧ LATIN SMALL LETTER T WITH STROKE */ - { 0x03bd, 0x014a }, /* ENG Ŋ LATIN CAPITAL LETTER ENG */ - { 0x03bf, 0x014b }, /* eng ŋ LATIN SMALL LETTER ENG */ - { 0x03c0, 0x0100 }, /* Amacron Ā LATIN CAPITAL LETTER A WITH MACRON */ - { 0x03c7, 0x012e }, /* Iogonek Į LATIN CAPITAL LETTER I WITH OGONEK */ - { 0x03cc, 0x0116 }, /* Eabovedot Ė LATIN CAPITAL LETTER E WITH DOT ABOVE */ - { 0x03cf, 0x012a }, /* Imacron Ī LATIN CAPITAL LETTER I WITH MACRON */ - { 0x03d1, 0x0145 }, /* Ncedilla Ņ LATIN CAPITAL LETTER N WITH CEDILLA */ - { 0x03d2, 0x014c }, /* Omacron Ō LATIN CAPITAL LETTER O WITH MACRON */ - { 0x03d3, 0x0136 }, /* Kcedilla Ķ LATIN CAPITAL LETTER K WITH CEDILLA */ - { 0x03d9, 0x0172 }, /* Uogonek Ų LATIN CAPITAL LETTER U WITH OGONEK */ - { 0x03dd, 0x0168 }, /* Utilde Ũ LATIN CAPITAL LETTER U WITH TILDE */ - { 0x03de, 0x016a }, /* Umacron Ū LATIN CAPITAL LETTER U WITH MACRON */ - { 0x03e0, 0x0101 }, /* amacron ā LATIN SMALL LETTER A WITH MACRON */ - { 0x03e7, 0x012f }, /* iogonek į LATIN SMALL LETTER I WITH OGONEK */ - { 0x03ec, 0x0117 }, /* eabovedot ė LATIN SMALL LETTER E WITH DOT ABOVE */ - { 0x03ef, 0x012b }, /* imacron ī LATIN SMALL LETTER I WITH MACRON */ - { 0x03f1, 0x0146 }, /* ncedilla ņ LATIN SMALL LETTER N WITH CEDILLA */ - { 0x03f2, 0x014d }, /* omacron ō LATIN SMALL LETTER O WITH MACRON */ - { 0x03f3, 0x0137 }, /* kcedilla ķ LATIN SMALL LETTER K WITH CEDILLA */ - { 0x03f9, 0x0173 }, /* uogonek ų LATIN SMALL LETTER U WITH OGONEK */ - { 0x03fd, 0x0169 }, /* utilde ũ LATIN SMALL LETTER U WITH TILDE */ - { 0x03fe, 0x016b }, /* umacron ū LATIN SMALL LETTER U WITH MACRON */ - { 0x047e, 0x203e }, /* overline ‾ OVERLINE */ - { 0x04a1, 0x3002 }, /* kana_fullstop 。 IDEOGRAPHIC FULL STOP */ - { 0x04a2, 0x300c }, /* kana_openingbracket 「 LEFT CORNER BRACKET */ - { 0x04a3, 0x300d }, /* kana_closingbracket 」 RIGHT CORNER BRACKET */ - { 0x04a4, 0x3001 }, /* kana_comma 、 IDEOGRAPHIC COMMA */ - { 0x04a5, 0x30fb }, /* kana_conjunctive ・ KATAKANA MIDDLE DOT */ - { 0x04a6, 0x30f2 }, /* kana_WO ヲ KATAKANA LETTER WO */ - { 0x04a7, 0x30a1 }, /* kana_a ァ KATAKANA LETTER SMALL A */ - { 0x04a8, 0x30a3 }, /* kana_i ィ KATAKANA LETTER SMALL I */ - { 0x04a9, 0x30a5 }, /* kana_u ゥ KATAKANA LETTER SMALL U */ - { 0x04aa, 0x30a7 }, /* kana_e ェ KATAKANA LETTER SMALL E */ - { 0x04ab, 0x30a9 }, /* kana_o ォ KATAKANA LETTER SMALL O */ - { 0x04ac, 0x30e3 }, /* kana_ya ャ KATAKANA LETTER SMALL YA */ - { 0x04ad, 0x30e5 }, /* kana_yu ュ KATAKANA LETTER SMALL YU */ - { 0x04ae, 0x30e7 }, /* kana_yo ョ KATAKANA LETTER SMALL YO */ - { 0x04af, 0x30c3 }, /* kana_tsu ッ KATAKANA LETTER SMALL TU */ - { 0x04b0, 0x30fc }, /* prolongedsound ー KATAKANA-HIRAGANA PROLONGED SOUND MARK */ - { 0x04b1, 0x30a2 }, /* kana_A ア KATAKANA LETTER A */ - { 0x04b2, 0x30a4 }, /* kana_I イ KATAKANA LETTER I */ - { 0x04b3, 0x30a6 }, /* kana_U ウ KATAKANA LETTER U */ - { 0x04b4, 0x30a8 }, /* kana_E エ KATAKANA LETTER E */ - { 0x04b5, 0x30aa }, /* kana_O オ KATAKANA LETTER O */ - { 0x04b6, 0x30ab }, /* kana_KA カ KATAKANA LETTER KA */ - { 0x04b7, 0x30ad }, /* kana_KI キ KATAKANA LETTER KI */ - { 0x04b8, 0x30af }, /* kana_KU ク KATAKANA LETTER KU */ - { 0x04b9, 0x30b1 }, /* kana_KE ケ KATAKANA LETTER KE */ - { 0x04ba, 0x30b3 }, /* kana_KO コ KATAKANA LETTER KO */ - { 0x04bb, 0x30b5 }, /* kana_SA サ KATAKANA LETTER SA */ - { 0x04bc, 0x30b7 }, /* kana_SHI シ KATAKANA LETTER SI */ - { 0x04bd, 0x30b9 }, /* kana_SU ス KATAKANA LETTER SU */ - { 0x04be, 0x30bb }, /* kana_SE セ KATAKANA LETTER SE */ - { 0x04bf, 0x30bd }, /* kana_SO ソ KATAKANA LETTER SO */ - { 0x04c0, 0x30bf }, /* kana_TA タ KATAKANA LETTER TA */ - { 0x04c1, 0x30c1 }, /* kana_CHI チ KATAKANA LETTER TI */ - { 0x04c2, 0x30c4 }, /* kana_TSU ツ KATAKANA LETTER TU */ - { 0x04c3, 0x30c6 }, /* kana_TE テ KATAKANA LETTER TE */ - { 0x04c4, 0x30c8 }, /* kana_TO ト KATAKANA LETTER TO */ - { 0x04c5, 0x30ca }, /* kana_NA ナ KATAKANA LETTER NA */ - { 0x04c6, 0x30cb }, /* kana_NI ニ KATAKANA LETTER NI */ - { 0x04c7, 0x30cc }, /* kana_NU ヌ KATAKANA LETTER NU */ - { 0x04c8, 0x30cd }, /* kana_NE ネ KATAKANA LETTER NE */ - { 0x04c9, 0x30ce }, /* kana_NO ノ KATAKANA LETTER NO */ - { 0x04ca, 0x30cf }, /* kana_HA ハ KATAKANA LETTER HA */ - { 0x04cb, 0x30d2 }, /* kana_HI ヒ KATAKANA LETTER HI */ - { 0x04cc, 0x30d5 }, /* kana_FU フ KATAKANA LETTER HU */ - { 0x04cd, 0x30d8 }, /* kana_HE ヘ KATAKANA LETTER HE */ - { 0x04ce, 0x30db }, /* kana_HO ホ KATAKANA LETTER HO */ - { 0x04cf, 0x30de }, /* kana_MA マ KATAKANA LETTER MA */ - { 0x04d0, 0x30df }, /* kana_MI ミ KATAKANA LETTER MI */ - { 0x04d1, 0x30e0 }, /* kana_MU ム KATAKANA LETTER MU */ - { 0x04d2, 0x30e1 }, /* kana_ME メ KATAKANA LETTER ME */ - { 0x04d3, 0x30e2 }, /* kana_MO モ KATAKANA LETTER MO */ - { 0x04d4, 0x30e4 }, /* kana_YA ヤ KATAKANA LETTER YA */ - { 0x04d5, 0x30e6 }, /* kana_YU ユ KATAKANA LETTER YU */ - { 0x04d6, 0x30e8 }, /* kana_YO ヨ KATAKANA LETTER YO */ - { 0x04d7, 0x30e9 }, /* kana_RA ラ KATAKANA LETTER RA */ - { 0x04d8, 0x30ea }, /* kana_RI リ KATAKANA LETTER RI */ - { 0x04d9, 0x30eb }, /* kana_RU ル KATAKANA LETTER RU */ - { 0x04da, 0x30ec }, /* kana_RE レ KATAKANA LETTER RE */ - { 0x04db, 0x30ed }, /* kana_RO ロ KATAKANA LETTER RO */ - { 0x04dc, 0x30ef }, /* kana_WA ワ KATAKANA LETTER WA */ - { 0x04dd, 0x30f3 }, /* kana_N ン KATAKANA LETTER N */ - { 0x04de, 0x309b }, /* voicedsound ゛ KATAKANA-HIRAGANA VOICED SOUND MARK */ - { 0x04df, 0x309c }, /* semivoicedsound ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */ - { 0x05ac, 0x060c }, /* Arabic_comma ، ARABIC COMMA */ - { 0x05bb, 0x061b }, /* Arabic_semicolon ؛ ARABIC SEMICOLON */ - { 0x05bf, 0x061f }, /* Arabic_question_mark ؟ ARABIC QUESTION MARK */ - { 0x05c1, 0x0621 }, /* Arabic_hamza ء ARABIC LETTER HAMZA */ - { 0x05c2, 0x0622 }, /* Arabic_maddaonalef آ ARABIC LETTER ALEF WITH MADDA ABOVE */ - { 0x05c3, 0x0623 }, /* Arabic_hamzaonalef أ ARABIC LETTER ALEF WITH HAMZA ABOVE */ - { 0x05c4, 0x0624 }, /* Arabic_hamzaonwaw ؤ ARABIC LETTER WAW WITH HAMZA ABOVE */ - { 0x05c5, 0x0625 }, /* Arabic_hamzaunderalef إ ARABIC LETTER ALEF WITH HAMZA BELOW */ - { 0x05c6, 0x0626 }, /* Arabic_hamzaonyeh ئ ARABIC LETTER YEH WITH HAMZA ABOVE */ - { 0x05c7, 0x0627 }, /* Arabic_alef ا ARABIC LETTER ALEF */ - { 0x05c8, 0x0628 }, /* Arabic_beh ب ARABIC LETTER BEH */ - { 0x05c9, 0x0629 }, /* Arabic_tehmarbuta ة ARABIC LETTER TEH MARBUTA */ - { 0x05ca, 0x062a }, /* Arabic_teh ت ARABIC LETTER TEH */ - { 0x05cb, 0x062b }, /* Arabic_theh ث ARABIC LETTER THEH */ - { 0x05cc, 0x062c }, /* Arabic_jeem ج ARABIC LETTER JEEM */ - { 0x05cd, 0x062d }, /* Arabic_hah ح ARABIC LETTER HAH */ - { 0x05ce, 0x062e }, /* Arabic_khah خ ARABIC LETTER KHAH */ - { 0x05cf, 0x062f }, /* Arabic_dal د ARABIC LETTER DAL */ - { 0x05d0, 0x0630 }, /* Arabic_thal ذ ARABIC LETTER THAL */ - { 0x05d1, 0x0631 }, /* Arabic_ra ر ARABIC LETTER REH */ - { 0x05d2, 0x0632 }, /* Arabic_zain ز ARABIC LETTER ZAIN */ - { 0x05d3, 0x0633 }, /* Arabic_seen س ARABIC LETTER SEEN */ - { 0x05d4, 0x0634 }, /* Arabic_sheen ش ARABIC LETTER SHEEN */ - { 0x05d5, 0x0635 }, /* Arabic_sad ص ARABIC LETTER SAD */ - { 0x05d6, 0x0636 }, /* Arabic_dad ض ARABIC LETTER DAD */ - { 0x05d7, 0x0637 }, /* Arabic_tah ط ARABIC LETTER TAH */ - { 0x05d8, 0x0638 }, /* Arabic_zah ظ ARABIC LETTER ZAH */ - { 0x05d9, 0x0639 }, /* Arabic_ain ع ARABIC LETTER AIN */ - { 0x05da, 0x063a }, /* Arabic_ghain غ ARABIC LETTER GHAIN */ - { 0x05e0, 0x0640 }, /* Arabic_tatweel ـ ARABIC TATWEEL */ - { 0x05e1, 0x0641 }, /* Arabic_feh ف ARABIC LETTER FEH */ - { 0x05e2, 0x0642 }, /* Arabic_qaf ق ARABIC LETTER QAF */ - { 0x05e3, 0x0643 }, /* Arabic_kaf ك ARABIC LETTER KAF */ - { 0x05e4, 0x0644 }, /* Arabic_lam ل ARABIC LETTER LAM */ - { 0x05e5, 0x0645 }, /* Arabic_meem م ARABIC LETTER MEEM */ - { 0x05e6, 0x0646 }, /* Arabic_noon ن ARABIC LETTER NOON */ - { 0x05e7, 0x0647 }, /* Arabic_ha ه ARABIC LETTER HEH */ - { 0x05e8, 0x0648 }, /* Arabic_waw و ARABIC LETTER WAW */ - { 0x05e9, 0x0649 }, /* Arabic_alefmaksura ى ARABIC LETTER ALEF MAKSURA */ - { 0x05ea, 0x064a }, /* Arabic_yeh ي ARABIC LETTER YEH */ - { 0x05eb, 0x064b }, /* Arabic_fathatan ً ARABIC FATHATAN */ - { 0x05ec, 0x064c }, /* Arabic_dammatan ٌ ARABIC DAMMATAN */ - { 0x05ed, 0x064d }, /* Arabic_kasratan ٍ ARABIC KASRATAN */ - { 0x05ee, 0x064e }, /* Arabic_fatha َ ARABIC FATHA */ - { 0x05ef, 0x064f }, /* Arabic_damma ُ ARABIC DAMMA */ - { 0x05f0, 0x0650 }, /* Arabic_kasra ِ ARABIC KASRA */ - { 0x05f1, 0x0651 }, /* Arabic_shadda ّ ARABIC SHADDA */ - { 0x05f2, 0x0652 }, /* Arabic_sukun ْ ARABIC SUKUN */ - { 0x06a1, 0x0452 }, /* Serbian_dje ђ CYRILLIC SMALL LETTER DJE */ - { 0x06a2, 0x0453 }, /* Macedonia_gje ѓ CYRILLIC SMALL LETTER GJE */ - { 0x06a3, 0x0451 }, /* Cyrillic_io ё CYRILLIC SMALL LETTER IO */ - { 0x06a4, 0x0454 }, /* Ukrainian_ie є CYRILLIC SMALL LETTER UKRAINIAN IE */ - { 0x06a5, 0x0455 }, /* Macedonia_dse ѕ CYRILLIC SMALL LETTER DZE */ - { 0x06a6, 0x0456 }, /* Ukrainian_i і CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */ - { 0x06a7, 0x0457 }, /* Ukrainian_yi ї CYRILLIC SMALL LETTER YI */ - { 0x06a8, 0x0458 }, /* Cyrillic_je ј CYRILLIC SMALL LETTER JE */ - { 0x06a9, 0x0459 }, /* Cyrillic_lje љ CYRILLIC SMALL LETTER LJE */ - { 0x06aa, 0x045a }, /* Cyrillic_nje њ CYRILLIC SMALL LETTER NJE */ - { 0x06ab, 0x045b }, /* Serbian_tshe ћ CYRILLIC SMALL LETTER TSHE */ - { 0x06ac, 0x045c }, /* Macedonia_kje ќ CYRILLIC SMALL LETTER KJE */ - { 0x06ad, 0x0491 }, /* Ukrainian_ghe_with_upturn ґ CYRILLIC SMALL LETTER GHE WITH UPTURN */ - { 0x06ae, 0x045e }, /* Byelorussian_shortu ў CYRILLIC SMALL LETTER SHORT U */ - { 0x06af, 0x045f }, /* Cyrillic_dzhe џ CYRILLIC SMALL LETTER DZHE */ - { 0x06b0, 0x2116 }, /* numerosign № NUMERO SIGN */ - { 0x06b1, 0x0402 }, /* Serbian_DJE Ђ CYRILLIC CAPITAL LETTER DJE */ - { 0x06b2, 0x0403 }, /* Macedonia_GJE Ѓ CYRILLIC CAPITAL LETTER GJE */ - { 0x06b3, 0x0401 }, /* Cyrillic_IO Ё CYRILLIC CAPITAL LETTER IO */ - { 0x06b4, 0x0404 }, /* Ukrainian_IE Є CYRILLIC CAPITAL LETTER UKRAINIAN IE */ - { 0x06b5, 0x0405 }, /* Macedonia_DSE Ѕ CYRILLIC CAPITAL LETTER DZE */ - { 0x06b6, 0x0406 }, /* Ukrainian_I І CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */ - { 0x06b7, 0x0407 }, /* Ukrainian_YI Ї CYRILLIC CAPITAL LETTER YI */ - { 0x06b8, 0x0408 }, /* Cyrillic_JE Ј CYRILLIC CAPITAL LETTER JE */ - { 0x06b9, 0x0409 }, /* Cyrillic_LJE Љ CYRILLIC CAPITAL LETTER LJE */ - { 0x06ba, 0x040a }, /* Cyrillic_NJE Њ CYRILLIC CAPITAL LETTER NJE */ - { 0x06bb, 0x040b }, /* Serbian_TSHE Ћ CYRILLIC CAPITAL LETTER TSHE */ - { 0x06bc, 0x040c }, /* Macedonia_KJE Ќ CYRILLIC CAPITAL LETTER KJE */ - { 0x06bd, 0x0490 }, /* Ukrainian_GHE_WITH_UPTURN Ґ CYRILLIC CAPITAL LETTER GHE WITH UPTURN */ - { 0x06be, 0x040e }, /* Byelorussian_SHORTU Ў CYRILLIC CAPITAL LETTER SHORT U */ - { 0x06bf, 0x040f }, /* Cyrillic_DZHE Џ CYRILLIC CAPITAL LETTER DZHE */ - { 0x06c0, 0x044e }, /* Cyrillic_yu ю CYRILLIC SMALL LETTER YU */ - { 0x06c1, 0x0430 }, /* Cyrillic_a а CYRILLIC SMALL LETTER A */ - { 0x06c2, 0x0431 }, /* Cyrillic_be б CYRILLIC SMALL LETTER BE */ - { 0x06c3, 0x0446 }, /* Cyrillic_tse ц CYRILLIC SMALL LETTER TSE */ - { 0x06c4, 0x0434 }, /* Cyrillic_de д CYRILLIC SMALL LETTER DE */ - { 0x06c5, 0x0435 }, /* Cyrillic_ie е CYRILLIC SMALL LETTER IE */ - { 0x06c6, 0x0444 }, /* Cyrillic_ef ф CYRILLIC SMALL LETTER EF */ - { 0x06c7, 0x0433 }, /* Cyrillic_ghe г CYRILLIC SMALL LETTER GHE */ - { 0x06c8, 0x0445 }, /* Cyrillic_ha х CYRILLIC SMALL LETTER HA */ - { 0x06c9, 0x0438 }, /* Cyrillic_i и CYRILLIC SMALL LETTER I */ - { 0x06ca, 0x0439 }, /* Cyrillic_shorti й CYRILLIC SMALL LETTER SHORT I */ - { 0x06cb, 0x043a }, /* Cyrillic_ka к CYRILLIC SMALL LETTER KA */ - { 0x06cc, 0x043b }, /* Cyrillic_el л CYRILLIC SMALL LETTER EL */ - { 0x06cd, 0x043c }, /* Cyrillic_em м CYRILLIC SMALL LETTER EM */ - { 0x06ce, 0x043d }, /* Cyrillic_en н CYRILLIC SMALL LETTER EN */ - { 0x06cf, 0x043e }, /* Cyrillic_o о CYRILLIC SMALL LETTER O */ - { 0x06d0, 0x043f }, /* Cyrillic_pe п CYRILLIC SMALL LETTER PE */ - { 0x06d1, 0x044f }, /* Cyrillic_ya я CYRILLIC SMALL LETTER YA */ - { 0x06d2, 0x0440 }, /* Cyrillic_er р CYRILLIC SMALL LETTER ER */ - { 0x06d3, 0x0441 }, /* Cyrillic_es с CYRILLIC SMALL LETTER ES */ - { 0x06d4, 0x0442 }, /* Cyrillic_te т CYRILLIC SMALL LETTER TE */ - { 0x06d5, 0x0443 }, /* Cyrillic_u у CYRILLIC SMALL LETTER U */ - { 0x06d6, 0x0436 }, /* Cyrillic_zhe ж CYRILLIC SMALL LETTER ZHE */ - { 0x06d7, 0x0432 }, /* Cyrillic_ve в CYRILLIC SMALL LETTER VE */ - { 0x06d8, 0x044c }, /* Cyrillic_softsign ь CYRILLIC SMALL LETTER SOFT SIGN */ - { 0x06d9, 0x044b }, /* Cyrillic_yeru ы CYRILLIC SMALL LETTER YERU */ - { 0x06da, 0x0437 }, /* Cyrillic_ze з CYRILLIC SMALL LETTER ZE */ - { 0x06db, 0x0448 }, /* Cyrillic_sha ш CYRILLIC SMALL LETTER SHA */ - { 0x06dc, 0x044d }, /* Cyrillic_e э CYRILLIC SMALL LETTER E */ - { 0x06dd, 0x0449 }, /* Cyrillic_shcha щ CYRILLIC SMALL LETTER SHCHA */ - { 0x06de, 0x0447 }, /* Cyrillic_che ч CYRILLIC SMALL LETTER CHE */ - { 0x06df, 0x044a }, /* Cyrillic_hardsign ъ CYRILLIC SMALL LETTER HARD SIGN */ - { 0x06e0, 0x042e }, /* Cyrillic_YU Ю CYRILLIC CAPITAL LETTER YU */ - { 0x06e1, 0x0410 }, /* Cyrillic_A А CYRILLIC CAPITAL LETTER A */ - { 0x06e2, 0x0411 }, /* Cyrillic_BE Б CYRILLIC CAPITAL LETTER BE */ - { 0x06e3, 0x0426 }, /* Cyrillic_TSE Ц CYRILLIC CAPITAL LETTER TSE */ - { 0x06e4, 0x0414 }, /* Cyrillic_DE Д CYRILLIC CAPITAL LETTER DE */ - { 0x06e5, 0x0415 }, /* Cyrillic_IE Е CYRILLIC CAPITAL LETTER IE */ - { 0x06e6, 0x0424 }, /* Cyrillic_EF Ф CYRILLIC CAPITAL LETTER EF */ - { 0x06e7, 0x0413 }, /* Cyrillic_GHE Г CYRILLIC CAPITAL LETTER GHE */ - { 0x06e8, 0x0425 }, /* Cyrillic_HA Х CYRILLIC CAPITAL LETTER HA */ - { 0x06e9, 0x0418 }, /* Cyrillic_I И CYRILLIC CAPITAL LETTER I */ - { 0x06ea, 0x0419 }, /* Cyrillic_SHORTI Й CYRILLIC CAPITAL LETTER SHORT I */ - { 0x06eb, 0x041a }, /* Cyrillic_KA К CYRILLIC CAPITAL LETTER KA */ - { 0x06ec, 0x041b }, /* Cyrillic_EL Л CYRILLIC CAPITAL LETTER EL */ - { 0x06ed, 0x041c }, /* Cyrillic_EM М CYRILLIC CAPITAL LETTER EM */ - { 0x06ee, 0x041d }, /* Cyrillic_EN Н CYRILLIC CAPITAL LETTER EN */ - { 0x06ef, 0x041e }, /* Cyrillic_O О CYRILLIC CAPITAL LETTER O */ - { 0x06f0, 0x041f }, /* Cyrillic_PE П CYRILLIC CAPITAL LETTER PE */ - { 0x06f1, 0x042f }, /* Cyrillic_YA Я CYRILLIC CAPITAL LETTER YA */ - { 0x06f2, 0x0420 }, /* Cyrillic_ER Р CYRILLIC CAPITAL LETTER ER */ - { 0x06f3, 0x0421 }, /* Cyrillic_ES С CYRILLIC CAPITAL LETTER ES */ - { 0x06f4, 0x0422 }, /* Cyrillic_TE Т CYRILLIC CAPITAL LETTER TE */ - { 0x06f5, 0x0423 }, /* Cyrillic_U У CYRILLIC CAPITAL LETTER U */ - { 0x06f6, 0x0416 }, /* Cyrillic_ZHE Ж CYRILLIC CAPITAL LETTER ZHE */ - { 0x06f7, 0x0412 }, /* Cyrillic_VE В CYRILLIC CAPITAL LETTER VE */ - { 0x06f8, 0x042c }, /* Cyrillic_SOFTSIGN Ь CYRILLIC CAPITAL LETTER SOFT SIGN */ - { 0x06f9, 0x042b }, /* Cyrillic_YERU Ы CYRILLIC CAPITAL LETTER YERU */ - { 0x06fa, 0x0417 }, /* Cyrillic_ZE З CYRILLIC CAPITAL LETTER ZE */ - { 0x06fb, 0x0428 }, /* Cyrillic_SHA Ш CYRILLIC CAPITAL LETTER SHA */ - { 0x06fc, 0x042d }, /* Cyrillic_E Э CYRILLIC CAPITAL LETTER E */ - { 0x06fd, 0x0429 }, /* Cyrillic_SHCHA Щ CYRILLIC CAPITAL LETTER SHCHA */ - { 0x06fe, 0x0427 }, /* Cyrillic_CHE Ч CYRILLIC CAPITAL LETTER CHE */ - { 0x06ff, 0x042a }, /* Cyrillic_HARDSIGN Ъ CYRILLIC CAPITAL LETTER HARD SIGN */ - { 0x07a1, 0x0386 }, /* Greek_ALPHAaccent Ά GREEK CAPITAL LETTER ALPHA WITH TONOS */ - { 0x07a2, 0x0388 }, /* Greek_EPSILONaccent Έ GREEK CAPITAL LETTER EPSILON WITH TONOS */ - { 0x07a3, 0x0389 }, /* Greek_ETAaccent Ή GREEK CAPITAL LETTER ETA WITH TONOS */ - { 0x07a4, 0x038a }, /* Greek_IOTAaccent Ί GREEK CAPITAL LETTER IOTA WITH TONOS */ - { 0x07a5, 0x03aa }, /* Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */ - { 0x07a7, 0x038c }, /* Greek_OMICRONaccent Ό GREEK CAPITAL LETTER OMICRON WITH TONOS */ - { 0x07a8, 0x038e }, /* Greek_UPSILONaccent Ύ GREEK CAPITAL LETTER UPSILON WITH TONOS */ - { 0x07a9, 0x03ab }, /* Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */ - { 0x07ab, 0x038f }, /* Greek_OMEGAaccent Ώ GREEK CAPITAL LETTER OMEGA WITH TONOS */ - { 0x07ae, 0x0385 }, /* Greek_accentdieresis ΅ GREEK DIALYTIKA TONOS */ - { 0x07af, 0x2015 }, /* Greek_horizbar ― HORIZONTAL BAR */ - { 0x07b1, 0x03ac }, /* Greek_alphaaccent ά GREEK SMALL LETTER ALPHA WITH TONOS */ - { 0x07b2, 0x03ad }, /* Greek_epsilonaccent έ GREEK SMALL LETTER EPSILON WITH TONOS */ - { 0x07b3, 0x03ae }, /* Greek_etaaccent ή GREEK SMALL LETTER ETA WITH TONOS */ - { 0x07b4, 0x03af }, /* Greek_iotaaccent ί GREEK SMALL LETTER IOTA WITH TONOS */ - { 0x07b5, 0x03ca }, /* Greek_iotadieresis ϊ GREEK SMALL LETTER IOTA WITH DIALYTIKA */ - { 0x07b6, 0x0390 }, /* Greek_iotaaccentdieresis ΐ GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ - { 0x07b7, 0x03cc }, /* Greek_omicronaccent ό GREEK SMALL LETTER OMICRON WITH TONOS */ - { 0x07b8, 0x03cd }, /* Greek_upsilonaccent ύ GREEK SMALL LETTER UPSILON WITH TONOS */ - { 0x07b9, 0x03cb }, /* Greek_upsilondieresis ϋ GREEK SMALL LETTER UPSILON WITH DIALYTIKA */ - { 0x07ba, 0x03b0 }, /* Greek_upsilonaccentdieresis ΰ GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */ - { 0x07bb, 0x03ce }, /* Greek_omegaaccent ώ GREEK SMALL LETTER OMEGA WITH TONOS */ - { 0x07c1, 0x0391 }, /* Greek_ALPHA Α GREEK CAPITAL LETTER ALPHA */ - { 0x07c2, 0x0392 }, /* Greek_BETA Β GREEK CAPITAL LETTER BETA */ - { 0x07c3, 0x0393 }, /* Greek_GAMMA Γ GREEK CAPITAL LETTER GAMMA */ - { 0x07c4, 0x0394 }, /* Greek_DELTA Δ GREEK CAPITAL LETTER DELTA */ - { 0x07c5, 0x0395 }, /* Greek_EPSILON Ε GREEK CAPITAL LETTER EPSILON */ - { 0x07c6, 0x0396 }, /* Greek_ZETA Ζ GREEK CAPITAL LETTER ZETA */ - { 0x07c7, 0x0397 }, /* Greek_ETA Η GREEK CAPITAL LETTER ETA */ - { 0x07c8, 0x0398 }, /* Greek_THETA Θ GREEK CAPITAL LETTER THETA */ - { 0x07c9, 0x0399 }, /* Greek_IOTA Ι GREEK CAPITAL LETTER IOTA */ - { 0x07ca, 0x039a }, /* Greek_KAPPA Κ GREEK CAPITAL LETTER KAPPA */ - { 0x07cb, 0x039b }, /* Greek_LAMBDA Λ GREEK CAPITAL LETTER LAMDA */ - { 0x07cc, 0x039c }, /* Greek_MU Μ GREEK CAPITAL LETTER MU */ - { 0x07cd, 0x039d }, /* Greek_NU Ν GREEK CAPITAL LETTER NU */ - { 0x07ce, 0x039e }, /* Greek_XI Ξ GREEK CAPITAL LETTER XI */ - { 0x07cf, 0x039f }, /* Greek_OMICRON Ο GREEK CAPITAL LETTER OMICRON */ - { 0x07d0, 0x03a0 }, /* Greek_PI Π GREEK CAPITAL LETTER PI */ - { 0x07d1, 0x03a1 }, /* Greek_RHO Ρ GREEK CAPITAL LETTER RHO */ - { 0x07d2, 0x03a3 }, /* Greek_SIGMA Σ GREEK CAPITAL LETTER SIGMA */ - { 0x07d4, 0x03a4 }, /* Greek_TAU Τ GREEK CAPITAL LETTER TAU */ - { 0x07d5, 0x03a5 }, /* Greek_UPSILON Υ GREEK CAPITAL LETTER UPSILON */ - { 0x07d6, 0x03a6 }, /* Greek_PHI Φ GREEK CAPITAL LETTER PHI */ - { 0x07d7, 0x03a7 }, /* Greek_CHI Χ GREEK CAPITAL LETTER CHI */ - { 0x07d8, 0x03a8 }, /* Greek_PSI Ψ GREEK CAPITAL LETTER PSI */ - { 0x07d9, 0x03a9 }, /* Greek_OMEGA Ω GREEK CAPITAL LETTER OMEGA */ - { 0x07e1, 0x03b1 }, /* Greek_alpha α GREEK SMALL LETTER ALPHA */ - { 0x07e2, 0x03b2 }, /* Greek_beta β GREEK SMALL LETTER BETA */ - { 0x07e3, 0x03b3 }, /* Greek_gamma γ GREEK SMALL LETTER GAMMA */ - { 0x07e4, 0x03b4 }, /* Greek_delta δ GREEK SMALL LETTER DELTA */ - { 0x07e5, 0x03b5 }, /* Greek_epsilon ε GREEK SMALL LETTER EPSILON */ - { 0x07e6, 0x03b6 }, /* Greek_zeta ζ GREEK SMALL LETTER ZETA */ - { 0x07e7, 0x03b7 }, /* Greek_eta η GREEK SMALL LETTER ETA */ - { 0x07e8, 0x03b8 }, /* Greek_theta θ GREEK SMALL LETTER THETA */ - { 0x07e9, 0x03b9 }, /* Greek_iota ι GREEK SMALL LETTER IOTA */ - { 0x07ea, 0x03ba }, /* Greek_kappa κ GREEK SMALL LETTER KAPPA */ - { 0x07eb, 0x03bb }, /* Greek_lambda λ GREEK SMALL LETTER LAMDA */ - { 0x07ec, 0x03bc }, /* Greek_mu μ GREEK SMALL LETTER MU */ - { 0x07ed, 0x03bd }, /* Greek_nu ν GREEK SMALL LETTER NU */ - { 0x07ee, 0x03be }, /* Greek_xi ξ GREEK SMALL LETTER XI */ - { 0x07ef, 0x03bf }, /* Greek_omicron ο GREEK SMALL LETTER OMICRON */ - { 0x07f0, 0x03c0 }, /* Greek_pi π GREEK SMALL LETTER PI */ - { 0x07f1, 0x03c1 }, /* Greek_rho ρ GREEK SMALL LETTER RHO */ - { 0x07f2, 0x03c3 }, /* Greek_sigma σ GREEK SMALL LETTER SIGMA */ - { 0x07f3, 0x03c2 }, /* Greek_finalsmallsigma ς GREEK SMALL LETTER FINAL SIGMA */ - { 0x07f4, 0x03c4 }, /* Greek_tau τ GREEK SMALL LETTER TAU */ - { 0x07f5, 0x03c5 }, /* Greek_upsilon υ GREEK SMALL LETTER UPSILON */ - { 0x07f6, 0x03c6 }, /* Greek_phi φ GREEK SMALL LETTER PHI */ - { 0x07f7, 0x03c7 }, /* Greek_chi χ GREEK SMALL LETTER CHI */ - { 0x07f8, 0x03c8 }, /* Greek_psi ψ GREEK SMALL LETTER PSI */ - { 0x07f9, 0x03c9 }, /* Greek_omega ω GREEK SMALL LETTER OMEGA */ - { 0x08a1, 0x23b7 }, /* leftradical ⎷ RADICAL SYMBOL BOTTOM */ - { 0x08a2, 0x250c }, /* topleftradical ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */ - { 0x08a3, 0x2500 }, /* horizconnector ─ BOX DRAWINGS LIGHT HORIZONTAL */ - { 0x08a4, 0x2320 }, /* topintegral ⌠ TOP HALF INTEGRAL */ - { 0x08a5, 0x2321 }, /* botintegral ⌡ BOTTOM HALF INTEGRAL */ - { 0x08a6, 0x2502 }, /* vertconnector │ BOX DRAWINGS LIGHT VERTICAL */ - { 0x08a7, 0x23a1 }, /* topleftsqbracket ⎡ LEFT SQUARE BRACKET UPPER CORNER */ - { 0x08a8, 0x23a3 }, /* botleftsqbracket ⎣ LEFT SQUARE BRACKET LOWER CORNER */ - { 0x08a9, 0x23a4 }, /* toprightsqbracket ⎤ RIGHT SQUARE BRACKET UPPER CORNER */ - { 0x08aa, 0x23a6 }, /* botrightsqbracket ⎦ RIGHT SQUARE BRACKET LOWER CORNER */ - { 0x08ab, 0x239b }, /* topleftparens ⎛ LEFT PARENTHESIS UPPER HOOK */ - { 0x08ac, 0x239d }, /* botleftparens ⎝ LEFT PARENTHESIS LOWER HOOK */ - { 0x08ad, 0x239e }, /* toprightparens ⎞ RIGHT PARENTHESIS UPPER HOOK */ - { 0x08ae, 0x23a0 }, /* botrightparens ⎠ RIGHT PARENTHESIS LOWER HOOK */ - { 0x08af, 0x23a8 }, /* leftmiddlecurlybrace ⎨ LEFT CURLY BRACKET MIDDLE PIECE */ - { 0x08b0, 0x23ac }, /* rightmiddlecurlybrace ⎬ RIGHT CURLY BRACKET MIDDLE PIECE */ - /* 0x08b1 topleftsummation ? ??? */ - /* 0x08b2 botleftsummation ? ??? */ - /* 0x08b3 topvertsummationconnector ? ??? */ - /* 0x08b4 botvertsummationconnector ? ??? */ - /* 0x08b5 toprightsummation ? ??? */ - /* 0x08b6 botrightsummation ? ??? */ - /* 0x08b7 rightmiddlesummation ? ??? */ - { 0x08bc, 0x2264 }, /* lessthanequal ≤ LESS-THAN OR EQUAL TO */ - { 0x08bd, 0x2260 }, /* notequal ≠ NOT EQUAL TO */ - { 0x08be, 0x2265 }, /* greaterthanequal ≥ GREATER-THAN OR EQUAL TO */ - { 0x08bf, 0x222b }, /* integral ∫ INTEGRAL */ - { 0x08c0, 0x2234 }, /* therefore ∴ THEREFORE */ - { 0x08c1, 0x221d }, /* variation ∝ PROPORTIONAL TO */ - { 0x08c2, 0x221e }, /* infinity ∞ INFINITY */ - { 0x08c5, 0x2207 }, /* nabla ∇ NABLA */ - { 0x08c8, 0x223c }, /* approximate ∼ TILDE OPERATOR */ - { 0x08c9, 0x2243 }, /* similarequal ≃ ASYMPTOTICALLY EQUAL TO */ - { 0x08cd, 0x21d4 }, /* ifonlyif ⇔ LEFT RIGHT DOUBLE ARROW */ - { 0x08ce, 0x21d2 }, /* implies ⇒ RIGHTWARDS DOUBLE ARROW */ - { 0x08cf, 0x2261 }, /* identical ≡ IDENTICAL TO */ - { 0x08d6, 0x221a }, /* radical √ SQUARE ROOT */ - { 0x08da, 0x2282 }, /* includedin ⊂ SUBSET OF */ - { 0x08db, 0x2283 }, /* includes ⊃ SUPERSET OF */ - { 0x08dc, 0x2229 }, /* intersection ∩ INTERSECTION */ - { 0x08dd, 0x222a }, /* union ∪ UNION */ - { 0x08de, 0x2227 }, /* logicaland ∧ LOGICAL AND */ - { 0x08df, 0x2228 }, /* logicalor ∨ LOGICAL OR */ - { 0x08ef, 0x2202 }, /* partialderivative ∂ PARTIAL DIFFERENTIAL */ - { 0x08f6, 0x0192 }, /* function ƒ LATIN SMALL LETTER F WITH HOOK */ - { 0x08fb, 0x2190 }, /* leftarrow ← LEFTWARDS ARROW */ - { 0x08fc, 0x2191 }, /* uparrow ↑ UPWARDS ARROW */ - { 0x08fd, 0x2192 }, /* rightarrow → RIGHTWARDS ARROW */ - { 0x08fe, 0x2193 }, /* downarrow ↓ DOWNWARDS ARROW */ - { 0x09df, 0x2422 }, /* blank ␢ BLANK SYMBOL */ - { 0x09e0, 0x25c6 }, /* soliddiamond ◆ BLACK DIAMOND */ - { 0x09e1, 0x2592 }, /* checkerboard ▒ MEDIUM SHADE */ - { 0x09e2, 0x2409 }, /* ht ␉ SYMBOL FOR HORIZONTAL TABULATION */ - { 0x09e3, 0x240c }, /* ff ␌ SYMBOL FOR FORM FEED */ - { 0x09e4, 0x240d }, /* cr ␍ SYMBOL FOR CARRIAGE RETURN */ - { 0x09e5, 0x240a }, /* lf ␊ SYMBOL FOR LINE FEED */ - { 0x09e8, 0x2424 }, /* nl ␤ SYMBOL FOR NEWLINE */ - { 0x09e9, 0x240b }, /* vt ␋ SYMBOL FOR VERTICAL TABULATION */ - { 0x09ea, 0x2518 }, /* lowrightcorner ┘ BOX DRAWINGS LIGHT UP AND LEFT */ - { 0x09eb, 0x2510 }, /* uprightcorner ┐ BOX DRAWINGS LIGHT DOWN AND LEFT */ - { 0x09ec, 0x250c }, /* upleftcorner ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */ - { 0x09ed, 0x2514 }, /* lowleftcorner └ BOX DRAWINGS LIGHT UP AND RIGHT */ - { 0x09ee, 0x253c }, /* crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */ - { 0x09ef, 0x23ba }, /* horizlinescan1 ⎺ HORIZONTAL SCAN LINE-1 */ - { 0x09f0, 0x23bb }, /* horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 */ - { 0x09f1, 0x2500 }, /* horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */ - { 0x09f2, 0x23bc }, /* horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 */ - { 0x09f3, 0x23bd }, /* horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 */ - { 0x09f4, 0x251c }, /* leftt ├ BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ - { 0x09f5, 0x2524 }, /* rightt ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT */ - { 0x09f6, 0x2534 }, /* bott ┴ BOX DRAWINGS LIGHT UP AND HORIZONTAL */ - { 0x09f7, 0x252c }, /* topt ┬ BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */ - { 0x09f8, 0x2502 }, /* vertbar │ BOX DRAWINGS LIGHT VERTICAL */ - { 0x0aa1, 0x2003 }, /* emspace   EM SPACE */ - { 0x0aa2, 0x2002 }, /* enspace   EN SPACE */ - { 0x0aa3, 0x2004 }, /* em3space   THREE-PER-EM SPACE */ - { 0x0aa4, 0x2005 }, /* em4space   FOUR-PER-EM SPACE */ - { 0x0aa5, 0x2007 }, /* digitspace   FIGURE SPACE */ - { 0x0aa6, 0x2008 }, /* punctspace   PUNCTUATION SPACE */ - { 0x0aa7, 0x2009 }, /* thinspace   THIN SPACE */ - { 0x0aa8, 0x200a }, /* hairspace   HAIR SPACE */ - { 0x0aa9, 0x2014 }, /* emdash — EM DASH */ - { 0x0aaa, 0x2013 }, /* endash – EN DASH */ - { 0x0aac, 0x2423 }, /* signifblank ␣ OPEN BOX */ - { 0x0aae, 0x2026 }, /* ellipsis … HORIZONTAL ELLIPSIS */ - { 0x0aaf, 0x2025 }, /* doubbaselinedot ‥ TWO DOT LEADER */ - { 0x0ab0, 0x2153 }, /* onethird ⅓ VULGAR FRACTION ONE THIRD */ - { 0x0ab1, 0x2154 }, /* twothirds ⅔ VULGAR FRACTION TWO THIRDS */ - { 0x0ab2, 0x2155 }, /* onefifth ⅕ VULGAR FRACTION ONE FIFTH */ - { 0x0ab3, 0x2156 }, /* twofifths ⅖ VULGAR FRACTION TWO FIFTHS */ - { 0x0ab4, 0x2157 }, /* threefifths ⅗ VULGAR FRACTION THREE FIFTHS */ - { 0x0ab5, 0x2158 }, /* fourfifths ⅘ VULGAR FRACTION FOUR FIFTHS */ - { 0x0ab6, 0x2159 }, /* onesixth ⅙ VULGAR FRACTION ONE SIXTH */ - { 0x0ab7, 0x215a }, /* fivesixths ⅚ VULGAR FRACTION FIVE SIXTHS */ - { 0x0ab8, 0x2105 }, /* careof ℅ CARE OF */ - { 0x0abb, 0x2012 }, /* figdash ‒ FIGURE DASH */ - { 0x0abc, 0x2329 }, /* leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */ - { 0x0abd, 0x002e }, /* decimalpoint . FULL STOP */ - { 0x0abe, 0x232a }, /* rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */ - /* 0x0abf marker ? ??? */ - { 0x0ac3, 0x215b }, /* oneeighth ⅛ VULGAR FRACTION ONE EIGHTH */ - { 0x0ac4, 0x215c }, /* threeeighths ⅜ VULGAR FRACTION THREE EIGHTHS */ - { 0x0ac5, 0x215d }, /* fiveeighths ⅝ VULGAR FRACTION FIVE EIGHTHS */ - { 0x0ac6, 0x215e }, /* seveneighths ⅞ VULGAR FRACTION SEVEN EIGHTHS */ - { 0x0ac9, 0x2122 }, /* trademark ™ TRADE MARK SIGN */ - { 0x0aca, 0x2613 }, /* signaturemark ☓ SALTIRE */ - /* 0x0acb trademarkincircle ? ??? */ - { 0x0acc, 0x25c1 }, /* leftopentriangle ◁ WHITE LEFT-POINTING TRIANGLE */ - { 0x0acd, 0x25b7 }, /* rightopentriangle ▷ WHITE RIGHT-POINTING TRIANGLE */ - { 0x0ace, 0x25cb }, /* emopencircle ○ WHITE CIRCLE */ - { 0x0acf, 0x25af }, /* emopenrectangle ▯ WHITE VERTICAL RECTANGLE */ - { 0x0ad0, 0x2018 }, /* leftsinglequotemark ‘ LEFT SINGLE QUOTATION MARK */ - { 0x0ad1, 0x2019 }, /* rightsinglequotemark ’ RIGHT SINGLE QUOTATION MARK */ - { 0x0ad2, 0x201c }, /* leftdoublequotemark “ LEFT DOUBLE QUOTATION MARK */ - { 0x0ad3, 0x201d }, /* rightdoublequotemark ” RIGHT DOUBLE QUOTATION MARK */ - { 0x0ad4, 0x211e }, /* prescription ℞ PRESCRIPTION TAKE */ - { 0x0ad5, 0x2030 }, /* permille ‰ PER MILLE SIGN */ - { 0x0ad6, 0x2032 }, /* minutes ′ PRIME */ - { 0x0ad7, 0x2033 }, /* seconds ″ DOUBLE PRIME */ - { 0x0ad9, 0x271d }, /* latincross ✝ LATIN CROSS */ - /* 0x0ada hexagram ? ??? */ - { 0x0adb, 0x25ac }, /* filledrectbullet ▬ BLACK RECTANGLE */ - { 0x0adc, 0x25c0 }, /* filledlefttribullet ◀ BLACK LEFT-POINTING TRIANGLE */ - { 0x0add, 0x25b6 }, /* filledrighttribullet ▶ BLACK RIGHT-POINTING TRIANGLE */ - { 0x0ade, 0x25cf }, /* emfilledcircle ● BLACK CIRCLE */ - { 0x0adf, 0x25ae }, /* emfilledrect ▮ BLACK VERTICAL RECTANGLE */ - { 0x0ae0, 0x25e6 }, /* enopencircbullet ◦ WHITE BULLET */ - { 0x0ae1, 0x25ab }, /* enopensquarebullet ▫ WHITE SMALL SQUARE */ - { 0x0ae2, 0x25ad }, /* openrectbullet ▭ WHITE RECTANGLE */ - { 0x0ae3, 0x25b3 }, /* opentribulletup △ WHITE UP-POINTING TRIANGLE */ - { 0x0ae4, 0x25bd }, /* opentribulletdown ▽ WHITE DOWN-POINTING TRIANGLE */ - { 0x0ae5, 0x2606 }, /* openstar ☆ WHITE STAR */ - { 0x0ae6, 0x2022 }, /* enfilledcircbullet • BULLET */ - { 0x0ae7, 0x25aa }, /* enfilledsqbullet ▪ BLACK SMALL SQUARE */ - { 0x0ae8, 0x25b2 }, /* filledtribulletup ▲ BLACK UP-POINTING TRIANGLE */ - { 0x0ae9, 0x25bc }, /* filledtribulletdown ▼ BLACK DOWN-POINTING TRIANGLE */ - { 0x0aea, 0x261c }, /* leftpointer ☜ WHITE LEFT POINTING INDEX */ - { 0x0aeb, 0x261e }, /* rightpointer ☞ WHITE RIGHT POINTING INDEX */ - { 0x0aec, 0x2663 }, /* club ♣ BLACK CLUB SUIT */ - { 0x0aed, 0x2666 }, /* diamond ♦ BLACK DIAMOND SUIT */ - { 0x0aee, 0x2665 }, /* heart ♥ BLACK HEART SUIT */ - { 0x0af0, 0x2720 }, /* maltesecross ✠ MALTESE CROSS */ - { 0x0af1, 0x2020 }, /* dagger † DAGGER */ - { 0x0af2, 0x2021 }, /* doubledagger ‡ DOUBLE DAGGER */ - { 0x0af3, 0x2713 }, /* checkmark ✓ CHECK MARK */ - { 0x0af4, 0x2717 }, /* ballotcross ✗ BALLOT X */ - { 0x0af5, 0x266f }, /* musicalsharp ♯ MUSIC SHARP SIGN */ - { 0x0af6, 0x266d }, /* musicalflat ♭ MUSIC FLAT SIGN */ - { 0x0af7, 0x2642 }, /* malesymbol ♂ MALE SIGN */ - { 0x0af8, 0x2640 }, /* femalesymbol ♀ FEMALE SIGN */ - { 0x0af9, 0x260e }, /* telephone ☎ BLACK TELEPHONE */ - { 0x0afa, 0x2315 }, /* telephonerecorder ⌕ TELEPHONE RECORDER */ - { 0x0afb, 0x2117 }, /* phonographcopyright ℗ SOUND RECORDING COPYRIGHT */ - { 0x0afc, 0x2038 }, /* caret ‸ CARET */ - { 0x0afd, 0x201a }, /* singlelowquotemark ‚ SINGLE LOW-9 QUOTATION MARK */ - { 0x0afe, 0x201e }, /* doublelowquotemark „ DOUBLE LOW-9 QUOTATION MARK */ - /* 0x0aff cursor ? ??? */ - { 0x0ba3, 0x003c }, /* leftcaret < LESS-THAN SIGN */ - { 0x0ba6, 0x003e }, /* rightcaret > GREATER-THAN SIGN */ - { 0x0ba8, 0x2228 }, /* downcaret ∨ LOGICAL OR */ - { 0x0ba9, 0x2227 }, /* upcaret ∧ LOGICAL AND */ - { 0x0bc0, 0x00af }, /* overbar ¯ MACRON */ - { 0x0bc2, 0x22a4 }, /* downtack ⊤ DOWN TACK */ - { 0x0bc3, 0x2229 }, /* upshoe ∩ INTERSECTION */ - { 0x0bc4, 0x230a }, /* downstile ⌊ LEFT FLOOR */ - { 0x0bc6, 0x005f }, /* underbar _ LOW LINE */ - { 0x0bca, 0x2218 }, /* jot ∘ RING OPERATOR */ - { 0x0bcc, 0x2395 }, /* quad ⎕ APL FUNCTIONAL SYMBOL QUAD */ - { 0x0bce, 0x22a5 }, /* uptack ⊥ UP TACK */ - { 0x0bcf, 0x25cb }, /* circle ○ WHITE CIRCLE */ - { 0x0bd3, 0x2308 }, /* upstile ⌈ LEFT CEILING */ - { 0x0bd6, 0x222a }, /* downshoe ∪ UNION */ - { 0x0bd8, 0x2283 }, /* rightshoe ⊃ SUPERSET OF */ - { 0x0bda, 0x2282 }, /* leftshoe ⊂ SUBSET OF */ - { 0x0bdc, 0x22a3 }, /* lefttack ⊣ LEFT TACK */ - { 0x0bfc, 0x22a2 }, /* righttack ⊢ RIGHT TACK */ - { 0x0cdf, 0x2017 }, /* hebrew_doublelowline ‗ DOUBLE LOW LINE */ - { 0x0ce0, 0x05d0 }, /* hebrew_aleph א HEBREW LETTER ALEF */ - { 0x0ce1, 0x05d1 }, /* hebrew_bet ב HEBREW LETTER BET */ - { 0x0ce2, 0x05d2 }, /* hebrew_gimel ג HEBREW LETTER GIMEL */ - { 0x0ce3, 0x05d3 }, /* hebrew_dalet ד HEBREW LETTER DALET */ - { 0x0ce4, 0x05d4 }, /* hebrew_he ה HEBREW LETTER HE */ - { 0x0ce5, 0x05d5 }, /* hebrew_waw ו HEBREW LETTER VAV */ - { 0x0ce6, 0x05d6 }, /* hebrew_zain ז HEBREW LETTER ZAYIN */ - { 0x0ce7, 0x05d7 }, /* hebrew_chet ח HEBREW LETTER HET */ - { 0x0ce8, 0x05d8 }, /* hebrew_tet ט HEBREW LETTER TET */ - { 0x0ce9, 0x05d9 }, /* hebrew_yod י HEBREW LETTER YOD */ - { 0x0cea, 0x05da }, /* hebrew_finalkaph ך HEBREW LETTER FINAL KAF */ - { 0x0ceb, 0x05db }, /* hebrew_kaph כ HEBREW LETTER KAF */ - { 0x0cec, 0x05dc }, /* hebrew_lamed ל HEBREW LETTER LAMED */ - { 0x0ced, 0x05dd }, /* hebrew_finalmem ם HEBREW LETTER FINAL MEM */ - { 0x0cee, 0x05de }, /* hebrew_mem מ HEBREW LETTER MEM */ - { 0x0cef, 0x05df }, /* hebrew_finalnun ן HEBREW LETTER FINAL NUN */ - { 0x0cf0, 0x05e0 }, /* hebrew_nun נ HEBREW LETTER NUN */ - { 0x0cf1, 0x05e1 }, /* hebrew_samech ס HEBREW LETTER SAMEKH */ - { 0x0cf2, 0x05e2 }, /* hebrew_ayin ע HEBREW LETTER AYIN */ - { 0x0cf3, 0x05e3 }, /* hebrew_finalpe ף HEBREW LETTER FINAL PE */ - { 0x0cf4, 0x05e4 }, /* hebrew_pe פ HEBREW LETTER PE */ - { 0x0cf5, 0x05e5 }, /* hebrew_finalzade ץ HEBREW LETTER FINAL TSADI */ - { 0x0cf6, 0x05e6 }, /* hebrew_zade צ HEBREW LETTER TSADI */ - { 0x0cf7, 0x05e7 }, /* hebrew_qoph ק HEBREW LETTER QOF */ - { 0x0cf8, 0x05e8 }, /* hebrew_resh ר HEBREW LETTER RESH */ - { 0x0cf9, 0x05e9 }, /* hebrew_shin ש HEBREW LETTER SHIN */ - { 0x0cfa, 0x05ea }, /* hebrew_taw ת HEBREW LETTER TAV */ - { 0x0da1, 0x0e01 }, /* Thai_kokai ก THAI CHARACTER KO KAI */ - { 0x0da2, 0x0e02 }, /* Thai_khokhai ข THAI CHARACTER KHO KHAI */ - { 0x0da3, 0x0e03 }, /* Thai_khokhuat ฃ THAI CHARACTER KHO KHUAT */ - { 0x0da4, 0x0e04 }, /* Thai_khokhwai ค THAI CHARACTER KHO KHWAI */ - { 0x0da5, 0x0e05 }, /* Thai_khokhon ฅ THAI CHARACTER KHO KHON */ - { 0x0da6, 0x0e06 }, /* Thai_khorakhang ฆ THAI CHARACTER KHO RAKHANG */ - { 0x0da7, 0x0e07 }, /* Thai_ngongu ง THAI CHARACTER NGO NGU */ - { 0x0da8, 0x0e08 }, /* Thai_chochan จ THAI CHARACTER CHO CHAN */ - { 0x0da9, 0x0e09 }, /* Thai_choching ฉ THAI CHARACTER CHO CHING */ - { 0x0daa, 0x0e0a }, /* Thai_chochang ช THAI CHARACTER CHO CHANG */ - { 0x0dab, 0x0e0b }, /* Thai_soso ซ THAI CHARACTER SO SO */ - { 0x0dac, 0x0e0c }, /* Thai_chochoe ฌ THAI CHARACTER CHO CHOE */ - { 0x0dad, 0x0e0d }, /* Thai_yoying ญ THAI CHARACTER YO YING */ - { 0x0dae, 0x0e0e }, /* Thai_dochada ฎ THAI CHARACTER DO CHADA */ - { 0x0daf, 0x0e0f }, /* Thai_topatak ฏ THAI CHARACTER TO PATAK */ - { 0x0db0, 0x0e10 }, /* Thai_thothan ฐ THAI CHARACTER THO THAN */ - { 0x0db1, 0x0e11 }, /* Thai_thonangmontho ฑ THAI CHARACTER THO NANGMONTHO */ - { 0x0db2, 0x0e12 }, /* Thai_thophuthao ฒ THAI CHARACTER THO PHUTHAO */ - { 0x0db3, 0x0e13 }, /* Thai_nonen ณ THAI CHARACTER NO NEN */ - { 0x0db4, 0x0e14 }, /* Thai_dodek ด THAI CHARACTER DO DEK */ - { 0x0db5, 0x0e15 }, /* Thai_totao ต THAI CHARACTER TO TAO */ - { 0x0db6, 0x0e16 }, /* Thai_thothung ถ THAI CHARACTER THO THUNG */ - { 0x0db7, 0x0e17 }, /* Thai_thothahan ท THAI CHARACTER THO THAHAN */ - { 0x0db8, 0x0e18 }, /* Thai_thothong ธ THAI CHARACTER THO THONG */ - { 0x0db9, 0x0e19 }, /* Thai_nonu น THAI CHARACTER NO NU */ - { 0x0dba, 0x0e1a }, /* Thai_bobaimai บ THAI CHARACTER BO BAIMAI */ - { 0x0dbb, 0x0e1b }, /* Thai_popla ป THAI CHARACTER PO PLA */ - { 0x0dbc, 0x0e1c }, /* Thai_phophung ผ THAI CHARACTER PHO PHUNG */ - { 0x0dbd, 0x0e1d }, /* Thai_fofa ฝ THAI CHARACTER FO FA */ - { 0x0dbe, 0x0e1e }, /* Thai_phophan พ THAI CHARACTER PHO PHAN */ - { 0x0dbf, 0x0e1f }, /* Thai_fofan ฟ THAI CHARACTER FO FAN */ - { 0x0dc0, 0x0e20 }, /* Thai_phosamphao ภ THAI CHARACTER PHO SAMPHAO */ - { 0x0dc1, 0x0e21 }, /* Thai_moma ม THAI CHARACTER MO MA */ - { 0x0dc2, 0x0e22 }, /* Thai_yoyak ย THAI CHARACTER YO YAK */ - { 0x0dc3, 0x0e23 }, /* Thai_rorua ร THAI CHARACTER RO RUA */ - { 0x0dc4, 0x0e24 }, /* Thai_ru ฤ THAI CHARACTER RU */ - { 0x0dc5, 0x0e25 }, /* Thai_loling ล THAI CHARACTER LO LING */ - { 0x0dc6, 0x0e26 }, /* Thai_lu ฦ THAI CHARACTER LU */ - { 0x0dc7, 0x0e27 }, /* Thai_wowaen ว THAI CHARACTER WO WAEN */ - { 0x0dc8, 0x0e28 }, /* Thai_sosala ศ THAI CHARACTER SO SALA */ - { 0x0dc9, 0x0e29 }, /* Thai_sorusi ษ THAI CHARACTER SO RUSI */ - { 0x0dca, 0x0e2a }, /* Thai_sosua ส THAI CHARACTER SO SUA */ - { 0x0dcb, 0x0e2b }, /* Thai_hohip ห THAI CHARACTER HO HIP */ - { 0x0dcc, 0x0e2c }, /* Thai_lochula ฬ THAI CHARACTER LO CHULA */ - { 0x0dcd, 0x0e2d }, /* Thai_oang อ THAI CHARACTER O ANG */ - { 0x0dce, 0x0e2e }, /* Thai_honokhuk ฮ THAI CHARACTER HO NOKHUK */ - { 0x0dcf, 0x0e2f }, /* Thai_paiyannoi ฯ THAI CHARACTER PAIYANNOI */ - { 0x0dd0, 0x0e30 }, /* Thai_saraa ะ THAI CHARACTER SARA A */ - { 0x0dd1, 0x0e31 }, /* Thai_maihanakat ั THAI CHARACTER MAI HAN-AKAT */ - { 0x0dd2, 0x0e32 }, /* Thai_saraaa า THAI CHARACTER SARA AA */ - { 0x0dd3, 0x0e33 }, /* Thai_saraam ำ THAI CHARACTER SARA AM */ - { 0x0dd4, 0x0e34 }, /* Thai_sarai ิ THAI CHARACTER SARA I */ - { 0x0dd5, 0x0e35 }, /* Thai_saraii ี THAI CHARACTER SARA II */ - { 0x0dd6, 0x0e36 }, /* Thai_saraue ึ THAI CHARACTER SARA UE */ - { 0x0dd7, 0x0e37 }, /* Thai_sarauee ื THAI CHARACTER SARA UEE */ - { 0x0dd8, 0x0e38 }, /* Thai_sarau ุ THAI CHARACTER SARA U */ - { 0x0dd9, 0x0e39 }, /* Thai_sarauu ู THAI CHARACTER SARA UU */ - { 0x0dda, 0x0e3a }, /* Thai_phinthu ฺ THAI CHARACTER PHINTHU */ - /* 0x0dde Thai_maihanakat_maitho ? ??? */ - { 0x0ddf, 0x0e3f }, /* Thai_baht ฿ THAI CURRENCY SYMBOL BAHT */ - { 0x0de0, 0x0e40 }, /* Thai_sarae เ THAI CHARACTER SARA E */ - { 0x0de1, 0x0e41 }, /* Thai_saraae แ THAI CHARACTER SARA AE */ - { 0x0de2, 0x0e42 }, /* Thai_sarao โ THAI CHARACTER SARA O */ - { 0x0de3, 0x0e43 }, /* Thai_saraaimaimuan ใ THAI CHARACTER SARA AI MAIMUAN */ - { 0x0de4, 0x0e44 }, /* Thai_saraaimaimalai ไ THAI CHARACTER SARA AI MAIMALAI */ - { 0x0de5, 0x0e45 }, /* Thai_lakkhangyao ๅ THAI CHARACTER LAKKHANGYAO */ - { 0x0de6, 0x0e46 }, /* Thai_maiyamok ๆ THAI CHARACTER MAIYAMOK */ - { 0x0de7, 0x0e47 }, /* Thai_maitaikhu ็ THAI CHARACTER MAITAIKHU */ - { 0x0de8, 0x0e48 }, /* Thai_maiek ่ THAI CHARACTER MAI EK */ - { 0x0de9, 0x0e49 }, /* Thai_maitho ้ THAI CHARACTER MAI THO */ - { 0x0dea, 0x0e4a }, /* Thai_maitri ๊ THAI CHARACTER MAI TRI */ - { 0x0deb, 0x0e4b }, /* Thai_maichattawa ๋ THAI CHARACTER MAI CHATTAWA */ - { 0x0dec, 0x0e4c }, /* Thai_thanthakhat ์ THAI CHARACTER THANTHAKHAT */ - { 0x0ded, 0x0e4d }, /* Thai_nikhahit ํ THAI CHARACTER NIKHAHIT */ - { 0x0df0, 0x0e50 }, /* Thai_leksun ๐ THAI DIGIT ZERO */ - { 0x0df1, 0x0e51 }, /* Thai_leknung ๑ THAI DIGIT ONE */ - { 0x0df2, 0x0e52 }, /* Thai_leksong ๒ THAI DIGIT TWO */ - { 0x0df3, 0x0e53 }, /* Thai_leksam ๓ THAI DIGIT THREE */ - { 0x0df4, 0x0e54 }, /* Thai_leksi ๔ THAI DIGIT FOUR */ - { 0x0df5, 0x0e55 }, /* Thai_lekha ๕ THAI DIGIT FIVE */ - { 0x0df6, 0x0e56 }, /* Thai_lekhok ๖ THAI DIGIT SIX */ - { 0x0df7, 0x0e57 }, /* Thai_lekchet ๗ THAI DIGIT SEVEN */ - { 0x0df8, 0x0e58 }, /* Thai_lekpaet ๘ THAI DIGIT EIGHT */ - { 0x0df9, 0x0e59 }, /* Thai_lekkao ๙ THAI DIGIT NINE */ - { 0x0ea1, 0x3131 }, /* Hangul_Kiyeog ㄱ HANGUL LETTER KIYEOK */ - { 0x0ea2, 0x3132 }, /* Hangul_SsangKiyeog ㄲ HANGUL LETTER SSANGKIYEOK */ - { 0x0ea3, 0x3133 }, /* Hangul_KiyeogSios ㄳ HANGUL LETTER KIYEOK-SIOS */ - { 0x0ea4, 0x3134 }, /* Hangul_Nieun ㄴ HANGUL LETTER NIEUN */ - { 0x0ea5, 0x3135 }, /* Hangul_NieunJieuj ㄵ HANGUL LETTER NIEUN-CIEUC */ - { 0x0ea6, 0x3136 }, /* Hangul_NieunHieuh ㄶ HANGUL LETTER NIEUN-HIEUH */ - { 0x0ea7, 0x3137 }, /* Hangul_Dikeud ㄷ HANGUL LETTER TIKEUT */ - { 0x0ea8, 0x3138 }, /* Hangul_SsangDikeud ㄸ HANGUL LETTER SSANGTIKEUT */ - { 0x0ea9, 0x3139 }, /* Hangul_Rieul ㄹ HANGUL LETTER RIEUL */ - { 0x0eaa, 0x313a }, /* Hangul_RieulKiyeog ㄺ HANGUL LETTER RIEUL-KIYEOK */ - { 0x0eab, 0x313b }, /* Hangul_RieulMieum ㄻ HANGUL LETTER RIEUL-MIEUM */ - { 0x0eac, 0x313c }, /* Hangul_RieulPieub ㄼ HANGUL LETTER RIEUL-PIEUP */ - { 0x0ead, 0x313d }, /* Hangul_RieulSios ㄽ HANGUL LETTER RIEUL-SIOS */ - { 0x0eae, 0x313e }, /* Hangul_RieulTieut ㄾ HANGUL LETTER RIEUL-THIEUTH */ - { 0x0eaf, 0x313f }, /* Hangul_RieulPhieuf ㄿ HANGUL LETTER RIEUL-PHIEUPH */ - { 0x0eb0, 0x3140 }, /* Hangul_RieulHieuh ㅀ HANGUL LETTER RIEUL-HIEUH */ - { 0x0eb1, 0x3141 }, /* Hangul_Mieum ㅁ HANGUL LETTER MIEUM */ - { 0x0eb2, 0x3142 }, /* Hangul_Pieub ㅂ HANGUL LETTER PIEUP */ - { 0x0eb3, 0x3143 }, /* Hangul_SsangPieub ㅃ HANGUL LETTER SSANGPIEUP */ - { 0x0eb4, 0x3144 }, /* Hangul_PieubSios ㅄ HANGUL LETTER PIEUP-SIOS */ - { 0x0eb5, 0x3145 }, /* Hangul_Sios ㅅ HANGUL LETTER SIOS */ - { 0x0eb6, 0x3146 }, /* Hangul_SsangSios ㅆ HANGUL LETTER SSANGSIOS */ - { 0x0eb7, 0x3147 }, /* Hangul_Ieung ㅇ HANGUL LETTER IEUNG */ - { 0x0eb8, 0x3148 }, /* Hangul_Jieuj ㅈ HANGUL LETTER CIEUC */ - { 0x0eb9, 0x3149 }, /* Hangul_SsangJieuj ㅉ HANGUL LETTER SSANGCIEUC */ - { 0x0eba, 0x314a }, /* Hangul_Cieuc ㅊ HANGUL LETTER CHIEUCH */ - { 0x0ebb, 0x314b }, /* Hangul_Khieuq ㅋ HANGUL LETTER KHIEUKH */ - { 0x0ebc, 0x314c }, /* Hangul_Tieut ㅌ HANGUL LETTER THIEUTH */ - { 0x0ebd, 0x314d }, /* Hangul_Phieuf ㅍ HANGUL LETTER PHIEUPH */ - { 0x0ebe, 0x314e }, /* Hangul_Hieuh ㅎ HANGUL LETTER HIEUH */ - { 0x0ebf, 0x314f }, /* Hangul_A ㅏ HANGUL LETTER A */ - { 0x0ec0, 0x3150 }, /* Hangul_AE ㅐ HANGUL LETTER AE */ - { 0x0ec1, 0x3151 }, /* Hangul_YA ㅑ HANGUL LETTER YA */ - { 0x0ec2, 0x3152 }, /* Hangul_YAE ㅒ HANGUL LETTER YAE */ - { 0x0ec3, 0x3153 }, /* Hangul_EO ㅓ HANGUL LETTER EO */ - { 0x0ec4, 0x3154 }, /* Hangul_E ㅔ HANGUL LETTER E */ - { 0x0ec5, 0x3155 }, /* Hangul_YEO ㅕ HANGUL LETTER YEO */ - { 0x0ec6, 0x3156 }, /* Hangul_YE ㅖ HANGUL LETTER YE */ - { 0x0ec7, 0x3157 }, /* Hangul_O ㅗ HANGUL LETTER O */ - { 0x0ec8, 0x3158 }, /* Hangul_WA ㅘ HANGUL LETTER WA */ - { 0x0ec9, 0x3159 }, /* Hangul_WAE ㅙ HANGUL LETTER WAE */ - { 0x0eca, 0x315a }, /* Hangul_OE ㅚ HANGUL LETTER OE */ - { 0x0ecb, 0x315b }, /* Hangul_YO ㅛ HANGUL LETTER YO */ - { 0x0ecc, 0x315c }, /* Hangul_U ㅜ HANGUL LETTER U */ - { 0x0ecd, 0x315d }, /* Hangul_WEO ㅝ HANGUL LETTER WEO */ - { 0x0ece, 0x315e }, /* Hangul_WE ㅞ HANGUL LETTER WE */ - { 0x0ecf, 0x315f }, /* Hangul_WI ㅟ HANGUL LETTER WI */ - { 0x0ed0, 0x3160 }, /* Hangul_YU ㅠ HANGUL LETTER YU */ - { 0x0ed1, 0x3161 }, /* Hangul_EU ㅡ HANGUL LETTER EU */ - { 0x0ed2, 0x3162 }, /* Hangul_YI ㅢ HANGUL LETTER YI */ - { 0x0ed3, 0x3163 }, /* Hangul_I ㅣ HANGUL LETTER I */ - { 0x0ed4, 0x11a8 }, /* Hangul_J_Kiyeog ᆨ HANGUL JONGSEONG KIYEOK */ - { 0x0ed5, 0x11a9 }, /* Hangul_J_SsangKiyeog ᆩ HANGUL JONGSEONG SSANGKIYEOK */ - { 0x0ed6, 0x11aa }, /* Hangul_J_KiyeogSios ᆪ HANGUL JONGSEONG KIYEOK-SIOS */ - { 0x0ed7, 0x11ab }, /* Hangul_J_Nieun ᆫ HANGUL JONGSEONG NIEUN */ - { 0x0ed8, 0x11ac }, /* Hangul_J_NieunJieuj ᆬ HANGUL JONGSEONG NIEUN-CIEUC */ - { 0x0ed9, 0x11ad }, /* Hangul_J_NieunHieuh ᆭ HANGUL JONGSEONG NIEUN-HIEUH */ - { 0x0eda, 0x11ae }, /* Hangul_J_Dikeud ᆮ HANGUL JONGSEONG TIKEUT */ - { 0x0edb, 0x11af }, /* Hangul_J_Rieul ᆯ HANGUL JONGSEONG RIEUL */ - { 0x0edc, 0x11b0 }, /* Hangul_J_RieulKiyeog ᆰ HANGUL JONGSEONG RIEUL-KIYEOK */ - { 0x0edd, 0x11b1 }, /* Hangul_J_RieulMieum ᆱ HANGUL JONGSEONG RIEUL-MIEUM */ - { 0x0ede, 0x11b2 }, /* Hangul_J_RieulPieub ᆲ HANGUL JONGSEONG RIEUL-PIEUP */ - { 0x0edf, 0x11b3 }, /* Hangul_J_RieulSios ᆳ HANGUL JONGSEONG RIEUL-SIOS */ - { 0x0ee0, 0x11b4 }, /* Hangul_J_RieulTieut ᆴ HANGUL JONGSEONG RIEUL-THIEUTH */ - { 0x0ee1, 0x11b5 }, /* Hangul_J_RieulPhieuf ᆵ HANGUL JONGSEONG RIEUL-PHIEUPH */ - { 0x0ee2, 0x11b6 }, /* Hangul_J_RieulHieuh ᆶ HANGUL JONGSEONG RIEUL-HIEUH */ - { 0x0ee3, 0x11b7 }, /* Hangul_J_Mieum ᆷ HANGUL JONGSEONG MIEUM */ - { 0x0ee4, 0x11b8 }, /* Hangul_J_Pieub ᆸ HANGUL JONGSEONG PIEUP */ - { 0x0ee5, 0x11b9 }, /* Hangul_J_PieubSios ᆹ HANGUL JONGSEONG PIEUP-SIOS */ - { 0x0ee6, 0x11ba }, /* Hangul_J_Sios ᆺ HANGUL JONGSEONG SIOS */ - { 0x0ee7, 0x11bb }, /* Hangul_J_SsangSios ᆻ HANGUL JONGSEONG SSANGSIOS */ - { 0x0ee8, 0x11bc }, /* Hangul_J_Ieung ᆼ HANGUL JONGSEONG IEUNG */ - { 0x0ee9, 0x11bd }, /* Hangul_J_Jieuj ᆽ HANGUL JONGSEONG CIEUC */ - { 0x0eea, 0x11be }, /* Hangul_J_Cieuc ᆾ HANGUL JONGSEONG CHIEUCH */ - { 0x0eeb, 0x11bf }, /* Hangul_J_Khieuq ᆿ HANGUL JONGSEONG KHIEUKH */ - { 0x0eec, 0x11c0 }, /* Hangul_J_Tieut ᇀ HANGUL JONGSEONG THIEUTH */ - { 0x0eed, 0x11c1 }, /* Hangul_J_Phieuf ᇁ HANGUL JONGSEONG PHIEUPH */ - { 0x0eee, 0x11c2 }, /* Hangul_J_Hieuh ᇂ HANGUL JONGSEONG HIEUH */ - { 0x0eef, 0x316d }, /* Hangul_RieulYeorinHieuh ㅭ HANGUL LETTER RIEUL-YEORINHIEUH */ - { 0x0ef0, 0x3171 }, /* Hangul_SunkyeongeumMieum ㅱ HANGUL LETTER KAPYEOUNMIEUM */ - { 0x0ef1, 0x3178 }, /* Hangul_SunkyeongeumPieub ㅸ HANGUL LETTER KAPYEOUNPIEUP */ - { 0x0ef2, 0x317f }, /* Hangul_PanSios ㅿ HANGUL LETTER PANSIOS */ - { 0x0ef3, 0x3181 }, /* Hangul_KkogjiDalrinIeung ㆁ HANGUL LETTER YESIEUNG */ - { 0x0ef4, 0x3184 }, /* Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */ - { 0x0ef5, 0x3186 }, /* Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */ - { 0x0ef6, 0x318d }, /* Hangul_AraeA ㆍ HANGUL LETTER ARAEA */ - { 0x0ef7, 0x318e }, /* Hangul_AraeAE ㆎ HANGUL LETTER ARAEAE */ - { 0x0ef8, 0x11eb }, /* Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */ - { 0x0ef9, 0x11f0 }, /* Hangul_J_KkogjiDalrinIeung ᇰ HANGUL JONGSEONG YESIEUNG */ - { 0x0efa, 0x11f9 }, /* Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */ - { 0x0eff, 0x20a9 }, /* Korean_Won ₩ WON SIGN */ - { 0x13a4, 0x20ac }, /* Euro € EURO SIGN */ - { 0x13bc, 0x0152 }, /* OE Œ LATIN CAPITAL LIGATURE OE */ - { 0x13bd, 0x0153 }, /* oe œ LATIN SMALL LIGATURE OE */ - { 0x13be, 0x0178 }, /* Ydiaeresis Ÿ LATIN CAPITAL LETTER Y WITH DIAERESIS */ - { 0x20a0, 0x20a0 }, /* EcuSign ₠ EURO-CURRENCY SIGN */ - { 0x20a1, 0x20a1 }, /* ColonSign ₡ COLON SIGN */ - { 0x20a2, 0x20a2 }, /* CruzeiroSign ₢ CRUZEIRO SIGN */ - { 0x20a3, 0x20a3 }, /* FFrancSign ₣ FRENCH FRANC SIGN */ - { 0x20a4, 0x20a4 }, /* LiraSign ₤ LIRA SIGN */ - { 0x20a5, 0x20a5 }, /* MillSign ₥ MILL SIGN */ - { 0x20a6, 0x20a6 }, /* NairaSign ₦ NAIRA SIGN */ - { 0x20a7, 0x20a7 }, /* PesetaSign ₧ PESETA SIGN */ - { 0x20a8, 0x20a8 }, /* RupeeSign ₨ RUPEE SIGN */ - { 0x20a9, 0x20a9 }, /* WonSign ₩ WON SIGN */ - { 0x20aa, 0x20aa }, /* NewSheqelSign ₪ NEW SHEQEL SIGN */ - { 0x20ab, 0x20ab }, /* DongSign ₫ DONG SIGN */ - { 0x20ac, 0x20ac }, /* EuroSign € EURO SIGN */ -}; - -long keysym2ucs(KeySym keysym) -{ - int min = 0; - int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; - int mid; - - /* first check for Latin-1 characters (1:1 mapping) */ - if ((keysym >= 0x0020 && keysym <= 0x007e) || - (keysym >= 0x00a0 && keysym <= 0x00ff)) { - return keysym; - } - - /* also check for directly encoded 24-bit UCS characters */ - if ((keysym & 0xff000000) == 0x01000000) { - return keysym & 0x00ffffff; - } - - /* binary search in table */ - while (max >= min) { - mid = (min + max) / 2; - if (keysymtab[mid].keysym < keysym) { - min = mid + 1; - } else if (keysymtab[mid].keysym > keysym) { - max = mid - 1; - } else { - /* found it */ - return keysymtab[mid].ucs; - } - } - - /* no matching Unicode value found */ - return -1; -} diff --git a/kcontrol/keyboard/preview/keysym2ucs.h b/kcontrol/keyboard/preview/keysym2ucs.h deleted file mode 100644 index 6e50c764..00000000 --- a/kcontrol/keyboard/preview/keysym2ucs.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Andriy Rysin (arysin@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef KEYSYM2UCS_H -#define KEYSYM2UCS_H - -#include -#include - -extern long keysym2ucs(KeySym keysym); - -#endif diff --git a/kcontrol/keyboard/preview/keysymbols.cpp b/kcontrol/keyboard/preview/keysymbols.cpp deleted file mode 100644 index af43f621..00000000 --- a/kcontrol/keyboard/preview/keysymbols.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include "keysymbols.h" - -#include -#include - - -static const int MAX_GROUPS_SUPPORTED = 4; - -KeySymbols::KeySymbols() -{ -} - -void KeySymbols::setKey(const QString& a) -{ - int i=a.indexOf("<"); - i++; - keyname=a.mid(i,4); - keyname.remove(" "); - i=a.indexOf("["); - i++; - - QString str=a.mid(i); - i=str.indexOf("]"); - - QString st=str.left(i); - st=st.remove(" "); - //QStringList klst; - symbols=st.split(","); - - if( symbols.size() > MAX_GROUPS_SUPPORTED ) { - symbols = symbols.mid(0, MAX_GROUPS_SUPPORTED); - } - - for(int k=0;k -#include - -class KeySymbols -{ -public: - KeySymbols(); - - QString keyname; - QList symbols; - - void setKey(const QString& opton); -}; - -#endif // KEYSYMBOLS_H diff --git a/kcontrol/keyboard/preview/keysymhelper.cpp b/kcontrol/keyboard/preview/keysymhelper.cpp deleted file mode 100644 index 7036dca8..00000000 --- a/kcontrol/keyboard/preview/keysymhelper.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "keysymhelper.h" -#include "keysym2ucs.h" - -#include -#include - -#include - -#include - - -KeySymHelper::KeySymHelper() -{ - nill = 0; -} - -QString KeySymHelper::getKeySymbol(const QString& opton) -{ - if( keySymbolMap.contains(opton) ) - return keySymbolMap[opton]; - - const QByteArray str = opton.toAscii(); - -#if 0 - //TODO: figure out how to use this so we don't need our own symkey2ucs mapping - int res = Xutf8LookupString(XIC ic, XKeyPressedEvent *event, char *buffer_return, int bytes_buffer, KeySym *keysym_return, Status *status_return); - -#else - - KeySym keysym = XStringToKeysym(str); - long ucs = keysym2ucs(keysym); - -// if( ucs == -1 && (keysym >= 0xFE50 && keysym <= 0xFE5F) ) { -// ucs = 0x0300 + (keysym & 0x000F); -// kWarning() << "Got dead symbol" << QString("0x%1").arg(keysym, 0, 16) << "named" << opton << "will use" << QString("0x%1").arg(ucs, 0, 16) << "as UCS"; -// } - - if( ucs == -1 ) { - nill++; - kWarning() << "No mapping from keysym:" << QString("0x%1").arg(keysym, 0, 16) << "named:" << opton << "to UCS"; - } - - QString ucsStr = QString(QChar((int)ucs)); - - // Combining Diacritical Marks - if( ucs >= 0x0300 && ucs <= 0x036F ) { - ucsStr = " " + ucsStr + " "; - } - -// kWarning() << "--" << opton << "keysym: " << keysym << QString("0x%1").arg(keysym, 0, 16) << "keysym2string" << XKeysymToString(keysym) -// << "---" << QString("0x%1").arg(ucs, 0, 16) << ucsStr; - - keySymbolMap[opton] = ucsStr; - - return ucsStr; - -#endif - -} - diff --git a/kcontrol/keyboard/preview/keysymhelper.h b/kcontrol/keyboard/preview/keysymhelper.h deleted file mode 100644 index 763e872e..00000000 --- a/kcontrol/keyboard/preview/keysymhelper.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef KEYSYMHELPER_H -#define KEYSYMHELPER_H - -#include -#include - -class KeySymHelper -{ -public: - KeySymHelper(); - - QString getKeySymbol(const QString &opton); - bool isFailed() const { - return nill >= 120; - } - -private: - QMap keySymbolMap; - int nill; -}; - -#endif // KEYSYMHELPER_H diff --git a/kcontrol/keyboard/tests/CMakeLists.txt b/kcontrol/keyboard/tests/CMakeLists.txt deleted file mode 100644 index c0d3520f..00000000 --- a/kcontrol/keyboard/tests/CMakeLists.txt +++ /dev/null @@ -1,82 +0,0 @@ -macro(KEYBOARD_DAEMON_UNIT_TESTS _testname) - kde4_add_test(kcm-keyboard-${_testname} ${_testname}_test.cpp ../${_testname}.cpp) - target_link_libraries(kcm-keyboard-${_testname} - KDE4::kdeui - ${QT_QTXML_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${X11_Xkbfile_LIB} - ${X11_LIBRARIES} - ) -endmacro(KEYBOARD_DAEMON_UNIT_TESTS) - -macro(KEYBOARD_DAEMON_UNIT_TESTS2 _testname _src1 _src2 _src3) - kde4_add_test(kcm-keyboard-${_testname} - ${_testname}_test.cpp - ../${_testname}.cpp - ../${_src1} - ../${_src2} - ../${_src3} - ) - target_link_libraries(kcm-keyboard-${_testname} - KDE4::kdeui - ${QT_QTXML_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${X11_Xkbfile_LIB} - ) -endmacro(KEYBOARD_DAEMON_UNIT_TESTS2) - - -KEYBOARD_DAEMON_UNIT_TESTS(xkb_rules) -KEYBOARD_DAEMON_UNIT_TESTS(iso_codes) - -kde4_add_test(kcm-keyboard-flags_test - flags_test.cpp - ../flags.cpp - ../x11_helper.cpp - ../keyboard_config.cpp - ../xkb_rules.cpp -) -target_link_libraries(kcm-keyboard-flags_test - KDE4::kdeui - KDE4::plasma - ${QT_QTXML_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${X11_Xkbfile_LIB} - ${X11_LIBRARIES} -) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/base.1.1.xml ${CMAKE_CURRENT_BINARY_DIR}/config/base.1.1.xml COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/base.bad.xml ${CMAKE_CURRENT_BINARY_DIR}/config/base.bad.xml COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/base.xml ${CMAKE_CURRENT_BINARY_DIR}/config/base.xml COPYONLY) - -if(X11_XTest_FOUND) - kde4_add_test(kcm-keyboard-keyboard_daemon_test - keyboard_daemon_test.cpp - ../keyboard_daemon.cpp - ../layout_memory.cpp - ../layout_memory_persister.cpp - ../flags.cpp - ../x11_helper.cpp - ../xkb_helper.cpp - ../xinput_helper.cpp - ../layout_tray_icon.cpp - ../keyboard_config.cpp - ../xkb_rules.cpp - ../keyboard_hardware.cpp - ../bindings.cpp - ../layouts_menu.cpp - ../numlockx.c - ) - target_link_libraries(kcm-keyboard-keyboard_daemon_test - KDE4::kdeui - KDE4::plasma - ${QT_QTXML_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${X11_Xkbfile_LIB} - ${X11_XTest_LIB} - ${X11_LIBRARIES} - ) - if(X11_Xinput_FOUND) - target_link_libraries(kcm-keyboard-keyboard_daemon_test ${X11_Xinput_LIB}) - endif() -endif(X11_XTest_FOUND) diff --git a/kcontrol/keyboard/tests/config/base.1.1.xml b/kcontrol/keyboard/tests/config/base.1.1.xml deleted file mode 100644 index 97206a0b..00000000 --- a/kcontrol/keyboard/tests/config/base.1.1.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - pc101 - Generic 101-key PC - Generic - - - - - - - us - USA - USA - eng - - - - - chr - Cherokee - chr - - - chr - Cherokee2 - - - - bad - Bad Variant Missing configItem tag - chr - - - - - - tw - - zh - Taiwanese - - fox - - - - - - - - - grp - Key(s) to change layout - - - - - - \ No newline at end of file diff --git a/kcontrol/keyboard/tests/config/base.bad.xml b/kcontrol/keyboard/tests/config/base.bad.xml deleted file mode 100644 index 75bacdd2..00000000 --- a/kcontrol/keyboard/tests/config/base.bad.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kcontrol/keyboard/tests/config/base.xml b/kcontrol/keyboard/tests/config/base.xml deleted file mode 100644 index ddab0561..00000000 --- a/kcontrol/keyboard/tests/config/base.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - pc101 - Generic 101-key PC - Generic - - - - - - - us - USA - USA - eng - - - - - chr - Cherokee - chr - - - - - - - - - - grp - Key(s) to change layout - - - - - - \ No newline at end of file diff --git a/kcontrol/keyboard/tests/flags_test.cpp b/kcontrol/keyboard/tests/flags_test.cpp deleted file mode 100644 index 13e9eac0..00000000 --- a/kcontrol/keyboard/tests/flags_test.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "../flags.h" -#include "../xkb_rules.h" -#include "../keyboard_config.h" - - -static QImage image(const QIcon& icon) { - return icon.pixmap(QSize(16,16), QIcon::Normal, QIcon::On).toImage(); -} - -class FlagsTest : public QObject -{ - Q_OBJECT - - Flags* flags; - const Rules* rules; - -private Q_SLOTS: - void initTestCase() { - flags = new Flags(); - rules = NULL; - } - - void cleanupTestCase() { - delete flags; - delete rules; - } - - void testRules() { - QVERIFY( flags != NULL ); - - QVERIFY( ! flags->getTransparentPixmap().isNull() ); - - const QIcon iconUs(flags->getIcon("us")); - QVERIFY( ! iconUs.isNull() ); - QVERIFY( flags->getIcon("--").isNull() ); - - KeyboardConfig keyboardConfig; - LayoutUnit layoutUnit("us"); - LayoutUnit layoutUnit1("us", "intl"); - layoutUnit1.setDisplayName("usi"); - LayoutUnit layoutUnit2("us", "other"); - - keyboardConfig.indicatorType = KeyboardConfig::SHOW_FLAG; - const QIcon iconUsFlag = flags->getIconWithText(layoutUnit, keyboardConfig); - QVERIFY( ! iconUsFlag.isNull() ); - QCOMPARE( image(iconUsFlag), image(iconUs) ); - - keyboardConfig.indicatorType = KeyboardConfig::SHOW_LABEL; - const QIcon iconUsText = flags->getIconWithText(layoutUnit, keyboardConfig); - QVERIFY( ! iconUsText.isNull() ); - QVERIFY( image(iconUsText) != image(iconUs) ); - - keyboardConfig.layouts.append(layoutUnit1); - QCOMPARE( flags->getShortText(layoutUnit, keyboardConfig), QString("us") ); - QCOMPARE( flags->getShortText(layoutUnit1, keyboardConfig), QString("usi") ); - QCOMPARE( flags->getShortText(layoutUnit2, keyboardConfig), QString("us") ); - - const Rules* rules = Rules::readRules(Rules::NO_EXTRAS); - QCOMPARE( flags->getLongText(layoutUnit, rules), QString("English (US)") ); - QVERIFY( flags->getLongText(layoutUnit1, rules).startsWith("English (US, intl., with dead keys)") ); - QCOMPARE( flags->getLongText(layoutUnit2, rules), QString("other") ); - - rules = NULL; // when no rules found - QCOMPARE( flags->getLongText(layoutUnit1, rules), QString("us - intl") ); - - flags->clearCache(); - } - -// void loadRulesBenchmark() { -// QBENCHMARK { -// Flags* flags = new Flags(); -// delete flags; -// } -// } - -}; - -// need GUI for xkb protocol in xkb_rules.cpp -QTEST_KDEMAIN( FlagsTest, GUI ) - -#include "flags_test.moc" diff --git a/kcontrol/keyboard/tests/iso_codes_test.cpp b/kcontrol/keyboard/tests/iso_codes_test.cpp deleted file mode 100644 index 14f16be8..00000000 --- a/kcontrol/keyboard/tests/iso_codes_test.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "../iso_codes.h" - - -class IsoCodesTest : public QObject -{ - Q_OBJECT - - IsoCodes* isoCodes; - -private Q_SLOTS: - void initTestCase() { -// isoCodes = new IsoCodes(IsoCodes::iso_639); - isoCodes = new IsoCodes(IsoCodes::iso_639_3); - } - - void cleanupTestCase() { - delete isoCodes; - } - - void testIsoCodes() { - QVERIFY( isoCodes != NULL ); - QVERIFY( ! isoCodes->getEntryList().isEmpty() ); -// const IsoCodeEntry* isoEntry = isoCodes->getEntry(IsoCodes::attr_iso_639_2T_code, "eng"); - const IsoCodeEntry* isoEntry = isoCodes->getEntry(IsoCodes::attr_iso_639_3_id, "eng"); - QVERIFY( isoEntry != NULL ); - QVERIFY( ! isoEntry->empty() ); -// QCOMPARE( isoEntry->value(IsoCodes::attr_iso_639_2T_code), QString("eng") ); -// QCOMPARE( isoEntry->value(IsoCodes::attr_iso_639_2B_code), QString("eng") ); -// QCOMPARE( isoEntry->value(IsoCodes::attr_iso_639_1_code), QString("en") ); - QCOMPARE( isoEntry->value("name"), QString("English") ); -// QCOMPARE( isoEntry->value("status"), QString("Active") ); - } - - void testIso639_3_Codes() { - QVERIFY( isoCodes != NULL ); - QVERIFY( ! isoCodes->getEntryList().isEmpty() ); - const IsoCodeEntry* isoEntry = isoCodes->getEntry(IsoCodes::attr_iso_639_3_id, "ant"); - QVERIFY( isoEntry != NULL ); - QVERIFY( ! isoEntry->empty() ); - QVERIFY( isoEntry->value("name") != QString("ant") ); - QCOMPARE( isoEntry->value("name"), QString("Antakarinya") ); - } - - void loadIsoCodesBenchmark() { - QBENCHMARK { - IsoCodes* isoCodes = new IsoCodes(IsoCodes::iso_639_3); - delete isoCodes; - } - } - -}; - -//TODO: something lighter than KDEMAIN ? -QTEST_KDEMAIN( IsoCodesTest, NoGUI ) - -#include "iso_codes_test.moc" diff --git a/kcontrol/keyboard/tests/keyboard_daemon_test.cpp b/kcontrol/keyboard/tests/keyboard_daemon_test.cpp deleted file mode 100644 index 8879daf9..00000000 --- a/kcontrol/keyboard/tests/keyboard_daemon_test.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -//#include - -#include -#include - -#include "../flags.h" -#include "../xkb_rules.h" -#include "../keyboard_config.h" -#include "../keyboard_daemon.h" - - -class KeyboardDaemonTest : public QObject -{ - Q_OBJECT - - KeyboardDaemon* keyboardDaemon; -// KApplication* kapplication; - -private Q_SLOTS: - void initTestCase() { -// kapplication = new KApplication(); -// const KAboutData* kAboutData = new KAboutData(i18n("a").toAscii(), i18n("a").toAscii(), KLocalizedString(), i18n("a").toAscii()); -// KCmdLineArgs::init(kAboutData); - keyboardDaemon = new KeyboardDaemon(this, QList()); - } - - void cleanupTestCase() { - delete keyboardDaemon; -// delete kapplication; - } - - void testDaemon() { - QVERIFY( keyboardDaemon != NULL ); - -// QVERIFY( ! flags->getTransparentPixmap().isNull() ); -// -// const QIcon iconUs(flags->getIcon("us")); -// QVERIFY( ! iconUs.isNull() ); -// QVERIFY( flags->getIcon("--").isNull() ); -// -// KeyboardConfig keyboardConfig; -// LayoutUnit layoutUnit("us"); -// LayoutUnit layoutUnit1("us", "intl"); -// layoutUnit1.setDisplayName("usi"); -// LayoutUnit layoutUnit2("us", "other"); -// -// keyboardConfig.showFlag = true; -// const QIcon iconUsFlag = flags->getIconWithText(layoutUnit, keyboardConfig); -// QVERIFY( ! iconUsFlag.isNull() ); -// QCOMPARE( image(iconUsFlag), image(iconUs) ); -// -// keyboardConfig.showFlag = false; -// const QIcon iconUsText = flags->getIconWithText(layoutUnit, keyboardConfig); -// QVERIFY( ! iconUsText.isNull() ); -// QVERIFY( image(iconUsText) != image(iconUs) ); -// -// keyboardConfig.layouts.append(layoutUnit1); -// QCOMPARE( flags->getShortText(layoutUnit, keyboardConfig), QString("us") ); -// QCOMPARE( flags->getShortText(layoutUnit1, keyboardConfig), QString("usi") ); -// QCOMPARE( flags->getShortText(layoutUnit2, keyboardConfig), QString("us") ); -// -// const Rules* rules = Rules::readRules(); -// QCOMPARE( flags->getLongText(layoutUnit, rules), QString("USA") ); -// QVERIFY( flags->getLongText(layoutUnit1, rules).startsWith("USA - International") ); -// QCOMPARE( flags->getLongText(layoutUnit2, rules), QString("USA - other") ); -// -// flags->clearCache(); - } - -// void loadRulesBenchmark() { -// QBENCHMARK { -// Flags* flags = new Flags(); -// delete flags; -// } -// } - -}; - -// need GUI for xkb protocol in xkb_rules.cpp -QTEST_KDEMAIN( KeyboardDaemonTest, GUI ) - -#include "keyboard_daemon_test.moc" diff --git a/kcontrol/keyboard/tests/layout_memory_persister_test.cpp b/kcontrol/keyboard/tests/layout_memory_persister_test.cpp deleted file mode 100644 index 0dd0c74c..00000000 --- a/kcontrol/keyboard/tests/layout_memory_persister_test.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "../layout_memory_persister.h" -#include "../layout_memory.h" -#include "../keyboard_config.h" - - -class TestLayoutMemory: public LayoutMemory { -public: - TestLayoutMemory(const KeyboardConfig& keyboardConfig): - LayoutMemory(keyboardConfig) {} - QMap& getLayoutMap() { return layoutMap; } -}; - -class LayoutMemoryPersisterTest : public QObject -{ - Q_OBJECT - - QString path; - KeyboardConfig keyboardConfig; - TestLayoutMemory* layoutMemory; - LayoutMemoryPersister* layoutMemoryPersister; - - const LayoutUnit layoutUnit1; - const LayoutUnit layoutUnit2; - const LayoutUnit layoutUnit3; - - -public: - LayoutMemoryPersisterTest(): - layoutUnit1("xx"), - layoutUnit2("yy", "var1"), - layoutUnit3("zz", "var2") - {} - -private Q_SLOTS: - void initTestCase() { - path = "keyboard_memory_test.xml"; - QFile(path).remove(); - - layoutMemory = new TestLayoutMemory(keyboardConfig); - layoutMemoryPersister = new LayoutMemoryPersister(*layoutMemory); - -// QFile(path).remove(); - } - - void cleanupTestCase() { - delete layoutMemoryPersister; - delete layoutMemory; - } - - void testSaveNA() { - QFile file(path); - - keyboardConfig.switchingPolicy = KeyboardConfig::SWITCH_POLICY_WINDOW; - QVERIFY( ! layoutMemoryPersister->saveToFile(file) ); - QVERIFY(QFile(path).size() == 0); - - QVERIFY( ! layoutMemoryPersister->restoreFromFile(file) ); - } - - void testSaveGlobal() { - QFile file(path); - - keyboardConfig.switchingPolicy = KeyboardConfig::SWITCH_POLICY_GLOBAL; - layoutMemoryPersister->setGlobalLayout(layoutUnit1); - QVERIFY( layoutMemoryPersister->saveToFile(file) ); - QVERIFY(QFile(path).size() > 0); -// file.close(); - - keyboardConfig.layouts.clear(); - - QVERIFY( layoutMemoryPersister->restoreFromFile(file) ); - QVERIFY( !layoutMemoryPersister->getGlobalLayout().isValid() ); - -// file.close(); - keyboardConfig.layouts << layoutUnit1; - QVERIFY( layoutMemoryPersister->restoreFromFile(file) ); - QVERIFY( layoutUnit1.isValid() ); - QVERIFY( layoutMemoryPersister->getGlobalLayout().isValid() ); - QCOMPARE( layoutMemoryPersister->getGlobalLayout(), layoutUnit1); - } - - void testSaveByApp() { - QFile file(path); - - keyboardConfig.switchingPolicy = KeyboardConfig::SWITCH_POLICY_APPLICATION; - - layoutMemoryPersister->setGlobalLayout(LayoutUnit()); - layoutMemory->getLayoutMap().clear(); - - keyboardConfig.layouts.clear(); - keyboardConfig.layouts << layoutUnit1 << layoutUnit2; - - LayoutSet layoutSet1; - layoutSet1.layouts << layoutUnit1 << layoutUnit2; - layoutSet1.currentLayout = layoutUnit1; - layoutMemory->getLayoutMap().insert(QString("app1"), layoutSet1); - - LayoutSet layoutSet2; - layoutSet2.layouts << layoutUnit2 << layoutUnit1 << layoutUnit3; - layoutSet2.currentLayout = layoutUnit2; - layoutMemory->getLayoutMap().insert(QString("app2"), layoutSet2); - - QVERIFY( layoutMemoryPersister->saveToFile(file) ); - QVERIFY(QFile(path).size() > 0); - file.close(); - - layoutMemory->getLayoutMap().clear(); - QVERIFY( ! layoutMemory->getLayoutMap().value("app1").isValid() ); - QVERIFY( ! layoutMemory->getLayoutMap().value("app2").isValid() ); - - QVERIFY( layoutMemoryPersister->restoreFromFile(file) ); - QVERIFY( ! layoutMemoryPersister->getGlobalLayout().isValid() ); - QCOMPARE( layoutMemory->getLayoutMap().value("app1"), layoutSet1 ); - QVERIFY( ! layoutMemory->getLayoutMap().value("app2").isValid() ); - - keyboardConfig.layouts << layoutUnit3; - - file.close(); - QVERIFY( layoutMemoryPersister->restoreFromFile(file) ); - QVERIFY( ! layoutMemoryPersister->getGlobalLayout().isValid() ); - QCOMPARE( layoutMemory->getLayoutMap().value("app1"), layoutSet1 ); - QCOMPARE( layoutMemory->getLayoutMap().value("app2"), layoutSet2 ); - } - -// void layoutMemroyPersisterBenchmark() { -// QBENCHMARK { -// //TODO: generate big map -// layoutMemoryPersister->save(); -// layoutMemoryPersister->restore(); -// } -// } - -}; - -// need GUI for xkb protocol -QTEST_KDEMAIN( LayoutMemoryPersisterTest, GUI ) - -#include "layout_memory_persister_test.moc" diff --git a/kcontrol/keyboard/tests/xkb_rules_test.cpp b/kcontrol/keyboard/tests/xkb_rules_test.cpp deleted file mode 100644 index 9cee188d..00000000 --- a/kcontrol/keyboard/tests/xkb_rules_test.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2011 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "../xkb_rules.h" - -#include -#include - -static const Rules::ExtrasFlag readExtras = Rules::NO_EXTRAS; - -class RulesTest : public QObject -{ - Q_OBJECT - - Rules* rules; - -private Q_SLOTS: - void initTestCase() { - rules = Rules::readRules(readExtras); - } - - void cleanupTestCase() { - delete rules; - } - - void testRules() { - QVERIFY( rules != NULL ); - QVERIFY( rules->modelInfos.size() > 0 ); - QVERIFY( rules->layoutInfos.size() > 0 ); - QVERIFY( rules->optionGroupInfos.size() > 0 ); - } - - void testModel() { - foreach(const ModelInfo* modelInfo, rules->modelInfos) { - QVERIFY( modelInfo != NULL); - QVERIFY( modelInfo->name.length() > 0 ); - QVERIFY( modelInfo->description.length() > 0 ); -// QVERIFY( ! modelInfo->vendor.isEmpty() ); - } - } - - void testLayouts() { - foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { - QVERIFY( layoutInfo != NULL); - QVERIFY( ! layoutInfo->name.isEmpty() ); -// const char* desc = layoutInfo->name.toUtf8() ; -// qDebug() << layoutInfo->name; - QVERIFY( ! layoutInfo->description.isEmpty() ); - - foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) { - QVERIFY( variantInfo != NULL ); - QVERIFY( ! variantInfo->name.isEmpty() ); - QVERIFY( ! variantInfo->description.isEmpty() ); - } - foreach(const QString& language, layoutInfo->languages) { - QVERIFY( ! language.isEmpty() ); - } - } - } - - void testOptionGroups() { - foreach(const OptionGroupInfo* optionGroupInfo, rules->optionGroupInfos) { - QVERIFY( optionGroupInfo != NULL); - QVERIFY( ! optionGroupInfo->name.isEmpty() ); - QVERIFY( ! optionGroupInfo->description.isEmpty() ); - // optionGroupInfo->exclusive - - foreach(const OptionInfo* optionInfo, optionGroupInfo->optionInfos) { - QVERIFY( optionInfo != NULL ); - QVERIFY( ! optionInfo->name.isEmpty() ); - QVERIFY( ! optionInfo->description.isEmpty() ); - } - } - } - - void testExtras() { - Rules* rulesWithExtras = Rules::readRules(Rules::READ_EXTRAS); - QVERIFY2(rulesWithExtras->layoutInfos.size() > rules->layoutInfos.size(), "Rules with extras should have more layouts"); - - foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { - QVERIFY( ! layoutInfo->fromExtras ); - } - - bool foundFromExtras = false, foundNonExtras = false; - foreach(const LayoutInfo* layoutInfo, rulesWithExtras->layoutInfos) { - if( layoutInfo->fromExtras ) foundFromExtras = true; - if( ! layoutInfo->fromExtras ) foundNonExtras = true; - layoutInfo->languages.size(); // make sure we can access all merged objects - layoutInfo->variantInfos.size(); // make sure we can access all merged objects - } - QVERIFY( foundNonExtras ); - QVERIFY( foundFromExtras ); - } - - void testWriteNewXml() { - QDomDocument doc("xkbConfigRegistry"); - QDomElement root = doc.createElement("xkbConfigRegistry"); - root.setAttribute("version", "2.0"); - doc.appendChild(root); - - QDomElement modelList = doc.createElement("modelList"); - root.appendChild(modelList); - foreach(const ModelInfo* modelInfo, rules->modelInfos) { - QDomElement model = doc.createElement("model"); - model.setAttribute("name", modelInfo->name); - model.setAttribute("description", modelInfo->description); - model.setAttribute("vendor", modelInfo->vendor); - modelList.appendChild(model); - } - - QDomElement layoutList = doc.createElement("layoutList"); - foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { - QDomElement layout = doc.createElement("layout"); - layout.setAttribute("name", layoutInfo->name); - layout.setAttribute("description", layoutInfo->description); - - QDomElement langList = doc.createElement("languageList"); - foreach(const QString& lang, layoutInfo->languages) { - QDomElement langNode = doc.createElement("lang"); - langNode.setAttribute("iso639Id", lang); - langList.appendChild(langNode); - } - if( langList.hasChildNodes() ) { - layout.appendChild(langList); - } - - QDomElement variantList = doc.createElement("variantList"); - foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) { - QDomElement variant = doc.createElement("variant"); - variant.setAttribute("name", variantInfo->name); - variant.setAttribute("description", variantInfo->description); - - QDomElement langList = doc.createElement("languageList"); - foreach(const QString& lang, variantInfo->languages) { - QDomElement langNode = doc.createElement("lang"); - langNode.setAttribute("iso639Id", lang); - langList.appendChild(langNode); - } - if( langList.hasChildNodes() ) { - variant.appendChild(langList); - } - - variantList.appendChild(variant); - } - if( variantList.hasChildNodes() ) { - layout.appendChild(variantList); - } - - layoutList.appendChild(layout); - } - root.appendChild(layoutList); - - QDomElement optionGroupList = doc.createElement("optionList"); - foreach(const OptionGroupInfo* optionGroupInfo, rules->optionGroupInfos) { - QDomElement optionGroup = doc.createElement("optionGroup"); - optionGroup.setAttribute("name", optionGroupInfo->name); - optionGroup.setAttribute("description", optionGroupInfo->description); - optionGroup.setAttribute("exclusive", optionGroupInfo->exclusive); - - foreach(const OptionInfo* optionGroupInfo, optionGroupInfo->optionInfos) { - QDomElement option = doc.createElement("option"); - option.setAttribute("name", optionGroupInfo->name); - option.setAttribute("description", optionGroupInfo->description); - optionGroup.appendChild(option); - } - - optionGroupList.appendChild(optionGroup); - } - root.appendChild(optionGroupList); - - QFile file("base2.xml"); - if( ! file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text) ) { - kWarning() << "Failed to open layout memory xml file for writing" << file.fileName(); - QFAIL("failed"); - } - - QTextStream out(&file); - out << doc.toString(); - } - - void testRulesVersion() { - QVERIFY(!rules->version.isEmpty()); - - Rules* rules10 = new Rules(); - Rules::readRules(rules10, QString("config/base.xml"), false); - QCOMPARE(rules10->version, QString("1.0")); - delete rules10; - - Rules* rules11 = new Rules(); - Rules::readRules(rules11, QString("config/base.1.1.xml"), false); - QCOMPARE(rules11->version, QString("1.1")); - - foreach(const LayoutInfo* layoutInfo, rules11->layoutInfos) { - QVERIFY( layoutInfo != NULL); - QVERIFY( ! layoutInfo->name.isEmpty() ); - QVERIFY( ! layoutInfo->description.isEmpty() ); - - foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) { - QVERIFY( variantInfo != NULL ); - QVERIFY( ! variantInfo->name.isEmpty() ); - QVERIFY( ! variantInfo->description.isEmpty() ); - } - } - - delete rules11; - } - - void loadRulesBenchmark() { - QBENCHMARK { - Rules* rules = Rules::readRules(readExtras); - delete rules; - } - } - -}; - -// need kde libs for config-workspace.h used in xkb_rules.cpp -// need GUI for xkb protocol -QTEST_KDEMAIN( RulesTest, GUI ) - -#include "xkb_rules_test.moc" diff --git a/kcontrol/keyboard/x11_helper.cpp b/kcontrol/keyboard/x11_helper.cpp deleted file mode 100644 index c541e662..00000000 --- a/kcontrol/keyboard/x11_helper.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "x11_helper.h" - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - - -// more information about the limit https://bugs.freedesktop.org/show_bug.cgi?id=19501 -int X11Helper::MAX_GROUP_COUNT = 4; -int X11Helper::ARTIFICIAL_GROUP_LIMIT_COUNT = 8; - -const char* X11Helper::LEFT_VARIANT_STR = "("; -const char* X11Helper::RIGHT_VARIANT_STR = ")"; - -bool X11Helper::xkbSupported(int* xkbOpcode) -{ - // Verify the Xlib has matching XKB extension. - - int major = XkbMajorVersion; - int minor = XkbMinorVersion; - - if (!XkbLibraryVersion(&major, &minor)) - { - kWarning() << "Xlib XKB extension " << major << '.' << minor << - " != " << XkbMajorVersion << '.' << XkbMinorVersion; - return false; - } - - // Verify the X server has matching XKB extension. - - int opcode_rtrn; - int error_rtrn; - int xkb_opcode; - if( ! XkbQueryExtension(QX11Info::display(), &opcode_rtrn, &xkb_opcode, &error_rtrn, &major, &minor)) { - kWarning() << "X server XKB extension " << major << '.' << minor << - " != " << XkbMajorVersion << '.' << XkbMinorVersion; - return false; - } - - if( xkbOpcode != NULL ) { - *xkbOpcode = xkb_opcode; - } - - return true; -} - -void X11Helper::switchToNextLayout() -{ - int size = getLayoutsList().size(); //TODO: could optimize a bit as we don't need the layouts - just count - int group = (X11Helper::getGroup() + 1) % size; - X11Helper::setGroup(group); -} - -void X11Helper::scrollLayouts(int delta) -{ - int size = getLayoutsList().size(); //TODO: could optimize a bit as we don't need the layouts - just count - int group = X11Helper::getGroup() + delta; - group = group < 0 ? size - ((-group) % size) : group % size; - - X11Helper::setGroup(group); -} - -QStringList X11Helper::getLayoutsListAsString(const QList& layoutsList) -{ - QStringList stringList; - foreach(const LayoutUnit& layoutUnit, layoutsList) { - stringList << layoutUnit.toString(); - } - return stringList; -} - -bool X11Helper::setLayout(const LayoutUnit& layout) -{ - QList currentLayouts = getLayoutsList(); - int idx = currentLayouts.indexOf(layout); - if( idx == -1 || idx >= X11Helper::MAX_GROUP_COUNT ) { - kWarning() << "Layout" << layout.toString() << "is not found in current layout list" - << getLayoutsListAsString(currentLayouts); - return false; - } - - return X11Helper::setGroup((unsigned int)idx); -} - -bool X11Helper::setDefaultLayout() { - return X11Helper::setGroup(0); -} - -bool X11Helper::isDefaultLayout() { - return X11Helper::getGroup() == 0; -} - -LayoutUnit X11Helper::getCurrentLayout() -{ - QList currentLayouts = getLayoutsList(); - unsigned int group = X11Helper::getGroup(); - if( group < (unsigned int)currentLayouts.size() ) - return currentLayouts[group]; - - kWarning() << "Current group number" << group << "is outside of current layout list" << - getLayoutsListAsString(currentLayouts); - return LayoutUnit(); -} - -LayoutSet X11Helper::getCurrentLayouts() -{ - LayoutSet layoutSet; - - QList currentLayouts = getLayoutsList(); - layoutSet.layouts = currentLayouts; - - unsigned int group = X11Helper::getGroup(); - if( group < (unsigned int)currentLayouts.size() ) { - layoutSet.currentLayout = currentLayouts[group]; - } - else { - kWarning() << "Current group number" << group << "is outside of current layout list" << getLayoutsListAsString(currentLayouts); - layoutSet.currentLayout = LayoutUnit(); - } - - return layoutSet; -} - - -//static QString addNum(const QString& str, int n) -//{ -// QString format("%1%2"); -// if( str.length() >= 3 ) return format.arg(str.left(2)).arg(n); -// return format.arg(str).arg(n); -//} - -QList X11Helper::getLayoutsList() -{ - XkbConfig xkbConfig; - QList layouts; - if( X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::LAYOUTS_ONLY) ) { - for(int i=0; i 0) || (real_prop_type != XA_STRING) || (fmt != 8)) { - if (prop_data) - XFree(prop_data); - kWarning() << "Failed to fetch layouts from server:" << "Wrong property format"; - return false; - } - -// qDebug() << "prop_data:" << nitems << prop_data; - QStringList names; - for(char* p=prop_data; p-prop_data < (long)nitems && p != NULL; p += strlen(p)+1) { - names.append( p ); -// kDebug() << " " << p; - } - - if( names.count() < 4 ) { //{ rules, model, layouts, variants, options } - XFree(prop_data); - return false; - } - - if( fetchType == ALL || fetchType == LAYOUTS_ONLY ) { - QStringList layouts = names[2].split(OPTIONS_SEPARATOR); - QStringList variants = names[3].split(OPTIONS_SEPARATOR); - - for(int ii=0; iilayouts << (layouts[ii] != NULL ? layouts[ii] : ""); - xkbConfig->variants << (ii < variants.count() && variants[ii] != NULL ? variants[ii] : ""); - } - kDebug() << "Fetched layout groups from X server:" - << "\tlayouts:" << xkbConfig->layouts - << "\tvariants:" << xkbConfig->variants; - } - - if( fetchType == ALL || fetchType == MODEL_ONLY ) { - xkbConfig->keyboardModel = (names[1] != NULL ? names[1] : ""); - kDebug() << "Fetched keyboard model from X server:" << xkbConfig->keyboardModel; - } - - if( fetchType == ALL ) { - if( names.count() >= 5 ) { - QString options = (names[4] != NULL ? names[4] : ""); - xkbConfig->options = options.split(OPTIONS_SEPARATOR); - kDebug() << "Fetched xkbOptions from X server:" << options; - } - } - - XFree(prop_data); - return true; -} - -XEventNotifier::XEventNotifier(QWidget* parent): - QWidget(parent), - xkbOpcode(-1) -{ - if( KApplication::kApplication() == NULL ) { - kWarning() << "Layout Widget won't work properly without KApplication instance"; - } -} - -void XEventNotifier::start() -{ - if( KApplication::kApplication() != NULL && X11Helper::xkbSupported(&xkbOpcode) ) { - registerForXkbEvents(QX11Info::display()); - - // start the event loop - KApplication::kApplication()->installX11EventFilter(this); - } -} - -void XEventNotifier::stop() -{ - if( KApplication::kApplication() != NULL ) { - //TODO: unregister - // XEventNotifier::unregisterForXkbEvents(QX11Info::display()); - - // stop the event loop - KApplication::kApplication()->removeX11EventFilter(this); - } -} - -bool XEventNotifier::isXkbEvent(XEvent* event) -{ - return event->type == xkbOpcode; -} - -bool XEventNotifier::processOtherEvents(XEvent* /*event*/) -{ - return true; -} - -bool XEventNotifier::processXkbEvents(XEvent* event) -{ - if( XEventNotifier::isGroupSwitchEvent(event) ) { - emit(layoutChanged()); - } - else if( XEventNotifier::isLayoutSwitchEvent(event) ) { - emit(layoutMapChanged()); - } - return true; -} - -bool XEventNotifier::x11Event(XEvent * event) -{ - // qApp->x11ProcessEvent ( event ); - if( isXkbEvent(event) ) { - processXkbEvents(event); - } - else { - processOtherEvents(event); - } - return QWidget::x11Event(event); -} - -bool XEventNotifier::isGroupSwitchEvent(XEvent* event) -{ - XkbEvent *xkbEvent = (XkbEvent*) event; -#define GROUP_CHANGE_MASK \ - ( XkbGroupStateMask | XkbGroupBaseMask | XkbGroupLatchMask | XkbGroupLockMask ) - - return xkbEvent->any.xkb_type == XkbStateNotify && (xkbEvent->state.changed & GROUP_CHANGE_MASK); -} - -bool XEventNotifier::isLayoutSwitchEvent(XEvent* event) -{ - XkbEvent *xkbEvent = (XkbEvent*) event; - - return //( (xkbEvent->any.xkb_type == XkbMapNotify) && (xkbEvent->map.changed & XkbKeySymsMask) ) || -/* || ( (xkbEvent->any.xkb_type == XkbNamesNotify) && (xkbEvent->names.changed & XkbGroupNamesMask) || )*/ - (xkbEvent->any.xkb_type == XkbNewKeyboardNotify); -} - -int XEventNotifier::registerForXkbEvents(Display* display) -{ - int eventMask = XkbNewKeyboardNotifyMask | XkbStateNotifyMask; - if( ! XkbSelectEvents(display, XkbUseCoreKbd, eventMask, eventMask) ) { - kWarning() << "Couldn't select desired XKB events"; - return false; - } - return true; -} - - -static const char* LAYOUT_VARIANT_SEPARATOR_PREFIX = "("; -static const char* LAYOUT_VARIANT_SEPARATOR_SUFFIX = ")"; - -static QString& stripVariantName(QString& variant) -{ - if( variant.endsWith(LAYOUT_VARIANT_SEPARATOR_SUFFIX) ) { - int suffixLen = strlen(LAYOUT_VARIANT_SEPARATOR_SUFFIX); - return variant.remove(variant.length()-suffixLen, suffixLen); - } - return variant; -} - -LayoutUnit::LayoutUnit(const QString& fullLayoutName) -{ - QStringList lv = fullLayoutName.split(LAYOUT_VARIANT_SEPARATOR_PREFIX); - layout = lv[0]; - variant = lv.size() > 1 ? stripVariantName(lv[1]) : ""; -} - -QString LayoutUnit::toString() const -{ - if( variant.isEmpty() ) - return layout; - - return layout + LAYOUT_VARIANT_SEPARATOR_PREFIX+variant+LAYOUT_VARIANT_SEPARATOR_SUFFIX; -} - -const int LayoutUnit::MAX_LABEL_LENGTH = 3; diff --git a/kcontrol/keyboard/x11_helper.h b/kcontrol/keyboard/x11_helper.h deleted file mode 100644 index 009aab06..00000000 --- a/kcontrol/keyboard/x11_helper.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef X11_HELPER_H_ -#define X11_HELPER_H_ - -#include -#include -#include -#include - - -class XEventNotifier : public QWidget { - Q_OBJECT - -Q_SIGNALS: - void layoutChanged(); - void layoutMapChanged(); - -public: - XEventNotifier(QWidget* parent=NULL); - virtual ~XEventNotifier() {} - - virtual void start(); - virtual void stop(); - -protected: - bool x11Event(XEvent * e); - virtual bool processOtherEvents(XEvent* e); - virtual bool processXkbEvents(XEvent* e); - -private: - int registerForXkbEvents(Display* display); - bool isXkbEvent(XEvent* event); - bool isGroupSwitchEvent(XEvent* event); - bool isLayoutSwitchEvent(XEvent* event); - - int xkbOpcode; -}; - -class XkbConfig { -public: - QString keyboardModel; - QStringList layouts; - QStringList variants; - QStringList options; - - bool isValid() { return ! layouts.empty(); } -}; - - -class LayoutUnit { -public: - static const int MAX_LABEL_LENGTH; - - //TODO: move these to private? - QString layout; - QString variant; - - LayoutUnit() {} - explicit LayoutUnit(const QString& fullLayoutName); - LayoutUnit(const QString& layout_, const QString& variant_) { - layout = layout_; - variant = variant_; - } - /*explicit*/ LayoutUnit(const LayoutUnit& layoutUnit) { - layout = layoutUnit.layout; - variant = layoutUnit.variant; - displayName = layoutUnit.displayName; - shortcut = layoutUnit.shortcut; - } - - QString getRawDisplayName() const { return displayName; } - QString getDisplayName() const { return !displayName.isEmpty() ? displayName : layout; } - void setDisplayName(const QString& name) { displayName = name; } - - void setShortcut(const QKeySequence& shortcut) { this->shortcut = shortcut; } - QKeySequence getShortcut() const { return shortcut; } - - bool isEmpty() const { return layout.isEmpty(); } - bool isValid() const { return ! isEmpty(); } - bool operator==(const LayoutUnit& layoutItem) const { - return layout==layoutItem.layout && variant==layoutItem.variant; - } - bool operator!=(const LayoutUnit& layoutItem) const { - return ! (*this == layoutItem); - } - QString toString() const; - -private: - QString displayName; - QKeySequence shortcut; -}; - -class LayoutSet { -public: - QList layouts; - LayoutUnit currentLayout; - - LayoutSet() {} - - LayoutSet(const LayoutSet& currentLayouts) { - this->layouts = currentLayouts.layouts; - this->currentLayout = currentLayouts.currentLayout; - } - - bool isValid() const { - return currentLayout.isValid() && layouts.contains(currentLayout); - } - - bool operator == (const LayoutSet& currentLayouts) const { - return this->layouts == currentLayouts.layouts - && this->currentLayout == currentLayouts.currentLayout; - } - - LayoutSet& operator = (const LayoutSet& currentLayouts) { - this->layouts = currentLayouts.layouts; - this->currentLayout = currentLayouts.currentLayout; - return *this; - } - - QString toString() const { - QString str(currentLayout.toString()); - str += ": "; - foreach(const LayoutUnit& layoutUnit, layouts) { - str += layoutUnit.toString() + " "; - } - return str; - } - - static QString toString(const QList& layoutUnits) { - QString str; - foreach(const LayoutUnit& layoutUnit, layoutUnits) { - str += layoutUnit.toString() + ","; - } - return str; - } -}; - -class X11Helper -{ -public: - static int MAX_GROUP_COUNT; - static int ARTIFICIAL_GROUP_LIMIT_COUNT; - - static const char* LEFT_VARIANT_STR; - static const char* RIGHT_VARIANT_STR; - - static bool xkbSupported(int* xkbOpcode); - - static void switchToNextLayout(); - static void scrollLayouts(int delta); - static bool isDefaultLayout(); - static bool setDefaultLayout(); - static bool setLayout(const LayoutUnit& layout); - static LayoutUnit getCurrentLayout(); - static LayoutSet getCurrentLayouts(); - static QList getLayoutsList(); - static QStringList getLayoutsListAsString(const QList& layoutsList); - - enum FetchType { ALL, LAYOUTS_ONLY, MODEL_ONLY }; - static bool getGroupNames(Display* dpy, XkbConfig* xkbConfig, FetchType fetchType); - -private: - static unsigned int getGroup(); - static bool setGroup(unsigned int group); -}; - -#endif /* X11_HELPER_H_ */ diff --git a/kcontrol/keyboard/xinput_helper.cpp b/kcontrol/keyboard/xinput_helper.cpp deleted file mode 100644 index 2312810e..00000000 --- a/kcontrol/keyboard/xinput_helper.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "xinput_helper.h" - -#include -#include - -#include - -#include -#include -#include - -#ifdef HAVE_XINPUT_AND_DEVICE_NOTIFY -#include -#endif - -#include - -#include "x11_helper.h" - -#include - -static int DEVICE_NONE = 0; -static int DEVICE_KEYBOARD = 1; -static int DEVICE_POINTER = 2; - -XInputEventNotifier::XInputEventNotifier(QWidget* parent): - XEventNotifier(parent), - xinputEventType(-1) -{ -} - -void XInputEventNotifier::start() -{ - if( KApplication::kApplication() != NULL ) { - registerForNewDeviceEvent(QX11Info::display()); - } - - XEventNotifier::start(); -} - -void XInputEventNotifier::stop() -{ - XEventNotifier::stop(); - - if( KApplication::kApplication() != NULL ) { - // XEventNotifier::unregisterForNewDeviceEvent(QX11Info::display()); - } -} - -bool XInputEventNotifier::processOtherEvents(XEvent* event) -{ - int newDeviceType = getNewDeviceEventType(event); - if( newDeviceType == DEVICE_KEYBOARD ) { - emit(newKeyboardDevice()); - } - else if( newDeviceType == DEVICE_POINTER ) { - emit(newPointerDevice()); - emit(newKeyboardDevice()); // arghhh, looks like X resets xkb map even when only pointer device is connected - } - return true; -} - - -#ifdef HAVE_XINPUT_AND_DEVICE_NOTIFY - -extern "C" { - extern int _XiGetDevicePresenceNotifyEvent(Display *); -} - -// This is ugly but allows to skip multiple execution of setxkbmap -// for all keyboard devices that don't care about layouts -static bool isRealKeyboard(const char* deviceName) -{ - return strstr(deviceName, "Video Bus") == NULL - && strstr(deviceName, "Sleep Button") == NULL - && strstr(deviceName, "Power Button") == NULL - && strstr(deviceName, "WMI hotkeys") == NULL; -} - -int XInputEventNotifier::getNewDeviceEventType(XEvent* event) -{ - int newDeviceType = DEVICE_NONE; - - if( xinputEventType != -1 && event->type == xinputEventType ) { - XDevicePresenceNotifyEvent *xdpne = (XDevicePresenceNotifyEvent*) event; - if( xdpne->devchange == DeviceEnabled ) { - int ndevices; - XDeviceInfo *devices = XListInputDevices(xdpne->display, &ndevices); - if( devices != NULL ) { -// kDebug() << "New device id:" << xdpne->deviceid; - for(int i=0; ideviceid ) { - if( devices[i].use == IsXKeyboard || devices[i].use == IsXExtensionKeyboard ) { - if( isRealKeyboard(devices[i].name) ) { - newDeviceType = DEVICE_KEYBOARD; - kDebug() << "new keyboard device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; - break; - } - } - if( devices[i].use == IsXPointer || devices[i].use == IsXExtensionPointer ) { - newDeviceType = DEVICE_POINTER; - kDebug() << "new pointer device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; - break; - } - } - } - XFreeDeviceList(devices); - } - } - } - return newDeviceType; -} - -int XInputEventNotifier::registerForNewDeviceEvent(Display* display) -{ - int xitype; - XEventClass xiclass; - - DevicePresence(display, xitype, xiclass); - XSelectExtensionEvent(display, DefaultRootWindow(display), &xiclass, 1); - kDebug() << "Registered for new device events from XInput, class" << xitype; - xinputEventType = xitype; - return xitype; -} - -#else - -#warning "Keyboard daemon is compiled without XInput, keyboard settings will be reset when new keyboard device is plugged in!" - -int XInputEventNotifier::registerForNewDeviceEvent(Display* /*display*/) -{ - kWarning() << "Keyboard kded daemon is compiled without XInput, xkb configuration will be reset when new keyboard device is plugged in!"; - return -1; -} - -int XInputEventNotifier::getNewDeviceEventType(XEvent* /*event*/) -{ - return DEVICE_NONE; -} - -#endif diff --git a/kcontrol/keyboard/xinput_helper.h b/kcontrol/keyboard/xinput_helper.h deleted file mode 100644 index 92f1eb65..00000000 --- a/kcontrol/keyboard/xinput_helper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef XINPUT_HELPER_H_ -#define XINPUT_HELPER_H_ - -#include "x11_helper.h" - - -class XInputEventNotifier: public XEventNotifier { - Q_OBJECT - -public: - XInputEventNotifier(QWidget* parent=NULL); - - void start(); - void stop(); - - int registerForNewDeviceEvent(Display* dpy); - -Q_SIGNALS: - void newKeyboardDevice(); - void newPointerDevice(); - -protected: - bool processOtherEvents(XEvent* event); - -private: - int getNewDeviceEventType(XEvent* event); - - int xinputEventType; -}; - -#endif /* XINPUT_HELPER_H_ */ diff --git a/kcontrol/keyboard/xkb_helper.cpp b/kcontrol/keyboard/xkb_helper.cpp deleted file mode 100644 index 46fa468a..00000000 --- a/kcontrol/keyboard/xkb_helper.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "xkb_helper.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "keyboard_config.h" - - -static const char* SETXKBMAP_EXEC = "setxkbmap"; -static const char* XMODMAP_EXEC = "xmodmap"; - -static bool setxkbmapNotFound = false; -static QString setxkbmapExe; - -static bool xmodmapNotFound = false; -static QString xmodmapExe; - -static const QString COMMAND_OPTIONS_SEPARATOR(","); - -static -QString getSetxkbmapExe() -{ - if( setxkbmapNotFound ) - return ""; - - if( setxkbmapExe.isEmpty() ) { - setxkbmapExe = KStandardDirs::findExe(SETXKBMAP_EXEC); - if( setxkbmapExe.isEmpty() ) { - setxkbmapNotFound = true; - kError() << "Can't find" << SETXKBMAP_EXEC << "- keyboard layouts won't be configured"; - return ""; - } - } - return setxkbmapExe; -} - -static -void executeXmodmap(const QString& configFileName) -{ - if( xmodmapNotFound ) { - return; - } - - if( QFile::exists(configFileName) ) { - if( xmodmapExe.isEmpty() ) { - xmodmapExe = KStandardDirs::findExe(XMODMAP_EXEC); - if( xmodmapExe.isEmpty() ) { - xmodmapNotFound = true; - kError() << "Can't find" << XMODMAP_EXEC << "- xmodmap files won't be run"; - return; - } - } - - kDebug() << "Executing" << xmodmapExe << configFileName; - QProcess xmodmapProcess; - xmodmapProcess.start(xmodmapExe, QStringList() << configFileName); - xmodmapProcess.waitForFinished(); - if( xmodmapProcess.exitCode() != 0 ) { - kError() << "Failed to execute " << xmodmapExe << configFileName; - } - } -} - -static -void restoreXmodmap() -{ - // TODO: is just home .Xmodmap enough or should system be involved too? - // QString configFileName = QDir("/etc/X11/xinit").filePath(".Xmodmap"); - // executeXmodmap(configFileName); - QString configFileName = QDir::home().filePath(".Xmodmap"); - executeXmodmap(configFileName); -} - -//TODO: make private -bool XkbHelper::runConfigLayoutCommand(const QStringList& setxkbmapCommandArguments) -{ - QElapsedTimer timer; - timer.start(); - - const QString setxkbmapProgram = getSetxkbmapExe(); - if (setxkbmapNotFound) { - return false; - } - - QProcess setxkbmapProcess; - setxkbmapProcess.start(setxkbmapProgram, setxkbmapCommandArguments); - setxkbmapProcess.waitForFinished(); - const int res = setxkbmapProcess.exitCode(); - - if( res == 0 ) { // restore Xmodmap mapping reset by setxkbmap - kDebug() << "Executed successfully in " << timer.elapsed() << "ms" << setxkbmapProgram << setxkbmapCommandArguments.join(" "); - restoreXmodmap(); - kDebug() << "\t and with xmodmap" << timer.elapsed() << "ms"; - return true; - } else { - kError() << "Failed to run" << setxkbmapProgram << setxkbmapCommandArguments.join(" ") << "return code:" << res; - } - return false; -} - -bool XkbHelper::initializeKeyboardLayouts(const QList& layoutUnits) -{ - QStringList layouts; - QStringList variants; - foreach (const LayoutUnit& layoutUnit, layoutUnits) { - layouts.append(layoutUnit.layout); - variants.append(layoutUnit.variant); - } - - QStringList setxkbmapCommandArguments; - setxkbmapCommandArguments.append("-layout"); - setxkbmapCommandArguments.append(layouts.join(COMMAND_OPTIONS_SEPARATOR)); - if( ! variants.join("").isEmpty() ) { - setxkbmapCommandArguments.append("-variant"); - setxkbmapCommandArguments.append(variants.join(COMMAND_OPTIONS_SEPARATOR)); - } - - return runConfigLayoutCommand(setxkbmapCommandArguments); -} - -bool XkbHelper::initializeKeyboardLayouts(KeyboardConfig& config) -{ - QStringList setxkbmapCommandArguments; - if( ! config.keyboardModel.isEmpty() ) { - XkbConfig xkbConfig; - X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::MODEL_ONLY); - if( xkbConfig.keyboardModel != config.keyboardModel ) { - setxkbmapCommandArguments.append("-model"); - setxkbmapCommandArguments.append(config.keyboardModel); - } - } - if( config.configureLayouts ) { - QStringList layouts; - QStringList variants; - QList defaultLayouts = config.getDefaultLayouts(); - foreach (const LayoutUnit& layoutUnit, defaultLayouts) { - layouts.append(layoutUnit.layout); - variants.append(layoutUnit.variant); - } - - setxkbmapCommandArguments.append("-layout"); - setxkbmapCommandArguments.append(layouts.join(COMMAND_OPTIONS_SEPARATOR)); - if( ! variants.join("").isEmpty() ) { - setxkbmapCommandArguments.append("-variant"); - setxkbmapCommandArguments.append(variants.join(COMMAND_OPTIONS_SEPARATOR)); - } - } - if( config.resetOldXkbOptions ) { - setxkbmapCommandArguments.append("-option"); - } - if( ! config.xkbOptions.isEmpty() ) { - setxkbmapCommandArguments.append("-option"); - setxkbmapCommandArguments.append(config.xkbOptions.join(COMMAND_OPTIONS_SEPARATOR)); - } - - if( ! setxkbmapCommandArguments.isEmpty() ) { - return runConfigLayoutCommand(setxkbmapCommandArguments); - if( config.configureLayouts ) { - X11Helper::setDefaultLayout(); - } - } - return false; -} diff --git a/kcontrol/keyboard/xkb_helper.h b/kcontrol/keyboard/xkb_helper.h deleted file mode 100644 index 76df5649..00000000 --- a/kcontrol/keyboard/xkb_helper.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef XKB_HELPER_H_ -#define XKB_HELPER_H_ - -#include -class LayoutUnit; -#include -class KeyboardConfig; - -class XkbHelper { -public: - static bool initializeKeyboardLayouts(KeyboardConfig& config); - static bool initializeKeyboardLayouts(const QList& layouts); - static bool runConfigLayoutCommand(const QStringList& setxkbmapCommandArguments); -}; - -#endif /* XKB_HELPER_H_ */ diff --git a/kcontrol/keyboard/xkb_rules.cpp b/kcontrol/keyboard/xkb_rules.cpp deleted file mode 100644 index c7859a9e..00000000 --- a/kcontrol/keyboard/xkb_rules.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "xkb_rules.h" - -#include -#include -#include - -#include -#include -#include // for Qt::escape -#include - -//#include -//#include - -#include "x11_helper.h" - -// for findXkbRuleFile -#include -#include -#include -#include -#include -#include -#include - - -class RulesHandler : public QXmlDefaultHandler -{ -public: - RulesHandler(Rules* rules_, bool fromExtras_): - rules(rules_), - fromExtras(fromExtras_){} - - bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &attributes); - bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - bool characters(const QString &str); -// bool fatalError(const QXmlParseException &exception); -// QString errorString() const; - -private: -// QString getString(const QString& text); - - QStringList path; - Rules* rules; - const bool fromExtras; -}; - -static QString translate_xml_item(const QString& itemText) -{ - return i18n(Qt::escape(itemText).toUtf8()); - // return QString::fromUtf8(dgettext("xkeyboard-config", itemText.toAscii())); -} - -static QString translate_description(ConfigItem* item) -{ - return item->description.isEmpty() - ? item->name : translate_xml_item(item->description); -} - -template -void removeEmptyItems(QList& list) -{ - QMutableListIterator filterit(list); - while (filterit.hasNext()) { - const T* it = filterit.next(); - if (it->name.isEmpty()) { - filterit.remove(); - } - } -} - -static -void postProcess(Rules* rules) -{ - //TODO remove elements with empty names to safeguard us - removeEmptyItems(rules->layoutInfos); - removeEmptyItems(rules->modelInfos); - removeEmptyItems(rules->optionGroupInfos); - - KGlobal::locale()->insertCatalog("xkeyboard-config"); -// setlocale(LC_ALL, ""); -// bindtextdomain("xkeyboard-config", LOCALE_DIR); - foreach(ModelInfo* modelInfo, rules->modelInfos) { - modelInfo->vendor = translate_xml_item(modelInfo->vendor); - modelInfo->description = translate_description(modelInfo); - } - - foreach(LayoutInfo* layoutInfo, rules->layoutInfos) { - layoutInfo->description = translate_description(layoutInfo); - - removeEmptyItems(layoutInfo->variantInfos); - foreach(VariantInfo* variantInfo, layoutInfo->variantInfos) { - variantInfo->description = translate_description(variantInfo); - } - } - foreach(OptionGroupInfo* optionGroupInfo, rules->optionGroupInfos) { - optionGroupInfo->description = translate_description(optionGroupInfo); - - removeEmptyItems(optionGroupInfo->optionInfos); - foreach(OptionInfo* optionInfo, optionGroupInfo->optionInfos) { - optionInfo->description = translate_description(optionInfo); - } - } - KGlobal::locale()->removeCatalog("xkeyboard-config"); -} - - -Rules::Rules(): - version("1.0") -{ -} - -QString Rules::getRulesName() -{ - XkbRF_VarDefsRec vd; - char *tmp = NULL; - - if (XkbRF_GetNamesProp(QX11Info::display(), &tmp, &vd) && tmp != NULL ) { - // qDebug() << "namesprop" << tmp ; - const QString name(tmp); - XFree(tmp); - return name; - } - - return QString(); -} - -static QString findXkbRulesFile() -{ - QString rulesFile; - QString rulesName = Rules::getRulesName(); - - if ( ! rulesName.isNull() ) { - rulesFile = QString("%1/xkb/rules/%2.xml").arg(XKBDIR, rulesName); - } - - return rulesFile; -} - -static -void mergeRules(Rules* rules, Rules* extraRules) -{ - rules->modelInfos.append( extraRules->modelInfos ); - rules->optionGroupInfos.append( extraRules->optionGroupInfos ); // need to iterate and merge? - - QList layoutsToAdd; - foreach(LayoutInfo* extraLayoutInfo, extraRules->layoutInfos) { - LayoutInfo* layoutInfo = findByName(rules->layoutInfos, extraLayoutInfo->name); - if( layoutInfo != NULL ) { - layoutInfo->variantInfos.append( extraLayoutInfo->variantInfos ); - layoutInfo->languages.append( extraLayoutInfo->languages ); - } - else { - layoutsToAdd.append(extraLayoutInfo); - } - } - rules->layoutInfos.append(layoutsToAdd); - kDebug() << "Merged from extra rules:" << extraRules->layoutInfos.size() << "layouts," << extraRules->modelInfos.size() << "models," << extraRules->optionGroupInfos.size() << "option groups"; - - // base rules now own the objects - remove them from extra rules so that it does not try to delete them - extraRules->layoutInfos.clear(); - extraRules->modelInfos.clear(); - extraRules->optionGroupInfos.clear(); -} - - -const char Rules::XKB_OPTION_GROUP_SEPARATOR = ':'; - -Rules* Rules::readRules(ExtrasFlag extrasFlag) -{ - Rules* rules = new Rules(); - QString rulesFile = findXkbRulesFile(); - if( ! readRules(rules, rulesFile, false) ) { - delete rules; - return NULL; - } - if( extrasFlag == Rules::READ_EXTRAS ) { - QRegExp regex("\\.xml$"); - Rules* rulesExtra = new Rules(); - QString extraRulesFile = rulesFile.replace(regex, ".extras.xml"); - if( readRules(rulesExtra, extraRulesFile, true) ) { // not fatal if it fails - mergeRules(rules, rulesExtra); - } - delete rulesExtra; - } - return rules; -} - - -Rules* Rules::readRules(Rules* rules, const QString& filename, bool fromExtras) -{ - QFile file(filename); - if( !file.open(QFile::ReadOnly | QFile::Text) ) { - kError() << "Cannot open the rules file" << file.fileName(); - return NULL; - } - - RulesHandler rulesHandler(rules, fromExtras); - - QXmlSimpleReader reader; - reader.setContentHandler(&rulesHandler); - reader.setErrorHandler(&rulesHandler); - - QXmlInputSource xmlInputSource(&file); - - kDebug() << "Parsing xkb rules from" << file.fileName(); - - if( ! reader.parse(xmlInputSource) ) { - kError() << "Failed to parse the rules file" << file.fileName(); - delete rules; - return NULL; - } - - postProcess(rules); - - return rules; -} - -bool RulesHandler::startElement(const QString &/*namespaceURI*/, const QString &/*localName*/, - const QString &qName, const QXmlAttributes &attributes) -{ - path << QString(qName); - - QString strPath = path.join("/"); - if( strPath.endsWith("layoutList/layout/configItem") ) { - rules->layoutInfos << new LayoutInfo(fromExtras); - } - else if( strPath.endsWith("layoutList/layout/variantList/variant") ) { - rules->layoutInfos.last()->variantInfos << new VariantInfo(fromExtras); - } - else if( strPath.endsWith("modelList/model") ) { - rules->modelInfos << new ModelInfo(); - } - else if( strPath.endsWith("optionList/group") ) { - rules->optionGroupInfos << new OptionGroupInfo(); - rules->optionGroupInfos.last()->exclusive = (attributes.value("allowMultipleSelection") != "true"); - } - else if( strPath.endsWith("optionList/group/option") ) { - rules->optionGroupInfos.last()->optionInfos << new OptionInfo(); - } - else if( strPath == ("xkbConfigRegistry") && ! attributes.value("version").isEmpty() ) { - rules->version = attributes.value("version"); - kDebug() << "xkbConfigRegistry version" << rules->version; - } - return true; -} - -bool RulesHandler::endElement(const QString &/*namespaceURI*/, const QString &/*localName*/, const QString &/*qName*/) -{ - path.removeLast(); - return true; -} - -bool RulesHandler::characters(const QString &str) -{ - if( !str.trimmed().isEmpty() ) { - QString strPath = path.join("/"); - if( strPath.endsWith("layoutList/layout/configItem/name") ) { - if( rules->layoutInfos.last() != NULL ) { - rules->layoutInfos.last()->name = str.trimmed(); -// qDebug() << "name:" << str; - } - // skipping invalid entry - } - else if( strPath.endsWith("layoutList/layout/configItem/description") ) { - rules->layoutInfos.last()->description = str.trimmed(); -// qDebug() << "descr:" << str; - } - else if( strPath.endsWith("layoutList/layout/configItem/languageList/iso639Id") ) { - rules->layoutInfos.last()->languages << str.trimmed(); -// qDebug() << "\tlang:" << str; - } - else if( strPath.endsWith("layoutList/layout/variantList/variant/configItem/name") ) { - rules->layoutInfos.last()->variantInfos.last()->name = str.trimmed(); -// qDebug() << "\tvariant name:" << str; - } - else if( strPath.endsWith("layoutList/layout/variantList/variant/configItem/description") ) { - rules->layoutInfos.last()->variantInfos.last()->description = str.trimmed(); -// qDebug() << "\tvariant descr:" << str; - } - else if( strPath.endsWith("layoutList/layout/variantList/variant/configItem/languageList/iso639Id") ) { - rules->layoutInfos.last()->variantInfos.last()->languages << str.trimmed(); -// qDebug() << "\tvlang:" << str; - } - else if( strPath.endsWith("modelList/model/configItem/name") ) { - rules->modelInfos.last()->name = str.trimmed(); -// qDebug() << "name:" << str; - } - else if( strPath.endsWith("modelList/model/configItem/description") ) { - rules->modelInfos.last()->description = str.trimmed(); -// qDebug() << "\tdescr:" << str; - } - else if( strPath.endsWith("modelList/model/configItem/vendor") ) { - rules->modelInfos.last()->vendor = str.trimmed(); -// qDebug() << "\tvendor:" << str; - } - else if( strPath.endsWith("optionList/group/configItem/name") ) { - rules->optionGroupInfos.last()->name = str.trimmed(); -// qDebug() << "name:" << str; - } - else if( strPath.endsWith("optionList/group/configItem/description") ) { - rules->optionGroupInfos.last()->description = str.trimmed(); -// qDebug() << "\tdescr:" << str; - } - else if( strPath.endsWith("optionList/group/option/configItem/name") ) { - rules->optionGroupInfos.last()->optionInfos.last()->name = str.trimmed(); -// qDebug() << "name:" << str; - } - else if( strPath.endsWith("optionList/group/option/configItem/description") ) { - rules->optionGroupInfos.last()->optionInfos.last()->description = str.trimmed(); -// qDebug() << "\tdescr:" << str; - } - } - return true; -} - -bool LayoutInfo::isLanguageSupportedByLayout(const QString& lang) const -{ - if( languages.contains(lang) || isLanguageSupportedByVariants(lang) ) - return true; - -// // return yes if no languages found in layout or its variants -// if( languages.empty() ) { -// foreach(const VariantInfo* info, variantInfos) { -// if( ! info->languages.empty() ) -// return false; -// } -// return true; -// } - - return false; -} - -bool LayoutInfo::isLanguageSupportedByVariants(const QString& lang) const -{ - foreach(const VariantInfo* info, variantInfos) { - if( info->languages.contains(lang) ) - return true; - } - return false; -} - -bool LayoutInfo::isLanguageSupportedByDefaultVariant(const QString& lang) const -{ - if( languages.contains(lang) ) - return true; - - if( languages.empty() && isLanguageSupportedByVariants(lang) ) - return true; - - return false; -} - -bool LayoutInfo::isLanguageSupportedByVariant(const VariantInfo* variantInfo, const QString& lang) const -{ - if( variantInfo->languages.contains(lang) ) - return true; - - // if variant has no languages try to "inherit" them from layout - if( variantInfo->languages.empty() && languages.contains(lang) ) - return true; - - return false; -} diff --git a/kcontrol/keyboard/xkb_rules.h b/kcontrol/keyboard/xkb_rules.h deleted file mode 100644 index 6400141e..00000000 --- a/kcontrol/keyboard/xkb_rules.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef XKB_RULES_H_ -#define XKB_RULES_H_ - -#include -#include -#include - - -struct ConfigItem { - QString name; - QString description; -}; - -template -inline T* findByName(QList list, QString name) { - foreach(T* info, list) { - if( info->name == name ) - return info; - } - return NULL; -} - -struct VariantInfo: public ConfigItem { - QList languages; - const bool fromExtras; - - VariantInfo(bool fromExtras_): - fromExtras(fromExtras_) {} -}; - -struct LayoutInfo: public ConfigItem { - QList variantInfos; - QList languages; - const bool fromExtras; - -// LayoutInfo() {} - LayoutInfo(bool fromExtras_): - fromExtras(fromExtras_) {} - ~LayoutInfo() { foreach(VariantInfo* variantInfo, variantInfos) delete variantInfo; } - - VariantInfo* getVariantInfo(const QString& variantName) const { - return findByName(variantInfos, variantName); - } - - bool isLanguageSupportedByLayout(const QString& lang) const; - bool isLanguageSupportedByDefaultVariant(const QString& lang) const; - bool isLanguageSupportedByVariants(const QString& lang) const; - bool isLanguageSupportedByVariant(const VariantInfo* variantInfo, const QString& lang) const; -}; - -struct ModelInfo: public ConfigItem { - QString vendor; -}; - -struct OptionInfo: public ConfigItem { -}; - -struct OptionGroupInfo: public ConfigItem { - QList optionInfos; - bool exclusive; - - ~OptionGroupInfo() { foreach(OptionInfo* opt, optionInfos) delete opt; } - - const OptionInfo* getOptionInfo(const QString& optionName) const { - return findByName(optionInfos, optionName); - } -}; - -class Rules { -public: - enum ExtrasFlag { NO_EXTRAS, READ_EXTRAS }; - - static const char XKB_OPTION_GROUP_SEPARATOR; - - QList layoutInfos; - QList modelInfos; - QList optionGroupInfos; - QString version; - - Rules(); - - ~Rules() { - foreach(LayoutInfo* layoutInfo, layoutInfos) delete layoutInfo; - foreach(ModelInfo* modelInfo, modelInfos) delete modelInfo; - foreach(OptionGroupInfo* optionGroupInfo, optionGroupInfos) delete optionGroupInfo; - } - - const LayoutInfo* getLayoutInfo(const QString& layoutName) const { - return findByName(layoutInfos, layoutName); - } - - const OptionGroupInfo* getOptionGroupInfo(const QString& optionGroupName) const { - return findByName(optionGroupInfos, optionGroupName); - } - - static Rules* readRules(ExtrasFlag extrasFlag); - static Rules* readRules(Rules* rules, const QString& filename, bool fromExtras); - static QString getRulesName(); -}; - -#endif /* XKB_RULES_H_ */ diff --git a/plasma/applets/CMakeLists.txt b/plasma/applets/CMakeLists.txt index 6e2a5da2..e76621b3 100644 --- a/plasma/applets/CMakeLists.txt +++ b/plasma/applets/CMakeLists.txt @@ -8,16 +8,13 @@ add_subdirectory(devicenotifier) add_subdirectory(digital-clock) add_subdirectory(quicklaunch) add_subdirectory(system-monitor) -#notifications -#should compile also on windows? (even if doesn't really make sense) add_subdirectory(notifications) add_subdirectory(systemtray) - +add_subdirectory(keyboard) add_subdirectory(kickoff) add_subdirectory(trash) add_subdirectory(folderview) - -#task and windowlist depend on libs/taskmanager +# task and windowlist depend on libs/taskmanager add_subdirectory(tasks) add_subdirectory(windowlist) add_subdirectory(pager) diff --git a/plasma/applets/keyboard/CMakeLists.txt b/plasma/applets/keyboard/CMakeLists.txt new file mode 100644 index 00000000..9aa423c5 --- /dev/null +++ b/plasma/applets/keyboard/CMakeLists.txt @@ -0,0 +1,21 @@ +project(plasma-applet-keyboard) + +set(keyboard_SRCS + keyboard.cpp +) + +kde4_add_plugin(plasma_applet_keyboard ${keyboard_SRCS}) +target_link_libraries(plasma_applet_keyboard + KDE4::plasma + KDE4::solid +) + +install( + TARGETS plasma_applet_keyboard + DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} +) + +install( + FILES plasma-applet-keyboard.desktop + DESTINATION ${KDE4_SERVICES_INSTALL_DIR} +) diff --git a/plasma/applets/keyboard/keyboard.cpp b/plasma/applets/keyboard/keyboard.cpp new file mode 100644 index 00000000..61d11932 --- /dev/null +++ b/plasma/applets/keyboard/keyboard.cpp @@ -0,0 +1,202 @@ +/* This file is part of the KDE project + Copyright (C) 2023 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "keyboard.h" + +#include +#include +#include +#include +#include +#include +#include + +KeyboardApplet::KeyboardApplet(QObject *parent, const QVariantList &args) + : Plasma::Applet(parent, args), + m_keyboardlayout(nullptr), + m_showflag(false), + m_showtext(true), + m_indicatorbox(nullptr), + m_spacer(nullptr) +{ + KGlobal::locale()->insertCatalog("plasma_applet_keyboard"); + setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio); + setHasConfigurationInterface(true); +} + +KeyboardApplet::~KeyboardApplet() +{ +} + +void KeyboardApplet::init() +{ + KConfigGroup configgroup = config(); + m_showflag = configgroup.readEntry("showFlag", false); + m_showtext = configgroup.readEntry("showText", true); + + m_keyboardlayout = new KKeyboardLayout(this); + connect( + m_keyboardlayout, SIGNAL(layoutChanged()), + this, SLOT(slotLayoutChanged()) + ); + + setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_K)); + connect( + this, SIGNAL(activate()), + this, SLOT(slotNextLayout()) + ); +} + +void KeyboardApplet::paintInterface(QPainter *painter, + const QStyleOptionGraphicsItem *option, + const QRect &contentsRect) +{ + const KKeyboardType activelayout = m_keyboardlayout->layouts().first(); + const QString layoutlayout = QString::fromLatin1(activelayout.layout.constData(), activelayout.layout.size()); + + QString flag; + if (m_showflag) { + flag = KStandardDirs::locate( + "locale", + QString::fromLatin1("l10n/%1/flag.png").arg(layoutlayout) + ); + } + QFont font = KGlobalSettings::smallestReadableFont(); + font.setBold(true); + font.setPointSize(qMax(font.pointSize(), contentsRect.width())); + + painter->setRenderHint(QPainter::SmoothPixmapTransform); + painter->setRenderHint(QPainter::Antialiasing); + + if (!flag.isEmpty()) { + painter->save(); + const QPixmap iconpixmap = QPixmap(flag).scaled(contentsRect.size(), Qt::KeepAspectRatio); + painter->drawPixmap(contentsRect, iconpixmap); + painter->restore(); + } + + if (m_showtext) { + if (!flag.isEmpty()) { + const QPixmap textpixmap = Plasma::PaintUtils::shadowText(layoutlayout, font, Qt::black, Qt::white, QPoint(), 3); + painter->drawPixmap(contentsRect, textpixmap); + } else { + Plasma::Svg svg = Plasma::Svg(this); + svg.setImagePath("widgets/labeltexture"); + svg.setContainsMultipleImages(true); + const QPixmap textpixmap = Plasma::PaintUtils::texturedText(layoutlayout, font, &svg); + painter->drawPixmap(contentsRect, textpixmap); + } + } +} + +void KeyboardApplet::createConfigurationInterface(KConfigDialog *parent) +{ + QWidget* widget = new QWidget(); + QVBoxLayout* widgetlayout = new QVBoxLayout(widget); + m_indicatorbox = new QComboBox(widget); + m_indicatorbox->addItem(i18n("Show text")); + m_indicatorbox->addItem(i18n("Show flag")); + m_indicatorbox->addItem(i18n("Show text and flag")); + if (m_showflag && m_showtext) { + m_indicatorbox->setCurrentIndex(2); + } else if (m_showflag) { + m_indicatorbox->setCurrentIndex(1); + } else { + m_indicatorbox->setCurrentIndex(0); + } + widgetlayout->addWidget(m_indicatorbox); + m_spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding); + widgetlayout->addSpacerItem(m_spacer); + widget->setLayout(widgetlayout); + parent->addPage(widget, i18n("Indicator"), "applications-graphics"); + + connect(parent, SIGNAL(applyClicked()), this, SLOT(slotConfigAccepted())); + connect(parent, SIGNAL(okClicked()), this, SLOT(slotConfigAccepted())); + connect(m_indicatorbox, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified())); +} +void KeyboardApplet::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + slotNextLayout(); + event->accept(); + return; + } + event->ignore(); +} + +void KeyboardApplet::wheelEvent(QGraphicsSceneWheelEvent *event) +{ + if (event->delta() < 0) { + slotNextLayout(); + } else { + slotPreviousLayout(); + } +} + +void KeyboardApplet::slotLayoutChanged() +{ + const KKeyboardType activelayout = m_keyboardlayout->layouts().first(); + const QString layoutlayout = QString::fromLatin1(activelayout.layout.constData(), activelayout.layout.size()); + const QString flag = KStandardDirs::locate( + "locale", + QString::fromLatin1("l10n/%1/flag.png").arg(layoutlayout) + ); + QString layouttooltip; + layouttooltip.append(i18n("Model: %1
", KKeyboardLayout::modelDescription(activelayout.model))); + layouttooltip.append(i18n("Variant: %1", KKeyboardLayout::variantDescription(activelayout.layout, activelayout.variant))); + Plasma::ToolTipContent plasmatooltipcontent = Plasma::ToolTipContent( + KKeyboardLayout::layoutDescription(activelayout.layout), layouttooltip, + KIcon(flag) + ); + Plasma::ToolTipManager::self()->setContent(this, plasmatooltipcontent); + + update(); +} + +void KeyboardApplet::slotNextLayout() +{ + QList layouts = m_keyboardlayout->layouts(); + if (layouts.size() > 1) { + layouts.move(0, layouts.size() - 1); + m_keyboardlayout->setLayouts(layouts); + } +} + +void KeyboardApplet::slotPreviousLayout() +{ + QList layouts = m_keyboardlayout->layouts(); + if (layouts.size() > 1) { + layouts.move(layouts.size() - 1, 0); + m_keyboardlayout->setLayouts(layouts); + } +} + +void KeyboardApplet::slotConfigAccepted() +{ + Q_ASSERT(m_indicatorbox); + const int iconindex = m_indicatorbox->currentIndex(); + m_showflag = (iconindex == 1 || iconindex == 2); + m_showtext = (iconindex == 0 || iconindex == 2); + KConfigGroup configgroup = config(); + configgroup.writeEntry("showFlag", m_showflag); + configgroup.writeEntry("showText", m_showtext); + emit configNeedsSaving(); + update(); +} + +#include "moc_keyboard.cpp" diff --git a/plasma/applets/keyboard/keyboard.h b/plasma/applets/keyboard/keyboard.h new file mode 100644 index 00000000..491a7e91 --- /dev/null +++ b/plasma/applets/keyboard/keyboard.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project + Copyright (C) 2023 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KEYBOARD_H +#define KEYBOARD_H + +#include +#include +#include +#include +#include +#include + +class KeyboardApplet : public Plasma::Applet +{ + Q_OBJECT +public: + KeyboardApplet(QObject *parent, const QVariantList &args); + ~KeyboardApplet(); + + // Plasma::Applet reimplementations + void init() final; + void paintInterface(QPainter *painter, + const QStyleOptionGraphicsItem *option, + const QRect &contentsRect); + void createConfigurationInterface(KConfigDialog *parent) final; + // QGraphicsWidget reimplementations + void mousePressEvent(QGraphicsSceneMouseEvent *event) final; + void wheelEvent(QGraphicsSceneWheelEvent *event) final; + +private Q_SLOTS: + void slotLayoutChanged(); + void slotNextLayout(); + void slotPreviousLayout(); + void slotConfigAccepted(); + +private: + KKeyboardLayout* m_keyboardlayout; + bool m_showflag; + bool m_showtext; + QComboBox* m_indicatorbox; + QSpacerItem* m_spacer; +}; + +K_EXPORT_PLASMA_APPLET(keyboard, KeyboardApplet) + +#endif // KEYBOARD_H diff --git a/kcontrol/keyboard/plasma_applet_keyboard.desktop b/plasma/applets/keyboard/plasma-applet-keyboard.desktop similarity index 98% rename from kcontrol/keyboard/plasma_applet_keyboard.desktop rename to plasma/applets/keyboard/plasma-applet-keyboard.desktop index 711c977f..0b62f7c9 100644 --- a/kcontrol/keyboard/plasma_applet_keyboard.desktop +++ b/plasma/applets/keyboard/plasma-applet-keyboard.desktop @@ -149,10 +149,10 @@ Type=Service X-KDE-ServiceTypes=Plasma/Applet X-KDE-Library=plasma_applet_keyboard -X-KDE-PluginInfo-Author=Andriy Rysin -X-KDE-PluginInfo-Email=rysin@kde.org -X-KDE-PluginInfo-Name=keyboard_applet -X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Author=Ivailo Monev +X-KDE-PluginInfo-Email=xakepa10@gmail.com +X-KDE-PluginInfo-Name=keyboard +X-KDE-PluginInfo-Version=1.0 X-KDE-PluginInfo-Website= X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends=