[app] Made BooksHints a singleton

This commit is contained in:
Slava Monich 2020-02-03 04:33:57 +02:00
parent 4bc47ef775
commit d2bc2d10cd
5 changed files with 37 additions and 29 deletions

View file

@ -52,7 +52,6 @@ ApplicationWindow {
property variant currentShelf: mainPage.currentShelf
BooksHints { id: globalHints }
DisplayBlanking {
pauseRequested: Qt.application.active &&
Settings.currentBook &&

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:
@ -313,7 +313,7 @@ Item {
Loader {
id: leftSwipeHintLoader
anchors.fill: parent
active: globalHints.storageLeftSwipe < MaximumHintCount || running
active: BooksHints.storageLeftSwipe < MaximumHintCount || running
property bool running
sourceComponent: Component {
HarbourHorizontalSwipeHint {
@ -321,12 +321,12 @@ Item {
storageView.visible &&
shelfIndex == storageListWatcher.currentIndex &&
(shelfIndex+1) < storageModel.count &&
globalHints.storageLeftSwipe < MaximumHintCount
BooksHints.storageLeftSwipe < MaximumHintCount
//% "Swipe left to see what's on the SD-card"
text: qsTrId("harbour-books-storage-view-swipe_left_hint")
swipeRight: false
onHintShown: globalHints.storageLeftSwipe++
onHintShown: BooksHints.storageLeftSwipe++
onHintRunningChanged: leftSwipeHintLoader.running = hintRunning
}
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 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
* 1. 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
* 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.
* * 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.
* 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
@ -61,3 +61,9 @@ BooksHints::setStorageLeftSwipe(
HDEBUG(aValue);
iStorageLeftSwipe->set(aValue);
}
// Callback for qmlRegisterSingletonType<BooksHints>
QObject* BooksHints::createSingleton(QQmlEngine*, QJSEngine*)
{
return new BooksHints;
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 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
* 1. 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
* 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.
* * 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.
* 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
@ -50,6 +50,9 @@ public:
int storageLeftSwipe() const;
void setStorageLeftSwipe(int aValue);
// Callback for qmlRegisterSingletonType<BooksHints>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
signals:
void storageLeftSwipeChanged();

View file

@ -83,9 +83,9 @@ 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(BooksHints, "BooksHints");
BOOKS_QML_REGISTER(BooksSettings, "BooksSettings");
BOOKS_QML_REGISTER(HarbourDisplayBlanking, "DisplayBlanking");
BOOKS_QML_REGISTER_SINGLETON(BooksHints, "BooksHints");
BOOKS_QML_REGISTER_SINGLETON(BooksFeedback, "BooksFeedback");
QLocale locale;