Commit 335be74e authored by Simon Schmeißer's avatar Simon Schmeißer
Browse files

Replace ContentView with Kirigami layers

moved everything into Kirigami.Page/ScrollablePage and
just push/pop "dialogs" to layers
parent 8d0c6206
......@@ -25,11 +25,9 @@ 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 {
......@@ -42,6 +40,7 @@ Item {
model: browserManager.bookmarks
delegate: UrlDelegate {
onClicked: pageStack.layers.pop()
onRemoved: browserManager.removeBookmark(url);
}
}
......
/***************************************************************************
* *
* 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 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"}
}
]
}
......@@ -24,11 +24,10 @@ 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 {
......@@ -41,6 +40,7 @@ Item {
model: browserManager.history
delegate: UrlDelegate {
onClicked: pageStack.layers.pop()
onRemoved: browserManager.removeFromHistory(url);
}
}
......
......@@ -37,8 +37,8 @@ ListView {
// 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
......
......@@ -89,9 +89,6 @@ Rectangle {
right: parent.right
//margins: Kirigami.Units.gridUnit / 2
}
MouseArea {
anchors.fill: parent
}
OptionsOverview {
Layout.fillWidth: true;
......
......@@ -32,7 +32,7 @@ ColumnLayout {
RowLayout {
id: layout
anchors.fill: parent
height: buttonSize
spacing: 0
// anchors.leftMargin: Kirigami.Units.gridUnit / 2
......@@ -110,10 +110,9 @@ ColumnLayout {
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")
}
......@@ -122,10 +121,9 @@ ColumnLayout {
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")
}
......@@ -134,10 +132,9 @@ ColumnLayout {
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")
}
......@@ -146,9 +143,8 @@ ColumnLayout {
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"
}
......
......@@ -26,36 +26,42 @@ 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
}
}
......@@ -31,10 +31,12 @@ import org.kde.kirigami 2.0 as Kirigami
// 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
......@@ -109,7 +111,7 @@ Item {
tabs.currentIndex = index;
tabs.positionViewAtIndex(index, ListView.Beginning);
//tabs.positionViewAtEnd();
contentView.state = "hidden"
pageStack.layers.pop()
return;
if (tabItem.width < tabsRoot.width) {
......@@ -140,6 +142,7 @@ Item {
//addressBar.forceActiveFocus();
//addressBar.selectAll();
tabs.currentIndex = tabs.count - 1;
pageStack.layers.pop()
}
}
......
......@@ -54,12 +54,8 @@ WebEngineView {
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"
......@@ -73,7 +69,6 @@ WebEngineView {
print("Load failed: " + loadRequest.errorCode + " " + loadRequest.errorString);
ec = loadRequest.errorCode;
es = loadRequest.errorString;
contentView.state = "hidden"
}
errorCode = ec;
errorString = es;
......
......@@ -23,7 +23,7 @@ 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 {
......@@ -41,7 +41,7 @@ Kirigami.ApplicationWindow {
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
......@@ -64,103 +64,113 @@ Kirigami.ApplicationWindow {
}
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)
......
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