mirror of
https://github.com/vicr123/theshell.git
synced 2025-01-23 04:11:49 -05:00
Switch between keyboard layouts with SUPER+ENTER
This commit is contained in:
parent
af4c5e0d7b
commit
b603abe21c
3 changed files with 31 additions and 0 deletions
|
@ -4107,6 +4107,7 @@ void InfoPaneDropdown::loadNewKeyboardLayoutMenu() {
|
|||
}
|
||||
emit newKeyboardLayoutMenuAvailable(menu);
|
||||
}
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void InfoPaneDropdown::setKeyboardLayout(QString layout) {
|
||||
|
@ -4115,3 +4116,19 @@ void InfoPaneDropdown::setKeyboardLayout(QString layout) {
|
|||
loadNewKeyboardLayoutMenu();
|
||||
emit keyboardLayoutChanged(layout.split("(").first().toUpper());
|
||||
}
|
||||
|
||||
QString InfoPaneDropdown::setNextKeyboardLayout() {
|
||||
QString currentLayout = settings.value("input/currentLayout", "us(basic)").toString();
|
||||
QStringList currentLayouts = settings.value("input/layout", "us(basic)").toString().split(",");
|
||||
int currentIndex = currentLayouts.indexOf(currentLayout);
|
||||
currentIndex++;
|
||||
if (currentIndex == currentLayouts.count()) currentIndex = 0;
|
||||
|
||||
QString layout = currentLayouts.at(currentIndex);
|
||||
setKeyboardLayout(layout);
|
||||
for (int i = 0; i < ui->selectedLayouts->count(); i++) {
|
||||
if (ui->selectedLayouts->item(i)->data(Qt::UserRole) == layout) {
|
||||
return ui->selectedLayouts->item(i)->text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,6 +498,8 @@ class InfoPaneDropdown : public QDialog
|
|||
void updateStruts();
|
||||
void changeSettingsPane(int pane);
|
||||
|
||||
QString setNextKeyboardLayout();
|
||||
|
||||
private:
|
||||
Ui::InfoPaneDropdown *ui;
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ NativeEventFilter::NativeEventFilter(QObject* parent) : QObject(parent)
|
|||
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F6), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Num_Lock), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Caps_Lock), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_space), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Return), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
|
||||
|
||||
|
||||
//Check if the user wants to capture the super key
|
||||
|
@ -97,6 +99,8 @@ NativeEventFilter::~NativeEventFilter() {
|
|||
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F6), Mod4Mask, QX11Info::appRootWindow());
|
||||
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Num_Lock), AnyModifier, QX11Info::appRootWindow());
|
||||
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Caps_Lock), AnyModifier, QX11Info::appRootWindow());
|
||||
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_space), Mod4Mask, QX11Info::appRootWindow());
|
||||
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Return), Mod4Mask, QX11Info::appRootWindow());
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,6 +312,14 @@ bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *mes
|
|||
/*} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XK_F6) && (button->state == Mod4Mask)) {
|
||||
MainWin->getInfoPane()->show(InfoPaneDropdown::Print);
|
||||
ignoreSuper = true;*/
|
||||
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XK_space) && (button->state == Mod4Mask)) {
|
||||
QString newKeyboardLayout = MainWin->getInfoPane()->setNextKeyboardLayout();
|
||||
Hotkeys->show(QIcon::fromTheme("input-keyboard"), tr("Keyboard Layout"), tr("Keyboard Layout set to %1").arg(newKeyboardLayout));
|
||||
ignoreSuper = true;
|
||||
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XK_Return) && (button->state == Mod4Mask)) {
|
||||
QString newKeyboardLayout = MainWin->getInfoPane()->setNextKeyboardLayout();
|
||||
Hotkeys->show(QIcon::fromTheme("input-keyboard"), tr("Keyboard Layout"), tr("Keyboard Layout set to %1").arg(newKeyboardLayout));
|
||||
ignoreSuper = true;
|
||||
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XK_Num_Lock) || button->detail == XKeysymToKeycode(QX11Info::display(), XK_Caps_Lock)) {
|
||||
if (themeSettings->value("accessibility/bellOnCapsNumLock", false).toBool()) {
|
||||
QSoundEffect* sound = new QSoundEffect();
|
||||
|
|
Loading…
Reference in a new issue