[app] Made BooksFeedback a singleton

And only do bzzzzz once, when selection is started.
This commit is contained in:
Slava Monich 2020-02-03 04:28:00 +02:00
parent d1f8cf015b
commit 4bc47ef775
6 changed files with 53 additions and 41 deletions

View file

@ -210,8 +210,9 @@ SilicaFlickable {
}
onSelectingChanged: {
if (currentPage) {
globalFeedback.start("push_gesture")
if (!pageView.selecting) {
if (pageView.selecting) {
BooksFeedback.start("push_gesture")
} else {
notification.publish()
}
root.selecting = pageView.selecting

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2015-2019 Jolla Ltd.
Copyright (C) 2015-2019 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:
@ -53,7 +53,6 @@ ApplicationWindow {
property variant currentShelf: mainPage.currentShelf
BooksHints { id: globalHints }
BooksFeedback { id: globalFeedback }
DisplayBlanking {
pauseRequested: Qt.application.active &&
Settings.currentBook &&

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2016 Jolla Ltd.
* Contact: 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 the BSD license as follows:
*
@ -8,15 +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
@ -58,6 +58,9 @@
#define BOOKS_QML_REGISTER(klass,name) \
qmlRegisterType<klass>(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \
BOOKS_QML_PLUGIN_V2, name)
#define BOOKS_QML_REGISTER_SINGLETON(klass,name) \
qmlRegisterSingletonType<klass>(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \
BOOKS_QML_PLUGIN_V2, name, klass::createSingleton)
#define BOOKS_STATE_FILE_SUFFIX ".state"

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Jolla Ltd.
* Copyright (C) 2017 Slava Monich <slava.monich@jolla.com>
* 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:
*
@ -8,15 +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
@ -159,4 +159,10 @@ void BooksFeedback::stop()
iPrivate->stop();
}
// Callback for qmlRegisterSingletonType<BooksFeedback>
QObject* BooksFeedback::createSingleton(QQmlEngine*, QJSEngine*)
{
return new BooksFeedback;
}
#include "BooksFeedback.moc"

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Jolla Ltd.
* Copyright (C) 2017 Slava Monich <slava.monich@jolla.com>
* 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:
*
@ -8,15 +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
@ -46,6 +46,9 @@ public:
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;

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2019 Jolla Ltd.
* Copyright (C) 2015-2019 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 the BSD license as follows:
*
@ -83,10 +83,10 @@ 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(BooksFeedback, "BooksFeedback");
BOOKS_QML_REGISTER(BooksHints, "BooksHints");
BOOKS_QML_REGISTER(BooksSettings, "BooksSettings");
BOOKS_QML_REGISTER(HarbourDisplayBlanking, "DisplayBlanking");
BOOKS_QML_REGISTER_SINGLETON(BooksFeedback, "BooksFeedback");
QLocale locale;
QTranslator* translator = new QTranslator(app);