diff --git a/applets/kickoff/package/contents/ui/ApplicationsView.qml b/applets/kickoff/package/contents/ui/ApplicationsView.qml --- a/applets/kickoff/package/contents/ui/ApplicationsView.qml +++ b/applets/kickoff/package/contents/ui/ApplicationsView.qml @@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -import QtQuick 2.0 +import QtQuick 2.6 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.components 2.0 as PlasmaComponents @@ -30,27 +30,15 @@ objectName: "ApplicationsView" - property ListView listView: applicationsView + Accessible.role: Accessible.Grouping + Accessible.name: i18n("Applications") - function decrementCurrentIndex() { - applicationsView.decrementCurrentIndex(); - } - - function incrementCurrentIndex() { - applicationsView.incrementCurrentIndex(); - } - - function activateCurrentIndex(start) { - if (!applicationsView.currentItem.modelChildren) { - if (!start) { - return; - } + function activateCurrentIndex() { + if (applicationsView.currentItem && applicationsView.currentItem.modelChildren) { + appViewScrollArea.state = "OutgoingLeft"; + return true; } - appViewScrollArea.state = "OutgoingLeft"; - } - - function openContextMenu() { - applicationsView.currentItem.openActionMenu(); + return false; } function deactivateCurrentIndex() { @@ -140,6 +128,7 @@ PlasmaExtras.ScrollArea { id: appViewScrollArea + focus: true property Item activatedItem: null @@ -150,6 +139,7 @@ leftMargin: -units.largeSpacing } + Accessible.role: Accessible.List Behavior on opacity { NumberAnimation { duration: units.longDuration } } width: parent.width @@ -181,13 +171,31 @@ highlightResizeDuration: 0 model: rootModel + currentIndex: -1 delegate: KickoffItem { id: kickoffItem appView: true } + Keys.onEnterPressed: currentItem.activate(); + Keys.onReturnPressed: currentItem.activate(); + Keys.onMenuPressed: currentItem.openActionMenu(); + Keys.onRightPressed: if (!appViewContainer.activateCurrentIndex()) { + event.accepted = false; + } + Keys.onLeftPressed: if (!appViewContainer.deactivateCurrentIndex()) { + event.accepted = false; + } + Keys.onEscapePressed: { + if (currentIndex == -1 ) { + event.accepted = false; + return; + } + currentIndex = -1; + } + function addBreadcrumb(model, title) { crumbModel.append({"text": title, "depth": crumbModel.count+1}) crumbModel.models.push(model); diff --git a/applets/kickoff/package/contents/ui/BaseView.qml b/applets/kickoff/package/contents/ui/BaseView.qml --- a/applets/kickoff/package/contents/ui/BaseView.qml +++ b/applets/kickoff/package/contents/ui/BaseView.qml @@ -28,38 +28,25 @@ property alias model: kickoffListView.model property alias delegate: kickoffListView.delegate - property ListView listView: kickoffListView - - function decrementCurrentIndex() { - kickoffListView.decrementCurrentIndex(); - } - - function incrementCurrentIndex() { - kickoffListView.incrementCurrentIndex(); - } - - function activateCurrentIndex() { - kickoffListView.currentItem.activate(); - } - - function openContextMenu() { - kickoffListView.currentItem.openActionMenu(); - } - PlasmaExtras.ScrollArea { anchors.fill: parent + focus: true ListView { id: kickoffListView - + Accessible.role: Accessible.List interactive: contentHeight > height boundsBehavior: Flickable.StopAtBounds currentIndex: -1 keyNavigationWraps: true highlight: KickoffHighlight {} highlightMoveDuration : 0 highlightResizeDuration: 0 + Keys.onEnterPressed: currentItem.activate(); + Keys.onReturnPressed: currentItem.activate(); + Keys.onMenuPressed: currentItem.openActionMenu(); + delegate: KickoffItem {} section { diff --git a/applets/kickoff/package/contents/ui/ComputerView.qml b/applets/kickoff/package/contents/ui/ComputerView.qml --- a/applets/kickoff/package/contents/ui/ComputerView.qml +++ b/applets/kickoff/package/contents/ui/ComputerView.qml @@ -23,6 +23,9 @@ BaseView { objectName: "ComputerView" + Accessible.role: Accessible.Grouping + Accessible.name: i18n("Computer") + model: Kicker.ComputerModel { id: computerModel diff --git a/applets/kickoff/package/contents/ui/FavoritesView.qml b/applets/kickoff/package/contents/ui/FavoritesView.qml --- a/applets/kickoff/package/contents/ui/FavoritesView.qml +++ b/applets/kickoff/package/contents/ui/FavoritesView.qml @@ -30,28 +30,13 @@ import org.kde.plasma.private.kicker 0.1 as Kicker -Item { +FocusScope { anchors.fill: parent objectName: "FavoritesView" - property ListView listView: kickoffListView - - function decrementCurrentIndex() { - kickoffListView.decrementCurrentIndex(); - } - - function incrementCurrentIndex() { - kickoffListView.incrementCurrentIndex(); - } - - function activateCurrentIndex() { - kickoffListView.currentItem.activate(); - } - - function openContextMenu() { - kickoffListView.currentItem.openActionMenu(); - } + Accessible.role: Accessible.Grouping + Accessible.name: i18n("Favorites") // QQuickItem::isAncestorOf is not invokable... function isChildOf(item, parent) { @@ -115,11 +100,12 @@ PlasmaExtras.ScrollArea { id: scrollArea - + focus: true anchors.fill: parent ListView { id: kickoffListView + Accessible.role: Accessible.List property bool animating: false property int animationDuration: resetAnimationDurationTimer.interval @@ -136,6 +122,10 @@ model: globalFavorites + Keys.onEnterPressed: currentItem.activate(); + Keys.onReturnPressed: currentItem.activate(); + Keys.onMenuPressed: currentItem.openActionMenu(); + onCountChanged: { animationDuration = 0; resetAnimationDurationTimer.start(); diff --git a/applets/kickoff/package/contents/ui/FullRepresentation.qml b/applets/kickoff/package/contents/ui/FullRepresentation.qml --- a/applets/kickoff/package/contents/ui/FullRepresentation.qml +++ b/applets/kickoff/package/contents/ui/FullRepresentation.qml @@ -29,16 +29,16 @@ import org.kde.plasma.private.kicker 0.1 as Kicker -Item { +FocusScope { id: root Layout.minimumWidth: units.gridUnit * 26 Layout.minimumHeight: units.gridUnit * 34 property string previousState property bool switchTabsOnHover: plasmoid.configuration.switchTabsOnHover - property Item currentView: mainTabGroup.currentTab.decrementCurrentIndex ? mainTabGroup.currentTab : mainTabGroup.currentTab.item property KickoffButton firstButton: null property var configMenuItems + property Item currentView: mainTabGroup.currentTab.decrementCurrentIndex ? mainTabGroup.currentTab : mainTabGroup.currentTab.item property QtObject globalFavorites: rootModelFavorites @@ -133,6 +133,7 @@ PlasmaComponents.TabGroup { id: mainTabGroup currentTab: favoritesPage + focus: true anchors { fill: parent @@ -389,7 +390,9 @@ } } - onCurrentTabChanged: root.forceActiveFocus(); + onCurrentTabChanged: { + mainTabGroup.currentTab.forceActiveFocus(); + } Connections { target: plasmoid @@ -404,60 +407,11 @@ } } // tabBar - Keys.forwardTo: [tabBar.layout] + Keys.forwardTo: [tabBar.layout, root.currentView] Keys.onPressed: { - - if (mainTabGroup.currentTab == applicationsPage) { - if (event.key != Qt.Key_Tab) { - root.state = "Applications"; - } - } - + console.log("root received ", event.key, root.currentView, root.currentView); switch(event.key) { - case Qt.Key_Up: { - currentView.decrementCurrentIndex(); - event.accepted = true; - break; - } - case Qt.Key_Down: { - currentView.incrementCurrentIndex(); - event.accepted = true; - break; - } - case Qt.Key_Left: { - if (header.input.focus) { - break; - } - if (!currentView.deactivateCurrentIndex()) { - if (root.state == "Applications") { - mainTabGroup.currentTab = firstButton.tab; - tabBar.currentTab = firstButton; - } - root.state = "Normal" - } - event.accepted = true; - break; - } - case Qt.Key_Right: { - if (header.input.focus) { - break; - } - currentView.activateCurrentIndex(); - event.accepted = true; - break; - } - case Qt.Key_Tab: { - root.state == "Applications" ? root.state = "Normal" : root.state = "Applications"; - event.accepted = true; - break; - } - case Qt.Key_Enter: - case Qt.Key_Return: { - currentView.activateCurrentIndex(1); - event.accepted = true; - break; - } case Qt.Key_Escape: { if (header.state != "query") { plasmoid.expanded = false; @@ -467,31 +421,26 @@ event.accepted = true; break; } - case Qt.Key_Menu: { - currentView.openContextMenu(); - event.accepted = true; - break; - } - default: { // forward key to searchView //header.query += event.text will break if the key is backspace, //since if the user continues to type, it will produce an invalid query, //having backspace as the first character if (event.key == Qt.Key_Backspace && header.query == "") { return; } - if (event.text != "" && !header.input.focus) { - root.currentView.listView.currentIndex = -1; - + if (event.text != "" && !header.focus) { if (event.matches(StandardKey.Paste) ) { - header.input.paste(); + header.paste(); + event.accepted = true; + return; } else if (! (event.key & Qt.Key_Escape)) { //if special key, do nothing. Qt.Escape is 0x10000000 which happens to be a mask used for all special keys in Qt. - header.query = ""; header.query += event.text; + header.forceActiveFocus(); + event.accepted = true; + return; } - header.input.forceActiveFocus(); - event.accepted = true; + event.accepted = false; } } } diff --git a/applets/kickoff/package/contents/ui/Header.qml b/applets/kickoff/package/contents/ui/Header.qml --- a/applets/kickoff/package/contents/ui/Header.qml +++ b/applets/kickoff/package/contents/ui/Header.qml @@ -16,25 +16,28 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -import QtQuick 2.0 +import QtQuick 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.kcoreaddons 1.0 as KCoreAddons import org.kde.kquickcontrolsaddons 2.0 -Item { +FocusScope { id: header implicitHeight: units.gridUnit * 5 property alias query: queryField.text - property Item input: queryField KCoreAddons.KUser { id: kuser } + function paste() { + queryField.paste(); + } + state: (query !== "") ? "query" : "hint" Timer { @@ -164,7 +167,10 @@ PlasmaComponents.TextField { id: queryField + focus: true anchors.fill: parent + Accessible.role: Accessible.EditableText + Accessible.name: i18n("Search") clearButtonShown: true visible: opacity > 0 placeholderText: i18nc("Type is a verb here, not a noun", "Type to search...") diff --git a/applets/kickoff/package/contents/ui/KickoffItem.qml b/applets/kickoff/package/contents/ui/KickoffItem.qml --- a/applets/kickoff/package/contents/ui/KickoffItem.qml +++ b/applets/kickoff/package/contents/ui/KickoffItem.qml @@ -61,6 +61,11 @@ } } + Accessible.role: Accessible.ListItem + Accessible.name: model.display + //if name and description match don't read it twice + Accessible.description: model.name == model.description ? "" : model.description + function activate() { var view = listItem.ListView.view; diff --git a/applets/kickoff/package/contents/ui/LeaveView.qml b/applets/kickoff/package/contents/ui/LeaveView.qml --- a/applets/kickoff/package/contents/ui/LeaveView.qml +++ b/applets/kickoff/package/contents/ui/LeaveView.qml @@ -24,6 +24,9 @@ BaseView { objectName: "LeaveView" + Accessible.role: Accessible.Grouping + Accessible.name: i18n("Leave") + model: Kicker.SystemModel { favoritesModel: globalFavorites } diff --git a/applets/kickoff/package/contents/ui/OftenUsedView.qml b/applets/kickoff/package/contents/ui/OftenUsedView.qml --- a/applets/kickoff/package/contents/ui/OftenUsedView.qml +++ b/applets/kickoff/package/contents/ui/OftenUsedView.qml @@ -26,6 +26,9 @@ BaseView { objectName: "OftenUsedView" + Accessible.role: Accessible.Grouping + Accessible.name: i18n("Often Used") + model: Kicker.RecentUsageModel { favoritesModel: globalFavorites ordering: 1 // Popular / Often Used diff --git a/applets/kickoff/package/contents/ui/RecentlyUsedView.qml b/applets/kickoff/package/contents/ui/RecentlyUsedView.qml --- a/applets/kickoff/package/contents/ui/RecentlyUsedView.qml +++ b/applets/kickoff/package/contents/ui/RecentlyUsedView.qml @@ -25,6 +25,9 @@ BaseView { objectName: "RecentlyUsedView" + Accessible.role: Accessible.Grouping + Accessible.name: i18n("History") + model: Kicker.RecentUsageModel { favoritesModel: globalFavorites } diff --git a/applets/kickoff/package/contents/ui/SearchView.qml b/applets/kickoff/package/contents/ui/SearchView.qml --- a/applets/kickoff/package/contents/ui/SearchView.qml +++ b/applets/kickoff/package/contents/ui/SearchView.qml @@ -27,29 +27,19 @@ anchors.fill: parent - objectName: "SearchView" - - function decrementCurrentIndex() { - searchView.decrementCurrentIndex(); - } - - function incrementCurrentIndex() { - searchView.incrementCurrentIndex(); - } - - function activateCurrentIndex() { - searchView.currentItem.activate(); - } + Keys.forwardTo: searchView - function openContextMenu() { - searchView.currentItem.openActionMenu(); - } + objectName: "SearchView" + Accessible.role: Accessible.Grouping + Accessible.name: i18n("Search Results") PlasmaExtras.ScrollArea { anchors.fill: parent + focus: true ListView { id: searchView + Accessible.role: Accessible.List anchors.fill: parent keyNavigationWraps: true @@ -61,6 +51,10 @@ highlightMoveDuration : 0 highlightResizeDuration: 0 + Keys.onEnterPressed: currentItem.activate(); + Keys.onReturnPressed: currentItem.activate(); + Keys.onMenuPressed: currentItem.openActionMenu(); + Connections { target: header @@ -75,7 +69,6 @@ Connections { target: runnerModel - onCountChanged: { if (runnerModel.count && !searchView.model) { searchView.model = runnerModel.modelForRow(0);