diff options
| author | Tomasz Sterna <tomek@xiaoka.com> | 2015-05-11 16:17:09 +0200 |
|---|---|---|
| committer | Tomasz Sterna <tomek@xiaoka.com> | 2015-05-11 16:17:09 +0200 |
| commit | 6fd4a07a3a317909524560201c576e1e7a3ce6f7 (patch) | |
| tree | 1e11316047bdb6bbe72d76609010a0b967b1a8af | |
| parent | 3f64297af4e7a070b4f62ebf3f17105ee6b0a3a8 (diff) | |
Improved local applications handling
- better filter listing local apps in Downloads
- option to remove app from local list
| -rw-r--r-- | app/pebbledinterface.cpp | 14 | ||||
| -rw-r--r-- | app/pebbledinterface.h | 1 | ||||
| -rw-r--r-- | app/qml/pages/InstallAppDialog.qml | 18 | ||||
| -rw-r--r-- | daemon/manager.cpp | 1 |
4 files changed, 31 insertions, 3 deletions
diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp index 13535da..84a4ae2 100644 --- a/app/pebbledinterface.cpp +++ b/app/pebbledinterface.cpp @@ -215,6 +215,19 @@ bool PebbledInterface::registerAppFile(const QString& filePath) return false; } +bool PebbledInterface::unregisterAppFile(const QString& filePath) +{ + if (filePath.endsWith(".pbw", Qt::CaseInsensitive)) { + QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + if (filePath.startsWith(dataDir.absolutePath())) { + QFile pbw(filePath); + return pbw.remove(); + } + } + + return false; +} + QUrl PebbledInterface::configureApp(const QString &uuid) { qDebug() << Q_FUNC_INFO << uuid; @@ -359,6 +372,7 @@ void PebbledInterface::refreshAllApps() m.insert("versionLabel", orig.value("version-label")); m.insert("isWatchface", orig.value("is-watchface")); m.insert("isConfigurable", orig.value("configurable")); + m.insert("path", orig.value("path")); QByteArray pngIcon = orig.value("menu-icon").toByteArray(); if (!pngIcon.isEmpty()) { diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h index df0b722..281ada7 100644 --- a/app/pebbledinterface.h +++ b/app/pebbledinterface.h @@ -39,6 +39,7 @@ public: QVariantList allApps() const; Q_INVOKABLE static bool registerAppFile(const QString& filePath); + Q_INVOKABLE static bool unregisterAppFile(const QString& filePath); Q_INVOKABLE QVariantMap appInfoByUuid(const QString& uuid) const; diff --git a/app/qml/pages/InstallAppDialog.qml b/app/qml/pages/InstallAppDialog.qml index 97513c0..cba3e4e 100644 --- a/app/qml/pages/InstallAppDialog.qml +++ b/app/qml/pages/InstallAppDialog.qml @@ -11,6 +11,7 @@ Dialog { Component { id: appPicker + // Copied+modified from /usr/lib/qt5/qml/Sailfish/Pickers/MultiDocumentPickerDialog.qml PickerDialog { id: appPickerDialog @@ -27,9 +28,9 @@ Dialog { DocumentModel { id: documentModel selectedModel: _selectedModel - contentFilter: GalleryStartsWithFilter { - property: "filePath" - value: StandardPaths.documents + "/../Downloads" + contentFilter: GalleryFilterIntersection { + GalleryStartsWithFilter { property: "filePath"; value: StandardPaths.documents + "/../Downloads" } + GalleryEndsWithFilter { property: "fileName"; value: ".pbw" } } } @@ -136,6 +137,17 @@ Dialog { accept(); } } + + menu: ContextMenu { + MenuItem { + text: qsTr("Delete App file") + onClicked: { + remorseAction(qsTr("Deleting " + modelData.shortName), function() { + pebbled.unregisterAppFile(modelData.path) + }); + } + } + } } model: pebbled.allApps diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 262fb4b..e6ebf26 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -416,6 +416,7 @@ QVariantList PebbledProxy::AllApps() const m.insert("version-label", QVariant::fromValue(info.versionLabel())); m.insert("is-watchface", QVariant::fromValue(info.isWatchface())); m.insert("configurable", QVariant::fromValue(info.capabilities().testFlag(AppInfo::Capability::Configurable))); + m.insert("path", QVariant::fromValue(info.path())); if (!info.getMenuIconImage().isNull()) { m.insert("menu-icon", QVariant::fromValue(info.getMenuIconPng())); |
