[app] Tweaking folder UI

This commit is contained in:
Slava Monich 2015-11-29 23:18:09 +02:00
parent 89f79e2492
commit 8a4e131452
6 changed files with 34 additions and 11 deletions

View file

@ -130,10 +130,7 @@ MouseArea {
}
onPressAndHold: {
if (!shelfView.editMode) {
var index = gridView.indexAt(mouseX + gridView.contentX, mouseY + currentShelfView.contentY)
if (index === pressedItemIndex) {
shelfView.startEditing()
}
shelfView.startEditing()
}
}
onPositionChanged: {

View file

@ -47,7 +47,7 @@ Item {
//% "No books"
text: qsTrId("shelf-view-no-books")
visible: footerState == 2
visible: footerState == 2 && !editMode
anchors.centerIn: parent
}

View file

@ -32,10 +32,14 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
BackgroundItem {
MouseArea {
id: root
implicitHeight: column.implicitHeight
property alias text: label.text
property bool currentFolder
property bool _highlighted: pressed
property color _highlightedColor: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity)
property bool _showPress: !currentFolder && (_highlighted || pressTimer.running)
Column {
id: column
@ -74,7 +78,7 @@ BackgroundItem {
leftMargin: Theme.paddingMedium
verticalCenter: parent.verticalCenter
}
color: (!root.enabled || pressed) ? Theme.highlightColor : Theme.primaryColor
color: (currentFolder || pressed) ? Theme.highlightColor : Theme.primaryColor
Behavior on color { ColorAnimation { duration: 100 } }
}
}
@ -129,4 +133,17 @@ BackgroundItem {
}
*/
}
onPressed: pressTimer.start()
onCanceled: pressTimer.stop()
Rectangle {
anchors.fill: parent
color: _showPress ? _highlightedColor : "transparent"
}
Timer {
id: pressTimer
interval: 50
}
}

View file

@ -175,10 +175,16 @@ SilicaFlickable {
BooksShelfTitle {
width: grid.width
text: model.name
enabled: model.index < (pathModel.count-1)
currentFolder: model.index === (pathModel.count-1)
onClicked: {
console.log("switching to", model.path)
shelfModel.relativePath = model.path
if (currentFolder) {
if (editMode) {
console.log("how about renaming", model.name)
}
} else {
console.log("switching to", model.path)
shelfModel.relativePath = model.path
}
}
}
}

View file

@ -519,6 +519,7 @@ void BooksShelf::Counts::emitSignals(BooksShelf* aShelf)
BooksShelf::BooksShelf(QObject* aParent) :
QAbstractListModel(aParent),
iLoadBookList(true),
iLoadTask(NULL),
iDummyItemIndex(-1),
iEditMode(false),
@ -531,6 +532,7 @@ BooksShelf::BooksShelf(QObject* aParent) :
}
BooksShelf::BooksShelf(BooksStorage aStorage, QString aRelativePath) :
iLoadBookList(false),
iLoadTask(NULL),
iRelativePath(aRelativePath),
iStorage(aStorage),
@ -614,7 +616,7 @@ void BooksShelf::updatePath()
endRemoveRows();
}
iDummyItemIndex = -1;
if (!iPath.isEmpty()) loadBookList();
if (!iPath.isEmpty() && iLoadBookList) loadBookList();
Q_EMIT pathChanged();
if (oldDummyItemIndex != iDummyItemIndex) {
Q_EMIT dummyItemIndexChanged();

View file

@ -165,6 +165,7 @@ private:
class DeleteTask;
friend class Counts;
bool iLoadBookList;
QList<Data*> iList;
QList<DeleteTask*> iDeleteTasks;
LoadTask* iLoadTask;