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

Commit

Permalink
Merge pull request #8 from kugiigi/xenial_-_tabsearch
Browse files Browse the repository at this point in the history
Xenial   tabsearch
  • Loading branch information
kugiigi authored May 3, 2021
2 parents 5b43683 + 5937232 commit 5cd7cf4
Show file tree
Hide file tree
Showing 5 changed files with 420 additions and 66 deletions.
93 changes: 84 additions & 9 deletions src/app/webbrowser/Browser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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 @@ -572,13 +579,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 @@ -594,11 +606,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 @@ -628,8 +689,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 @@ -771,6 +832,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 @@ -994,9 +1056,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 @@ -1847,6 +1908,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 @@ -58,6 +58,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 @@ -107,6 +108,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 @@ -60,6 +61,7 @@ QQC2.SwipeDelegate {
right: parent.right
}
tabWidth: units.gu(26)
height: tabPreview.chromeHeight

onSelected: tabPreview.selected()
onClosed: tabPreview.closed()
Expand All @@ -76,7 +78,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

0 comments on commit 5cd7cf4

Please sign in to comment.