diff --git a/sidebar/SidebarMode.cpp b/sidebar/SidebarMode.cpp --- a/sidebar/SidebarMode.cpp +++ b/sidebar/SidebarMode.cpp @@ -491,6 +491,9 @@ d->placeHolderWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(d->placeHolderWidget)); d->placeHolderWidget->engine()->rootContext()->setContextProperty("systemsettings", this); d->placeHolderWidget->setSource(QUrl::fromLocalFile(d->package.filePath("ui", "introPage.qml"))); + connect(d->placeHolderWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); + connect(d->placeHolderWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); + d->placeHolderWidget->installEventFilter(this); d->mainLayout->addWidget( d->quickWidget ); d->moduleView->hide(); @@ -504,13 +507,26 @@ bool SidebarMode::eventFilter(QObject* watched, QEvent* event) { //FIXME: those are all workarounds around the QQuickWidget brokeness - if (watched == d->quickWidget && event->type() == QEvent::KeyPress) { + if ((watched == d->quickWidget || watched == d->placeHolderWidget) + && event->type() == QEvent::KeyPress) { //allow tab navigation inside the qquickwidget QKeyEvent *ke = static_cast(event); - if (ke->key() == Qt::Key_Tab) { - QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event); + QQuickWidget *qqw = static_cast(watched); + if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) { + QCoreApplication::sendEvent(qqw->quickWindow(), event); return true; } + } else if ((watched == d->quickWidget || watched == d->placeHolderWidget) + && event->type() == QEvent::FocusIn) { + QFocusEvent *fe = static_cast(event); + QQuickWidget *qqw = static_cast(watched); + if (qqw && qqw->rootObject()) { + if (fe->reason() == Qt::TabFocusReason) { + qqw->rootObject()->metaObject()->invokeMethod(qqw->rootObject(), "focusFirstChild"); + } else if (fe->reason() == Qt::BacktabFocusReason) { + qqw->rootObject()->metaObject()->invokeMethod(qqw->rootObject(), "focusLastChild"); + } + } } else if (watched == d->quickWidget && event->type() == QEvent::Leave) { QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event); } else if (watched == d->mainWidget && event->type() == QEvent::Resize) { diff --git a/sidebar/package/contents/ui/IntroIcon.qml b/sidebar/package/contents/ui/IntroIcon.qml --- a/sidebar/package/contents/ui/IntroIcon.qml +++ b/sidebar/package/contents/ui/IntroIcon.qml @@ -23,7 +23,7 @@ MouseArea { - id: root + id: item property alias icon: iconItem.source property alias text: label.text property string module @@ -33,29 +33,60 @@ cursorShape: Qt.PointingHandCursor Layout.fillWidth: true Layout.alignment: Qt.AlignTop + activeFocusOnTab: true onClicked: systemsettings.loadMostUsed(index); + + Keys.onTabPressed: { + if (index < 4) { + event.accepted = false; + } else { + root.focusNextRequest(); + } + } + Keys.onBacktabPressed: { + if (index >0) { + event.accepted = false; + } else { + root.focusPreviousRequest(); + } + } + Keys.onSpacePressed: systemsettings.loadMostUsed(index); + Keys.onEnterPressed: systemsettings.loadMostUsed(index); + Keys.onReturnPressed: systemsettings.loadMostUsed(index); + + Kirigami.Separator { + anchors{ + left: parent.left + right: parent.right + bottom: parent.bottom + } + visible: item.activeFocus + color: Kirigami.Theme.highlightColor + } ColumnLayout { id: column width: parent.width Kirigami.Icon { id: iconItem Layout.alignment: Qt.AlignHCenter - Layout.minimumWidth: root.iconSize + Layout.minimumWidth: item.iconSize Layout.minimumHeight: Layout.minimumWidth height: width } QQC2.Label { id: label Layout.fillWidth: true - Layout.maximumWidth: root.width + Layout.maximumWidth: item.width Layout.alignment: Qt.AlignHCenter horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap } } + Accessible.role: Accessible.Button Accessible.name: label.text + Accessible.description: i18n("Most used modeule number %1", index+1) Accessible.onPressAction: systemsettings.loadMostUsed(index); } diff --git a/sidebar/package/contents/ui/SubCategoryPage.qml b/sidebar/package/contents/ui/SubCategoryPage.qml --- a/sidebar/package/contents/ui/SubCategoryPage.qml +++ b/sidebar/package/contents/ui/SubCategoryPage.qml @@ -101,6 +101,10 @@ activeFocusOnTab: true keyNavigationWraps: true Accessible.role: Accessible.List + Keys.onTabPressed: root.focusNextRequest(); + Keys.onBacktabPressed: { + mainColumn.focus = true; + } onCountChanged: { if (count > 1) { if (root.pageStack.depth < 2) { diff --git a/sidebar/package/contents/ui/introPage.qml b/sidebar/package/contents/ui/introPage.qml --- a/sidebar/package/contents/ui/introPage.qml +++ b/sidebar/package/contents/ui/introPage.qml @@ -23,6 +23,18 @@ Rectangle { id: root color: Kirigami.Theme.backgroundColor + + signal focusNextRequest() + signal focusPreviousRequest() + + function focusFirstChild() { + iconsRow.children[0].focus = true; + } + + function focusLastChild() { + iconsRow.children[iconsRow.children.length-1].focus = true; + } + ColumnLayout { anchors { bottom: separator.top diff --git a/sidebar/package/contents/ui/main.qml b/sidebar/package/contents/ui/main.qml --- a/sidebar/package/contents/ui/main.qml +++ b/sidebar/package/contents/ui/main.qml @@ -29,6 +29,15 @@ signal focusNextRequest() signal focusPreviousRequest() + + function focusFirstChild() { + mainColumn.focus = true; + } + + function focusLastChild() { + subCategoryColumn.focus = true; + } + wideScreen: pageStack.depth > 1 && systemsettings.width > Kirigami.Units.gridUnit * 70 CategoriesPage { id: mainColumn