From 94db06ff082d2b5e1ad99ed52c844dcec0d070ca Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Thu, 22 Nov 2018 14:48:25 +0900 Subject: change blank icons --- app/images/blank.svg | 133 +++++++++++++++++++++++++++++++++++++++++++ app/images/images.qrc | 1 + app/main.qml | 2 +- app/pages/DetailPage.qml | 17 +++++- app/pages/ListPage.qml | 92 +++++++++++++++++++++++++----- app/pages/ManagementPage.qml | 23 ++++++-- app/src/appinfo.cpp | 16 +++++- app/src/config.h | 8 +++ app/src/nativeappmodel.cpp | 7 ++- app/src/serverappmodel.cpp | 13 +++-- app/src/serverappmodel.h | 4 +- 11 files changed, 283 insertions(+), 33 deletions(-) create mode 100644 app/images/blank.svg diff --git a/app/images/blank.svg b/app/images/blank.svg new file mode 100644 index 0000000..10c0a89 --- /dev/null +++ b/app/images/blank.svg @@ -0,0 +1,133 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/images.qrc b/app/images/images.qrc index 867a055..cc30231 100644 --- a/app/images/images.qrc +++ b/app/images/images.qrc @@ -3,5 +3,6 @@ DividingLine.svg Back.svg Top.svg + blank.svg \ No newline at end of file diff --git a/app/main.qml b/app/main.qml index a481320..2ecc8ac 100644 --- a/app/main.qml +++ b/app/main.qml @@ -84,7 +84,7 @@ ApplicationWindow { height: parent.height } TabButton { - text: "Management" + text: "Installed Application" font.pixelSize: 20 height: parent.height } diff --git a/app/pages/DetailPage.qml b/app/pages/DetailPage.qml index 043714d..45e5202 100644 --- a/app/pages/DetailPage.qml +++ b/app/pages/DetailPage.qml @@ -56,9 +56,22 @@ import QtQuick.Controls 2.0 Item { Layout.preferredWidth: 200 Layout.preferredHeight: 200 - Image { + + Image { + id: imageicon anchors.fill: parent - source: model.icon + source: model.icon != ""?model.icon : 'qrc:/images/blank.svg' + property string initial: model.name.substring(0,1).toUpperCase() + + Label { + style: Text.Outline + styleColor: "#00ADDC" + color: 'transparent' + font.pixelSize: parent.height * 0.5 + anchors.centerIn: parent + text: parent.initial + visible: model.icon == "" + } } } diff --git a/app/pages/ListPage.qml b/app/pages/ListPage.qml index f4b78da..c9116d4 100644 --- a/app/pages/ListPage.qml +++ b/app/pages/ListPage.qml @@ -35,6 +35,14 @@ Page { implicitHeight: 60 running: false } + BusyIndicator { + id: nextBusyIndicator + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + implicitWidth: 60 + implicitHeight: 60 + running: false + } StackView { id: stack @@ -58,21 +66,35 @@ Page { anchors.fill: parent Item { - Layout.preferredWidth: 100 - Layout.preferredHeight: 100 + Layout.preferredWidth: 80 + Layout.preferredHeight: 80 MouseArea{ anchors.fill: parent z: 2 - onClicked: { - stack.push("qrc:/pages/DetailPage.qml", {stack: stack, model: model}, StackView.Immediate) + onClicked: { + stack.push("qrc:/pages/DetailPage.qml", {stack: stack, model: model}, StackView.Immediate) } } + Image { + id: imageicon anchors.fill: parent - source: model.icon + source: model.icon != ""?model.icon : 'qrc:/images/blank.svg' + property string initial: model.name.substring(0,1).toUpperCase() + + Label { + style: Text.Outline + styleColor: "#00ADDC" + color: 'transparent' + font.pixelSize: parent.height * 0.5 + anchors.centerIn: parent + text: parent.initial + visible: model.icon == "" + } } } + ColumnLayout { Label { Layout.fillWidth: true @@ -96,9 +118,10 @@ Page { ColumnLayout { spacing: 5 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - + Button { - x: x - 6 + anchors.right: parent.right + anchors.rightMargin: 6 text: model.statetext onClicked: { if (model.statetext === 'Install' || model.statetext === 'Update') { @@ -113,11 +136,10 @@ Page { } implicitWidth: 140 implicitHeight: 40 - //Layout.rightMargin: 5 } } - } + DownloadBar { anchors.fill: parent progress: model.progress @@ -134,12 +156,19 @@ Page { states: [ State { - name: "prevPageState"; when: listView.contentY < -nPullHeight + name: "prevPageState"; when: (prevBusyIndicator.running == false) && listView.contentY < -nPullHeight StateChangeScript { name: "prevPageScript" script: getPrevPage() } - } + }, + State { + name: "nextPageState"; when: appSize > 8 && (nextBusyIndicator.running == false) && (listView.contentHeight > 0) && (listView.contentY > (listView.contentHeight - listView.height + nPullHeight)) + StateChangeScript { + name: "nextPageScript" + script: getNextPage() + } + } ] } @@ -147,10 +176,18 @@ Page { listView.y = nPullHeight; currentPageIndex = currentPageIndex > 0 ? currentPageIndex-1 : 0; - prevBusyIndicator.running = true + prevBusyIndicator.running = true; prevPageTimer.start(); } + function getNextPage() { + listView.y = nPullHeight; + + currentPageIndex++; + nextBusyIndicator.running = true; + nextPageTimer.start(); + } + Timer { id: prevPageTimer interval: 1000 @@ -162,6 +199,16 @@ Page { } } + Timer { + id: nextPageTimer + interval: 1000 + repeat: false + running: false + onTriggered: { + listView.model.getNextPage(currentPageIndex) + nextPageAnimation.start(); + } + } NumberAnimation { id: prevPageAnimation target: listView @@ -171,16 +218,33 @@ Page { to: 0 onStopped: { prevBusyIndicator.running = false - listView.y = 0; + //listView.y = 0; } } + NumberAnimation { + id: nextPageAnimation + target: listView + property: "y" + duration: 100 + from: nPullHeight + to: 0 + onStopped: { + nextBusyIndicator.running = false + //listView.y = 0; + } + } Connections { target: listView.model onRequestCompleted: { appSize = appsize pageSize = pagesize - console.log("request completed!", appSize, pageSize) + console.log("request completed!", appSize, pageSize, currentPageIndex) + if(appSize == 0 && currentPageIndex > 0) { + listView.model.getPrevPage(--currentPageIndex) + }else{ + listView.y = 0; + } } } } diff --git a/app/pages/ManagementPage.qml b/app/pages/ManagementPage.qml index 9a4cf31..e445c63 100644 --- a/app/pages/ManagementPage.qml +++ b/app/pages/ManagementPage.qml @@ -47,9 +47,22 @@ Page { Item { Layout.preferredWidth: 100 Layout.preferredHeight: 100 - Image { + + Image { + id: imageicon anchors.fill: parent - source: 'file://' + model.icon + source: model.icon != ""?'file://' + model.icon : 'qrc:/images/blank.svg' + property string initial: model.name.substring(0,1).toUpperCase() + + Label { + style: Text.Outline + styleColor: "#00ADDC" + color: 'transparent' + font.pixelSize: parent.height * 0.5 + anchors.centerIn: parent + text: parent.initial + visible: model.icon == "" + } } } ColumnLayout { @@ -77,7 +90,8 @@ Page { Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Button { - x: x - 6 + anchors.right: parent.right + anchors.rightMargin: 6 text: 'Launch' onClicked: { if (listView.model.launch(model.id) > 1) { @@ -90,7 +104,8 @@ Page { implicitHeight: 40 } Button { - x: x - 6 + anchors.right: parent.right + anchors.rightMargin: 6 visible: model.name.toUpperCase() != "HOMESCREEN" && model.name.toUpperCase() != "LAUNCHER" text: 'Uninstall' onClicked: { diff --git a/app/src/appinfo.cpp b/app/src/appinfo.cpp index b06dd2f..05daad4 100644 --- a/app/src/appinfo.cpp +++ b/app/src/appinfo.cpp @@ -16,7 +16,9 @@ * limitations under the License. */ +#include #include "appinfo.h" +#include "config.h" #include "hmi-debug.h" class AppInfo::Private : public QSharedData { @@ -176,6 +178,11 @@ void AppInfo::read(const QJsonObject& json) { d->shortname = json["shortname"].toString(); d->author = json["author"].toString(); d->iconPath = json["icon"].toString(); + QFileInfo fi(d->iconPath); + if(!fi.isFile()){ + d->iconPath = ""; + } + d->state = Launch; } @@ -193,8 +200,13 @@ void AppInfo::readFromServer(const QJsonObject& json) { d->deviceid = json["appDeviceTypeId"].toString(); d->devicename = json["appDeviceTypeName"].toString(); d->createdtime = json["updateDate"].toDouble(); - // d->iconPath = json["icon"].toString(); - d->iconPath = "file:///var/local/lib/afm/applications/launcher/0.1/icon.svg"; + d->iconPath = json["imagePath"].toString(); + + if(json["imagePath"].toString().isEmpty()){ + d->iconPath = ""; + } else { + d->iconPath = getIconUrl(json["imagePath"].toString()); + } d->state = Install; d->progress = 0.0; } diff --git a/app/src/config.h b/app/src/config.h index 0f2d5ed..e3aefc1 100644 --- a/app/src/config.h +++ b/app/src/config.h @@ -18,8 +18,12 @@ #define CONFIG_H // server url config +//#define SERVER_DOMAIN_IP "192.168.20.161" +#define SERVER_DOMAIN_IP "202.7.19.45" + //#define SERVER_DOMAIN "192.168.20.161/webservice" #define SERVER_DOMAIN "202.7.19.45/webservice" + //#define SERVER_DOMAIN "warehouse.tmc-tokai.jp/webservice" #define SERVER_BASE_URL "/api/v1/app" #define SERVER_API_LIST "/collection" @@ -38,6 +42,10 @@ QString("http://%1%2/file?filePath=%3") \ .arg(SERVER_DOMAIN, SERVER_BASE_URL, path) +#define getIconUrl(path) \ + QString("http://%1%2") \ + .arg(SERVER_DOMAIN_IP, path) + // server app page config #define PAGE_SIZE 20 diff --git a/app/src/nativeappmodel.cpp b/app/src/nativeappmodel.cpp index a5fa42d..fb48163 100644 --- a/app/src/nativeappmodel.cpp +++ b/app/src/nativeappmodel.cpp @@ -140,9 +140,12 @@ int NativeAppModel::launch(const QString& application) { void NativeAppModel::uninstall(int index) { const QString& id = this->d->data[index].id(); + + //afm_user_daemon_proxy->terminate(id); + QString result = afm_user_daemon_proxy->uninstall(id); - if (result == "null") { - beginRemoveRows(QModelIndex(), index, index); + if (result == "null") { + beginRemoveRows(QModelIndex(), index, index); this->d->data.removeAt(index); endRemoveRows(); } diff --git a/app/src/serverappmodel.cpp b/app/src/serverappmodel.cpp index ad79159..f1f1238 100644 --- a/app/src/serverappmodel.cpp +++ b/app/src/serverappmodel.cpp @@ -209,12 +209,12 @@ void ServerAppModel::install(int index) { }); } -void ServerAppModel::getPrevPage(int pageIndex) { - this->getAppPage(pageIndex, PAGE_SIZE, true); +void ServerAppModel::getPrevPage(int PageIndex) { + this->getAppPage(PageIndex, PAGE_SIZE, true); } -void ServerAppModel::getNextPage(int pageIndex) { - this->getAppPage(pageIndex, PAGE_SIZE); +void ServerAppModel::getNextPage(int PageIndex) { + this->getAppPage(PageIndex, PAGE_SIZE); } void ServerAppModel::setNativeApplist(const QList& applist) { @@ -250,7 +250,7 @@ void ServerAppModel::getAppPage(int pageIndex, int pageSize, bool isPrev) { // .append(QString("&appDeviceTypeId=%1&appDeveloper=%2") // .arg(QString::number(0), "zhang_xu")); QString url = - getUrlWithPage(SERVER_API_LIST, pageIndex, pageSize) + getUrlWithPage(SERVER_API_LIST, pageIndex * pageSize, pageSize) .append(QString("&appDeviceTypeId=%1").arg(QString::number(0))); HttpClient client(url); @@ -273,7 +273,7 @@ void ServerAppModel::getAppPage(int pageIndex, int pageSize, bool isPrev) { if (isPrev || jappList.size() >= PAGE_SIZE) { applist.clear(); } - applist += newList; + applist += newList; endResetModel(); checkAppState(); @@ -283,4 +283,5 @@ void ServerAppModel::getAppPage(int pageIndex, int pageSize, bool isPrev) { [=](const QString& msg) { HMI_ERROR("response", "response error: %s", msg.toStdString().c_str()); }); + } diff --git a/app/src/serverappmodel.h b/app/src/serverappmodel.h index ea3608f..9d7f352 100644 --- a/app/src/serverappmodel.h +++ b/app/src/serverappmodel.h @@ -56,8 +56,8 @@ class ServerAppModel : public QAbstractListModel { Q_INVOKABLE void install(int index); Q_INVOKABLE int launch(const QString& application); - Q_INVOKABLE void getPrevPage(int pageIndex); - Q_INVOKABLE void getNextPage(int pageIndex); + Q_INVOKABLE void getPrevPage(int PageIndex); + Q_INVOKABLE void getNextPage(int PageIndex); Q_INVOKABLE void setNativeApplist(const QList& applist); -- cgit 1.2.3-korg