Changeset View
Changeset View
Standalone View
Standalone View
src/context/applets/wikipedia/package/contents/ui/main.qml
Show All 11 Lines | |||||
12 | * * | 12 | * * | ||
13 | * You should have received a copy of the GNU General Public License along with * | 13 | * You should have received a copy of the GNU General Public License along with * | ||
14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | 14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||
15 | ****************************************************************************************/ | 15 | ****************************************************************************************/ | ||
16 | 16 | | |||
17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 | ||
18 | import QtQuick.Controls 1.4 | 18 | import QtQuick.Controls 1.4 | ||
19 | import QtQuick.Layouts 1.3 | 19 | import QtQuick.Layouts 1.3 | ||
20 | import QtWebEngine 1.1 | 20 | import QtWebEngine 1.3 | ||
21 | import org.kde.kirigami 2.0 as Kirigami | | |||
22 | import org.kde.amarok.qml 1.0 as AmarokQml | 21 | import org.kde.amarok.qml 1.0 as AmarokQml | ||
23 | import org.kde.amarok.wikipedia 1.0 | 22 | import org.kde.amarok.wikipedia 1.0 | ||
24 | 23 | | |||
25 | AmarokQml.Applet { | 24 | AmarokQml.Applet { | ||
26 | id: applet | 25 | id: applet | ||
27 | 26 | | |||
28 | ColumnLayout { | 27 | ColumnLayout { | ||
29 | anchors.fill: parent | 28 | anchors.fill: parent | ||
30 | 29 | | |||
31 | RowLayout { | 30 | RowLayout { | ||
32 | Layout:fillWidth: true | 31 | Layout.fillWidth: true | ||
33 | Layout.alignment: Qt.AlignTop | 32 | Layout.alignment: Qt.AlignTop | ||
34 | 33 | | |||
35 | Button { | 34 | Button { | ||
36 | iconName: "go-previous" | 35 | iconName: "go-previous" | ||
37 | enabled: content.canGoBack | 36 | enabled: content.canGoBack | ||
38 | Layout.alignment: Qt.AlignLeft | 37 | Layout.alignment: Qt.AlignLeft | ||
39 | ToolTip.text: i18n("Previous") | 38 | tooltip: i18n("Previous") | ||
40 | 39 | | |||
41 | onClicked: content.goBack() | 40 | onClicked: content.goBack() | ||
42 | } | 41 | } | ||
43 | Button { | 42 | Button { | ||
44 | iconName: "go-next" | 43 | iconName: "go-next" | ||
45 | enabled: content.canGoForward | 44 | enabled: content.canGoForward | ||
46 | Layout.alignment: Qt.AlignLeft | 45 | Layout.alignment: Qt.AlignLeft | ||
47 | ToolTip.text: i18n("Next") | 46 | tooltip: i18n("Next") | ||
48 | 47 | | |||
49 | onClicked: content.goForward() | 48 | onClicked: content.goForward() | ||
50 | } | 49 | } | ||
51 | Button { | 50 | Button { | ||
52 | iconName: "view-refresh" | 51 | iconName: "view-refresh" | ||
53 | enabled: !content.loading | 52 | enabled: !content.loading | ||
54 | Layout.alignment: Qt.AlignLeft | 53 | Layout.alignment: Qt.AlignLeft | ||
55 | ToolTip.text: i18n("Refresh") | 54 | tooltip: i18n("Refresh") | ||
56 | 55 | | |||
57 | onClicked: content.reload() | 56 | onClicked: content.reload() | ||
58 | } | 57 | } | ||
59 | Item { | 58 | Item { | ||
60 | Layout.fillWidth: true | 59 | Layout.fillWidth: true | ||
61 | } | 60 | } | ||
62 | Button { | 61 | Button { | ||
63 | iconName: "filename-artist-amarok" | 62 | iconName: "filename-artist-amarok" | ||
64 | Layout.alignment: Qt.AlignRight | 63 | Layout.alignment: Qt.AlignRight | ||
65 | ToolTip.text: i18n("Artist") | 64 | tooltip: i18n("Artist") | ||
66 | 65 | | |||
67 | onClicked: WikipediaEngine.selection = WikipediaEngine.Artist | 66 | onClicked: WikipediaEngine.selection = WikipediaEngine.Artist | ||
68 | } | 67 | } | ||
69 | Button { | 68 | Button { | ||
70 | iconName: "filename-composer-amarok" | 69 | iconName: "filename-composer-amarok" | ||
71 | Layout.alignment: Qt.AlignRight | 70 | Layout.alignment: Qt.AlignRight | ||
72 | ToolTip.text: i18n("Composer") | 71 | tooltip: i18n("Composer") | ||
73 | 72 | | |||
74 | onClicked: WikipediaEngine.selection = WikipediaEngine.Composer | 73 | onClicked: WikipediaEngine.selection = WikipediaEngine.Composer | ||
75 | } | 74 | } | ||
76 | Button { | 75 | Button { | ||
77 | iconName: "filename-album-amarok" | 76 | iconName: "filename-album-amarok" | ||
78 | Layout.alignment: Qt.AlignRight | 77 | Layout.alignment: Qt.AlignRight | ||
79 | ToolTip.text: i18n("Album") | 78 | tooltip: i18n("Album") | ||
80 | 79 | | |||
81 | onClicked: WikipediaEngine.selection = WikipediaEngine.Album | 80 | onClicked: WikipediaEngine.selection = WikipediaEngine.Album | ||
82 | } | 81 | } | ||
83 | Button { | 82 | Button { | ||
84 | iconName: "filename-title-amarok" | 83 | iconName: "filename-title-amarok" | ||
85 | Layout.alignment: Qt.AlignRight | 84 | Layout.alignment: Qt.AlignRight | ||
86 | ToolTip.text: i18n("Track") | 85 | tooltip: i18n("Track") | ||
87 | 86 | | |||
88 | onClicked: WikipediaEngine.selection = WikipediaEngine.Track | 87 | onClicked: WikipediaEngine.selection = WikipediaEngine.Track | ||
89 | } | 88 | } | ||
90 | } | 89 | } | ||
91 | 90 | | |||
92 | WebEngineView { | 91 | WebEngineView { | ||
93 | id: content | 92 | id: content | ||
94 | 93 | | |||
94 | backgroundColor: "transparent" | ||||
95 | | ||||
95 | Layout.fillWidth: true | 96 | Layout.fillWidth: true | ||
96 | Layout.fillHeight: true | 97 | Layout.fillHeight: true | ||
97 | Layout.alignment: Qt.AlignBottom | 98 | Layout.alignment: Qt.AlignBottom | ||
98 | height: Kirigami.Units.largeSpacing * 25 //TODO: Find a more elegant solution to set the height | | |||
99 | 99 | | |||
100 | onNavigationRequested: { | 100 | onNavigationRequested: { | ||
101 | if (request.navigationType == WebEngineNavigationRequest.LinkClickedNavigation) { | | |||
102 | request.action = WebEngineNavigationRequest.IgnoreRequest; | 101 | request.action = WebEngineNavigationRequest.IgnoreRequest; | ||
103 | WikipediaEngine.url = request.url; | 102 | WikipediaEngine.url = request.url; | ||
104 | } | 103 | } | ||
105 | } | | |||
106 | 104 | | |||
107 | Connections { | 105 | Connections { | ||
108 | target: WikipediaEngine | 106 | target: WikipediaEngine | ||
109 | 107 | | |||
110 | onPageChanged: content.loadHtml(WikipediaEngine.page, WikipediaEngine.url) | 108 | onPageChanged: content.loadHtml(WikipediaEngine.page, WikipediaEngine.url) | ||
111 | } | 109 | } | ||
112 | 110 | | |||
113 | BusyIndicator { | 111 | BusyIndicator { | ||
114 | anchors.centerIn: parent | 112 | anchors.centerIn: parent | ||
115 | running: WikipediaEngine.busy | 113 | running: WikipediaEngine.busy | ||
116 | } | 114 | } | ||
117 | } | 115 | } | ||
118 | } | 116 | } | ||
119 | } | 117 | } |