Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sailfish-browser] Use pulley menu for actions in tab page. #957

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions apps/browser/qml/pages/components/Overlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,6 @@ Shared.Background {
portrait: tabPage.isPortrait
privateMode: webView.privateMode

scaledPortraitHeight: toolBar.scaledPortraitHeight
scaledLandscapeHeight: toolBar.scaledLandscapeHeight

onHide: pageStack.pop()

onPrivateModeChanged: {
Expand Down
35 changes: 15 additions & 20 deletions apps/browser/qml/pages/components/TabGridView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SilicaGridView {
property bool closingAllTabs

property var remorsePopup
readonly property int _spacing: Theme.paddingLarge
readonly property bool largeScreen: Screen.sizeCategory > Screen.Medium
readonly property real thumbnailHeight: largeScreen
? Screen.width / 3
Expand All @@ -27,10 +28,9 @@ SilicaGridView {
? portrait ? 2 : 3
: parent.width < 2 * parent.height
? parent.width <= height ? 1 : 2 : 3
readonly property real thumbnailWidth: (parent.width - Theme.horizontalPageMargin * 2 - (Theme.paddingLarge * (columns - 1))) / columns
readonly property real thumbnailWidth: (parent.width - Theme.horizontalPageMargin * 2 - (_spacing * (columns - 1))) / columns

signal hide
signal enterNewTabUrl
signal activateTab(int index)
signal closeTab(int index)
signal closeAll
Expand Down Expand Up @@ -59,12 +59,17 @@ SilicaGridView {
onCountChanged: if (count > 0) closingAllTabs = false
onClosingAllTabsChanged: if (closingAllTabs) closeAllPending()

width: parent.width - Theme.horizontalPageMargin
height: parent.height
x: Theme.horizontalPageMargin
anchors.fill: parent
currentIndex: model.activeTabIndex
cellWidth: thumbnailWidth + Theme.paddingLarge
cellHeight: thumbnailHeight + Theme.paddingLarge
cellWidth: thumbnailWidth + _spacing
cellHeight: thumbnailHeight + _spacing
contentItem.anchors.left: tabGridView.left
contentItem.anchors.leftMargin: Theme.horizontalPageMargin

header: Item {
width: 1
height: _spacing
}

delegate: TabItem {
id: tabItem
Expand Down Expand Up @@ -94,25 +99,15 @@ SilicaGridView {
}
]


Item {
height: parent.height
anchors.right: parent.right
width: Math.round(Theme.paddingSmall/2)

VerticalScrollDecorator {
_forcedParent: parent
flickable: tabGridView
}
}
VerticalScrollDecorator {}

ViewPlaceholder {
x: -Theme.horizontalPageMargin
width: parent.width + Theme.horizontalPageMargin
enabled: !model.count || closingAllTabs
//: Hint to create a new tab via button new tab.
//% "Push button plus to create a new tab"
text: qsTrId("sailfish_browser-la-push_button_plus_to_create_tab_hint")
//% "Pull down menu to create a new tab"
text: qsTrId("sailfish_browser-la-pull_menu_to_create_tab_hint")
}

Timer {
Expand Down
137 changes: 32 additions & 105 deletions apps/browser/qml/pages/components/TabView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ SilicaControl {
property bool portrait
property bool privateMode
property var tabModel
property alias scaledPortraitHeight: tabsToolBar.scaledPortraitHeight
property alias scaledLandscapeHeight: tabsToolBar.scaledLandscapeHeight

signal hide
signal enterNewTabUrl
Expand All @@ -42,12 +40,9 @@ SilicaControl {
Private.TabView {
id: tabs

anchors {
fill: parent
bottomMargin: tabsToolBar.height
}
anchors.fill: parent

header: Private.TabBar {
footer: Private.TabBar {
id: headerTabs
model: modeModel
delegate: Private.TabButton {
Expand Down Expand Up @@ -113,18 +108,43 @@ SilicaControl {

portrait: tabView.portrait
model: tabItem.privateMode ? webView.privateTabModel : webView.persistentTabModel
header: Item {
width: 1
height: Theme.paddingLarge
}

onHide: tabView.hide()
onEnterNewTabUrl: tabView.enterNewTabUrl()
onActivateTab: tabView.activateTab(index)
onCloseTab: tabView.closeTab(index)
onCloseAll: tabView.closeAll()
onCloseAllCanceled: tabView.closeAllCanceled()
onCloseAllPending: tabView.closeAllPending()

PullDownMenu {
MenuItem {
visible: tabView.showCloseAllAction.value && model.count
//% "Close all tabs"
text: qsTrId("sailfish_browser-me-close_all")
onClicked: _tabView.closeAllTabs()
}
MenuItem {
text: tabItem.privateMode
//% "New tab"
? qsTrId("sailfish_browser-la-new_tab")
//% "New private tab"
: qsTrId("sailfish_browser-la-new_private_tab")
onClicked: {
// remove binding to block animation
tabs.currentIndex = tabs.currentIndex
tabView.privateMode = !tabItem.privateMode
tabView.enterNewTabUrl()
}
}
MenuItem {
text: tabItem.privateMode
//% "New private tab"
? qsTrId("sailfish_browser-la-new_private_tab")
//% "New tab"
: qsTrId("sailfish_browser-la-new_tab")
onClicked: tabView.enterNewTabUrl()
}
}
}

onIsCurrentItemChanged: {
Expand All @@ -134,14 +154,6 @@ SilicaControl {
}
}

Connections {
target: popupMenu
onCloseAllTabs: {
if (isCurrentItem)
_tabView.closeAllTabs()
}
}

PrivateModeTexture {
visible: privateMode
z: -1
Expand All @@ -167,91 +179,6 @@ SilicaControl {
}
}

TabsToolBar {
id: tabsToolBar
anchors.bottom: parent.bottom
onBack: pageStack.pop()
onEnterNewTabUrl: tabView.enterNewTabUrl()
onOpenMenu: popupMenu.active = true
}

PopUpMenu {
id: popupMenu

signal closeAllTabs

anchors.fill: parent
active: false

menuItem: Component {
Item {
id: menuItem_
readonly property int iconWidth: Theme.iconSizeMedium + Theme.paddingLarge
readonly property int verticalPadding: 3 * Theme.paddingSmall

height: content.height + verticalPadding * 2

Column {
id: content

y: verticalPadding
width: parent.width
spacing: Theme.paddingLarge

Column {
width: parent.width

OverlayListItem {
height: Theme.itemSizeSmall
iconWidth: menuItem_.iconWidth
iconSource: "image://theme/icon-m-tab-new"
enabled: !_closingAllTabs
//% "New tab"
text: qsTrId("sailfish_browser-la-new_tab")
onClicked: {
popupMenu.visible = false
// override to block animation
tabs.currentIndex = privateMode ? 1 : 0
tabView.privateMode = false
tabView.enterNewTabUrl()
}
}

OverlayListItem {
height: Theme.itemSizeSmall
iconWidth: menuItem_.iconWidth
iconSource: "image://theme/icon-m-incognito-new"
enabled: !_closingAllTabs
//% "New private tab"
text: qsTrId("sailfish_browser-la-new_private_tab")
onClicked: {
popupMenu.visible = false
// override to block animation
tabs.currentIndex = privateMode ? 1 : 0
tabView.privateMode = true
tabView.enterNewTabUrl()
}
}

OverlayListItem {
height: Theme.itemSizeSmall
iconWidth: menuItem_.iconWidth
iconSource: "image://theme/icon-m-tab-close"
enabled: showCloseAllAction.value && webView.tabModel.count && !_closingAllTabs
//% "Close all tabs"
text: qsTrId("sailfish_browser-me-close_all")
onClicked: {
popupMenu.active = false
popupMenu.closeAllTabs()
}
}
}
}
}
}
onClosed: active = false
}

ConfigurationValue {
id: showCloseAllAction
key: "/apps/sailfish-browser/settings/show_close_all"
Expand Down