From ca2f50cb4bd5087a3153f1f999a7d224ee41300a Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Thu, 23 Jun 2016 18:34:13 +0300 Subject: [PATCH] [app] Restore current folder at startup --- app/qml/BooksShelfView.qml | 51 ++++++++++++++++++++++++-------------- app/src/BooksSettings.cpp | 13 ++++++++-- app/src/BooksSettings.h | 7 ++++-- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/app/qml/BooksShelfView.qml b/app/qml/BooksShelfView.qml index 353242b..da8c964 100644 --- a/app/qml/BooksShelfView.qml +++ b/app/qml/BooksShelfView.qml @@ -1,32 +1,34 @@ /* - Copyright (C) 2015 Jolla Ltd. + Copyright (C) 2015-2016 Jolla Ltd. Contact: Slava Monich - You may use this file under the terms of BSD license as follows: + You may use this file under the terms of the BSD license as follows: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Jolla Ltd nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import QtQuick 2.0 @@ -67,10 +69,21 @@ Item { Shelf { id: shelfModel property bool needDummyItem: dragInProgress && dragItem.shelfIndex !== shelfView.shelfIndex + property bool _completed // Received Component.onCompleted onNeedDummyItemChanged: if (needDummyItem) hasDummyItem = true editMode: shelfView.editMode onRelativePathChanged: longStartTimer.restart() - onPathChanged: globalSettings.currentFolder = path + onPathChanged: { + if (globalSettings.currentStorage === device && _completed) { + globalSettings.currentFolder = path + } + } + onDeviceChanged: { + if (device === globalSettings.currentStorage) { + relativePath = globalSettings.relativePath + } + } + Component.onCompleted: _completed = true } BooksPathModel { diff --git a/app/src/BooksSettings.cpp b/app/src/BooksSettings.cpp index 1f174d0..e811057 100644 --- a/app/src/BooksSettings.cpp +++ b/app/src/BooksSettings.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Jolla Ltd. + * Copyright (C) 2015-2016 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors + * * Neither the name of Jolla Ltd nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * @@ -330,6 +330,14 @@ BooksSettings::setInvertColors( iInvertColorsConf->set(aValue); } +QString +BooksSettings::relativePath() const +{ + QString rel; + BooksStorageManager::instance()->storageForPath(currentFolder(), &rel); + return rel; +} + QString BooksSettings::currentFolder() const { @@ -351,6 +359,7 @@ BooksSettings::onCurrentFolderChanged() Q_EMIT currentStorageChanged(); } Q_EMIT currentFolderChanged(); + Q_EMIT relativePathChanged(); } bool diff --git a/app/src/BooksSettings.h b/app/src/BooksSettings.h index feadeab..27cca25 100644 --- a/app/src/BooksSettings.h +++ b/app/src/BooksSettings.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Jolla Ltd. + * Copyright (C) 2015-2016 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors + * * Neither the name of Jolla Ltd nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * @@ -51,6 +51,7 @@ class BooksSettings : public QObject Q_PROPERTY(QObject* currentBook READ currentBook WRITE setCurrentBook NOTIFY currentBookChanged) Q_PROPERTY(QString currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged) Q_PROPERTY(QString currentStorage READ currentStorage NOTIFY currentStorageChanged) + Q_PROPERTY(QString relativePath READ relativePath NOTIFY relativePathChanged) Q_PROPERTY(QColor primaryPageToolColor READ primaryPageToolColor CONSTANT) Q_PROPERTY(QColor highlightPageToolColor READ highlightPageToolColor NOTIFY invertColorsChanged) class TextStyle; @@ -82,6 +83,7 @@ public: QObject* currentBook() const; void setCurrentBook(QObject* aBook); + QString relativePath() const; QString currentFolder() const; void setCurrentFolder(QString aValue); @@ -97,6 +99,7 @@ Q_SIGNALS: void currentBookChanged(); void currentFolderChanged(); void currentStorageChanged(); + void relativePathChanged(); private Q_SLOTS: void onFontSizeValueChanged();