on xenial help sign in
fix the launching of the searched item by pressing enter
6824477Michael Zanetti
plugins/Utils/CMakeLists.txt+1
@@ -17,6 +17,7 @@ set(QMLPLUGIN_SRC
17 applicationsfiltermodel.cpp
17 applicationsfiltermodel.cpp
18 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/AppDrawerModelInterface.h
18 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/AppDrawerModelInterface.h
19 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
19 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
20+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
20 appdrawerproxymodel.cpp
21 appdrawerproxymodel.cpp
21 constants.cpp
22 constants.cpp
22 WindowInputMonitor.cpp
23 WindowInputMonitor.cpp
plugins/Utils/appdrawerproxymodel.cpp+23
@@ -16,6 +16,8 @@
16
16
17#include "appdrawerproxymodel.h"
17#include "appdrawerproxymodel.h"
18
18
19+#include <unity/shell/launcher/LauncherItemInterface.h>
20+
19#include <QDebug>
21#include <QDebug>
20
22
21AppDrawerProxyModel::AppDrawerProxyModel(QObject *parent):
23AppDrawerProxyModel::AppDrawerProxyModel(QObject *parent):
@@ -167,3 +169,24 @@ bool AppDrawerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &so
167 }
169 }
168 return true;
170 return true;
169}
171}
172+
173+QString AppDrawerProxyModel::appId(int index) const
174+{
175+ qDebug() << "get called:" << index << this << m_source->staticMetaObject.className() << m_source;
176+ if (index >= 0 && index < rowCount()) {
177+ QModelIndex sourceIndex = mapToSource(this->index(index, 0));
178+
179+ AppDrawerModelInterface* adm = dynamic_cast<AppDrawerModelInterface*>(m_source);
180+ qDebug() << "tried casting to ADMI:" << adm;
181+ if (adm) {
182+ return adm->data(sourceIndex, AppDrawerModelInterface::RoleAppId).toString();
183+ }
184+
185+ AppDrawerProxyModel* adpm = qobject_cast<AppDrawerProxyModel*>(m_source);
186+ if (adpm) {
187+ return adpm->appId(sourceIndex.row());
188+ }
189+ }
190+ qDebug() << "could nto cast source model";
191+ return nullptr;
192+}
plugins/Utils/appdrawerproxymodel.h+2
@@ -65,6 +65,8 @@ public:
65 QVariant data(const QModelIndex &index, int role) const override;
65 QVariant data(const QModelIndex &index, int role) const override;
66 QHash<int, QByteArray> roleNames() const override;
66 QHash<int, QByteArray> roleNames() const override;
67
67
68+ Q_INVOKABLE QString appId(int index) const;
69+
68protected:
70protected:
69 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
71 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
70
72
qml/Launcher/Drawer.qml+3−13
@@ -81,7 +81,7 @@ FocusScope {
81 focus: true
81 focus: true
82 onAccepted: {
82 onAccepted: {
83 if (searchField.displayText != "" && listLoader.item && listLoader.item.currentItem) {
83 if (searchField.displayText != "" && listLoader.item && listLoader.item.currentItem) {
84− root.applicationSelected(listLoader.item.currentItem.appId);
84+ root.applicationSelected(listLoader.item.getFirstAppId());
85 }
85 }
86 }
86 }
87 }
87 }
@@ -166,12 +166,7 @@ FocusScope {
166
166
167 Component {
167 Component {
168 id: mostUsedComponent
168 id: mostUsedComponent
169− ListView {
169+ DrawerListView {
170− anchors.fill: parent
171− topMargin: units.gu(1)
172− bottomMargin: units.gu(1)
173− spacing: units.gu(1)
174− clip: true
175
170
176 header: MoreAppsHeader {
171 header: MoreAppsHeader {
177 width: parent.width
172 width: parent.width
@@ -213,12 +208,7 @@ FocusScope {
213
208
214 Component {
209 Component {
215 id: aToZComponent
210 id: aToZComponent
216− ListView {
211+ DrawerListView {
217− anchors.fill: parent
218− topMargin: units.gu(1)
219− bottomMargin: units.gu(1)
220− spacing: units.gu(1)
221− clip: true
222
212
223 header: MoreAppsHeader {
213 header: MoreAppsHeader {
224 width: parent.width
214 width: parent.width
qml/Launcher/DrawerListView.qmlnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2016 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+
20+ListView {
21+ id: root
22+ anchors.fill: parent
23+ topMargin: units.gu(1)
24+ bottomMargin: units.gu(1)
25+ spacing: units.gu(1)
26+ clip: true
27+
28+ function getFirstAppId() {
29+ return model.appId(0);
30+ }
31+}
tests/mocks/Utils/CMakeLists.txt+2
@@ -31,6 +31,8 @@ set(QMLPLUGIN_SRC
31 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
31 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
32 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
32 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
33 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/AppDrawerModelInterface.h
33 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/AppDrawerModelInterface.h
34+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
35+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
34 constants.cpp
36 constants.cpp
35 plugin.cpp
37 plugin.cpp
36 windowstatestorage.cpp
38 windowstatestorage.cpp