Added global shortcuts for switching to previous/next group

This resolves issue #6.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/7/head
Mavridis Philippe 1 year ago
parent 89ac8264b9
commit 2f27dd9940
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -109,6 +109,16 @@ void KBConfig::load(TDEConfig *config){
TQString::null, TQt::ALT+TQt::CTRL+TQt::Key_1 + i, KKey::QtWIN+TQt::CTRL+TQt::Key_1 + i, TQString::null, TQt::ALT+TQt::CTRL+TQt::Key_1 + i, KKey::QtWIN+TQt::CTRL+TQt::Key_1 + i,
kapp, SLOT(slotGroupSelected(int))); kapp, SLOT(slotGroupSelected(int)));
} }
m_keys->insert("NextGroup", i18n("Cycle keyboard layouts"),
i18n("Activates the next keyboard layout or, if the current layout is the last one, "
"activates the first layout."),
TQt::SHIFT+TQt::CTRL+TQt::Key_Plus, TQt::SHIFT+TQt::CTRL+TQt::Key_Plus,
kapp, SLOT(slotSelectNextGroup()));
m_keys->insert("PrevGroup", i18n("Cycle keyboard layouts (reverse)"),
i18n("Activates the previous keyboard layout or, if the current layout is the first one, "
"activates the last layout."),
TQt::SHIFT+TQt::CTRL+TQt::Key_Minus, TQt::SHIFT+TQt::CTRL+TQt::Key_Minus,
kapp, SLOT(slotSelectPrevGroup()));
m_keys->readSettings(config); m_keys->readSettings(config);
checkKeysEnabled(); checkKeysEnabled();
} }

@ -85,9 +85,12 @@ public:
void drawIcons(IconStyle icon_style, TQValueVector<TQPixmap> *icons, void drawIcons(IconStyle icon_style, TQValueVector<TQPixmap> *icons,
TQStringList *iconpaths); TQStringList *iconpaths);
void checkKeysEnabled(); void checkKeysEnabled();
int getPrevGroup(int groupno) {
return groupno == 0 ? groupCount() - 1 : groupno - 1;
}
int getNextGroup(int groupno) { int getNextGroup(int groupno) {
return groupno >= groupCount() - 1 ? 0 : groupno + 1; return groupno >= groupCount() - 1 ? 0 : groupno + 1;
} }
private: // Private methods private: // Private methods
/** No descriptions */ /** No descriptions */
//void guessGroupPixmaps(); //void guessGroupPixmaps();

@ -130,15 +130,25 @@ void KBSwitchApp::forceSetGroup(int groupno)
m_xkb.setGroupNo(groupno); m_xkb.setGroupNo(groupno);
} }
/** No descriptions */ /** Select the next keyboard layout (wraps around) */
void KBSwitchApp::slotSelectNextGroup() void KBSwitchApp::slotSelectNextGroup()
{ {
#ifdef HAVE_LIBXKLAVIER #ifdef HAVE_LIBXKLAVIER
m_xkb.setGroupNo(XklGetNextGroup()); m_xkb.setGroupNo(XklGetNextGroup());
#else #else
//forceSetGroup(m_next_groupno); //forceSetGroup(m_next_groupno);
m_xkb.setGroupNo(m_next_groupno); m_xkb.setGroupNo(m_next_groupno);
#endif #endif
}
/** Select the previous keyboard layout (wraps around) */
void KBSwitchApp::slotSelectPrevGroup()
{
#ifdef HAVE_LIBXKLAVIER
m_xkb.setGroupNo(XklGetPrevGroup());
#else
m_xkb.setGroupNo(m_kbconf.getPrevGroup(m_cur_groupno));
#endif
} }
/** No descriptions */ /** No descriptions */

@ -110,8 +110,10 @@ private: // Private methods
private slots: // Private slots private slots: // Private slots
/** No descriptions */ /** No descriptions */
void slotGroupSelected(int groupno); void slotGroupSelected(int groupno);
/** No descriptions */ /** Select the next keyboard layout (wraps around) */
void slotSelectNextGroup(); void slotSelectNextGroup();
/** Select the previous keyboard layout (wraps around) */
void slotSelectPrevGroup();
/** No descriptions */ /** No descriptions */
void slotPreferences(); void slotPreferences();
/** No descriptions */ /** No descriptions */

Loading…
Cancel
Save