[app] Dropped BooksFeedback

Now that QtFeedback is allowed in Jolla Store, it's no longer needed
This commit is contained in:
Slava Monich 2020-09-17 01:30:34 +03:00
parent 4a4a78e769
commit 429c58efb0
6 changed files with 43 additions and 273 deletions

View file

@ -109,7 +109,6 @@ SOURCES += \
src/BooksCoverModel.cpp \
src/BooksCoverWidget.cpp \
src/BooksDialogManager.cpp \
src/BooksFeedback.cpp \
src/BooksHints.cpp \
src/BooksImageProvider.cpp \
src/BooksImportModel.cpp \
@ -153,7 +152,6 @@ HEADERS += \
src/BooksCoverWidget.h \
src/BooksDefs.h \
src/BooksDialogManager.h \
src/BooksFeedback.h \
src/BooksHints.h \
src/BooksImageProvider.h \
src/BooksImportModel.h \

View file

@ -32,6 +32,7 @@
*/
import QtQuick 2.0
import QtFeedback 5.0
import Sailfish.Silica 1.0
import org.nemomobile.notifications 1.0
import harbour.books 1.0
@ -45,7 +46,8 @@ SilicaFlickable {
id: root
property variant book
property bool selecting
readonly property bool selecting: bookView.currentItem && bookView.currentItem.selecting
readonly property bool selectionEmpty: !bookView.currentItem || bookView.currentItem.selectionEmpty
signal closeBook()
signal pageClicked(var page)
@ -71,6 +73,7 @@ SilicaFlickable {
readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
readonly property bool haveKeyAction: haveVolumeUpAction || haveVolumeDownAction
property var hapticFeedback
property var linkMenu
property var imageView
property var footnoteView
@ -89,6 +92,17 @@ SilicaFlickable {
onBookChanged: if (!book) pager.currentPage = 0
onSelectingChanged: {
if (selecting) {
if (!hapticFeedback) {
hapticFeedback = hapticFeedbackComponent.createObject(root)
}
hapticFeedback.play()
} else if (!selectionEmpty) {
notification.publish()
}
}
Component {
id: linkMenuComponent
BooksLinkMenu { }
@ -104,6 +118,11 @@ SilicaFlickable {
BooksFootnoteView { }
}
Component {
id: hapticFeedbackComponent
ThemeEffect { effect: ThemeEffect.Press }
}
PullDownMenu {
MenuItem {
//% "Back to library"
@ -143,6 +162,7 @@ SilicaFlickable {
flickDeceleration: maximumFlickVelocity
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
spacing: Theme.paddingMedium
opacity: loading ? 0 : 1
visible: opacity > 0
@ -199,25 +219,10 @@ SilicaFlickable {
rightSpaceReserved: pageTools.visible ? pageTools.rightSpaceUsed: 0
titleVisible: _currentState.title
pageNumberVisible: _currentState.page
currentPage: bookViewWatcher.currentIndex == index
currentPage: bookViewWatcher.currentIndex === index
title: bookModel.title
onJumpToPage: bookView.jumpTo(page)
onPushPosition: stackModel.pushPosition(position) // bookView.jumpTo(page)
onCurrentPageChanged: {
if (currentPage) {
root.selecting = pageView.selecting
}
}
onSelectingChanged: {
if (currentPage) {
if (pageView.selecting) {
BooksFeedback.start("push_gesture")
} else {
notification.publish()
}
root.selecting = pageView.selecting
}
}
onPageClicked: {
root.pageClicked(index)
if (Settings.turnPageByTap && mouseY > bookModel.topMargin && mouseY < (pageView.height - bookModel.topMargin)) {
@ -235,28 +240,22 @@ SilicaFlickable {
}
}
onImagePressed: {
if (currentPage) {
if (!imageView) {
imageView = imageViewComponent.createObject(root)
}
imageView.show(url,rect)
if (!imageView) {
imageView = imageViewComponent.createObject(root)
}
imageView.show(url,rect)
}
onBrowserLinkPressed: {
if (currentPage) {
if (!linkMenu) {
linkMenu = linkMenuComponent.createObject(root)
}
linkMenu.show(url)
if (!linkMenu) {
linkMenu = linkMenuComponent.createObject(root)
}
linkMenu.show(url)
}
onFootnotePressed: {
if (bookViewWatcher.currentIndex == index) {
if (!footnoteView) {
footnoteView = footnoteViewComponent.createObject(root)
}
footnoteView.show(touchX,touchY,text,url)
if (!footnoteView) {
footnoteView = footnoteViewComponent.createObject(root)
}
footnoteView.show(touchX,touchY,text,url)
}
}

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2015-2018 Jolla Ltd.
Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
Copyright (C) 2015-2020 Jolla Ltd.
Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@ -8,14 +8,15 @@
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 Jolla Ltd nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. Neither the names of the copyright holders 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
@ -44,6 +45,7 @@ Item {
property alias topMargin: widget.topMargin
property alias bottomMargin: widget.bottomMargin
property alias selecting: widget.selecting
property alias selectionEmpty: widget.selectionEmpty
property alias currentPage: widget.currentPage
property alias title: titleLabel.text
property real leftSpaceReserved

View file

@ -1,168 +0,0 @@
/*
* Copyright (C) 2017-2020 Jolla Ltd.
* Copyright (C) 2017-2020 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:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the names of the copyright holders 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 "BooksFeedback.h"
#include "HarbourDebug.h"
#include <QDBusConnection>
#include <QDBusAbstractInterface>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#define NGFD_CONNECTION QDBusConnection::systemBus()
#define NGFD_SERVICE "com.nokia.NonGraphicFeedback1.Backend"
#define NGFD_PATH "/com/nokia/NonGraphicFeedback1"
#define NGFD_INTERFACE "com.nokia.NonGraphicFeedback1"
#define NGFD_STATUS_FAILED (0)
#define NGFD_STATUS_COMPLETED (1)
#define NGFD_STATUS_PLAYING (2)
#define NGFD_STATUS_PAUSED (3)
class BooksFeedback::Private : QDBusAbstractInterface {
Q_OBJECT
public:
Private(QObject* aParent);
bool start(QString aEvent);
void stop();
void stop(uint aEventId);
public Q_SLOTS:
void onPlayFinished(QDBusPendingCallWatcher* aCall);
void onStatusChanged(uint aId, uint aStatus);
Q_SIGNALS:
void Status(uint aId, uint aStatus);
public:
uint iEventId;
bool iPlaying;
};
BooksFeedback::Private::Private(QObject* aParent) :
QDBusAbstractInterface(NGFD_SERVICE,NGFD_PATH, NGFD_INTERFACE,
NGFD_CONNECTION, aParent), iEventId(0), iPlaying(false)
{
connect(this, SIGNAL(Status(uint,uint)), SLOT(onStatusChanged(uint,uint)));
}
bool BooksFeedback::Private::start(QString aEvent)
{
if (!iPlaying) {
iPlaying = true;
HDEBUG(aEvent);
connect(new QDBusPendingCallWatcher(asyncCall(QString("Play"),
aEvent, QVariantMap()), this),
SIGNAL(finished(QDBusPendingCallWatcher*)),
SLOT(onPlayFinished(QDBusPendingCallWatcher*)));
return true;
}
return false;
}
void BooksFeedback::Private::stop(uint aEventId)
{
HDEBUG(aEventId);
asyncCall(QString("Stop"), iPlaying);
}
void BooksFeedback::Private::stop()
{
if (iPlaying) {
iPlaying = false;
if (iEventId) {
stop(iEventId);
iEventId = 0;
}
}
}
void BooksFeedback::Private::onPlayFinished(QDBusPendingCallWatcher* aCall)
{
QDBusPendingReply<uint> reply = *aCall;
if (reply.isError()) {
HWARN(reply.error());
iPlaying = false;
} else {
uint eventId= reply.value();
HDEBUG(eventId);
if (iPlaying) {
iEventId = eventId;
} else {
stop(eventId);
}
}
aCall->deleteLater();
}
void BooksFeedback::Private::onStatusChanged(uint aId, uint aStatus)
{
HDEBUG(aId << aStatus);
switch (aStatus) {
case NGFD_STATUS_PLAYING:
case NGFD_STATUS_PAUSED:
break;
default:
if (aId == iEventId) {
iEventId = 0;
iPlaying = false;
}
break;
}
}
BooksFeedback::BooksFeedback(QObject* aParent) :
QObject(aParent),
iPrivate(new Private(this))
{
}
bool BooksFeedback::start(QString aEvent)
{
return iPrivate->start(aEvent);
}
void BooksFeedback::stop()
{
iPrivate->stop();
}
// Callback for qmlRegisterSingletonType<BooksFeedback>
QObject* BooksFeedback::createSingleton(QQmlEngine*, QJSEngine*)
{
return new BooksFeedback;
}
#include "BooksFeedback.moc"

View file

@ -1,59 +0,0 @@
/*
* Copyright (C) 2017-2020 Jolla Ltd.
* Copyright (C) 2017-2020 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:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the names of the copyright holders 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_FEEDBACK_H
#define BOOKS_FEEDBACK_H
#include <QtQml>
class BooksFeedback : public QObject
{
Q_OBJECT
public:
explicit BooksFeedback(QObject* aParent = NULL);
Q_INVOKABLE bool start(QString aEvent);
Q_INVOKABLE void stop();
// Callback for qmlRegisterSingletonType<BooksFeedback>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
private:
class Private;
Private* iPrivate;
};
QML_DECLARE_TYPE(BooksFeedback)
#endif // BOOKS_FEEDBACK_H

View file

@ -46,7 +46,6 @@
#include "BooksListWatcher.h"
#include "BooksCoverWidget.h"
#include "BooksTaskQueue.h"
#include "BooksFeedback.h"
#include "BooksHints.h"
#include "HarbourDisplayBlanking.h"
@ -88,7 +87,6 @@ Q_DECL_EXPORT int main(int argc, char **argv)
BOOKS_QML_REGISTER(HarbourDisplayBlanking, "DisplayBlanking");
BOOKS_QML_REGISTER_SINGLETON(HarbourTheme, "HarbourTheme");
BOOKS_QML_REGISTER_SINGLETON(BooksHints, "BooksHints");
BOOKS_QML_REGISTER_SINGLETON(BooksFeedback, "BooksFeedback");
QLocale locale;
QTranslator* translator = new QTranslator(app);