[app] Added dconf option to turn pages by tapping the screen

This commit is contained in:
Slava Monich 2018-07-23 23:55:56 +03:00
parent be2b66f955
commit 278baef519
4 changed files with 38 additions and 4 deletions

View file

@ -213,6 +213,16 @@ SilicaFlickable {
}
onPageClicked: {
root.pageClicked(index)
if (Settings.turnPageByTap && mouseY > bookModel.topMargin && mouseY < (pageView.height - bookModel.topMargin)) {
if (mouseX < pageView.width/4) {
bookView.prevPage()
return
}
if (mouseX > pageView.width*3/4) {
bookView.nextPage()
return
}
}
if (!Settings.pageDetailsFixed) {
Settings.pageDetails = (Settings.pageDetails + 1) % _visibilityStates.length
}

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2015-2017 Jolla Ltd.
Contact: Slava Monich <slava.monich@jolla.com>
Copyright (C) 2015-2018 Jolla Ltd.
Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@ -51,7 +51,7 @@ Item {
property bool titleVisible
property bool pageNumberVisible
signal pageClicked()
signal pageClicked(var mouseX, var mouseY)
signal imagePressed(var url, var rect)
signal footnotePressed(var touchX, var touchY, var text, var url)
signal browserLinkPressed(var url)
@ -163,7 +163,7 @@ Item {
anchors.fill: parent
onClicked: {
if (widget.selectionEmpty) {
view.pageClicked()
view.pageClicked(mouseX, mouseY)
} else {
widget.clearSelection()
}

View file

@ -46,6 +46,7 @@
#define KEY_FONT_SIZE "fontSize"
#define KEY_PAGE_DETAILS "pageDetails"
#define KEY_PAGE_DETAILS_FIXED "pageDetailsFixed"
#define KEY_TURN_PAGE_BY_TAP "turnPageByTap"
#define KEY_CURRENT_BOOK "currentBook"
#define KEY_CURRENT_FOLDER "currentFolder"
#define KEY_REMOVABLE_ROOT "removableRoot"
@ -58,6 +59,7 @@
#define DEFAULT_FONT_SIZE 0
#define DEFAULT_PAGE_DETAILS 0
#define DEFAULT_PAGE_DETAILS_FIXED false
#define DEFAULT_TURN_PAGE_BY_TAP false
#define DEFAULT_CURRENT_BOOK QString()
#define DEFAULT_CURRENT_FOLDER QString()
#define DEFAULT_REMOVABLE_ROOT "Books"
@ -236,6 +238,7 @@ public:
MGConfItem* iFontSizeConf;
MGConfItem* iPageDetailsConf;
MGConfItem* iPageDetailsFixedConf;
MGConfItem* iTurnPageByTapConf;
MGConfItem* iInvertColorsConf;
MGConfItem* iKeepDisplayOnConf;
MGConfItem* iVolumeUpActionConf;
@ -258,6 +261,7 @@ BooksSettings::Private::Private(BooksSettings* aParent) :
iFontSizeConf(new MGConfItem(DCONF_PATH KEY_FONT_SIZE, this)),
iPageDetailsConf(new MGConfItem(DCONF_PATH KEY_PAGE_DETAILS, this)),
iPageDetailsFixedConf(new MGConfItem(DCONF_PATH KEY_PAGE_DETAILS_FIXED, this)),
iTurnPageByTapConf(new MGConfItem(DCONF_PATH KEY_TURN_PAGE_BY_TAP, this)),
iInvertColorsConf(new MGConfItem(DCONF_PATH KEY_INVERT_COLORS, this)),
iKeepDisplayOnConf(new MGConfItem(DCONF_PATH KEY_KEEP_DISPLAY_ON, this)),
iVolumeUpActionConf(new MGConfItem(DCONF_PATH KEY_VOLUME_UP_ACTION, this)),
@ -274,6 +278,7 @@ BooksSettings::Private::Private(BooksSettings* aParent) :
connect(iCurrentBookPathConf, SIGNAL(valueChanged()), SLOT(onCurrentBookPathChanged()));
connect(iPageDetailsConf, SIGNAL(valueChanged()), iParent, SIGNAL(pageDetailsChanged()));
connect(iPageDetailsFixedConf, SIGNAL(valueChanged()), iParent, SIGNAL(pageDetailsFixedChanged()));
connect(iTurnPageByTapConf, SIGNAL(valueChanged()), iParent, SIGNAL(turnPageByTapChanged()));
connect(iInvertColorsConf, SIGNAL(valueChanged()), iParent, SIGNAL(invertColorsChanged()));
connect(iInvertColorsConf, SIGNAL(valueChanged()), iParent, SIGNAL(pageBackgroundColorChanged()));
connect(iKeepDisplayOnConf, SIGNAL(valueChanged()), iParent, SIGNAL(keepDisplayOnChanged()));
@ -553,6 +558,20 @@ BooksSettings::setPageDetailsFixed(
iPrivate->iPageDetailsFixedConf->set(aValue);
}
bool
BooksSettings::turnPageByTap() const
{
return iPrivate->iTurnPageByTapConf->value(DEFAULT_TURN_PAGE_BY_TAP).toBool();
}
void
BooksSettings::setTurnPageByTap(
bool aValue)
{
HDEBUG(aValue);
iPrivate->iTurnPageByTapConf->set(aValue);
}
bool
BooksSettings::invertColors() const
{

View file

@ -49,6 +49,7 @@ class BooksSettings : public QObject
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(int pageDetails READ pageDetails WRITE setPageDetails NOTIFY pageDetailsChanged)
Q_PROPERTY(bool pageDetailsFixed READ pageDetailsFixed WRITE setPageDetailsFixed NOTIFY pageDetailsFixedChanged)
Q_PROPERTY(bool turnPageByTap READ turnPageByTap WRITE setTurnPageByTap NOTIFY turnPageByTapChanged)
Q_PROPERTY(bool invertColors READ invertColors WRITE setInvertColors NOTIFY invertColorsChanged)
Q_PROPERTY(bool keepDisplayOn READ keepDisplayOn WRITE setKeepDisplayOn NOTIFY keepDisplayOnChanged)
Q_PROPERTY(int volumeUpAction READ volumeUpAction WRITE setVolumeUpAction NOTIFY volumeUpActionChanged)
@ -101,6 +102,9 @@ public:
bool pageDetailsFixed() const;
void setPageDetailsFixed(bool aValue);
bool turnPageByTap() const;
void setTurnPageByTap(bool aValue);
shared_ptr<ZLTextStyle> textStyle(int aFontSizeAdjust) const;
bool invertColors() const;
@ -135,6 +139,7 @@ Q_SIGNALS:
void textStyleChanged();
void pageDetailsChanged();
void pageDetailsFixedChanged();
void turnPageByTapChanged();
void invertColorsChanged();
void keepDisplayOnChanged();
void volumeUpActionChanged();