diff options
| author | Tomasz Sterna <tomek@xiaoka.com> | 2015-01-11 21:26:02 +0100 |
|---|---|---|
| committer | Tomasz Sterna <tomek@xiaoka.com> | 2015-01-11 21:26:02 +0100 |
| commit | f0e644896d34c4c354a978788cbb461db653484b (patch) | |
| tree | 31086457b3a8f7c30e94e20a287914dcdb3d3c95 | |
| parent | 341c38a31f4bde9a2f016b4d58a11b8beb2bae5a (diff) | |
Implemented "Add App file" dialog
| -rw-r--r-- | app/pebble.cpp | 11 | ||||
| -rw-r--r-- | app/pebbledinterface.cpp | 16 | ||||
| -rw-r--r-- | app/pebbledinterface.h | 2 | ||||
| -rw-r--r-- | app/qml/pages/InstallAppDialog.qml | 70 | ||||
| -rw-r--r-- | app/translations/pebble-es.ts | 20 | ||||
| -rw-r--r-- | app/translations/pebble.ts | 16 |
6 files changed, 118 insertions, 17 deletions
diff --git a/app/pebble.cpp b/app/pebble.cpp index 6f5d605..22f6ac1 100644 --- a/app/pebble.cpp +++ b/app/pebble.cpp @@ -42,16 +42,7 @@ int main(int argc, char *argv[]) app->setOrganizationName(""); for (int i = 1; i < argc; i++) { - if (QString(argv[i]).endsWith(".pbw", Qt::CaseInsensitive)) { - QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); - if (dataDir.mkpath("apps")) { - QFile pbw(argv[i]); - QFileInfo dst(pbw); - dst.setFile(dataDir.absoluteFilePath("apps"), dst.fileName()); - QFile(dst.filePath()).remove(); - pbw.copy(dst.filePath()); - } - } + PebbledInterface::registerAppFile(argv[i]); } qmlRegisterUncreatableType<PebbledInterface>("org.pebbled", 0, 1, "PebbledInterface", diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp index cc9a617..b30af28 100644 --- a/app/pebbledinterface.cpp +++ b/app/pebbledinterface.cpp @@ -170,6 +170,22 @@ void PebbledInterface::reconnect() watch->Reconnect(); } +bool PebbledInterface::registerAppFile(const QString& filePath) +{ + if (filePath.endsWith(".pbw", Qt::CaseInsensitive)) { + QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + if (dataDir.mkpath("apps")) { + QFile pbw(filePath); + QFileInfo dst(pbw); + dst.setFile(dataDir.absoluteFilePath("apps"), dst.fileName()); + QFile(dst.filePath()).remove(); + return pbw.copy(dst.filePath()); + } + } + + return false; +} + QUrl PebbledInterface::configureApp(const QString &uuid) { qDebug() << Q_FUNC_INFO << uuid; diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h index 51efa12..50269ff 100644 --- a/app/pebbledinterface.h +++ b/app/pebbledinterface.h @@ -36,6 +36,8 @@ public: QStringList appSlots() const; QVariantList allApps() const; + Q_INVOKABLE static bool registerAppFile(const QString& filePath); + Q_INVOKABLE QVariantMap appInfoByUuid(const QString& uuid) const; Q_INVOKABLE QUrl configureApp(const QString &uuid); diff --git a/app/qml/pages/InstallAppDialog.qml b/app/qml/pages/InstallAppDialog.qml index debb48f..ecc3d78 100644 --- a/app/qml/pages/InstallAppDialog.qml +++ b/app/qml/pages/InstallAppDialog.qml @@ -1,23 +1,91 @@ import QtQuick 2.0 import QtQml 2.1 import Sailfish.Silica 1.0 +import QtDocGallery 5.0 +import Sailfish.Pickers 1.0 Dialog { id: installAppPage property string selectedUuid; + Component { + id: appPicker + + PickerDialog { + id: appPickerDialog + title: qsTr("Select App files") + + SilicaListView { + id: listView + + currentIndex: -1 + anchors.fill: parent + + model: documentModel.model + + DocumentModel { + id: documentModel + selectedModel: _selectedModel + contentFilter: GalleryStartsWithFilter { + property: "filePath" + value: StandardPaths.documents + "/../Downloads" + } + } + + header: PageHeader { + id: pageHeader + title: appPickerDialog.title + } + + + delegate: DocumentItem { + id: documentItem + baseName: Theme.highlightText(documentModel.baseName(model.fileName), documentModel.filter, Theme.highlightColor) + extension: Theme.highlightText(documentModel.extension(model.fileName), documentModel.filter, Theme.highlightColor) + selected: model.selected + + ListView.onAdd: AddAnimation { target: documentItem; duration: _animationDuration } + ListView.onRemove: RemoveAnimation { target: documentItem; duration: _animationDuration } + onClicked: documentModel.updateSelected(index, !selected) + } + + VerticalScrollDecorator {} + } + } + + } + SilicaListView { id: appList anchors.fill: parent header: DialogHeader { - title: qsTr("Install app") + title: qsTr("Install App") defaultAcceptText: qsTr("Install") } VerticalScrollDecorator { flickable: flickable } + PullDownMenu { + MenuItem { + text: qsTr("Add App file...") + onClicked: { + var addApps = function() { + for(var i=0; i < picker.selectedContent.count; ++i) { + var appPath = picker.selectedContent.get(i).filePath + console.log(appPath) + pebbled.registerAppFile(appPath) + } + picker.selectedContentChanged.disconnect(addApps) + } + var picker = pageStack.push(appPicker) + picker.selectedContentChanged.connect(addApps) + } + + } + } + currentIndex: -1 delegate: ListItem { diff --git a/app/translations/pebble-es.ts b/app/translations/pebble-es.ts index 9be8be2..af9e522 100644 --- a/app/translations/pebble-es.ts +++ b/app/translations/pebble-es.ts @@ -43,15 +43,29 @@ <context> <name>InstallAppDialog</name> <message> - <location filename="../qml/pages/InstallAppDialog.qml" line="15"/> <source>Install app</source> - <translation>Instalar app</translation> + <translation type="vanished">Instalar app</translation> </message> <message> - <location filename="../qml/pages/InstallAppDialog.qml" line="16"/> + <location filename="../qml/pages/InstallAppDialog.qml" line="17"/> + <source>Select App files</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/InstallAppDialog.qml" line="64"/> + <source>Install App</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/InstallAppDialog.qml" line="65"/> <source>Install</source> <translation>Instalar</translation> </message> + <message> + <location filename="../qml/pages/InstallAppDialog.qml" line="72"/> + <source>Add App file...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ManagerPage</name> diff --git a/app/translations/pebble.ts b/app/translations/pebble.ts index 0f953bc..07393f6 100644 --- a/app/translations/pebble.ts +++ b/app/translations/pebble.ts @@ -43,15 +43,25 @@ <context> <name>InstallAppDialog</name> <message> - <location filename="../qml/pages/InstallAppDialog.qml" line="15"/> - <source>Install app</source> + <location filename="../qml/pages/InstallAppDialog.qml" line="17"/> + <source>Select App files</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/InstallAppDialog.qml" line="16"/> + <location filename="../qml/pages/InstallAppDialog.qml" line="64"/> + <source>Install App</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/InstallAppDialog.qml" line="65"/> <source>Install</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../qml/pages/InstallAppDialog.qml" line="72"/> + <source>Add App file...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ManagerPage</name> |
