SVN commit 954481 by ruberg: You can untoggle Strg, Alt, etc. now by clicking on them again M +1 -0 BoardKey.cpp M +1 -0 BoardKey.h M +19 -1 FuncKey.cpp M +2 -0 FuncKey.h --- trunk/playground/base/plasma/applets/plasmaboard/BoardKey.cpp #954480:954481 @@ -46,3 +46,4 @@ void BoardKey::sendKeycodePress() {} void BoardKey::sendKeycodeRelease() {} +void BoardKey::sendKeycodeToggled() {} --- trunk/playground/base/plasma/applets/plasmaboard/BoardKey.h #954480:954481 @@ -36,6 +36,7 @@ public Q_SLOTS: virtual void sendKeycodePress(); virtual void sendKeycodeRelease(); + virtual void sendKeycodeToggled(); protected: unsigned int keycode; --- trunk/playground/base/plasma/applets/plasmaboard/FuncKey.cpp #954480:954481 @@ -25,23 +25,30 @@ FuncKey::FuncKey(PlasmaboardWidget *parent): BoardKey::BoardKey(parent) { // TODO Auto-generated constructor stub - QObject::connect(static_cast(this->nativeWidget()), SIGNAL( pressed() ), this, SLOT( sendKeycodePress() ) ); + oldStyle = Plasma::PushButton::styleSheet(); + pressed = false; } void FuncKey::toggleOn(){ Plasma::PushButton::setStyleSheet(oldStyle + "color:red;text-align:center;"); // sorry, but I need some visual confirmation + pressed = true; } void FuncKey::toggleOff(){ Plasma::PushButton::setStyleSheet(oldStyle); + pressed = false; } void FuncKey::setKeycode(unsigned int code, bool sendUp){ keycode = Helpers::keysymToKeycode(code); if(sendUp){ + QObject::connect(static_cast(this->nativeWidget()), SIGNAL( pressed() ), this, SLOT( sendKeycodePress() ) ); QObject::connect(static_cast(this->nativeWidget()), SIGNAL( released() ), this, SLOT( sendKeycodeRelease() ) ); } + else { + QObject::connect(static_cast(this->nativeWidget()), SIGNAL( pressed() ), this, SLOT( sendKeycodeToggled() ) ); + } } void FuncKey::sendKeycodePress() { @@ -49,6 +56,17 @@ toggleOn(); } +void FuncKey::sendKeycodeToggled() { + if( pressed ) { + sendKeycodeRelease(); + toggleOff(); + } + else { + Helpers::fakeKeyPress(getKeycode()); + toggleOn(); + } +} + void FuncKey::sendKeycodeRelease() { Helpers::fakeKeyRelease(getKeycode()); toggleOff(); --- trunk/playground/base/plasma/applets/plasmaboard/FuncKey.h #954480:954481 @@ -35,9 +35,11 @@ public Q_SLOTS: virtual void sendKeycodePress(); virtual void sendKeycodeRelease(); + virtual void sendKeycodeToggled(); private: QString oldStyle; + bool pressed; }; #endif /* FUNCKEY_H_ */