Commit 2ecebd81 authored by Rinigus Saar's avatar Rinigus Saar

add settings backend and allow to select navigation buttons

parent 6e7a12d2
......@@ -56,7 +56,9 @@ Item {
Kirigami.Theme.inherit: true
Controls.ToolButton {
id: mainMenuButton
icon.name: rootPage.privateMode ? "view-private" : "open-menu-symbolic"
visible: webBrowser.landscape || settings.navBarMainMenu
Layout.preferredWidth: buttonSize
Layout.preferredHeight: buttonSize
......@@ -67,6 +69,7 @@ Item {
}
Controls.ToolButton {
visible: webBrowser.landscape || settings.navBarTabs
Layout.preferredWidth: buttonSize
Layout.preferredHeight: buttonSize
......@@ -106,7 +109,7 @@ Item {
Layout.preferredWidth: buttonSize
Layout.preferredHeight: buttonSize
visible: currentWebView.canGoBack && !Kirigami.Settings.isMobile
visible: currentWebView.canGoBack && settings.navBarBack
icon.name: "go-previous"
Kirigami.Theme.inherit: true
......@@ -120,7 +123,7 @@ Item {
Layout.preferredWidth: buttonSize
Layout.preferredHeight: buttonSize
visible: currentWebView.canGoForward && !Kirigami.Settings.isMobile
visible: currentWebView.canGoForward && settings.navBarForward
icon.name: "go-next"
Kirigami.Theme.inherit: true
......@@ -186,7 +189,7 @@ Item {
Layout.preferredWidth: buttonSize
Layout.preferredHeight: buttonSize
visible: !Kirigami.Settings.isMobile
visible: settings.navBarReload
icon.name: currentWebView.loading ? "process-stop" : "view-refresh"
Kirigami.Theme.inherit: true
......@@ -204,6 +207,7 @@ Item {
Layout.preferredWidth: buttonSize
Layout.preferredHeight: buttonSize
visible: webBrowser.landscape || settings.navBarContextMenu
icon.name: "overflow-menu"
Kirigami.Theme.inherit: true
......
/***************************************************************************
* *
* Copyright 2014-2015 Sebastian Kügler <sebas@kde.org> *
* Copyright 2020 Rinigus <rinigus.git@gmail.com> *
* 2020 Jonah Brüchert <jbb@kaidan.im> *
* *
* 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 *
......@@ -20,117 +21,42 @@
***************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 2.4 as Controls
import QtQuick.Layouts 1.11
import Qt.labs.settings 1.0 as QtSettings
import org.kde.kirigami 2.7 as Kirigami
import org.kde.mobile.angelfish 1.0
Kirigami.ScrollablePage {
title: i18n("Settings")
QtObject {
id: settings
topPadding: 0
bottomPadding: 0
leftPadding: 0
rightPadding: 0
Kirigami.ColumnView.fillWidth: false
// WebView
property bool webAutoLoadImages: true
property bool webJavascriptEnabled: true
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.View
color: Kirigami.Theme.backgroundColor
}
ColumnLayout {
id: settingsPage
spacing: 0
Controls.SwitchDelegate {
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
}
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
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
}
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
// Navigation bar
property bool navBarMainMenu: true
property bool navBarTabs: true
property bool navBarBack: !Kirigami.Settings.isMobile
property bool navBarForward: !Kirigami.Settings.isMobile
property bool navBarReload: !Kirigami.Settings.isMobile
property bool navBarContextMenu: true
InputSheet {
id: homePagePopup
title: i18n("Homepage")
description: i18n("Website that should be loaded on startup")
placeholderText: BrowserManager.homepage
onAccepted: {
if (homePagePopup.text !== "")
BrowserManager.homepage = UrlUtils.urlFromUserInput(homePagePopup.text)
}
}
///////////////////////////////////
// settings storage
InputSheet {
id: searchEnginePopup
title: i18n("Search Engine")
description: i18n("Base URL of your preferred search engine")
placeholderText: BrowserManager.searchBaseUrl
onAccepted: {
if (searchEnginePopup.text !== "")
BrowserManager.searchBaseUrl = UrlUtils.urlFromUserInput(searchEnginePopup.text)
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.ItemDelegate {
text: i18n("Homepage")
Layout.fillWidth: true
onClicked: {
homePagePopup.open()
}
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.ItemDelegate {
text: i18n("Search Engine")
Layout.fillWidth: true
onClicked: {
searchEnginePopup.open()
}
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
property QtSettings.Settings _settingsWebView: QtSettings.Settings {
category: "WebView"
property alias autoLoadImages: settings.webAutoLoadImages
property alias javascriptEnabled: settings.webJavascriptEnabled
}
Item {
Layout.fillHeight: true
}
property QtSettings.Settings _settingsNavBar: QtSettings.Settings {
category: "NavigationBar"
property alias mainMenu: settings.navBarMainMenu
property alias tabs: settings.navBarTabs
property alias back: settings.navBarBack
property alias forward: settings.navBarForward
property alias reload: settings.navBarReload
property alias contextMenu: settings.navBarContextMenu
}
}
/***************************************************************************
* *
* Copyright 2020 Rinigus <rinigus.git@gmail.com> *
* 2020 Jonah Brüchert <jbb@kaidan.im> *
* *
* 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.7 as Kirigami
import org.kde.mobile.angelfish 1.0
Kirigami.ScrollablePage {
title: i18n("Navigation bar")
topPadding: 0
bottomPadding: 0
leftPadding: 0
rightPadding: 0
Kirigami.ColumnView.fillWidth: false
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.View
color: Kirigami.Theme.backgroundColor
}
ColumnLayout {
spacing: 0
property real itemHeight: Kirigami.Units.gridUnit * 2.5
Controls.Label {
padding: Kirigami.Units.gridUnit
text: i18n("Choose the buttons enabled in navigation bar. " +
"Some of the buttons can be hidden only in portrait " +
"orientation of the browser and are always shown if " +
"the browser is wider than its height.\n\n" +
"Note that if you disable the menu buttons, you " +
"will be able to access the menus either by swiping " +
"from the left or right side or to a side along the bottom " +
"of the window.")
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Main menu in portrait")
Layout.fillWidth: true
checked: settings.navBarMainMenu
implicitHeight: parent.itemHeight
onCheckedChanged: settings.navBarMainMenu = checked
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Tabs in portrait")
Layout.fillWidth: true
checked: settings.navBarTabs
implicitHeight: parent.itemHeight
onCheckedChanged: settings.navBarTabs = checked
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Context menu in portrait")
Layout.fillWidth: true
checked: settings.navBarContextMenu
implicitHeight: parent.itemHeight
onCheckedChanged: settings.navBarContextMenu = checked
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Go back")
Layout.fillWidth: true
checked: settings.navBarBack
implicitHeight: parent.itemHeight
onCheckedChanged: settings.navBarBack = checked
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Go forward")
Layout.fillWidth: true
checked: settings.navBarForward
implicitHeight: parent.itemHeight
onCheckedChanged: settings.navBarForward = checked
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Reload/Stop")
Layout.fillWidth: true
checked: settings.navBarReload
implicitHeight: parent.itemHeight
onCheckedChanged: settings.navBarReload = checked
}
Kirigami.Separator {
Layout.fillWidth: true
}
Kirigami.Separator {
Layout.fillWidth: true
}
Item {
Layout.fillHeight: true
}
}
}
/***************************************************************************
* *
* Copyright 2014-2015 Sebastian Kügler <sebas@kde.org> *
* *
* 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.7 as Kirigami
import org.kde.mobile.angelfish 1.0
Kirigami.ScrollablePage {
title: i18n("Settings")
topPadding: 0
bottomPadding: 0
leftPadding: 0
rightPadding: 0
Kirigami.ColumnView.fillWidth: false
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.View
color: Kirigami.Theme.backgroundColor
}
ColumnLayout {
id: settingsPage
spacing: 0
Controls.SwitchDelegate {
text: i18n("Enable JavaScript")
Layout.fillWidth: true
checked: settings.webJavascriptEnabled
onCheckedChanged: settings.webJavascriptEnabled = checked
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.SwitchDelegate {
text: i18n("Load images")
Layout.fillWidth: true
checked: settings.webAutoLoadImages
onCheckedChanged: settings.webAutoLoadImages = checked
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
InputSheet {
id: homePagePopup
title: i18n("Homepage")
description: i18n("Website that should be loaded on startup")
placeholderText: BrowserManager.homepage
onAccepted: {
if (homePagePopup.text !== "")
BrowserManager.homepage = UrlUtils.urlFromUserInput(homePagePopup.text)
}
}
InputSheet {
id: searchEnginePopup
title: i18n("Search Engine")
description: i18n("Base URL of your preferred search engine")
placeholderText: BrowserManager.searchBaseUrl
onAccepted: {
if (searchEnginePopup.text !== "")
BrowserManager.searchBaseUrl = UrlUtils.urlFromUserInput(searchEnginePopup.text)
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.ItemDelegate {
text: i18n("Homepage")
Layout.fillWidth: true
onClicked: {
homePagePopup.open()
}
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.ItemDelegate {
text: i18n("Search Engine")
Layout.fillWidth: true
onClicked: {
searchEnginePopup.open()
}
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls.ItemDelegate {
text: i18n("Navigation bar")
Layout.fillWidth: true
onClicked: pageStack.push(Qt.resolvedUrl("SettingsNavigationBarPage.qml"))
implicitHeight: Kirigami.Units.gridUnit * 2.5
}
Kirigami.Separator {
Layout.fillWidth: true
}
Item {
Layout.fillHeight: true
}
}
}
......@@ -95,6 +95,8 @@ WebEngineView {
}
settings {
autoLoadImages: webBrowser.settings.webAutoLoadImages
javascriptEnabled: webBrowser.settings.webJavascriptEnabled
// Disable builtin error pages in favor of our own
errorPageEnabled: false
// Load larger touch icons
......
......@@ -23,7 +23,7 @@ import QtQuick 2.1
import QtWebEngine 1.6
import QtQuick.Window 2.3
import QtGraphicalEffects 1.0
import Qt.labs.settings 1.0
import Qt.labs.settings 1.0 as QtSettings
import org.kde.kirigami 2.7 as Kirigami
import org.kde.mobile.angelfish 1.0
......@@ -47,6 +47,12 @@ Kirigami.ApplicationWindow {
// them according to the current mode.
property ListWebView tabs: rootPage.privateMode ? privateTabs : regularTabs
// Pointer to browser settings
property Settings settings: settings
// Used to determine if the window is in landscape mode
property bool landscape: width > height
onCurrentWebViewChanged: {
print("Current WebView is now : " + tabs.currentIndex);
}
......@@ -103,7 +109,7 @@ Kirigami.ApplicationWindow {
icon.name: "configure"
text: i18n("Settings")
onTriggered: {
pageStack.push(Qt.resolvedUrl("Settings.qml"))
pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
}
}
]
......@@ -371,16 +377,22 @@ Kirigami.ApplicationWindow {
// drop all sub pages as soon as the browser window is the
// focussed one
if (webBrowser.pageStack.currentIndex === 0)
webBrowser.pageStack.pop();
while (webBrowser.pageStack.depth > 1)
webBrowser.pageStack.pop();
}
}
Settings {
QtSettings.Settings {
// kept separate to simplify definition of aliases
property alias x: webBrowser.x
property alias y: webBrowser.y
property alias width: webBrowser.width
property alias height: webBrowser.height
}
Settings {
id: settings
}
Component.onCompleted: rootPage.initialized = true
}
......@@ -6,6 +6,8 @@
<file alias="ListWebView.qml">contents/ui/ListWebView.qml</file>
<file alias="Navigation.qml">contents/ui/Navigation.qml</file>
<file alias="Settings.qml">contents/ui/Settings.qml</file>
<file alias="SettingsPage.qml">contents/ui/SettingsPage.qml</file>
<file alias="SettingsNavigationBarPage.qml">contents/ui/SettingsNavigationBarPage.qml</file>
<file alias="Tabs.qml">contents/ui/Tabs.qml</file>
<file alias="UrlDelegate.qml">contents/ui/UrlDelegate.qml</file>
<file alias="webbrowser.qml">contents/ui/webbrowser.qml</file>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment