Warning, /graphics/peruse/src/app/qml/Store.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) version 3, or any
0008  * later version accepted by the membership of KDE e.V. (or its
0009  * successor approved by the membership of KDE e.V.), which shall
0010  * act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019  *
0020  */
0021 
0022 import QtQuick 2.12
0023 import QtQuick.Controls 2.12 as QtControls
0024 import QtQuick.Dialogs 1.3
0025 
0026 import org.kde.kirigami 2.7 as Kirigami
0027 import org.kde.newstuff 1.0 as NewStuff
0028 
0029 import org.kde.peruse 0.1 as Peruse
0030 
0031 /**
0032  * @brief This holds the NewStuff list, for getting new books from the KDE store.
0033  */
0034 Kirigami.ScrollablePage {
0035     id: root;
0036     property string categoryName: "storePage";
0037     title: i18nc("title of the book store page", "Book Store");
0038     NewStuff.NewStuffList {
0039         configFile: peruseConfig.newstuffLocation;
0040         onMessage: { busy = false; messageLabel.text = message; }
0041         onIdleMessage: { busy = false; messageLabel.text = message; }
0042         onBusyMessage: { busy = true; messageLabel.text = message; }
0043         onErrorMessage: { busy = false; messageLabel.text = message; }
0044         property bool busy: false;
0045         onDownloadedItemClicked: {
0046             if(Array.isArray(installedFiles) && installedFiles.length > 0) {
0047                 applicationWindow().showBook(installedFiles[0], 0);
0048             }
0049             else if(installedFiles.length > 0) {
0050                 applicationWindow().showBook(installedFiles, 0);
0051             }
0052         }
0053         Item {
0054             anchors.fill: parent
0055             opacity: parent.busy ? 1 : 0
0056             Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } }
0057             Rectangle {
0058                 anchors.fill: parent
0059                 opacity: 0.8
0060                 color: Kirigami.Theme.backgroundColor
0061             }
0062             QtControls.BusyIndicator {
0063                 anchors {
0064                     top: parent.top
0065                     topMargin: parent.width / 3
0066                     left: parent.left
0067                     right: parent.right
0068                 }
0069                 running: parent.opacity > 0
0070                 QtControls.Label {
0071                     id: messageLabel
0072                     anchors {
0073                         horizontalCenter: parent.horizontalCenter
0074                         top: parent.bottom
0075                         topMargin: Kirigami.Units.largeSpacing
0076                     }
0077                 }
0078             }
0079         }
0080         Item {
0081             anchors.fill: parent;
0082             opacity: parent.count === 0 && !parent.busy ? 1 : 0
0083             Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } }
0084             Rectangle {
0085                 anchors.fill: parent
0086                 opacity: 0.8
0087                 color: Kirigami.Theme.backgroundColor
0088             }
0089             QtControls.Label {
0090                 anchors {
0091                     top: parent.top
0092                     topMargin: width / 3
0093                     left: parent.left
0094                     right: parent.right
0095                 }
0096                 horizontalAlignment: Text.AlignHCenter
0097                 text: i18nc("Message shown when the engine is not busy and there are no entries (which means the store connection is broken in some way, usually caused by a broken internet connection, or the store being down)", "Sorry, no books.\nThis is unusual, and likely means your internet is down, or the store is.");
0098             }
0099         }
0100     }
0101 }