Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Add search tabs functionality and grid layout #429

Open
wants to merge 7 commits into
base: xenial
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 84 additions & 9 deletions src/app/webbrowser/Browser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ Common.BrowserView {
internal.switchToTab(tabsModel.count - 1, true);
}

function openRecentView() {
recentView.state = "shown"
if (!browser.wide) {
recentToolbar.state = "shown"
}
}

signal newWindowRequested(bool incognito)
signal newWindowFromTab(var tab, var callback)
signal openLinkInNewWindowRequested(url url, bool incognito)
Expand Down Expand Up @@ -554,13 +561,18 @@ Common.BrowserView {
id: recentView
objectName: "recentView"

z: browser.wide ? 1 : 0
anchors.fill: parent
visible: bottomEdgeHandle.dragging || tabslist.animating || (state == "shown")
onVisibleChanged: {
if (visible) {

forceActiveFocus()
currentWebview.hideContextMenu();
chrome.state = "hidden";
tabslist.reset()

if (!browser.wide) {
chrome.state = "hidden";
}
}
else {
chrome.state = "shown";
Expand All @@ -576,11 +588,60 @@ Common.BrowserView {
internal.switchToTab(index, false)
}

Keys.onEscapePressed: closeAndSwitchToTab(0)
Keys.onEscapePressed: {
if (browser.wide) {
recentView.reset()
} else {
closeAndSwitchToTab(0)
}
}

Keys.onPressed: {
if (event.text.trim() !== "") {
tabslist.focusInput();
tabslist.searchText = event.text;
}
switch (event.key) {
case Qt.Key_Right:
case Qt.Key_Left:
case Qt.Key_Down:
tabslist.view.forceActiveFocus()
break;
case Qt.Key_Up:
tabslist.focusInput();
break;
}

event.accepted = true;
}

Rectangle {
id: backgroundRec

anchors.fill: parent
color: UbuntuColors.jet
opacity: 0.5
visible: browser.wide

MouseArea {
anchors.fill: parent
preventStealing: true
onClicked: recentView.reset()
}
}

TabsList {
id: tabslist
anchors.fill: parent

anchors {
top: parent.top
topMargin: !browser.wide ? 0 :
browser.height > units.gu(90) ? chrome.height : units.gu(2)
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
}

width: browser.wide ? browser.width * 0.7 : parent.width
model: tabsModel
readonly property real delegateMinHeight: units.gu(20)
delegateHeight: {
Expand Down Expand Up @@ -610,8 +671,8 @@ Common.BrowserView {
objectName: "recentToolbar"

anchors {
left: parent.left
right: parent.right
left: tabslist.left
right: tabslist.right
}
height: units.gu(7)
state: "hidden"
Expand Down Expand Up @@ -750,6 +811,7 @@ Common.BrowserView {
onSwitchToTab: internal.switchToTab(index, true)
onRequestNewTab: internal.openUrlInNewTab("", makeCurrent, true, index)
onTabClosed: internal.closeTab(index, moving)
onOpenRecentView: browser.openRecentView()

onFindInPageModeChanged: {
if (!chrome.findInPageMode) internal.resetFocus()
Expand Down Expand Up @@ -973,9 +1035,8 @@ Common.BrowserView {
}

onWideChanged: {
if (wide) {
recentView.reset()
} else {
recentView.reset()
if (!wide) {
// In narrow mode, the tabslist is a stack: the current tab is always at the top.
tabsModel.move(tabsModel.currentIndex, 0)
}
Expand Down Expand Up @@ -1792,6 +1853,20 @@ Common.BrowserView {
onActivated: currentWebview.zoomController.resetSaveFit()
}

// Ctrl+W: Open and search tabs list
Shortcut {
sequence: "Ctrl+Space"
enabled: currentWebview || recentView.visible
onActivated: {
console.log();
if (recentView.visible) {
recentView.reset()
} else {
browser.openRecentView()
}
}
}

Loader {
id: contentHandlerLoader
source: "../ContentHandler.qml"
Expand Down
2 changes: 2 additions & 0 deletions src/app/webbrowser/Chrome.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ChromeBase {
signal switchToTab(int index)
signal requestNewTab(int index, bool makeCurrent)
signal tabClosed(int index, bool moving)
signal openRecentView

backgroundColor: incognito ? UbuntuColors.darkGrey : theme.palette.normal.background

Expand Down Expand Up @@ -103,6 +104,7 @@ ChromeBase {

onRequestNewTab: chrome.requestNewTab(index, makeCurrent)
onTabClosed: chrome.tabClosed(index, moving)
onOpenRecentView: chrome.openRecentView()
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/app/webbrowser/TabPreview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ QQC2.SwipeDelegate {
property alias title: chrome.title
property alias tabIcon: chrome.icon
property alias incognito: chrome.incognito
property real chromeHeight
property var tab
readonly property url url: tab ? tab.url : ""

Expand Down Expand Up @@ -57,6 +58,7 @@ QQC2.SwipeDelegate {
right: parent.right
}
tabWidth: units.gu(26)
height: tabPreview.chromeHeight

onSelected: tabPreview.selected()
onClosed: tabPreview.closed()
Expand All @@ -73,7 +75,7 @@ QQC2.SwipeDelegate {


visible: !tab.loadingPreview
height: parent.height
height: parent.height - chrome.height
clip: true

Rectangle {
Expand Down
6 changes: 6 additions & 0 deletions src/app/webbrowser/TabsBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Extras.TabsBar {

signal requestNewTab(int index, bool makeCurrent)
signal tabClosed(int index, bool moving)
signal openRecentView

onContextMenu: PopupUtils.open(contextualOptionsComponent, tabDelegate, {"targetIndex": index})

Expand All @@ -65,6 +66,11 @@ Extras.TabsBar {
}

actions: [
Action {
iconName: "search"
objectName: "searchTabButton"
onTriggered: tabsBar.openRecentView()
},
Action {
// FIXME: icon from theme is fuzzy at many GUs
// iconSource: Qt.resolvedUrl("Tabs/tab_add.png")
Expand Down
Loading