diff --git a/app/qml/BooksBookView.qml b/app/qml/BooksBookView.qml index 687810e..6e97e3e 100644 --- a/app/qml/BooksBookView.qml +++ b/app/qml/BooksBookView.qml @@ -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 diff --git a/app/qml/BooksMain.qml b/app/qml/BooksMain.qml index b35124f..6afdf12 100644 --- a/app/qml/BooksMain.qml +++ b/app/qml/BooksMain.qml @@ -1,6 +1,6 @@ /* - Copyright (C) 2015-2019 Jolla Ltd. - Copyright (C) 2015-2019 Slava Monich + Copyright (C) 2015-2020 Jolla Ltd. + Copyright (C) 2015-2020 Slava Monich 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 && diff --git a/app/src/BooksDefs.h b/app/src/BooksDefs.h index 8e15c0a..41734b9 100644 --- a/app/src/BooksDefs.h +++ b/app/src/BooksDefs.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2015-2016 Jolla Ltd. - * Contact: Slava Monich + * Copyright (C) 2015-2020 Jolla Ltd. + * Copyright (C) 2015-2020 Slava Monich * * 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(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \ BOOKS_QML_PLUGIN_V2, name) +#define BOOKS_QML_REGISTER_SINGLETON(klass,name) \ + qmlRegisterSingletonType(BOOKS_QML_PLUGIN, BOOKS_QML_PLUGIN_V1, \ + BOOKS_QML_PLUGIN_V2, name, klass::createSingleton) #define BOOKS_STATE_FILE_SUFFIX ".state" diff --git a/app/src/BooksFeedback.cpp b/app/src/BooksFeedback.cpp index c0a65d7..fed19d5 100644 --- a/app/src/BooksFeedback.cpp +++ b/app/src/BooksFeedback.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2017 Jolla Ltd. - * Copyright (C) 2017 Slava Monich + * Copyright (C) 2017-2020 Jolla Ltd. + * Copyright (C) 2017-2020 Slava Monich * * 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 +QObject* BooksFeedback::createSingleton(QQmlEngine*, QJSEngine*) +{ + return new BooksFeedback; +} + #include "BooksFeedback.moc" diff --git a/app/src/BooksFeedback.h b/app/src/BooksFeedback.h index aa1c9e1..2666dcb 100644 --- a/app/src/BooksFeedback.h +++ b/app/src/BooksFeedback.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2017 Jolla Ltd. - * Copyright (C) 2017 Slava Monich + * Copyright (C) 2017-2020 Jolla Ltd. + * Copyright (C) 2017-2020 Slava Monich * * 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 + static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript); + private: class Private; Private* iPrivate; diff --git a/app/src/main.cpp b/app/src/main.cpp index 451fdce..b466589 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2015-2019 Jolla Ltd. - * Copyright (C) 2015-2019 Slava Monich + * Copyright (C) 2015-2020 Jolla Ltd. + * Copyright (C) 2015-2020 Slava Monich * * 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);