[app] Added left swipe hint
This commit is contained in:
parent
c47ab22077
commit
af87d79ceb
15 changed files with 228 additions and 7 deletions
|
@ -94,6 +94,7 @@ SOURCES += \
|
|||
src/BooksCoverModel.cpp \
|
||||
src/BooksCoverWidget.cpp \
|
||||
src/BooksDialogManager.cpp \
|
||||
src/BooksHints.cpp \
|
||||
src/BooksImportModel.cpp \
|
||||
src/BooksListWatcher.cpp \
|
||||
src/BooksLoadingProperty.cpp \
|
||||
|
@ -126,6 +127,7 @@ HEADERS += \
|
|||
src/BooksCoverWidget.h \
|
||||
src/BooksDefs.h \
|
||||
src/BooksDialogManager.h \
|
||||
src/BooksHints.h \
|
||||
src/BooksImportModel.h \
|
||||
src/BooksItem.h \
|
||||
src/BooksListWatcher.h \
|
||||
|
|
|
@ -55,21 +55,21 @@ SilicaFlickable {
|
|||
id: defaultFontMenuItem
|
||||
//% "Use default fonts"
|
||||
text: qsTrId("book-font-default")
|
||||
enabled: globalSettings.fontSize != Settings.DefaultFontSize
|
||||
onClicked: globalSettings.fontSize = Settings.DefaultFontSize
|
||||
enabled: globalSettings.fontSize != BooksSettings.DefaultFontSize
|
||||
onClicked: globalSettings.fontSize = BooksSettings.DefaultFontSize
|
||||
}
|
||||
MenuItem {
|
||||
id: smallerFontMenuItem
|
||||
//% "Use smaller fonts"
|
||||
text: qsTrId("book-font-smaller")
|
||||
enabled: globalSettings.fontSize >= Settings.MinFontSize
|
||||
enabled: globalSettings.fontSize >= BooksSettings.MinFontSize
|
||||
onClicked: globalSettings.fontSize -= 1
|
||||
}
|
||||
MenuItem {
|
||||
id: largerFontMenuItem
|
||||
//% "Use larger fonts"
|
||||
text: qsTrId("book-font-larger")
|
||||
enabled: globalSettings.fontSize <= Settings.MaxFontSize
|
||||
enabled: globalSettings.fontSize <= BooksSettings.MaxFontSize
|
||||
onClicked: globalSettings.fontSize += 1
|
||||
}
|
||||
MenuItem {
|
||||
|
|
|
@ -39,7 +39,8 @@ ApplicationWindow {
|
|||
|
||||
property variant currentShelf: mainPage.currentShelf
|
||||
|
||||
Settings { id: globalSettings }
|
||||
BooksSettings { id: globalSettings }
|
||||
BooksHints { id: globalHints }
|
||||
|
||||
initialPage: BooksMainPage { id: mainPage }
|
||||
|
||||
|
|
|
@ -254,4 +254,30 @@ SilicaFlickable {
|
|||
id: startAnimationTimer
|
||||
interval: 2000
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: leftSwipeHintLoader
|
||||
anchors.fill: parent
|
||||
active: globalHints.storageLeftSwipe < MaximumHintCount || running
|
||||
property bool running
|
||||
sourceComponent: Component {
|
||||
BooksStorageLeftSwipeHint {
|
||||
property bool hintCanBeEnabled: !_loading &&
|
||||
storageView.visible &&
|
||||
shelfIndex == storageListWatcher.currentIndex &&
|
||||
(shelfIndex+1) < storageModel.count &&
|
||||
globalHints.storageLeftSwipe < MaximumHintCount
|
||||
|
||||
hintEnabled: hintCanBeEnabled && !hintDelayTimer.running
|
||||
onHintShown: globalHints.storageLeftSwipe++
|
||||
onHintRunningChanged: leftSwipeHintLoader.running = hintRunning
|
||||
onHintCanBeEnabledChanged: if (hintCanBeEnabled) hintDelayTimer.restart()
|
||||
Component.onCompleted: if (hintCanBeEnabled) hintDelayTimer.restart()
|
||||
Timer {
|
||||
id: hintDelayTimer
|
||||
interval: 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
47
app/qml/BooksStorageLeftSwipeHint.qml
Normal file
47
app/qml/BooksStorageLeftSwipeHint.qml
Normal file
|
@ -0,0 +1,47 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Loader {
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
active: hintEnabled || hintRunning
|
||||
|
||||
property bool hintEnabled
|
||||
property bool hintRunning
|
||||
signal hintShown()
|
||||
|
||||
sourceComponent: Component {
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
property bool cancelled
|
||||
function showHint() {
|
||||
hintRunning = true
|
||||
hintShownTimer.restart()
|
||||
touchInteractionHint.start()
|
||||
}
|
||||
Connections {
|
||||
target: root
|
||||
onHintEnabledChanged: if (root.hintEnabled) showHint();
|
||||
}
|
||||
Component.onCompleted: if (root.hintEnabled) showHint();
|
||||
InteractionHintLabel {
|
||||
//% "Swipe left to see what's on the SD-card"
|
||||
text: qsTrId("storage-view-swipe-left-hint")
|
||||
anchors.bottom: parent.bottom
|
||||
opacity: touchInteractionHint.running ? 1.0 : 0.0
|
||||
Behavior on opacity { FadeAnimation { duration: 1000 } }
|
||||
}
|
||||
TouchInteractionHint {
|
||||
id: touchInteractionHint
|
||||
direction: TouchInteraction.Left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onRunningChanged: hintRunning = running
|
||||
}
|
||||
Timer {
|
||||
id: hintShownTimer
|
||||
interval: 1000
|
||||
onTriggered: root.hintShown()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@
|
|||
#include <QString>
|
||||
|
||||
#define BOOKS_APP_NAME "harbour-books"
|
||||
#define BOOKS_DCONF_ROOT "/apps/" BOOKS_APP_NAME "/"
|
||||
#define BOOKS_DATA_ROOT "usr/share/" BOOKS_APP_NAME
|
||||
#define BOOKS_QML_DIR BOOKS_DATA_ROOT "/qml"
|
||||
#define BOOKS_ICONS_DIR BOOKS_DATA_ROOT "/icons"
|
||||
|
|
63
app/src/BooksHints.cpp
Normal file
63
app/src/BooksHints.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (C) 2015 Jolla Ltd.
|
||||
* Contact: Slava Monich <slava.monich@jolla.com>
|
||||
*
|
||||
* 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 Nemo Mobile 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "BooksHints.h"
|
||||
#include "BooksDefs.h"
|
||||
#include "HarbourDebug.h"
|
||||
|
||||
#include <MGConfItem>
|
||||
|
||||
#define DCONF_PATH BOOKS_DCONF_ROOT "hints/"
|
||||
#define KEY_STORAGE_LEFT_SWIPE "storageLeftSwipt"
|
||||
#define DEFAULT_STORAGE_LEFT_SWIPE 0
|
||||
|
||||
BooksHints::BooksHints(QObject* aParent) :
|
||||
QObject(aParent),
|
||||
iStorageLeftSwipe(new MGConfItem(DCONF_PATH KEY_STORAGE_LEFT_SWIPE, this))
|
||||
{
|
||||
connect(iStorageLeftSwipe, SIGNAL(valueChanged()), SIGNAL(storageLeftSwipeChanged()));
|
||||
}
|
||||
|
||||
int
|
||||
BooksHints::storageLeftSwipe() const
|
||||
{
|
||||
return iStorageLeftSwipe->value(DEFAULT_STORAGE_LEFT_SWIPE).toInt();
|
||||
}
|
||||
|
||||
void
|
||||
BooksHints::setStorageLeftSwipe(
|
||||
int aValue)
|
||||
{
|
||||
HDEBUG(aValue);
|
||||
iStorageLeftSwipe->set(aValue);
|
||||
}
|
62
app/src/BooksHints.h
Normal file
62
app/src/BooksHints.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2015 Jolla Ltd.
|
||||
* Contact: Slava Monich <slava.monich@jolla.com>
|
||||
*
|
||||
* 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 Nemo Mobile 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BOOKS_HINTS_H
|
||||
#define BOOKS_HINTS_H
|
||||
|
||||
#include "BooksTypes.h"
|
||||
#include <QtQml>
|
||||
|
||||
class MGConfItem;
|
||||
|
||||
class BooksHints : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int storageLeftSwipe READ storageLeftSwipe WRITE setStorageLeftSwipe NOTIFY storageLeftSwipeChanged)
|
||||
|
||||
public:
|
||||
explicit BooksHints(QObject* aParent = NULL);
|
||||
|
||||
int storageLeftSwipe() const;
|
||||
void setStorageLeftSwipe(int aValue);
|
||||
|
||||
signals:
|
||||
void storageLeftSwipeChanged();
|
||||
|
||||
private:
|
||||
MGConfItem* iStorageLeftSwipe;
|
||||
};
|
||||
|
||||
QML_DECLARE_TYPE(BooksHints)
|
||||
|
||||
#endif // BOOKS_HINTS_H
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include <MGConfItem>
|
||||
|
||||
#define DCONF_PATH "/apps/" BOOKS_APP_NAME "/"
|
||||
#define DCONF_PATH BOOKS_DCONF_ROOT
|
||||
#define KEY_FONT_SIZE "fontSize"
|
||||
#define KEY_PAGE_DETAILS "pageDetails"
|
||||
#define KEY_CURRENT_BOOK "currentBook"
|
||||
|
|
|
@ -170,6 +170,7 @@ void ZLibrary::run(ZLApplication* aApp)
|
|||
|
||||
QQmlContext* root = view->rootContext();
|
||||
root->setContextProperty("PointsPerInch", BOOKS_PPI);
|
||||
root->setContextProperty("MaximumHintCount", 1);
|
||||
root->setContextProperty("DoubleClickInterval",
|
||||
qApp->styleHints()->mouseDoubleClickInterval());
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "BooksListWatcher.h"
|
||||
#include "BooksCoverWidget.h"
|
||||
#include "BooksTaskQueue.h"
|
||||
#include "BooksHints.h"
|
||||
|
||||
#include "HarbourDebug.h"
|
||||
#include "HarbourLib.h"
|
||||
|
@ -76,7 +77,8 @@ Q_DECL_EXPORT int main(int argc, char **argv)
|
|||
BOOKS_QML_REGISTER(BooksPageWidget, "PageWidget");
|
||||
BOOKS_QML_REGISTER(BooksListWatcher, "ListWatcher");
|
||||
BOOKS_QML_REGISTER(BooksCoverWidget, "BookCover");
|
||||
BOOKS_QML_REGISTER(BooksSettings, "Settings");
|
||||
BOOKS_QML_REGISTER(BooksSettings, "BooksSettings");
|
||||
BOOKS_QML_REGISTER(BooksHints, "BooksHints");
|
||||
HarbourLib::registerTypes(BOOKS_QML_PLUGIN,
|
||||
BOOKS_QML_PLUGIN_V1, BOOKS_QML_PLUGIN_V2);
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@
|
|||
<source>Delete all books</source>
|
||||
<translation>Poista kaikki kirjat</translation>
|
||||
</message>
|
||||
<message id="storage-view-swipe-left-hint">
|
||||
<source>Swipe left to see what's on the SD-card</source>
|
||||
<translation>Näytä muistikortin sisältö pyyhkäisemällä vasemmalle</translation>
|
||||
</message>
|
||||
<message id="import-view-import-n-books" numerus="yes">
|
||||
<source>Import %0 book(s)</source>
|
||||
<translation>
|
||||
|
|
|
@ -55,6 +55,10 @@
|
|||
<source>Delete all books</source>
|
||||
<translation>Удалить все книги</translation>
|
||||
</message>
|
||||
<message id="storage-view-swipe-left-hint">
|
||||
<source>Swipe left to see what's on the SD-card</source>
|
||||
<translation>Проведите влево, вдруг что-нибудь есть на карте памяти</translation>
|
||||
</message>
|
||||
<message id="import-view-import-n-books" numerus="yes">
|
||||
<source>Import %0 book(s)</source>
|
||||
<translation>
|
||||
|
|
|
@ -54,6 +54,10 @@
|
|||
<source>Delete all books</source>
|
||||
<translation>Ta bort alla böcker</translation>
|
||||
</message>
|
||||
<message id="storage-view-swipe-left-hint">
|
||||
<source>Swipe left to see what's on the SD-card</source>
|
||||
<translation>Svep åt vänster för att se vad som finns på SD-kortet</translation>
|
||||
</message>
|
||||
<message id="import-view-import-n-books" numerus="yes">
|
||||
<source>Import %0 book(s)</source>
|
||||
<translation>
|
||||
|
|
|
@ -54,6 +54,10 @@
|
|||
<source>Delete all books</source>
|
||||
<translation>Delete all books</translation>
|
||||
</message>
|
||||
<message id="storage-view-swipe-left-hint">
|
||||
<source>Swipe left to see what's on the SD-card</source>
|
||||
<translation>Swipe left to see what's on the SD-card</translation>
|
||||
</message>
|
||||
<message id="import-view-import-n-books" numerus="yes">
|
||||
<source>Import %0 book(s)</source>
|
||||
<translation>
|
||||
|
|
Loading…
Reference in a new issue