diff --git a/applets/CMakeLists.txt b/applets/CMakeLists.txt --- a/applets/CMakeLists.txt +++ b/applets/CMakeLists.txt @@ -27,3 +27,4 @@ add_subdirectory(timer) add_subdirectory(userswitcher) add_subdirectory(weather) +add_subdirectory(webbrowser) diff --git a/applets/webbrowser/contents/config/main.xml b/applets/webbrowser/contents/config/main.xml deleted file mode 100644 --- a/applets/webbrowser/contents/config/main.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - https://www.kde.org/ - - - diff --git a/applets/webbrowser/contents/ui/main.qml b/applets/webbrowser/contents/ui/main.qml deleted file mode 100644 --- a/applets/webbrowser/contents/ui/main.qml +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright 2014, 2016 by Mikhail Ivchenko * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -import QtQuick 2.0 -import QtWebKit 3.0 -import QtQuick.Layouts 1.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras - -ColumnLayout { - RowLayout{ - Layout.fillWidth: true - PlasmaComponents.Button{ - iconSource: "go-previous" - onClicked: webview.goBack() - enabled: webview.canGoBack - } - PlasmaComponents.Button{ - iconSource: "go-next" - onClicked: webview.goForward() - enabled: webview.canGoForward - } - PlasmaComponents.TextField{ - Layout.fillWidth: true - onAccepted: { - var url = text; - if (url.indexOf(":/") < 0) { - url = "http://" + url; - } - webview.url = url; - } - text: webview.url - } - PlasmaComponents.Button{ - iconSource: "view-refresh" - onClicked: webview.reload() - } - } - PlasmaExtras.ScrollArea { - Layout.fillWidth: true - Layout.fillHeight: true - WebView { - id: webview - anchors.fill: parent - onUrlChanged: plasmoid.configuration.url = url; - Component.onCompleted: url = plasmoid.configuration.url; - } - } - //There will be RowLayout with buttons for bookmarks and zooming. - -} diff --git a/applets/webbrowser/metadata.desktop b/applets/webbrowser/metadata.desktop deleted file mode 100644 --- a/applets/webbrowser/metadata.desktop +++ /dev/null @@ -1,93 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=Web browser -Name[ca]=Navegador web -Name[ca@valencia]=Navegador web -Name[cs]=Webový prohlížeč -Name[da]=Webbrowser -Name[de]=Webbrowser -Name[el]=Περιηγητής ιστού -Name[en_GB]=Web browser -Name[es]=Navegador web -Name[et]=Veebibrauser -Name[eu]=Web arakatzailea -Name[fi]=Verkkoselain -Name[fr]=Navigateur Web -Name[gl]=Navegador web -Name[he]=דפדפן -Name[hu]=Webböngésző -Name[ia]=Navigator Web -Name[it]=Browser web -Name[ko]=웹 브라우저 -Name[lt]=Žiniatinklio naršyklė -Name[nb]=Nettleser -Name[nl]=Webbrowser -Name[nn]=Nettlesar -Name[pl]=Przeglądarka sieciowa -Name[pt]=Navegador Web -Name[pt_BR]=Navegador Web -Name[ru]=Веб-браузер -Name[sk]=Webový prehliadač -Name[sl]=Spletni brskalnik -Name[sr]=веб прегледач -Name[sr@ijekavian]=веб прегледач -Name[sr@ijekavianlatin]=veb pregledač -Name[sr@latin]=veb pregledač -Name[sv]=Webbläsare -Name[tr]=Web tarayıcı -Name[uk]=Перегляд інтернету -Name[x-test]=xxWeb browserxx -Name[zh_CN]=网页浏览器 -Name[zh_TW]=網頁瀏覽器 -Comment=Add a webpage on your desktop. -Comment[ca]=Afegeix una pàgina web a l'escriptori. -Comment[ca@valencia]=Afig una pàgina web a l'escriptori. -Comment[da]=Tilføj en webside til dit skrivebord. -Comment[de]=Fügt eine Webseite zu Ihrer Arbeitsfläche hinzu. -Comment[el]=Προσθήκη ιστοσελίδας στην επιφάνεια εργασίας σας. -Comment[en_GB]=Add a webpage on your desktop. -Comment[es]=Añadir una página web a su escritorio. -Comment[et]=Veebilehe lisamine töölauale -Comment[eu]=Erantsi web-orri bat zure mahaigainean. -Comment[fi]=Lisää verkkosivu työpöydällesi. -Comment[fr]=Ajouter une page Web sur votre bureau. -Comment[gl]=Engadir unha páxina web ao escritorio. -Comment[he]=הוסף דף אינטרנט לשולחן העבודה שלך. -Comment[hu]=Adjon hozzá egy weboldalt az asztalhoz! -Comment[it]=Aggiungi una pagina web al tuo desktop. -Comment[ko]=데스크톱에 웹 페이지를 추가합니다. -Comment[lt]=Internetinis puslapis darbalaukyje. -Comment[nb]=Legg de merkeligste plott på skrivebordet! -Comment[nl]=Een webpagina toevoegen aan uw bureaublad. -Comment[nn]=Legg ei nettside på skrivebordet -Comment[pl]=Dodaje stronę internetową na pulpit. -Comment[pt]=Adiciona uma página Web ao seu ecrã. -Comment[pt_BR]=Adiciona uma página da Web na sua área de trabalho. -Comment[ru]=Просмотр веб-страницы на рабочем столе -Comment[sk]=Pridať webovú stránku na vašu plochu. -Comment[sl]=Dodajte spletno stran na vaše namizje. -Comment[sr]=Додајте веб страницу на површ -Comment[sr@ijekavian]=Додајте веб страницу на површ -Comment[sr@ijekavianlatin]=Dodajte veb stranicu na površ -Comment[sr@latin]=Dodajte veb stranicu na površ -Comment[sv]=Lägg till en webbsida på skrivbordet. -Comment[tr]=Masaüstünüze bir dosya ekleyin. -Comment[uk]=Додати сторінку інтернету на вашу стільницю. -Comment[x-test]=xxAdd a webpage on your desktop.xx -Comment[zh_CN]=添加网页到您的桌面 -Comment[zh_TW]=在桌面上新增網頁。 -Type=Service -Icon=internet-web-browser -X-KDE-ParentApp= -X-KDE-PluginInfo-Author=Mikhail Ivchenko -X-KDE-PluginInfo-Email=ematirov@gmail.com -X-KDE-PluginInfo-License=GPL-2.0+ -X-KDE-PluginInfo-Name=org.kde.plasma.webbrowser -X-KDE-PluginInfo-Version=0.1.0 -X-KDE-PluginInfo-Website=plasma.kde.org -X-KDE-ServiceTypes=Plasma/Applet -X-Plasma-API=declarativeappletscript -X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation= -X-KDE-PluginInfo-Category=Online Services -X-Plasma-StandAloneApp=true diff --git a/applets/webbrowser/package/contents/config/main.xml b/applets/webbrowser/package/contents/config/main.xml new file mode 100644 --- /dev/null +++ b/applets/webbrowser/package/contents/config/main.xml @@ -0,0 +1,13 @@ + + + + + + + https://www.kde.org/ + + + diff --git a/applets/webbrowser/package/contents/ui/main.qml b/applets/webbrowser/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/applets/webbrowser/package/contents/ui/main.qml @@ -0,0 +1,117 @@ +/*************************************************************************** + * Copyright 2014, 2016 by Mikhail Ivchenko * + * Copyright 2018 by Kai Uwe Broulik * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +import QtQuick 2.0 +import QtWebEngine 1.1 +import QtQuick.Layouts 1.1 +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras + +ColumnLayout { + RowLayout{ + Layout.fillWidth: true + PlasmaComponents.Button{ + iconSource: "go-previous" + onClicked: webview.goBack() + enabled: webview.canGoBack + } + PlasmaComponents.Button{ + iconSource: "go-next" + onClicked: webview.goForward() + enabled: webview.canGoForward + } + PlasmaComponents.TextField{ + Layout.fillWidth: true + onAccepted: { + var url = text; + if (url.indexOf(":/") < 0) { + url = "http://" + url; + } + webview.url = url; + } + onActiveFocusChanged: { + if (activeFocus) { + selectAll(); + } + } + + text: webview.url + } + PlasmaComponents.Button{ + iconSource: webview.loading ? "process-stop" : "view-refresh" + onClicked: webview.loading ? webview.stop() : webview.reload() + } + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + + // TODO use contentsSize but that crashes, now mostly for some sane initial size + Layout.preferredWidth: units.gridUnit * 25 + Layout.preferredHeight: units.gridUnit * 12 + + // Binding it to e.g. width will be super slow on resizing + Timer { + id: updateZoomTimer + interval: 100 + onTriggered: { + // Try to fit contents for a smaller screen + webview.zoomFactor = Math.min(1, webview.width / 1000); + } + + } + + WebEngineView { + id: webview + anchors.fill: parent + onUrlChanged: plasmoid.configuration.url = url; + Component.onCompleted: url = plasmoid.configuration.url; + + onLinkHovered: { + if (hoveredUrl.toString() !== "") { + mouseArea.cursorShape = Qt.PointingHandCursor; + } else { + mouseArea.cursorShape = Qt.ArrowCursor; + } + } + + onWidthChanged: updateZoomTimer.start() + onLoadingChanged: { + if (loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus) { + updateZoomTimer.start(); + } + } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + acceptedButtons: Qt.BackButton | Qt.ForwardButton + onPressed: { + if (mouse.button === Qt.BackButton) { + webview.goBack(); + } else if (mouse.button === Qt.ForwardButton) { + webview.goForward(); + } + } + } + } +} diff --git a/applets/webbrowser/package/metadata.desktop b/applets/webbrowser/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/applets/webbrowser/package/metadata.desktop @@ -0,0 +1,93 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Web browser +Name[ca]=Navegador web +Name[ca@valencia]=Navegador web +Name[cs]=Webový prohlížeč +Name[da]=Webbrowser +Name[de]=Webbrowser +Name[el]=Περιηγητής ιστού +Name[en_GB]=Web browser +Name[es]=Navegador web +Name[et]=Veebibrauser +Name[eu]=Web arakatzailea +Name[fi]=Verkkoselain +Name[fr]=Navigateur Web +Name[gl]=Navegador web +Name[he]=דפדפן +Name[hu]=Webböngésző +Name[ia]=Navigator Web +Name[it]=Browser web +Name[ko]=웹 브라우저 +Name[lt]=Žiniatinklio naršyklė +Name[nb]=Nettleser +Name[nl]=Webbrowser +Name[nn]=Nettlesar +Name[pl]=Przeglądarka sieciowa +Name[pt]=Navegador Web +Name[pt_BR]=Navegador Web +Name[ru]=Веб-браузер +Name[sk]=Webový prehliadač +Name[sl]=Spletni brskalnik +Name[sr]=веб прегледач +Name[sr@ijekavian]=веб прегледач +Name[sr@ijekavianlatin]=veb pregledač +Name[sr@latin]=veb pregledač +Name[sv]=Webbläsare +Name[tr]=Web tarayıcı +Name[uk]=Перегляд інтернету +Name[x-test]=xxWeb browserxx +Name[zh_CN]=网页浏览器 +Name[zh_TW]=網頁瀏覽器 +Comment=Add a webpage on your desktop. +Comment[ca]=Afegeix una pàgina web a l'escriptori. +Comment[ca@valencia]=Afig una pàgina web a l'escriptori. +Comment[da]=Tilføj en webside til dit skrivebord. +Comment[de]=Fügt eine Webseite zu Ihrer Arbeitsfläche hinzu. +Comment[el]=Προσθήκη ιστοσελίδας στην επιφάνεια εργασίας σας. +Comment[en_GB]=Add a webpage on your desktop. +Comment[es]=Añadir una página web a su escritorio. +Comment[et]=Veebilehe lisamine töölauale +Comment[eu]=Erantsi web-orri bat zure mahaigainean. +Comment[fi]=Lisää verkkosivu työpöydällesi. +Comment[fr]=Ajouter une page Web sur votre bureau. +Comment[gl]=Engadir unha páxina web ao escritorio. +Comment[he]=הוסף דף אינטרנט לשולחן העבודה שלך. +Comment[hu]=Adjon hozzá egy weboldalt az asztalhoz! +Comment[it]=Aggiungi una pagina web al tuo desktop. +Comment[ko]=데스크톱에 웹 페이지를 추가합니다. +Comment[lt]=Internetinis puslapis darbalaukyje. +Comment[nb]=Legg de merkeligste plott på skrivebordet! +Comment[nl]=Een webpagina toevoegen aan uw bureaublad. +Comment[nn]=Legg ei nettside på skrivebordet +Comment[pl]=Dodaje stronę internetową na pulpit. +Comment[pt]=Adiciona uma página Web ao seu ecrã. +Comment[pt_BR]=Adiciona uma página da Web na sua área de trabalho. +Comment[ru]=Просмотр веб-страницы на рабочем столе +Comment[sk]=Pridať webovú stránku na vašu plochu. +Comment[sl]=Dodajte spletno stran na vaše namizje. +Comment[sr]=Додајте веб страницу на површ +Comment[sr@ijekavian]=Додајте веб страницу на површ +Comment[sr@ijekavianlatin]=Dodajte veb stranicu na površ +Comment[sr@latin]=Dodajte veb stranicu na površ +Comment[sv]=Lägg till en webbsida på skrivbordet. +Comment[tr]=Masaüstünüze bir dosya ekleyin. +Comment[uk]=Додати сторінку інтернету на вашу стільницю. +Comment[x-test]=xxAdd a webpage on your desktop.xx +Comment[zh_CN]=添加网页到您的桌面 +Comment[zh_TW]=在桌面上新增網頁。 +Type=Service +Icon=internet-web-browser +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Mikhail Ivchenko +X-KDE-PluginInfo-Email=ematirov@gmail.com +X-KDE-PluginInfo-License=GPL-2.0+ +X-KDE-PluginInfo-Name=org.kde.plasma.webbrowser +X-KDE-PluginInfo-Version=0.1.0 +X-KDE-PluginInfo-Website=plasma.kde.org +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-Plasma-MainScript=ui/main.qml +X-Plasma-RemoteLocation= +X-KDE-PluginInfo-Category=Online Services +X-Plasma-StandAloneApp=true