diff --git a/kvkbd/src/vkeyboard.h b/kvkbd/src/vkeyboard.h index 320cce57..f8b2a8d7 100644 --- a/kvkbd/src/vkeyboard.h +++ b/kvkbd/src/vkeyboard.h @@ -45,7 +45,6 @@ public: public slots: virtual void processKeyPress(unsigned int)=0; virtual void queryModState()=0; - virtual void constructLayouts()=0; virtual void layoutChanged()=0; virtual void start()=0; diff --git a/kvkbd/src/x11keyboard.cpp b/kvkbd/src/x11keyboard.cpp index 5f42cb6d..078d6efc 100644 --- a/kvkbd/src/x11keyboard.cpp +++ b/kvkbd/src/x11keyboard.cpp @@ -21,9 +21,7 @@ #include #include -#include -#include -#include +#include #include #include @@ -33,18 +31,13 @@ extern QList modKeys; -X11Keyboard::X11Keyboard(QObject *parent): VKeyboard(parent) +X11Keyboard::X11Keyboard(QObject *parent) + : VKeyboard(parent), + kkeyboardlayout(this), + layout_index(0) { - QString service = ""; - QString path = "/Layouts"; - QString interface = "org.kde.KeyboardLayouts"; + connect(&kkeyboardlayout, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); - QDBusConnection session = QDBusConnection::sessionBus(); - - session.connect(service, path, interface, "currentLayoutChanged", this, SLOT(layoutChanged())); - session.connect(service, path, interface, "layoutListChanged", this, SLOT(constructLayouts())); - - constructLayouts(); groupTimer = new QTimer(parent); groupTimer->setInterval(250); @@ -66,23 +59,6 @@ void X11Keyboard::start() groupTimer->start(); } -void X11Keyboard::constructLayouts() -{ - QDBusInterface iface("org.kde.keyboard", "/Layouts", "org.kde.KeyboardLayouts", QDBusConnection::sessionBus()); - - QDBusReply reply = iface.call("getLayoutsList"); - if (reply.isValid()) { - QStringList lst = reply.value(); - layouts.clear(); - - QListIterator itr(lst); - while (itr.hasNext()) { - QString layout_name = itr.next(); - layouts << layout_name; - } - } -} - void X11Keyboard::processKeyPress(unsigned int keyCode) { groupTimer->stop(); @@ -169,23 +145,8 @@ void X11Keyboard::layoutChanged() //std::cerr << "LayoutChanged" << std::endl; - QDBusInterface iface("org.kde.keyboard", "/Layouts", "org.kde.KeyboardLayouts", QDBusConnection::sessionBus()); - - QDBusReply reply = iface.call("getCurrentLayout"); - - if (reply.isValid()) { - - QString current_layout = reply.value(); - - layout_index = layouts.indexOf(current_layout); - - emit layoutUpdated(layout_index, layouts.at(layout_index)); - } - else { - layout_index = 0; - - emit layoutUpdated(0, "us"); - } + QString current_layout = kkeyboardlayout.layouts().first().layout; + emit layoutUpdated(layout_index, current_layout); } void X11Keyboard::textForKeyCode(unsigned int keyCode, ButtonText& text) diff --git a/kvkbd/src/x11keyboard.h b/kvkbd/src/x11keyboard.h index f366fce9..008e740e 100644 --- a/kvkbd/src/x11keyboard.h +++ b/kvkbd/src/x11keyboard.h @@ -30,8 +30,7 @@ #include #include #include - - +#include class X11Keyboard : public VKeyboard { @@ -45,7 +44,6 @@ public: public slots: virtual void processKeyPress(unsigned int); virtual void queryModState(); - virtual void constructLayouts(); virtual void layoutChanged(); virtual void start(); @@ -53,12 +51,11 @@ protected: void sendKey(unsigned int keycode); - QStringList layouts; int layout_index; + KKeyboardLayout kkeyboardlayout; KeySymConvert kconvert; - bool queryModKeyState(KeySym keyCode); ModifierGroupStateMap groupState; QTimer *groupTimer;