[app] Store the current directory in dconf, not just the mountpoint
This will play better with the folder support when it gets implemented.
This commit is contained in:
parent
ae06b6f808
commit
87ebcecd28
3 changed files with 56 additions and 20 deletions
|
@ -81,6 +81,12 @@ SilicaFlickable {
|
||||||
|
|
||||||
Component.onCompleted: _cellWidth = calculateCellWidth()
|
Component.onCompleted: _cellWidth = calculateCellWidth()
|
||||||
|
|
||||||
|
onCurrentShelfChanged: {
|
||||||
|
if (storageList.completed && currentShelf) {
|
||||||
|
globalSettings.currentFolder = currentShelf.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PullDownMenu {
|
PullDownMenu {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
//% "Scan downloads"
|
//% "Scan downloads"
|
||||||
|
@ -132,11 +138,6 @@ SilicaFlickable {
|
||||||
id: storageListWatcher
|
id: storageListWatcher
|
||||||
listView: storageList
|
listView: storageList
|
||||||
onSizeChanged: _cellWidth = calculateCellWidth()
|
onSizeChanged: _cellWidth = calculateCellWidth()
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if (storageList._completed && currentIndex >= 0) {
|
|
||||||
globalSettings.currentStorage = storageModel.deviceAt(currentIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SilicaListView {
|
SilicaListView {
|
||||||
|
@ -149,7 +150,7 @@ SilicaFlickable {
|
||||||
spacing: Theme.paddingMedium
|
spacing: Theme.paddingMedium
|
||||||
interactive: !dragInProgress && !dragScrollAnimation.running
|
interactive: !dragInProgress && !dragScrollAnimation.running
|
||||||
|
|
||||||
property bool _completed
|
property bool completed
|
||||||
readonly property real maxContentX: Math.max(0, contentWidth - width)
|
readonly property real maxContentX: Math.max(0, contentWidth - width)
|
||||||
|
|
||||||
onMaxContentXChanged: {
|
onMaxContentXChanged: {
|
||||||
|
@ -163,8 +164,14 @@ SilicaFlickable {
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var index = model.deviceIndex(globalSettings.currentStorage)
|
var index = model.deviceIndex(globalSettings.currentStorage)
|
||||||
// positionViewAtIndex doesn't work here, update contentX directly
|
// positionViewAtIndex doesn't work here, update contentX directly
|
||||||
if (index >= 0) contentX = (width + spacing) * index
|
if (index >= 0) {
|
||||||
_completed = true
|
contentX = (width + spacing) * index
|
||||||
|
} else {
|
||||||
|
// Most likely, removable storage is gone
|
||||||
|
console.log(globalSettings.currentFolder, "is gone")
|
||||||
|
globalSettings.currentFolder = currentShelf ? currentShelf.path : ""
|
||||||
|
}
|
||||||
|
completed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: BooksShelfView {
|
delegate: BooksShelfView {
|
||||||
|
|
|
@ -45,12 +45,12 @@
|
||||||
#define KEY_FONT_SIZE "fontSize"
|
#define KEY_FONT_SIZE "fontSize"
|
||||||
#define KEY_PAGE_DETAILS "pageDetails"
|
#define KEY_PAGE_DETAILS "pageDetails"
|
||||||
#define KEY_CURRENT_BOOK "currentBook"
|
#define KEY_CURRENT_BOOK "currentBook"
|
||||||
#define KEY_CURRENT_STORAGE "currentStorage"
|
#define KEY_CURRENT_FOLDER "currentFolder"
|
||||||
#define KEY_INVERT_COLORS "invertColors"
|
#define KEY_INVERT_COLORS "invertColors"
|
||||||
#define DEFAULT_FONT_SIZE 0
|
#define DEFAULT_FONT_SIZE 0
|
||||||
#define DEFAULT_PAGE_DETAILS 0
|
#define DEFAULT_PAGE_DETAILS 0
|
||||||
#define DEFAULT_CURRENT_BOOK QString()
|
#define DEFAULT_CURRENT_BOOK QString()
|
||||||
#define DEFAULT_CURRENT_STORAGE QString()
|
#define DEFAULT_CURRENT_FOLDER QString()
|
||||||
#define DEFAULT_INVERT_COLORS false
|
#define DEFAULT_INVERT_COLORS false
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
@ -198,16 +198,17 @@ BooksSettings::BooksSettings(QObject* aParent) :
|
||||||
iFontSize(new MGConfItem(DCONF_PATH KEY_FONT_SIZE, this)),
|
iFontSize(new MGConfItem(DCONF_PATH KEY_FONT_SIZE, this)),
|
||||||
iPageDetails(new MGConfItem(DCONF_PATH KEY_PAGE_DETAILS, this)),
|
iPageDetails(new MGConfItem(DCONF_PATH KEY_PAGE_DETAILS, this)),
|
||||||
iInvertColors(new MGConfItem(DCONF_PATH KEY_INVERT_COLORS, this)),
|
iInvertColors(new MGConfItem(DCONF_PATH KEY_INVERT_COLORS, this)),
|
||||||
iCurrentStorage(new MGConfItem(DCONF_PATH KEY_CURRENT_STORAGE, this)),
|
iCurrentFolder(new MGConfItem(DCONF_PATH KEY_CURRENT_FOLDER, this)),
|
||||||
iCurrentBookPath(new MGConfItem(DCONF_PATH KEY_CURRENT_BOOK, this)),
|
iCurrentBookPath(new MGConfItem(DCONF_PATH KEY_CURRENT_BOOK, this)),
|
||||||
iCurrentBook(NULL)
|
iCurrentBook(NULL)
|
||||||
{
|
{
|
||||||
iTextStyle = new TextStyle(fontSize());
|
iTextStyle = new TextStyle(fontSize());
|
||||||
updateCurrentBook();
|
updateCurrentBook();
|
||||||
|
updateCurrentStorage();
|
||||||
connect(iFontSize, SIGNAL(valueChanged()), SLOT(onFontSizeValueChanged()));
|
connect(iFontSize, SIGNAL(valueChanged()), SLOT(onFontSizeValueChanged()));
|
||||||
connect(iPageDetails, SIGNAL(valueChanged()), SIGNAL(pageDetailsChanged()));
|
connect(iPageDetails, SIGNAL(valueChanged()), SIGNAL(pageDetailsChanged()));
|
||||||
connect(iInvertColors, SIGNAL(valueChanged()), SIGNAL(invertColorsChanged()));
|
connect(iInvertColors, SIGNAL(valueChanged()), SIGNAL(invertColorsChanged()));
|
||||||
connect(iCurrentStorage, SIGNAL(valueChanged()), SIGNAL(currentStorageChanged()));
|
connect(iCurrentFolder, SIGNAL(valueChanged()), SLOT(onCurrentFolderChanged()));
|
||||||
connect(iCurrentBookPath, SIGNAL(valueChanged()), SLOT(onCurrentBookPathChanged()));
|
connect(iCurrentBookPath, SIGNAL(valueChanged()), SLOT(onCurrentBookPathChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,17 +265,38 @@ BooksSettings::setInvertColors(
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
BooksSettings::currentStorage() const
|
BooksSettings::currentFolder() const
|
||||||
{
|
{
|
||||||
return iCurrentStorage->value(DEFAULT_CURRENT_STORAGE).toString();
|
return iCurrentFolder->value(DEFAULT_CURRENT_FOLDER).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BooksSettings::setCurrentStorage(
|
BooksSettings::setCurrentFolder(
|
||||||
QString aValue)
|
QString aValue)
|
||||||
{
|
{
|
||||||
HDEBUG(aValue);
|
HDEBUG(aValue);
|
||||||
iCurrentStorage->set(aValue);
|
iCurrentFolder->set(aValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BooksSettings::onCurrentFolderChanged()
|
||||||
|
{
|
||||||
|
if (updateCurrentStorage()) {
|
||||||
|
Q_EMIT currentStorageChanged();
|
||||||
|
}
|
||||||
|
Q_EMIT currentFolderChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BooksSettings::updateCurrentStorage()
|
||||||
|
{
|
||||||
|
BooksStorageManager* mgr = BooksStorageManager::instance();
|
||||||
|
BooksStorage storage = mgr->storageForPath(currentFolder());
|
||||||
|
if (storage.isValid() && storage.device() != iCurrentStorageDevice) {
|
||||||
|
iCurrentStorageDevice = storage.device();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject*
|
QObject*
|
||||||
|
|
|
@ -48,7 +48,8 @@ class BooksSettings : public QObject
|
||||||
Q_PROPERTY(int pageDetails READ pageDetails WRITE setPageDetails NOTIFY pageDetailsChanged)
|
Q_PROPERTY(int pageDetails READ pageDetails WRITE setPageDetails NOTIFY pageDetailsChanged)
|
||||||
Q_PROPERTY(bool invertColors READ invertColors WRITE setInvertColors NOTIFY invertColorsChanged)
|
Q_PROPERTY(bool invertColors READ invertColors WRITE setInvertColors NOTIFY invertColorsChanged)
|
||||||
Q_PROPERTY(QObject* currentBook READ currentBook WRITE setCurrentBook NOTIFY currentBookChanged)
|
Q_PROPERTY(QObject* currentBook READ currentBook WRITE setCurrentBook NOTIFY currentBookChanged)
|
||||||
Q_PROPERTY(QString currentStorage READ currentStorage WRITE setCurrentStorage NOTIFY currentStorageChanged)
|
Q_PROPERTY(QString currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged)
|
||||||
|
Q_PROPERTY(QString currentStorage READ currentStorage NOTIFY currentStorageChanged)
|
||||||
class TextStyle;
|
class TextStyle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -74,8 +75,10 @@ public:
|
||||||
QObject* currentBook() const;
|
QObject* currentBook() const;
|
||||||
void setCurrentBook(QObject* aBook);
|
void setCurrentBook(QObject* aBook);
|
||||||
|
|
||||||
QString currentStorage() const;
|
QString currentFolder() const;
|
||||||
void setCurrentStorage(QString aValue);
|
void setCurrentFolder(QString aValue);
|
||||||
|
|
||||||
|
QString currentStorage() const { return iCurrentStorageDevice; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fontSizeChanged();
|
void fontSizeChanged();
|
||||||
|
@ -83,24 +86,28 @@ signals:
|
||||||
void pageDetailsChanged();
|
void pageDetailsChanged();
|
||||||
void invertColorsChanged();
|
void invertColorsChanged();
|
||||||
void currentBookChanged();
|
void currentBookChanged();
|
||||||
|
void currentFolderChanged();
|
||||||
void currentStorageChanged();
|
void currentStorageChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onFontSizeValueChanged();
|
void onFontSizeValueChanged();
|
||||||
void onCurrentBookPathChanged();
|
void onCurrentBookPathChanged();
|
||||||
|
void onCurrentFolderChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateRenderType();
|
void updateRenderType();
|
||||||
bool updateCurrentBook();
|
bool updateCurrentBook();
|
||||||
|
bool updateCurrentStorage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MGConfItem* iFontSize;
|
MGConfItem* iFontSize;
|
||||||
MGConfItem* iPageDetails;
|
MGConfItem* iPageDetails;
|
||||||
MGConfItem* iInvertColors;
|
MGConfItem* iInvertColors;
|
||||||
MGConfItem* iCurrentStorage;
|
MGConfItem* iCurrentFolder;
|
||||||
MGConfItem* iCurrentBookPath;
|
MGConfItem* iCurrentBookPath;
|
||||||
shared_ptr<ZLTextStyle> iTextStyle;
|
shared_ptr<ZLTextStyle> iTextStyle;
|
||||||
BooksBook* iCurrentBook;
|
BooksBook* iCurrentBook;
|
||||||
|
QString iCurrentStorageDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
QML_DECLARE_TYPE(BooksSettings)
|
QML_DECLARE_TYPE(BooksSettings)
|
||||||
|
|
Loading…
Reference in a new issue