mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-24 02:42:52 +00:00
kvkbd: port to the new KKeyboardLayout class
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1c3fef07ca
commit
06daeac969
3 changed files with 10 additions and 53 deletions
|
@ -45,7 +45,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void processKeyPress(unsigned int)=0;
|
virtual void processKeyPress(unsigned int)=0;
|
||||||
virtual void queryModState()=0;
|
virtual void queryModState()=0;
|
||||||
virtual void constructLayouts()=0;
|
|
||||||
virtual void layoutChanged()=0;
|
virtual void layoutChanged()=0;
|
||||||
virtual void start()=0;
|
virtual void start()=0;
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
|
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QDBusConnection>
|
#include <QVariant>
|
||||||
#include <QDBusInterface>
|
|
||||||
#include <QDBusReply>
|
|
||||||
|
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
@ -33,18 +31,13 @@
|
||||||
|
|
||||||
extern QList<VButton *> modKeys;
|
extern QList<VButton *> modKeys;
|
||||||
|
|
||||||
X11Keyboard::X11Keyboard(QObject *parent): VKeyboard(parent)
|
X11Keyboard::X11Keyboard(QObject *parent)
|
||||||
|
: VKeyboard(parent),
|
||||||
|
kkeyboardlayout(this),
|
||||||
|
layout_index(0)
|
||||||
{
|
{
|
||||||
QString service = "";
|
connect(&kkeyboardlayout, SIGNAL(layoutChanged()), this, SLOT(layoutChanged()));
|
||||||
QString path = "/Layouts";
|
|
||||||
QString interface = "org.kde.KeyboardLayouts";
|
|
||||||
|
|
||||||
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 = new QTimer(parent);
|
||||||
groupTimer->setInterval(250);
|
groupTimer->setInterval(250);
|
||||||
|
|
||||||
|
@ -66,23 +59,6 @@ void X11Keyboard::start()
|
||||||
groupTimer->start();
|
groupTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11Keyboard::constructLayouts()
|
|
||||||
{
|
|
||||||
QDBusInterface iface("org.kde.keyboard", "/Layouts", "org.kde.KeyboardLayouts", QDBusConnection::sessionBus());
|
|
||||||
|
|
||||||
QDBusReply<QStringList> reply = iface.call("getLayoutsList");
|
|
||||||
if (reply.isValid()) {
|
|
||||||
QStringList lst = reply.value();
|
|
||||||
layouts.clear();
|
|
||||||
|
|
||||||
QListIterator<QString> itr(lst);
|
|
||||||
while (itr.hasNext()) {
|
|
||||||
QString layout_name = itr.next();
|
|
||||||
layouts << layout_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void X11Keyboard::processKeyPress(unsigned int keyCode)
|
void X11Keyboard::processKeyPress(unsigned int keyCode)
|
||||||
{
|
{
|
||||||
groupTimer->stop();
|
groupTimer->stop();
|
||||||
|
@ -169,23 +145,8 @@ void X11Keyboard::layoutChanged()
|
||||||
|
|
||||||
//std::cerr << "LayoutChanged" << std::endl;
|
//std::cerr << "LayoutChanged" << std::endl;
|
||||||
|
|
||||||
QDBusInterface iface("org.kde.keyboard", "/Layouts", "org.kde.KeyboardLayouts", QDBusConnection::sessionBus());
|
QString current_layout = kkeyboardlayout.layouts().first().layout;
|
||||||
|
emit layoutUpdated(layout_index, current_layout);
|
||||||
QDBusReply<QString> 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void X11Keyboard::textForKeyCode(unsigned int keyCode, ButtonText& text)
|
void X11Keyboard::textForKeyCode(unsigned int keyCode, ButtonText& text)
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <KKeyboardLayout>
|
||||||
|
|
||||||
|
|
||||||
class X11Keyboard : public VKeyboard
|
class X11Keyboard : public VKeyboard
|
||||||
{
|
{
|
||||||
|
@ -45,7 +44,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void processKeyPress(unsigned int);
|
virtual void processKeyPress(unsigned int);
|
||||||
virtual void queryModState();
|
virtual void queryModState();
|
||||||
virtual void constructLayouts();
|
|
||||||
virtual void layoutChanged();
|
virtual void layoutChanged();
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
|
||||||
|
@ -53,12 +51,11 @@ protected:
|
||||||
|
|
||||||
void sendKey(unsigned int keycode);
|
void sendKey(unsigned int keycode);
|
||||||
|
|
||||||
QStringList layouts;
|
|
||||||
int layout_index;
|
int layout_index;
|
||||||
|
KKeyboardLayout kkeyboardlayout;
|
||||||
|
|
||||||
KeySymConvert kconvert;
|
KeySymConvert kconvert;
|
||||||
|
|
||||||
|
|
||||||
bool queryModKeyState(KeySym keyCode);
|
bool queryModKeyState(KeySym keyCode);
|
||||||
ModifierGroupStateMap groupState;
|
ModifierGroupStateMap groupState;
|
||||||
QTimer *groupTimer;
|
QTimer *groupTimer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue