diff --git a/src/contents/ui/Navigation.qml b/src/contents/ui/Navigation.qml index 4f77054..21604ad 100644 --- a/src/contents/ui/Navigation.qml +++ b/src/contents/ui/Navigation.qml @@ -1,166 +1,166 @@ /*************************************************************************** * * * 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 QtWebEngine 1.4 import QtQuick.Controls 2.0 as Controls import org.kde.kirigami 2.5 as Kirigami import "regex-weburl.js" as RegexWebUrl Item { id: navigation property bool navigationShown: true property alias textFocus: urlInput.activeFocus property alias text: urlInput.text property int expandedHeight: Kirigami.Units.gridUnit * 3 property int buttonSize: Kirigami.Units.gridUnit * 2 Behavior on height { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad} } Rectangle { anchors.fill: parent; color: Kirigami.Theme.backgroundColor; } RowLayout { id: layout anchors.fill: parent anchors.leftMargin: Kirigami.Units.gridUnit / 2 anchors.rightMargin: Kirigami.Units.gridUnit / 2 visible: navigationShown spacing: Kirigami.Units.smallSpacing Controls.ToolButton { icon.name: "tab-duplicate" Layout.preferredWidth: buttonSize Layout.preferredHeight: buttonSize onClicked: { pageStack.layers.push("Tabs.qml") options.state = "hidden" } } Controls.ToolButton { id: backButton Layout.preferredWidth: buttonSize Layout.preferredHeight: buttonSize visible: currentWebView.canGoBack && !Kirigami.Settings.isMobile icon.name: "go-previous" onClicked: currentWebView.goBack() } Controls.ToolButton { id: forwardButton Layout.preferredWidth: buttonSize Layout.preferredHeight: buttonSize visible: currentWebView.canGoForward && !Kirigami.Settings.isMobile icon.name: "go-next" onClicked: currentWebView.goForward() } Controls.TextField { id: urlInput Layout.fillWidth: true text: currentWebView.url selectByMouse: true focus: false onAccepted: { if (text.match(RegexWebUrl.re_weburl)) { load(browserManager.urlFromUserInput(text)) } else { load(browserManager.urlFromUserInput(browserManager.searchBaseUrl + text)) } } } Controls.ToolButton { id: reloadButton Layout.preferredWidth: buttonSize Layout.preferredHeight: buttonSize visible: !Kirigami.Settings.isMobile icon.name: currentWebView.loading ? "process-stop" : "view-refresh" onClicked: currentWebView.loading ? currentWebView.stop() : currentWebView.reload() } Item { Layout.preferredWidth: buttonSize Layout.preferredHeight: buttonSize visible: currentWebView.loading Controls.BusyIndicator { width: buttonSize height: width anchors.centerIn: parent running: currentWebView.loading } } - OptionButton { + Controls.ToolButton { id: optionsButton property string targetState: "overview" Layout.fillWidth: false Layout.preferredWidth: buttonSize Layout.preferredHeight: buttonSize - iconSource: "open-menu-symbolic" + icon.name: "open-menu-symbolic" - onClicked: options.state = (options.state != "hidden" ? "hidden" : targetState) + onClicked: contextDrawer.open() } } states: [ State { name: "shown" when: navigationShown PropertyChanges { target: navigation; height: expandedHeight} }, State { name: "hidden" when: !navigationShown PropertyChanges { target: navigation; height: 0} } ] } diff --git a/src/contents/ui/OptionButton.qml b/src/contents/ui/OptionButton.qml deleted file mode 100644 index 484cddd..0000000 --- a/src/contents/ui/OptionButton.qml +++ /dev/null @@ -1,54 +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 QtQuick.Controls 2.2 as Controls -import QtQuick.Layouts 1.0 - -import org.kde.kirigami 2.4 as Kirigami - - -Controls.ToolButton { - id: button - - property alias iconSource: iconItem.source - - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - - Kirigami.Icon { - id: iconItem - anchors.fill: parent - visible: text == "" - } - - RowLayout { - id: layoutRow - anchors.fill: parent - Kirigami.Icon { - id: rowIcon - Layout.preferredWidth: parent.width * 0.25 - Layout.fillWidth: false - source: iconItem.source - } - visible: text != "" - } -} diff --git a/src/contents/ui/Options.qml b/src/contents/ui/Options.qml deleted file mode 100644 index 7b81124..0000000 --- a/src/contents/ui/Options.qml +++ /dev/null @@ -1,105 +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: options - - state: "hidden" - //state: "bookmarks" - color: Kirigami.Theme.backgroundColor - - property string title: "" - - 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} } - - width: expandedWidth - height: childrenRect.height - - 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 - top: parent.top - right: parent.right - } - } - - ColumnLayout { - spacing: 0 - anchors { - //fill: parent - top: parent.top - //topMargin: Kirigami.Units.gridUnit - left: parent.left - right: parent.right - //margins: Kirigami.Units.gridUnit / 2 - } - - OptionsOverview { - Layout.fillWidth: true; - } - Loader { - id: loader - Layout.fillHeight: true - Layout.fillWidth: true - //Rectangle { anchors.fill: parent; color: "black"; opacity: 0.1; } - } - } - 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 } - - } - ] -} diff --git a/src/contents/ui/OptionsOverview.qml b/src/contents/ui/OptionsOverview.qml deleted file mode 100644 index 188503a..0000000 --- a/src/contents/ui/OptionsOverview.qml +++ /dev/null @@ -1,189 +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 QtQuick.Layouts 1.0 - -import org.kde.kirigami 2.0 as Kirigami - - -ColumnLayout { - id: optionsOverview - - property int buttonSize: Kirigami.Units.gridUnit * 2 - - Item { - Layout.preferredHeight: Kirigami.Units.smallSpacing - Layout.fillWidth: true - } - - OptionButton { - iconSource: "tab-duplicate" - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - onClicked: { - pageStack.layers.push("Tabs.qml") - options.state = "hidden" - } - text: i18n("Tabs") - } - - OptionButton { - iconSource: "bookmarks" - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - onClicked: { - pageStack.layers.push("Bookmarks.qml") - options.state = "hidden" - } - text: i18n("Bookmarks") - } - - OptionButton { - iconSource: "view-history" - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - onClicked: { - pageStack.layers.push("History.qml") - options.state = "hidden" - } - text: i18n("History") - } - - InputSheet { - id: findSheet - title: i18n("Find in page") - placeholderText: i18n("Find...") - description: i18n("Highlight text on the current website") - onAccepted: currentWebView.findText(findSheet.text) - } - - OptionButton { - iconSource: "edit-find" - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - onClicked: findSheet.open() - text: i18n("Find in page") - } - - OptionButton { - iconSource: "configure" - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - text: i18n("Settings") - onClicked: { - pageStack.layers.push("Settings.qml") - options.state = "hidden" - } - } - - OptionButton { - iconSource: "document-share" - Layout.fillWidth: true - Layout.preferredHeight: buttonSize - text: i18n("Share page") - onClicked: { - shareSheet.url = currentWebView.url - shareSheet.title = currentWebView.title - shareSheet.open() - } - } - - ShareSheet { - id: shareSheet - } - - - Item { - Layout.preferredHeight: Kirigami.Units.smallSpacing - Layout.fillWidth: true - } - - RowLayout { - id: layout - - 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.icon = currentWebView.icon; - request.bookmarked = true; - browserManager.addBookmark(request); - options.state = "hidden" - - } - - } - - } -} diff --git a/src/contents/ui/webbrowser.qml b/src/contents/ui/webbrowser.qml index f0871b8..f8f9937 100644 --- a/src/contents/ui/webbrowser.qml +++ b/src/contents/ui/webbrowser.qml @@ -1,251 +1,348 @@ /*************************************************************************** * * * 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.3 import QtGraphicalEffects 1.0 import org.kde.kirigami 2.4 as Kirigami Kirigami.ApplicationWindow { id: webBrowser title: i18n("Angelfish Web Browser") /** 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 color borderColor: Kirigami.Theme.highlightColor; /** * Load a url in the current tab */ function load(url) { print("Loading url: " + url); currentWebView.url = url; currentWebView.forceActiveFocus() } 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); } property bool layerShown : pageStack.layers.depth > 1 pageStack.globalToolBar.style: layerShown ? Kirigami.ApplicationHeaderStyle.Auto : Kirigami.ApplicationHeaderStyle.None pageStack.initialPage: Kirigami.Page { leftPadding: 0 rightPadding: 0 topPadding: 0 bottomPadding: 0 ListWebView { id: tabs anchors { top: parent.top left: parent.left right: parent.right bottom: navigation.top } } ErrorHandler { id: errorHandler errorString: currentWebView.errorString errorCode: currentWebView.errorCode anchors { top: parent.top left: parent.left right: parent.right bottom: navigation.top } visible: currentWebView.errorCode !== "" } Kirigami.InlineMessage { id: newTabQuestion type: Kirigami.MessageType.Warning text: i18n("Site wants to open a new tab: \n%1", url.toString()) showCloseButton: true anchors.bottom: navigation.top anchors.left: parent.left anchors.right: parent.right property var url actions: [ Kirigami.Action { iconName: "tab-new" text: i18n("Open") onTriggered: { tabs.newTab(newTabQuestion.url.toString()) newTabQuestion.visible = false } } ] } Kirigami.InlineMessage { id: downloadQuestion text: i18n("Do you want to download this file?") showCloseButton: false anchors.bottom: navigation.top anchors.left: parent.left anchors.right: parent.right property var download actions: [ Kirigami.Action { iconName: "download" text: i18n("Download") onTriggered: { downloadQuestion.download.resume() downloadQuestion.visible = false } }, Kirigami.Action { iconName: "dialog-cancel" text: i18n("Cancel") onTriggered: { downloadQuestion.download.cancel() downloadQuestion.visible = false } } ] } // Container for the progress bar Item { id: progressItem height: Math.round(Kirigami.Units.gridUnit / 6) z: navigation.z + 1 anchors { top: tabs.bottom 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 } + InputSheet { + id: findSheet + title: i18n("Find in page") + placeholderText: i18n("Find...") + description: i18n("Highlight text on the current website") + onAccepted: currentWebView.findText(findSheet.text) + } + + ShareSheet { + id: shareSheet + } + + Kirigami.ContextDrawer { + id: contextDrawer + + handleVisible: false + } + // The menu at the top right - Options { - id: options + contextualActions: [ + Kirigami.Action { + icon.name: "tab-duplicate" + onTriggered: { + pageStack.layers.push("Tabs.qml") + } + text: i18n("Tabs") + }, + Kirigami.Action { + icon.name: "bookmarks" + onTriggered: { + pageStack.layers.push("Bookmarks.qml") + } + text: i18n("Bookmarks") + }, + Kirigami.Action { + icon.name: "view-history" + onTriggered: { + pageStack.layers.push("History.qml") + } + text: i18n("History") + }, + Kirigami.Action { + icon.name: "edit-find" + onTriggered: findSheet.open() + text: i18n("Find in page") + }, + Kirigami.Action { + icon.name: "configure" + text: i18n("Settings") + onTriggered: { + pageStack.layers.push("Settings.qml") + } + }, + Kirigami.Action { + icon.name: "document-share" + text: i18n("Share page") + onTriggered: { + shareSheet.url = currentWebView.url + shareSheet.title = currentWebView.title + shareSheet.open() + } + }, + Kirigami.Action { + enabled: currentWebView.canGoBack + icon.name: "go-previous" + text: i18n("Go previous") + + onTriggered: { + options.state = "hidden"; + currentWebView.goBack() + } + }, + Kirigami.Action { + enabled: currentWebView.canGoForward + icon.name: "go-next" + text: i18n("Go forward") - anchors { - bottom: navigation.top + + onTriggered: { + currentWebView.goForward() + } + }, + Kirigami.Action { + icon.name: currentWebView.loading ? "process-stop" : "view-refresh" + text: currentWebView.loading ? i18n("Stop loading") : i18n("Refresh") + + onTriggered: { + currentWebView.loading ? currentWebView.stop() : currentWebView.reload() + } + }, + Kirigami.Action { + icon.name: "bookmarks" + text: i18n("Add bookmark") + + onTriggered: { + print("Adding bookmark"); + var request = new Object;// FIXME + request.url = currentWebView.url; + request.title = currentWebView.title; + request.icon = currentWebView.icon; + request.bookmarked = true; + browserManager.addBookmark(request); + } } - } + ] Navigation { id: navigation navigationShown: !webappcontainer && webBrowser.visibility !== Window.FullScreen layer.enabled: true layer.effect: DropShadow { verticalOffset: 1 color: Kirigami.Theme.disabledTextColor samples: 20 spread: 0.3 cached: true // element is static } anchors { bottom: completion.top left: parent.left right: parent.right } onTextChanged: urlFilter.setFilterFixedString(text) } Completion { id: completion model: urlFilter width: parent.width height: 0.5 * parent.height visible: navigation.textFocus searchText: navigation.text anchors { bottom: parent.bottom horizontalCenter: navigation.horizontalCenter } } // Thin line underneath navigation Rectangle { height: webBrowser.borderWidth color: webBrowser.borderColor anchors { left: parent.left bottom: navigation.top right: options.left } } } } diff --git a/src/resources.qrc b/src/resources.qrc index 085c550..716c299 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -1,21 +1,18 @@ contents/ui/Bookmarks.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/UrlDelegate.qml contents/ui/webbrowser.qml contents/ui/WebView.qml regex-weburl/regex-weburl.js contents/ui/InputSheet.qml contents/ui/ShareSheet.qml contents/ui/Completion.qml