[app] Restore current folder at startup

This commit is contained in:
Slava Monich 2016-06-23 18:34:13 +03:00
parent 93b07f46fa
commit ca2f50cb4b
3 changed files with 48 additions and 23 deletions

View file

@ -1,32 +1,34 @@
/* /*
Copyright (C) 2015 Jolla Ltd. Copyright (C) 2015-2016 Jolla Ltd.
Contact: Slava Monich <slava.monich@jolla.com> Contact: Slava Monich <slava.monich@jolla.com>
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 Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: are met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in
documentation and/or other materials provided with the distribution. the documentation and/or other materials provided with the
* Neither the name of the Jolla Ltd nor the distribution.
names of its contributors may be used to endorse or promote products * Neither the name of Jolla Ltd nor the names of its contributors
derived from this software without specific prior written permission. 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" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
import QtQuick 2.0 import QtQuick 2.0
@ -67,10 +69,21 @@ Item {
Shelf { Shelf {
id: shelfModel id: shelfModel
property bool needDummyItem: dragInProgress && dragItem.shelfIndex !== shelfView.shelfIndex property bool needDummyItem: dragInProgress && dragItem.shelfIndex !== shelfView.shelfIndex
property bool _completed // Received Component.onCompleted
onNeedDummyItemChanged: if (needDummyItem) hasDummyItem = true onNeedDummyItemChanged: if (needDummyItem) hasDummyItem = true
editMode: shelfView.editMode editMode: shelfView.editMode
onRelativePathChanged: longStartTimer.restart() 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 { BooksPathModel {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jolla Ltd. * Copyright (C) 2015-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Contact: Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of the BSD license as follows: * 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 * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * 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 * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
@ -330,6 +330,14 @@ BooksSettings::setInvertColors(
iInvertColorsConf->set(aValue); iInvertColorsConf->set(aValue);
} }
QString
BooksSettings::relativePath() const
{
QString rel;
BooksStorageManager::instance()->storageForPath(currentFolder(), &rel);
return rel;
}
QString QString
BooksSettings::currentFolder() const BooksSettings::currentFolder() const
{ {
@ -351,6 +359,7 @@ BooksSettings::onCurrentFolderChanged()
Q_EMIT currentStorageChanged(); Q_EMIT currentStorageChanged();
} }
Q_EMIT currentFolderChanged(); Q_EMIT currentFolderChanged();
Q_EMIT relativePathChanged();
} }
bool bool

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jolla Ltd. * Copyright (C) 2015-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Contact: Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of the BSD license as follows: * 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 * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * 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 * may be used to endorse or promote products derived from this
* software without specific prior written permission. * 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(QObject* currentBook READ currentBook WRITE setCurrentBook NOTIFY currentBookChanged)
Q_PROPERTY(QString currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged) Q_PROPERTY(QString currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged)
Q_PROPERTY(QString currentStorage READ currentStorage NOTIFY currentStorageChanged) 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 primaryPageToolColor READ primaryPageToolColor CONSTANT)
Q_PROPERTY(QColor highlightPageToolColor READ highlightPageToolColor NOTIFY invertColorsChanged) Q_PROPERTY(QColor highlightPageToolColor READ highlightPageToolColor NOTIFY invertColorsChanged)
class TextStyle; class TextStyle;
@ -82,6 +83,7 @@ public:
QObject* currentBook() const; QObject* currentBook() const;
void setCurrentBook(QObject* aBook); void setCurrentBook(QObject* aBook);
QString relativePath() const;
QString currentFolder() const; QString currentFolder() const;
void setCurrentFolder(QString aValue); void setCurrentFolder(QString aValue);
@ -97,6 +99,7 @@ Q_SIGNALS:
void currentBookChanged(); void currentBookChanged();
void currentFolderChanged(); void currentFolderChanged();
void currentStorageChanged(); void currentStorageChanged();
void relativePathChanged();
private Q_SLOTS: private Q_SLOTS:
void onFontSizeValueChanged(); void onFontSizeValueChanged();