diff --git a/src/contents/ui/Bookmarks.qml b/src/contents/ui/Bookmarks.qml index 7caae51..208b755 100644 --- a/src/contents/ui/Bookmarks.qml +++ b/src/contents/ui/Bookmarks.qml @@ -1,50 +1,49 @@ /*************************************************************************** * * * 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.Layouts 1.0 import org.kde.kirigami 2.0 as Kirigami -Item { +Kirigami.ScrollablePage { // id: options - - //Rectangle { anchors.fill: parent; color: "orange"; opacity: 0.5; } - anchors.fill: parent + title: i18n("Bookmarks") ListView { anchors.fill: parent spacing: Kirigami.Units.smallSpacing interactive: height < contentHeight clip: true model: browserManager.bookmarks delegate: UrlDelegate { + onClicked: pageStack.layers.pop() onRemoved: browserManager.removeBookmark(url); } } Component.onCompleted: print("Bookmarks.qml complete."); } diff --git a/src/contents/ui/ContentView.qml b/src/contents/ui/ContentView.qml deleted file mode 100644 index a63c192..0000000 --- a/src/contents/ui/ContentView.qml +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - * * - * 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 QtWebEngine 1.0 -//import QtQuick.Controls 1.0 -//import QtQuick.Controls.Styles 1.0 -import QtQuick.Layouts 1.0 -//import QtQuick.Window 2.1 -//import QtQuick.Controls.Private 1.0 -import org.kde.kirigami 2.0 as Kirigami - - -Rectangle { - id: contentView - - //state: "hidden" - state: "hidden" - - property string title: "" - - color: Kirigami.Theme.backgroundColor - Rectangle { - color: "white" - opacity: 0.6 - anchors.fill: parent - } - - opacity: state == "hidden" ? 0.0 : 1.0 - Behavior on opacity { - NumberAnimation { - duration: Kirigami.Units.longDuration/2; - easing.type: Easing.InOutQuad - } - } - MouseArea { - // block intput from arriving in the webview - anchors.fill: parent - visible: contentView.state != "hidden" - onPressed: { - mouse.accepted = true; - print("Blocked Mouse."); - } - } - - Loader { - id: contentViewLoader - - anchors { - top: heading.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - margins: Kirigami.Units.gridUnit / 2 - } - } - - Kirigami.Heading { - id: heading - - level: 2 - - text: contentView.title - anchors { - right: closeButton.left - top: parent.top - left: parent.left - margins: Kirigami.Units.gridUnit / 2 - } - MouseArea { - anchors.fill: parent - onClicked: contentView.state = "hidden" - } - } - - Kirigami.Icon { - id: closeButton - - width: Kirigami.Units.gridUnit - height: width - source: "dialog-close" - - anchors { - right: parent.right - top: parent.top - margins: Kirigami.Units.gridUnit - } - MouseArea { - anchors.fill: parent - onClicked: contentView.state = "hidden" - } - } - - states: [ - State { - name: "hidden" - //PropertyChanges { target: currentWebView; visible: true} - }, - State { - name: "history" - PropertyChanges { target: contentView; title: i18n("History")} - PropertyChanges { target: contentViewLoader; source: "History.qml"} - - }, - State { - name: "bookmarks" - PropertyChanges { target: contentViewLoader; source: "Bookmarks.qml"} - PropertyChanges { target: contentView; title: i18n("Bookmarks")} - }, - State { - name: "tabs" - PropertyChanges { target: contentView; title: i18n("Tabs")} - PropertyChanges { target: contentViewLoader; source: "Tabs.qml"} - //PropertyChanges { target: currentWebView; visible: false} - }, - State { - name: "settings" - PropertyChanges { target: contentView; title: i18n("Settings")} - PropertyChanges { target: contentViewLoader; source: "Settings.qml"} - } - ] - -} diff --git a/src/contents/ui/History.qml b/src/contents/ui/History.qml index 3f3a759..8dd2626 100644 --- a/src/contents/ui/History.qml +++ b/src/contents/ui/History.qml @@ -1,48 +1,48 @@ /*************************************************************************** * * * 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.Layouts 1.0 import org.kde.kirigami 2.2 as Kirigami -Item { -// id: options +Kirigami.ScrollablePage { +// id: history - //Rectangle { anchors.fill: parent; color: "orange"; opacity: 0.5; } - anchors.fill: parent + title: i18n("History") ListView { anchors.fill: parent spacing: Kirigami.Units.smallSpacing interactive: height < contentHeight clip: true model: browserManager.history delegate: UrlDelegate { + onClicked: pageStack.layers.pop() onRemoved: browserManager.removeFromHistory(url); } } Component.onCompleted: print("History.qml complete."); } diff --git a/src/contents/ui/ListWebView.qml b/src/contents/ui/ListWebView.qml index 319cd48..91d26dc 100644 --- a/src/contents/ui/ListWebView.qml +++ b/src/contents/ui/ListWebView.qml @@ -1,67 +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 int pageHeight: height + property int pageWidth: 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/Options.qml b/src/contents/ui/Options.qml index b0f81d9..a9cc3c9 100644 --- a/src/contents/ui/Options.qml +++ b/src/contents/ui/Options.qml @@ -1,147 +1,144 @@ /*************************************************************************** * * * 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 QtWebEngine 1.0 //import QtQuick.Controls 1.0 //import QtQuick.Controls.Styles 1.0 import QtQuick.Layouts 1.0 //import QtQuick.Window 2.1 //import QtQuick.Controls.Private 1.0 import org.kde.kirigami 2.0 as Kirigami Rectangle { id: options state: "hidden" //state: "bookmarks" color: Kirigami.Theme.backgroundColor property string title: "" property int expandedHeight: Kirigami.Units.gridUnit * 12 property int expandedWidth: Kirigami.Units.gridUnit * 14 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration/2; easing.type: Easing.InOutQuad} } Behavior on x { NumberAnimation { duration: Kirigami.Units.longDuration/2; easing.type: Easing.InOutQuad} } height: expandedHeight width: expandedWidth //height: childrenRect.height + Kirigami.Units.gridUnit //width: childrenRect.width + Kirigami.Units.gridUnit/2 //width: expandedWidth //anchors.rightMargin: -options.margins.right //Rectangle { anchors.fill: parent; color: theme.backgroundColor; } Rectangle { width: webBrowser.borderWidth color: webBrowser.borderColor anchors { left: parent.left top: parent.top bottom: parent.bottom } } Rectangle { height: webBrowser.borderWidth color: webBrowser.borderColor anchors { left: parent.left bottom: parent.bottom right: parent.right } } ColumnLayout { //visible: parent.height > 0 //spacing: Kirigami.Units.gridUnit spacing: 0 //x: Kirigami.Units.gridUnit / 2 //y: - (Kirigami.Units.gridUnit + webBrowser.borderWidth) //width: Kirigami.Units.gridUnit * 14 anchors { //fill: parent top: parent.top //topMargin: Kirigami.Units.gridUnit left: parent.left right: parent.right //margins: Kirigami.Units.gridUnit / 2 } - MouseArea { - anchors.fill: parent - } OptionsOverview { Layout.fillWidth: true; } Loader { id: loader Layout.fillHeight: true Layout.fillWidth: true //Rectangle { anchors.fill: parent; color: "black"; opacity: 0.1; } } } // NumberAnimation on state { // //loops: Animation.Infinite // from: state == "hidden" ? 0 : 1.0 // to: state == "hidden" ? 1.0 : 0.0 // } states: [ State { name: "hidden" PropertyChanges { target: options; opacity: 0.0} PropertyChanges { target: options; x: webBrowser.width} }, State { name: "overview" PropertyChanges { target: options; title: ""} //PropertyChanges { target: options; height: Kirigami.Units.gridUnit * 3} PropertyChanges { target: options; opacity: 1.0} PropertyChanges { target: options; x: webBrowser.width - options.width } }/*, State { name: "bookmarks" PropertyChanges { target: loader; source: "Bookmarks.qml"} PropertyChanges { target: options; title: i18n("Bookmarks")} PropertyChanges { target: options; height: expandedHeight} }, State { name: "tabs" PropertyChanges { target: options; title: i18n("Tabs")} PropertyChanges { target: loader; source: "Tabs.qml"} PropertyChanges { target: options; height: expandedHeight} }, State { name: "settings" PropertyChanges { target: options; title: i18n("Settings")} PropertyChanges { target: loader; source: "Settings.qml"} PropertyChanges { target: options; height: expandedHeight} } */ ] } diff --git a/src/contents/ui/OptionsOverview.qml b/src/contents/ui/OptionsOverview.qml index 635c045..88a4bd6 100644 --- a/src/contents/ui/OptionsOverview.qml +++ b/src/contents/ui/OptionsOverview.qml @@ -1,156 +1,152 @@ /*************************************************************************** * * * 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.Layouts 1.0 import org.kde.kirigami 2.0 as Kirigami ColumnLayout { id: optionsOverview property int buttonSize: Kirigami.Units.gridUnit * 2 RowLayout { id: layout - anchors.fill: parent + height: buttonSize spacing: 0 // anchors.leftMargin: Kirigami.Units.gridUnit / 2 // anchors.rightMargin: Kirigami.Units.gridUnit / 2 //visible: navigationShown //spacing: Kirigami.Units.smallSpacing OptionButton { id: backButton enabled: currentWebView.canGoBack iconSource: "go-previous" onClicked: { options.state = "hidden"; currentWebView.goBack() } } OptionButton { id: forwardButton enabled: currentWebView.canGoForward iconSource: "go-next" onClicked: { options.state = "hidden"; currentWebView.goForward() } } OptionButton { id: reloadButton iconSource: currentWebView.loading ? "process-stop" : "view-refresh" onClicked: { options.state = "hidden"; currentWebView.loading ? currentWebView.stop() : currentWebView.reload() } } OptionButton { id: bookmarkButton iconSource: "bookmarks" onClicked: { print("Adding bookmark"); var request = new Object;// FIXME request.url = currentWebView.url; request.title = currentWebView.title; request.iconSource = currentWebView.iconSource; request.bookmarked = true; browserManager.addBookmark(request); options.state = "hidden" } } } Item { Layout.preferredHeight: Kirigami.Units.smallSpacing Layout.fillWidth: true } OptionButton { iconSource: "tab-duplicate" Layout.fillWidth: true Layout.preferredHeight: buttonSize onClicked: { - contentView.state = "tabs" + pageStack.layers.push("Tabs.qml") options.state = "hidden" } - //checked: contentView.state == "tabs" text: i18n("Tabs") } OptionButton { iconSource: "bookmarks" Layout.fillWidth: true Layout.preferredHeight: buttonSize onClicked: { - contentView.state = "bookmarks" + pageStack.layers.push("Bookmarks.qml") options.state = "hidden" } - //checked: contentView.state == "bookmarks" text: i18n("Bookmarks") } OptionButton { iconSource: "view-history" Layout.fillWidth: true Layout.preferredHeight: buttonSize onClicked: { - contentView.state = "history" + pageStack.layers.push("History.qml") options.state = "hidden" } - //checked: contentView.state == "bookmarks" text: i18n("History") } OptionButton { iconSource: "configure" Layout.fillWidth: true Layout.preferredHeight: buttonSize text: i18n("Settings") - //checked: contentView.state == "settings" onClicked: { - contentView.state = "settings" + pageStack.layers.push("Settings.qml") options.state = "hidden" } } } diff --git a/src/contents/ui/Settings.qml b/src/contents/ui/Settings.qml index 57d4d5d..97818e3 100644 --- a/src/contents/ui/Settings.qml +++ b/src/contents/ui/Settings.qml @@ -1,61 +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.4 as Controls import QtQuick.Layouts 1.11 import org.kde.kirigami 2.2 as Kirigami -ColumnLayout { - id: settingsPage - - Controls.CheckDelegate { - text: i18n("Enable javascript") - Layout.fillWidth: true - onCheckedChanged: { - var settings = currentWebView.settings; - settings.javascriptEnabled = checked; - // FIXME: save to config - } - Component.onCompleted: { - checked = currentWebView.settings.javascriptEnabled; +Kirigami.ScrollablePage { + title: i18n("Settings") + + ColumnLayout { + id: settingsPage + + Controls.CheckDelegate { + text: i18n("Enable javascript") + Layout.fillWidth: true + onCheckedChanged: { + var settings = currentWebView.settings; + settings.javascriptEnabled = checked; + // FIXME: save to config + } + Component.onCompleted: { + checked = currentWebView.settings.javascriptEnabled; + } } - } - Controls.CheckDelegate { - text: i18n("Load images") - Layout.fillWidth: true - onCheckedChanged: { - var settings = currentWebView.settings; - settings.autoLoadImages = checked; - // FIXME: save to config + Controls.CheckDelegate { + text: i18n("Load images") + Layout.fillWidth: true + onCheckedChanged: { + var settings = currentWebView.settings; + settings.autoLoadImages = checked; + // FIXME: save to config + } + Component.onCompleted: { + checked = currentWebView.settings.autoLoadImages; + } } - Component.onCompleted: { - checked = currentWebView.settings.autoLoadImages; + + Item { + Layout.fillHeight: true } } - Item { - Layout.fillHeight: true - } } + diff --git a/src/contents/ui/Tabs.qml b/src/contents/ui/Tabs.qml index 9b866bb..25abac2 100644 --- a/src/contents/ui/Tabs.qml +++ b/src/contents/ui/Tabs.qml @@ -1,151 +1,154 @@ /*************************************************************************** * * * 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 as Controls //import QtWebEngine 1.0 import QtQuick.Layouts 1.0 import org.kde.kirigami 2.0 as Kirigami // import org.kde.plasma.components 2.0 as PlasmaComponents // import org.kde.plasma.extras 2.0 as PlasmaExtras -Item { +Kirigami.ScrollablePage { id: tabsRoot + title: i18n("Tabs") + property int itemHeight: Math.round(itemWidth/ 3 * 2) property int itemWidth: (width / 2) - Kirigami.Units.gridUnit //Rectangle { anchors.fill: parent; color: "brown"; opacity: 0.5; } GridView { //columns: 2 anchors.fill: parent //model: tabs.count + model: tabs.model //model: 4 cellWidth: itemWidth cellHeight: itemHeight delegate: Item { id: tabItem width: itemWidth height: itemHeight ShaderEffectSource { id: shaderItem //live: true anchors.fill: parent anchors.margins: Kirigami.Units.gridUnit / 2 sourceRect: Qt.rect(0, 0, width * 2, height * 2) sourceItem: { tabs.itemAt(tabs.pageWidth * index, 0); } //opacity: tabs.currentIndex == index ? 1 : 0.0 Behavior on height { SequentialAnimation { ScriptAction { script: { print("Animation start"); // switch to tabs } } NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad } NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad; target: contentView; property: opacity } ScriptAction { script: { print("Animation done"); contentView.state = "hidden" } } } } Behavior on width { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad} } } Rectangle { anchors.fill: parent; anchors.margins: Kirigami.Units.gridUnit / 4; border.color: theme.textColor; border.width: webBrowser.borderWidth color: "transparent" opacity: 0.3; } MouseArea { anchors.fill: parent onClicked: { print("Switch from " + tabs.currentIndex + " to tab " + index); tabs.currentIndex = index; tabs.positionViewAtIndex(index, ListView.Beginning); //tabs.positionViewAtEnd(); - contentView.state = "hidden" + pageStack.layers.pop() return; if (tabItem.width < tabsRoot.width) { // tabItem.width = currentWebView.width // tabItem.height = currentWebView.height } else { tabItem.width = itemWidth tabItem.height = itemHeight } } } } footer: Rectangle { color: "white" width: itemWidth height: itemHeight Kirigami.Icon { anchors.fill: parent anchors.margins: Math.round(itemHeight / 4) source: "list-add" } MouseArea { anchors.fill: parent onClicked: { tabs.newTab("https://duckduckgo.com") //addressBar.forceActiveFocus(); //addressBar.selectAll(); tabs.currentIndex = tabs.count - 1; + pageStack.layers.pop() } } } } } diff --git a/src/contents/ui/WebView.qml b/src/contents/ui/WebView.qml index b831632..8c71d3a 100644 --- a/src/contents/ui/WebView.qml +++ b/src/contents/ui/WebView.qml @@ -1,92 +1,87 @@ /*************************************************************************** * * * 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 QtWebEngine 1.4 WebEngineView { id: webEngineView property string errorCode: "" property string errorString: "" property string userAgent: "Mozilla/5.0 (Linux; Plasma Mobile, like Android 7.0 ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36" width: pageWidth height: pageHeight profile.httpUserAgent: userAgent //Rectangle { color: "yellow"; opacity: 0.3; anchors.fill: parent } focus: true onLoadingChanged: { // Doesn't work!?! //print("Loading: " + loading); print(" url: " + loadRequest.url) //print(" icon: " + webEngineView.icon) //print(" title: " + webEngineView.title) /* Handle * - WebEngineView::LoadStartedStatus, * - WebEngineView::LoadStoppedStatus, * - WebEngineView::LoadSucceededStatus and * - WebEngineView::LoadFailedStatus */ var ec = ""; var es = ""; //print("Load: " + loadRequest.errorCode + " " + loadRequest.errorString); - if (loadRequest.status == WebEngineView.LoadStartedStatus) { - if (contentView.state != "settings") { // Kludge! - - contentView.state = "hidden"; - } - } + //if (loadRequest.status == WebEngineView.LoadStartedStatus) { + //} if (loadRequest.status == WebEngineView.LoadSucceededStatus) { // record history, set current page info //contentView.state = "hidden" //pageInfo.url = webEngineView.url; //pageInfo.title = webEngineView.title; //pageInfo.icon = webEngineView.icon; addHistoryEntry(); } if (loadRequest.status == WebEngineView.LoadFailedStatus) { print("Load failed: " + loadRequest.errorCode + " " + loadRequest.errorString); ec = loadRequest.errorCode; es = loadRequest.errorString; - contentView.state = "hidden" } errorCode = ec; errorString = es; } // onLoadProgressChanged: { // if (loadProgress > 50) { // contentView.state = "hidden"; // } // } Component.onCompleted: { print("WebView completed."); var settings = webEngineView.settings; print("Settings: " + settings); } } diff --git a/src/contents/ui/webbrowser.qml b/src/contents/ui/webbrowser.qml index 52ee8f0..4321f55 100644 --- a/src/contents/ui/webbrowser.qml +++ b/src/contents/ui/webbrowser.qml @@ -1,168 +1,178 @@ /*************************************************************************** * * * 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 +import org.kde.kirigami 2.4 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; + property color borderColor: Kirigami.Theme.highlightColor; /** * Load a url in the current tab */ function load(url) { print("Loading url: " + url); currentWebView.url = 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 - } - } + property bool layerShown : pageStack.layers.depth > 1 - ErrorHandler { - id: errorHandler + pageStack.globalToolBar.style: layerShown ? Kirigami.ApplicationHeaderStyle.Auto : Kirigami.ApplicationHeaderStyle.None - errorString: currentWebView.errorString - errorCode: currentWebView.errorCode - anchors { - top: navigation.bottom - left: parent.left - right: parent.right - } - } + pageStack.initialPage: Kirigami.Page { - ContentView { - id: contentView - anchors.fill: tabs - } + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 - // 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 + ListWebView { + id: tabs + anchors { + top: navigation.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } } - opacity: currentWebView.loading ? 1 : 0 - Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad; } } + ErrorHandler { + id: errorHandler - Rectangle { - color: Kirigami.Theme.highlightColor + errorString: currentWebView.errorString + errorCode: currentWebView.errorCode - width: Math.round((currentWebView.loadProgress / 100) * parent.width) anchors { - top: parent.top + top: navigation.bottom left: parent.left - bottom: parent.bottom + right: parent.right } } - } + // Container for the progress bar + Item { + id: progressItem - // When clicked outside the menu, hide it - MouseArea { - id: optionsDismisser - visible: options.state != "hidden" - onClicked: options.state = "hidden" - anchors.fill: parent - } + 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 + } + } - // The menu at the top right - Options { - id: options + } - anchors { - top: navigation.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 + Navigation { + id: navigation - height: Kirigami.Units.gridUnit * 3 + height: Kirigami.Units.gridUnit * 3 - anchors { - top: parent.top - left: parent.left - right: parent.right + 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 + // Thin line underneath navigation + Rectangle { + height: webBrowser.borderWidth + color: webBrowser.borderColor + anchors { + left: parent.left + bottom: navigation.bottom + right: options.left + } } + } + Component.onCompleted: { if (!initialUrl.isEmpty) load(initialUrl) } } diff --git a/src/resources.qrc b/src/resources.qrc index c85824d..e9096bf 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -1,20 +1,19 @@ contents/ui/Bookmarks.qml - contents/ui/ContentView.qml contents/ui/ErrorHandler.qml contents/ui/History.qml contents/ui/ListWebView.qml contents/ui/Navigation.qml contents/ui/OptionButton.qml contents/ui/Options.qml contents/ui/OptionsOverview.qml contents/ui/Settings.qml contents/ui/Tabs.qml contents/ui/TabWebView.qml contents/ui/UrlDelegate.qml contents/ui/webbrowser.qml contents/ui/WebView.qml regex-weburl/regex-weburl.js