diff --git a/org.kde.mobile.angelfish.desktop b/org.kde.mobile.angelfish.desktop index 6b9c561..29e75f1 100755 --- a/org.kde.mobile.angelfish.desktop +++ b/org.kde.mobile.angelfish.desktop @@ -1,52 +1,52 @@ [Desktop Entry] Name=Angelfish Web Browser Comment=Mobile web browser GenericName=Web Browser GenericName[bs]=Čitač veba GenericName[ca]=Navegador web GenericName[ca@valencia]=Navegador web GenericName[cs]=Webový prohlížeč GenericName[da]=Webbrowser GenericName[de]=Webbrowser GenericName[el]=Περιηγητής ιστού GenericName[en_GB]=Web Browser GenericName[es]=Navegador web GenericName[et]=Veebibrauser GenericName[fi]=Verkkoselain GenericName[fr]=Navigateur web GenericName[ga]=Brabhsálaí Gréasáin GenericName[gl]=Navegador web GenericName[hu]=Webböngésző GenericName[it]=Browser Web GenericName[kk]=Веб-шолғышы GenericName[km]=កម្មវិធី​រុករក​បណ្ដាញ GenericName[ko]=웹 브라우저 GenericName[lt]=Žiniatinklio naršyklė GenericName[mr]=वेब ब्राऊजर GenericName[nb]=Nettleser GenericName[nds]=Nettkieker GenericName[nl]=Webbrowser GenericName[pa]=ਵੈੱਬ ਬਰਾਊਜ਼ਰ GenericName[pl]=Przeglądarka internetowa GenericName[pt]=Navegador Web GenericName[pt_BR]=Navegador Web GenericName[ro]=Navigator web GenericName[sk]=Webový prehliadač GenericName[sl]=Spletni brskalnik GenericName[sv]=Webbläsare GenericName[tr]=Web Tarayıcı GenericName[ug]=توركۆرگۈ GenericName[uk]=Переглядач інтернету GenericName[wa]=Betchteu waibe GenericName[x-test]=xxWeb Browserxx GenericName[zh_CN]=网页浏览器 GenericName[zh_TW]=網頁瀏覽器 Encoding=UTF-8 Icon=internet-web-browser -Exec=angelfish +Exec=angelfish %u Type=Application X-DocPath=angelfish/index.html Categories=Qt;KDE;Network;WebBrowser; Terminal=false MimeType=text/html; InitialPreference=10 diff --git a/src/contents/ui/ListWebView.qml b/src/contents/ui/ListWebView.qml index aa5607a..319cd48 100644 --- a/src/contents/ui/ListWebView.qml +++ b/src/contents/ui/ListWebView.qml @@ -1,69 +1,67 @@ /*************************************************************************** * * * Copyright 2014-2015 Sebastian Kügler * * * * 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.3 import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.0 import QtQml.Models 2.1 import QtWebEngine 1.6 ListView { id: tabs // Make sure we don't delete and re-create tabs "randomly" cacheBuffer: 10000 // Don't animate tab switching, this just feels slow highlightMoveDuration: 0 // No horizontal swiping between tabs, disturbs page interaction interactive: false property int pageHeight: parent.height property int pageWidth: parent.width property alias count: tabsModel.count orientation: Qt.Horizontal model: ListModel { id: tabsModel ListElement { pageurl: "https://duckduckgo.com" } // ListElement { pageurl: "http://tagesschau.de" } // ListElement { pageurl: "http://bbc.co.uk" } } delegate: WebView { url: pageurl; } function createEmptyTab() { var t = newTab(""); tabs.currentIndex = tabs.count - 1 return t; } function newTab(url) { - tabsModel.append({pageurl: url}); } - } diff --git a/src/contents/ui/webbrowser.qml b/src/contents/ui/webbrowser.qml index 0ba5236..52ee8f0 100644 --- a/src/contents/ui/webbrowser.qml +++ b/src/contents/ui/webbrowser.qml @@ -1,168 +1,168 @@ /*************************************************************************** * * * Copyright 2014-2015 Sebastian Kügler * * * * 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.1 import QtWebEngine 1.6 import QtQuick.Window 2.1 import org.kde.kirigami 2.0 as Kirigami Kirigami.ApplicationWindow { id: webBrowser title: "Angelfish Webbrowser" /** Pointer to the currently active view. * * Browser-level functionality should use this to refer to the current * view, rather than looking up views in the mode, as far as possible. */ property Item currentWebView: tabs.currentIndex < tabs.count ? tabs.currentItem : null onCurrentWebViewChanged: { print("Current WebView is now : " + tabs.currentIndex); } property int borderWidth: Math.round(Kirigami.Units.gridUnit / 18); property var borderColor: Kirigami.Theme.highlightColor; /** * Load a url in the current tab */ function load(url) { print("Loading url: " + url); currentWebView.url = url; - //tabs.newTab(url) } width: Kirigami.Units.gridUnit * 20 height: Kirigami.Units.gridUnit * 30 function addHistoryEntry() { //print("Adding history"); var request = new Object;// FIXME request.url = currentWebView.url; request.title = currentWebView.title; request.icon = currentWebView.icon; browserManager.addToHistory(request); } ListWebView { id: tabs anchors { top: navigation.bottom left: parent.left right: parent.right bottom: parent.bottom } } ErrorHandler { id: errorHandler errorString: currentWebView.errorString errorCode: currentWebView.errorCode anchors { top: navigation.bottom left: parent.left right: parent.right } } ContentView { id: contentView anchors.fill: tabs } // Container for the progress bar Item { id: progressItem height: Math.round(Kirigami.Units.gridUnit / 6) z: navigation.z + 1 anchors { top: tabs.top topMargin: -Math.round(height / 2) left: tabs.left right: tabs.right } opacity: currentWebView.loading ? 1 : 0 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad; } } Rectangle { color: Kirigami.Theme.highlightColor width: Math.round((currentWebView.loadProgress / 100) * parent.width) anchors { top: parent.top left: parent.left bottom: parent.bottom } } } // When clicked outside the menu, hide it MouseArea { id: optionsDismisser visible: options.state != "hidden" onClicked: options.state = "hidden" anchors.fill: parent } // The menu at the top right Options { id: options anchors { top: navigation.bottom } } Navigation { id: navigation height: Kirigami.Units.gridUnit * 3 anchors { top: parent.top left: parent.left right: parent.right } } // Thin line underneath navigation Rectangle { height: webBrowser.borderWidth color: webBrowser.borderColor anchors { left: parent.left bottom: navigation.bottom right: options.left } } Component.onCompleted: { - //contentView.state = "settings"; // For testing + if (!initialUrl.isEmpty) + load(initialUrl) } } diff --git a/src/main.cpp b/src/main.cpp index 4eca33b..a230317 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,36 +1,51 @@ #include #include #include #include #include #include #include #include "browsermanager.h" Q_DECL_EXPORT int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QCoreApplication::setOrganizationName("KDE"); QCoreApplication::setOrganizationDomain("kde.org"); QCoreApplication::setApplicationName("angelfish"); + // Command line parser + QCommandLineParser parser; + QCommandLineOption helpOption = parser.addHelpOption(); + parser.addPositionalArgument("url", "An url to open", "[url]"); + parser.parse(QGuiApplication::arguments()); + + // QML loading QQmlApplicationEngine engine; QtWebEngine::initialize(); + + // initial url command line parameter + if (!parser.positionalArguments().isEmpty()) + engine.rootContext()->setContextProperty("initialUrl", QUrl::fromUserInput(parser.positionalArguments()[0].toUtf8())); + engine.load(QUrl(QStringLiteral("qrc:///webbrowser.qml"))); + // Browser managger AngelFish::BrowserManager *browserManager = new AngelFish::BrowserManager(engine.rootContext()); engine.rootContext()->setContextProperty("browserManager", browserManager); qmlRegisterUncreatableType("org.kde.mobile.angelfish", 1, 0, "BrowserManager", ""); qmlRegisterType(); - + // Error handling if (engine.rootObjects().isEmpty()) { return -1; } + + int ret = app.exec(); return ret; }