mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22: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:
|
||||
virtual void processKeyPress(unsigned int)=0;
|
||||
virtual void queryModState()=0;
|
||||
virtual void constructLayouts()=0;
|
||||
virtual void layoutChanged()=0;
|
||||
virtual void start()=0;
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
|
||||
#include <QX11Info>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QVariant>
|
||||
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
@ -33,18 +31,13 @@
|
|||
|
||||
extern QList<VButton *> 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<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)
|
||||
{
|
||||
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<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");
|
||||
}
|
||||
QString current_layout = kkeyboardlayout.layouts().first().layout;
|
||||
emit layoutUpdated(layout_index, current_layout);
|
||||
|
||||
}
|
||||
void X11Keyboard::textForKeyCode(unsigned int keyCode, ButtonText& text)
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
#include <QStringList>
|
||||
#include <QChar>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
#include <KKeyboardLayout>
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue