Warning, /multimedia/amarok/src/context/applets/wikipedia/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /****************************************************************************************
0002  * Copyright (c) 2017 Malte Veerman <malte.veerman@gmail.com>                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 import QtQuick 2.4
0018 import QtQuick.Controls 1.4
0019 import QtQuick.Layouts 1.3
0020 import QtWebEngine 1.3
0021 import org.kde.amarok.qml 1.0 as AmarokQml
0022 import org.kde.amarok.wikipedia 1.0
0023 
0024 AmarokQml.Applet {
0025     id: applet
0026 
0027     ColumnLayout {
0028         anchors.fill: parent
0029 
0030         RowLayout {
0031             Layout.fillWidth: true
0032             Layout.alignment: Qt.AlignTop
0033 
0034             Button {
0035                 iconName: "go-previous"
0036                 enabled: content.canGoBack
0037                 Layout.alignment: Qt.AlignLeft
0038                 tooltip: i18n("Previous")
0039 
0040                 onClicked: content.goBack()
0041             }
0042             Button {
0043                 iconName: "go-next"
0044                 enabled: content.canGoForward
0045                 Layout.alignment: Qt.AlignLeft
0046                 tooltip: i18n("Next")
0047 
0048                 onClicked: content.goForward()
0049             }
0050             Button {
0051                 iconName: "view-refresh"
0052                 enabled: !content.loading
0053                 Layout.alignment: Qt.AlignLeft
0054                 tooltip: i18n("Refresh")
0055 
0056                 onClicked: WikipediaEngine.reloadWikipedia()
0057             }
0058             Item {
0059                 Layout.fillWidth: true
0060             }
0061             Button {
0062                 iconName: "filename-artist-amarok"
0063                 Layout.alignment: Qt.AlignRight
0064                 tooltip: i18n("Artist")
0065 
0066                 onClicked: WikipediaEngine.selection = WikipediaEngine.Artist
0067             }
0068             Button {
0069                 iconName: "filename-composer-amarok"
0070                 Layout.alignment: Qt.AlignRight
0071                 tooltip: i18n("Composer")
0072 
0073                 onClicked: WikipediaEngine.selection = WikipediaEngine.Composer
0074             }
0075             Button {
0076                 iconName: "filename-album-amarok"
0077                 Layout.alignment: Qt.AlignRight
0078                 tooltip: i18n("Album")
0079 
0080                 onClicked: WikipediaEngine.selection = WikipediaEngine.Album
0081             }
0082             Button {
0083                 iconName: "filename-title-amarok"
0084                 Layout.alignment: Qt.AlignRight
0085                 tooltip: i18n("Track")
0086 
0087                 onClicked: WikipediaEngine.selection = WikipediaEngine.Track
0088             }
0089         }
0090 
0091         WebEngineView {
0092             id: content
0093 
0094             backgroundColor: "transparent"
0095 
0096             Layout.fillWidth: true
0097             Layout.fillHeight: true
0098             Layout.alignment: Qt.AlignBottom
0099 
0100             onNavigationRequested: {
0101                 if (request.navigationType == WebEngineNavigationRequest.LinkClickedNavigation) {
0102                     request.action = WebEngineNavigationRequest.IgnoreRequest
0103                     WikipediaEngine.url = request.url
0104                 }
0105             }
0106 
0107             Connections {
0108                 target: WikipediaEngine
0109 
0110                 onPageChanged: content.loadHtml(WikipediaEngine.page, WikipediaEngine.url)
0111             }
0112 
0113             BusyIndicator {
0114                 anchors.centerIn: parent
0115                 running: WikipediaEngine.busy
0116             }
0117         }
0118     }
0119 }