~osomon/webbrowser-app/escape-all-html-entities-in-search-queries

« back to all changes in this revision

Viewing changes to src/app/webbrowser/TabComponent.qml

  • Committer: Olivier Tilloy
  • Author(s): Andrew Hayzen
  • Date: 2016-11-29 14:37:59 UTC
  • mfrom: (1465.2.87 dnd-tabs-001)
  • Revision ID: olivier.tilloy@canonical.com-20161129143759-sgjf5kp74dafm7no
Add Drag and drop support of tabs between windows on non-mir clients.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
    BrowserTab {
36
36
        anchors.fill: parent
37
 
        incognito: browser.incognito
38
 
        current: tabsModel && tabsModel.currentTab === this
 
37
        incognito: browser ? browser.incognito : false
 
38
        current: browser ? browser.tabsModel && browser.tabsModel.currentTab === this : false
39
39
        focus: current
40
40
 
 
41
        property var bottomEdgeHandle
 
42
        property var browser
 
43
        property var chrome
 
44
        property var chromeController
 
45
        property var contentHandlerLoader
 
46
        property var downloadDialogLoader
 
47
        property var downloadsViewLoader
 
48
        property var filePickerLoader
 
49
        property var internal
 
50
        property var recentView
 
51
        property var tabsModel
 
52
 
41
53
        Item {
42
54
            id: contextualMenuTarget
43
55
            visible: false
49
61
            property BrowserTab tab
50
62
            readonly property bool current: tab.current
51
63
 
52
 
            currentWebview: browser.currentWebview
53
 
            filePicker: filePickerLoader.item
 
64
            currentWebview: browser ? browser.currentWebview : null
 
65
            filePicker: filePickerLoader ? filePickerLoader.item : null
54
66
 
55
67
            anchors.fill: parent
56
68
 
57
69
            focus: true
58
70
 
59
 
            enabled: current && !bottomEdgeHandle.dragging && !recentView.visible && tabContainer.focus
 
71
            enabled: current && !bottomEdgeHandle.dragging && !recentView.visible && parent.focus
60
72
 
61
73
            locationBarController {
62
 
                height: chrome.height
63
 
                mode: chromeController.defaultMode
 
74
                height: chrome ? chrome.height : 0
 
75
                mode: chromeController ? chromeController.defaultMode : null
64
76
            }
65
77
 
66
78
            //experimental.preferences.developerExtrasEnabled: developerExtrasEnabled
115
127
                }
116
128
                Actions.Share {
117
129
                    objectName: "ShareContextualAction"
118
 
                    enabled: (contentHandlerLoader.status == Loader.Ready) && contextModel &&
 
130
                    enabled: (contentHandlerLoader && contentHandlerLoader.status == Loader.Ready) && contextModel &&
119
131
                             (contextModel.linkUrl.toString() || contextModel.selectionText)
120
132
                    onTriggered: {
121
133
                        if (contextModel.linkUrl.toString()) {
238
250
                    Component.onCompleted: webviewimpl.contextMenuOnCompleted(this)
239
251
                }
240
252
            }
241
 
            contextMenu: browser.wide ? contextMenuWideComponent : contextMenuNarrowComponent
 
253
            contextMenu: browser && browser.wide ? contextMenuWideComponent : contextMenuNarrowComponent
242
254
 
243
255
            onNewViewRequested: {
244
 
                var tab = tabComponent.createObject(tabContainer, {"request": request})
 
256
                var tab = browser.createTab({"request": request})
245
257
                var setCurrent = (request.disposition == Oxide.NewViewRequest.DispositionNewForegroundTab)
246
258
                internal.addTab(tab, setCurrent)
247
259
                if (setCurrent) tabContainer.forceActiveFocus()
257
269
                                break
258
270
                            }
259
271
                        }
 
272
 
 
273
                        // tab.close() destroys the context so add new tab before destroy if required
 
274
                        if (tabsModel.count === 0) {
 
275
                            internal.openUrlInNewTab("", true, true)
 
276
                        }
 
277
 
260
278
                        tab.close()
261
 
                    }
262
 
                    if (tabsModel.count === 0) {
 
279
                    } else if (tabsModel.count === 0) {
263
280
                        internal.openUrlInNewTab("", true, true)
264
281
                    }
265
282
                }