Commit e6daa48e authored by Marco Martin's avatar Marco Martin

some keyboard navigation

parent 64520fc5
......@@ -241,6 +241,7 @@ void SidebarMode::initWidget()
d->quickWidget->setSource(d->package.filePath("mainscript"));
//FIXME
d->quickWidget->setFixedWidth(240);
d->quickWidget->installEventFilter(this);
// Prepare the Base Data
MenuItem *rootModule = new MenuItem( true, 0 );
......@@ -252,6 +253,15 @@ void SidebarMode::initWidget()
emit changeToolBarItems(BaseMode::NoItems);
}
bool SidebarMode::eventFilter(QObject* watched, QEvent* event)
{
//TODO: patch Qt
if (watched == d->quickWidget && event->type() == QEvent::Leave) {
QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event);
}
return BaseMode::eventFilter(watched, event);
}
void SidebarMode::initMenuList(MenuItem * parent)
{
KService::List categories = KServiceTypeTrader::self()->query("SystemSettingsCategory");
......
......@@ -59,6 +59,7 @@ public:
protected:
QList<QAbstractItemView*> views() const;
bool eventFilter(QObject* watched, QEvent* event);
private Q_SLOTS:
void changeModule( const QModelIndex& activeModule );
......
......@@ -107,9 +107,12 @@ Kirigami.PageRow {
}
delegate: Kirigami.BasicListItem {
id: delegate
icon: model.decoration
label: model.display
separatorVisible: false
activeFocusOnTab: root.currentIndex == 0
highlighted: focus
onClicked: {
if (systemsettings.activeCategory == index) {
root.currentIndex = 1;
......@@ -118,6 +121,18 @@ Kirigami.PageRow {
}
}
checked: systemsettings.activeCategory == index
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Up:
delegate.nextItemInFocusChain(false).forceActiveFocus();
break;
case Qt.Key_Down:
delegate.nextItemInFocusChain(true).forceActiveFocus();
break;
default:
break;
}
}
}
}
}
......@@ -145,17 +160,38 @@ Kirigami.PageRow {
if (count > 1) {
root.push(subCategoryColumn);
root.currentIndex = 1;
subCategoryView.forceActiveFocus();
} else {
root.pop(mainColumn)
}
}
delegate: Kirigami.BasicListItem {
id: delegate
icon: model.decoration
label: model.display
separatorVisible: false
activeFocusOnTab: root.currentIndex == 1
highlighted: focus
onClicked: systemsettings.activeSubCategory = index
checked: systemsettings.activeSubCategory == index
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Up:
delegate.nextItemInFocusChain(false).forceActiveFocus();
break;
case Qt.Key_Down:
delegate.nextItemInFocusChain(true).forceActiveFocus();
break;
case Qt.Key_left:
case Qt.Key_Backspace:
root.currentIndex = 0;
mainColumn.forceActiveFocus();
break;
default:
break;
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment