Merge lp:~artmello/webbrowser-app/webbrowser-app-multi_window into lp:webbrowser-app

Proposed by Arthur Mello
Status: Rejected
Rejected by: Olivier Tilloy
Proposed branch: lp:~artmello/webbrowser-app/webbrowser-app-multi_window
Merge into: lp:webbrowser-app
Diff against target: 772 lines (+440/-91)
13 files modified
src/app/BrowserView.qml (+4/-0)
src/app/actions/NewPrivateWindow.qml (+28/-0)
src/app/actions/NewWindow.qml (+28/-0)
src/app/actions/OpenLinkInNewPrivateWindow.qml (+23/-0)
src/app/actions/OpenLinkInNewWindow.qml (+23/-0)
src/app/webbrowser/BookmarksModel.qml (+0/-24)
src/app/webbrowser/Browser.qml (+118/-33)
src/app/webbrowser/CMakeLists.txt (+1/-0)
src/app/webbrowser/HistoryModel.qml (+0/-24)
src/app/webbrowser/webbrowser-app.cpp (+40/-9)
src/app/webbrowser/webbrowser-app.qml (+9/-1)
src/app/webbrowser/windows-model.cpp (+106/-0)
src/app/webbrowser/windows-model.h (+60/-0)
To merge this branch: bzr merge lp:~artmello/webbrowser-app/webbrowser-app-multi_window
Reviewer Review Type Date Requested Status
Olivier Tilloy Disapprove
system-apps-ci-bot continuous-integration Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+272681@code.launchpad.net

Description of the change

*DO NOT MERGE/REVIEW*
Initial prototype of Multi Window using QML approach

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1207. By Arthur Mello

Undo changes on the models

1208. By Arthur Mello

Make HistoryModel and BookmarksModel to be singletons

1209. By Arthur Mello

Open new window with startuo url wn nothing is set

1210. By Arthur Mello

Add support to open new windows in private mode

1211. By Arthur Mello

Add initial support to storing all opened windows

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1212. By Arthur Mello

Expand session storage support

1213. By Arthur Mello

Merge with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1214. By Arthur Mello

Make sure that only a single instance of webbrowser is running

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1214
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~artmello/webbrowser-app/webbrowser-app-multi_window/+merge/272681/+edit-commit-message

https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/208/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-0-fetch/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/208/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/208/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/208/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :
review: Disapprove

Unmerged revisions

1214. By Arthur Mello

Make sure that only a single instance of webbrowser is running

1213. By Arthur Mello

Merge with trunk

1212. By Arthur Mello

Expand session storage support

1211. By Arthur Mello

Add initial support to storing all opened windows

1210. By Arthur Mello

Add support to open new windows in private mode

1209. By Arthur Mello

Open new window with startuo url wn nothing is set

1208. By Arthur Mello

Make HistoryModel and BookmarksModel to be singletons

1207. By Arthur Mello

Undo changes on the models

1206. By Arthur Mello

Initial prototype of Multi Window using QML approach

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/BrowserView.qml'
--- src/app/BrowserView.qml 2015-08-10 15:22:00 +0000
+++ src/app/BrowserView.qml 2015-10-07 00:51:42 +0000
@@ -37,11 +37,15 @@
3737
38 focus: true38 focus: true
3939
40 /* FIXME: Error when opening new windows
41 * Reason: An object is already exported for the interface org.gtk.Actions at /com/canonical/unity/actions
42
40 property QtObject actionManager: UnityActions.ActionManager {43 property QtObject actionManager: UnityActions.ActionManager {
41 id: unityActionManager44 id: unityActionManager
42 onQuit: Qt.quit()45 onQuit: Qt.quit()
43 }46 }
44 property alias actions: unityActionManager.actions47 property alias actions: unityActionManager.actions
48 */
4549
46 default property alias contents: contentsItem.data50 default property alias contents: contentsItem.data
47 property alias automaticOrientation: contentsItem.automaticOrientation51 property alias automaticOrientation: contentsItem.automaticOrientation
4852
=== added file 'src/app/actions/NewPrivateWindow.qml'
--- src/app/actions/NewPrivateWindow.qml 1970-01-01 00:00:00 +0000
+++ src/app/actions/NewPrivateWindow.qml 2015-10-07 00:51:42 +0000
@@ -0,0 +1,28 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import Ubuntu.Components 1.3
20import Ubuntu.Unity.Action 1.1 as UnityActions
21
22UnityActions.Action {
23 text: i18n.tr("New Private Window")
24 // TRANSLATORS: This is a free-form list of keywords associated to the 'New Private Window' action.
25 // Keywords may actually be sentences, and must be separated by semi-colons.
26 keywords: i18n.tr("Open a New Private Window")
27}
28
029
=== added file 'src/app/actions/NewWindow.qml'
--- src/app/actions/NewWindow.qml 1970-01-01 00:00:00 +0000
+++ src/app/actions/NewWindow.qml 2015-10-07 00:51:42 +0000
@@ -0,0 +1,28 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import Ubuntu.Components 1.3
20import Ubuntu.Unity.Action 1.1 as UnityActions
21
22UnityActions.Action {
23 text: i18n.tr("New Window")
24 // TRANSLATORS: This is a free-form list of keywords associated to the 'New Window' action.
25 // Keywords may actually be sentences, and must be separated by semi-colons.
26 keywords: i18n.tr("Open a New Window")
27}
28
029
=== added file 'src/app/actions/OpenLinkInNewPrivateWindow.qml'
--- src/app/actions/OpenLinkInNewPrivateWindow.qml 1970-01-01 00:00:00 +0000
+++ src/app/actions/OpenLinkInNewPrivateWindow.qml 2015-10-07 00:51:42 +0000
@@ -0,0 +1,23 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import Ubuntu.Components 1.3
20
21Action {
22 text: i18n.tr("Open link in new private window")
23}
024
=== added file 'src/app/actions/OpenLinkInNewWindow.qml'
--- src/app/actions/OpenLinkInNewWindow.qml 1970-01-01 00:00:00 +0000
+++ src/app/actions/OpenLinkInNewWindow.qml 2015-10-07 00:51:42 +0000
@@ -0,0 +1,23 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import Ubuntu.Components 1.3
20
21Action {
22 text: i18n.tr("Open link in new window")
23}
024
=== removed file 'src/app/webbrowser/BookmarksModel.qml'
--- src/app/webbrowser/BookmarksModel.qml 2015-08-10 15:22:00 +0000
+++ src/app/webbrowser/BookmarksModel.qml 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1/*
2 * Copyright 2014-2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import webbrowserapp.private 0.1
21
22BookmarksModel {
23 databasePath: dataLocation + "/bookmarks.sqlite"
24}
250
=== modified file 'src/app/webbrowser/Browser.qml'
--- src/app/webbrowser/Browser.qml 2015-09-28 08:15:10 +0000
+++ src/app/webbrowser/Browser.qml 2015-10-07 00:51:42 +0000
@@ -31,13 +31,15 @@
31BrowserView {31BrowserView {
32 id: browser32 id: browser
3333
34 signal closingWindow()
35
34 // Should be true when the containing window is fullscreen.36 // Should be true when the containing window is fullscreen.
35 property bool fullscreen: false37 property bool fullscreen: false
3638
37 currentWebview: tabsModel && tabsModel.currentTab ? tabsModel.currentTab.webview : null39 currentWebview: tabsModel && tabsModel.currentTab ? tabsModel.currentTab.webview : null
3840
39 property var historyModel: (historyModelLoader.status == Loader.Ready) ? historyModelLoader.item : null41 property var historyModel: HistoryModel
40 property var bookmarksModel: (bookmarksModelLoader.status == Loader.Ready) ? bookmarksModelLoader.item : null42 property var bookmarksModel: BookmarksModel
4143
42 property bool newSession: false44 property bool newSession: false
4345
@@ -54,6 +56,21 @@
54 // tab objects (see http://pad.lv/1376433).56 // tab objects (see http://pad.lv/1376433).
55 readonly property int maxTabsToRestore: 1057 readonly property int maxTabsToRestore: 10
5658
59 property alias tabContainer: tabContainer
60 property alias currentTabIndex: publicTabsModel.currentIndex
61
62 Component.onCompleted: {
63 WindowsModel.add(browser)
64 HistoryModel.databasePath = dataLocation + "/history.sqlite"
65 BookmarksModel.databasePath = dataLocation + "/bookmarks.sqlite"
66 }
67
68 Component.onDestruction: closingWindow()
69
70 onClosingWindow: {
71 WindowsModel.remove(browser)
72 }
73
57 onTabsModelChanged: {74 onTabsModelChanged: {
58 if (incognito && privateTabsModelLoader.item) {75 if (incognito && privateTabsModelLoader.item) {
59 browser.openUrlInNewTab("", true)76 browser.openUrlInNewTab("", true)
@@ -75,6 +92,7 @@
75 }92 }
76 }93 }
7794
95 /*
78 actions: [96 actions: [
79 Actions.GoTo {97 Actions.GoTo {
80 onTriggered: currentWebview.url = value98 onTriggered: currentWebview.url = value
@@ -98,6 +116,12 @@
98 Actions.NewTab {116 Actions.NewTab {
99 onTriggered: browser.openUrlInNewTab("", true)117 onTriggered: browser.openUrlInNewTab("", true)
100 },118 },
119 Actions.NewWindow {
120 onTriggered: browser.openUrlInNewWindow("")
121 },
122 Actions.NewPrivateWindow {
123 onTriggered: browser.openUrlInNewWindow("", true)
124 },
101 Actions.ClearHistory {125 Actions.ClearHistory {
102 enabled: browser.historyModel126 enabled: browser.historyModel
103 onTriggered: browser.historyModel.clearAll()127 onTriggered: browser.historyModel.clearAll()
@@ -110,6 +134,7 @@
110 }134 }
111 }135 }
112 ]136 ]
137 */
113138
114 Settings {139 Settings {
115 id: settings140 id: settings
@@ -335,7 +360,7 @@
335 y: webview ? webview.locationBarController.offset : 0360 y: webview ? webview.locationBarController.offset : 0
336361
337 function isCurrentUrlBookmarked() {362 function isCurrentUrlBookmarked() {
338 return ((webview && browser.bookmarksModel) ? browser.bookmarksModel.contains(webview.url) : false)363 return ((webview && BookmarksModel) ? BookmarksModel.contains(webview.url) : false)
339 }364 }
340 bookmarked: isCurrentUrlBookmarked()365 bookmarked: isCurrentUrlBookmarked()
341 onToggleBookmark: {366 onToggleBookmark: {
@@ -348,7 +373,7 @@
348 onUrlChanged: chrome.bookmarked = chrome.isCurrentUrlBookmarked()373 onUrlChanged: chrome.bookmarked = chrome.isCurrentUrlBookmarked()
349 }374 }
350 Connections {375 Connections {
351 target: browser.bookmarksModel376 target: BookmarksModel
352 onAdded: if (!chrome.bookmarked && (url === chrome.webview.url)) chrome.bookmarked = true377 onAdded: if (!chrome.bookmarked && (url === chrome.webview.url)) chrome.bookmarked = true
353 onRemoved: if (chrome.bookmarked && (url === chrome.webview.url)) chrome.bookmarked = false378 onRemoved: if (chrome.bookmarked && (url === chrome.webview.url)) chrome.bookmarked = false
354 }379 }
@@ -395,6 +420,20 @@
395 onTriggered: browser.openUrlInNewTab("", true)420 onTriggered: browser.openUrlInNewTab("", true)
396 },421 },
397 Action {422 Action {
423 objectName: "newwindow"
424 text: i18n.tr("New window")
425 iconName: "note-new"
426 visible: (formFactor === "desktop")
427 onTriggered: browser.openUrlInNewWindow("")
428 },
429 Action {
430 objectName: "newprivatewindow"
431 text: i18n.tr("New private window")
432 iconName: "note-new"
433 visible: (formFactor === "desktop")
434 onTriggered: browser.openUrlInNewWindow("", true)
435 },
436 Action {
398 objectName: "findinpage"437 objectName: "findinpage"
399 text: i18n.tr("Find in page")438 text: i18n.tr("Find in page")
400 iconName: "search"439 iconName: "search"
@@ -899,19 +938,7 @@
899 }938 }
900 }939 }
901 }940 }
902941
903 Loader {
904 id: historyModelLoader
905 source: "HistoryModel.qml"
906 asynchronous: true
907 }
908
909 Loader {
910 id: bookmarksModelLoader
911 source: "BookmarksModel.qml"
912 asynchronous: true
913 }
914
915 Component {942 Component {
916 id: tabComponent943 id: tabComponent
917944
@@ -961,6 +988,16 @@
961 (formFactor === "desktop")))988 (formFactor === "desktop")))
962 onTriggered: browser.openUrlInNewTab(contextModel.linkUrl, false)989 onTriggered: browser.openUrlInNewTab(contextModel.linkUrl, false)
963 }990 }
991 Actions.OpenLinkInNewWindow {
992 objectName: "openLinkInNewWindowContextualAction"
993 enabled: contextModel && contextModel.linkUrl.toString() && formFactor === "desktop"
994 onTriggered: browser.openUrlInNewWindow(contextModel.linkUrl)
995 }
996 Actions.OpenLinkInNewPrivateWindow {
997 objectName: "OpenLinkInNewPrivateWindowContextualAction"
998 enabled: contextModel && contextModel.linkUrl.toString() && formFactor === "desktop"
999 onTriggered: browser.openUrlInNewWindow(contextModel.linkUrl, true)
1000 }
964 Actions.BookmarkLink {1001 Actions.BookmarkLink {
965 objectName: "BookmarkLinkContextualAction"1002 objectName: "BookmarkLinkContextualAction"
966 enabled: contextModel && contextModel.linkUrl.toString() &&1003 enabled: contextModel && contextModel.linkUrl.toString() &&
@@ -1364,6 +1401,27 @@
1364 }1401 }
1365 }1402 }
13661403
1404 function openUrlInNewWindow(url, incognito) {
1405 incognito = typeof incognito !== 'undefined' ? incognito : false
1406
1407 var component = Qt.createComponent("./webbrowser-app.qml")
1408 if (component.status == Component.Ready) {
1409 var newWindow = component.createObject()
1410
1411 newWindow.incognito = incognito
1412
1413 if (url.toString()) {
1414 newWindow.urls = [url]
1415 }
1416 newWindow.show()
1417 return newWindow
1418 }
1419 }
1420
1421 function restoreTab(tab, setCurrent) {
1422 internal.addTab(tab, setCurrent)
1423 }
1424
1367 SessionStorage {1425 SessionStorage {
1368 id: session1426 id: session
13691427
@@ -1373,12 +1431,27 @@
1373 if (!locked) {1431 if (!locked) {
1374 return1432 return
1375 }1433 }
1376 var tabs = []1434
1377 for (var i = 0; i < publicTabsModel.count; ++i) {1435 var session = {
1378 var tab = publicTabsModel.get(i)1436 'windows': []
1379 tabs.push(serializeTabState(tab))1437 }
1380 }1438
1381 store(JSON.stringify({tabs: tabs, currentIndex: publicTabsModel.currentIndex}))1439 for (var i = 0; i < WindowsModel.count; ++i) {
1440 var window = WindowsModel.get(i)
1441 var tabs = window.tabsModel
1442 var sessionWindow = {
1443 'tabs': [],
1444 'currentIndex': tabsModel.currentIndex
1445 }
1446
1447 for (var j = 0; j < tabsModel.count; ++j) {
1448 var tab = tabs.get(j)
1449 sessionWindow.tabs.push(serializeTabState(tab))
1450 }
1451
1452 session.windows.push(sessionWindow)
1453 }
1454 store(JSON.stringify(session))
1382 }1455 }
13831456
1384 function restore() {1457 function restore() {
@@ -1392,16 +1465,28 @@
1392 return1465 return
1393 }1466 }
1394 if (state) {1467 if (state) {
1395 var tabs = state.tabs1468 var windows = state.windows
1396 if (tabs) {1469 if (windows) {
1397 for (var i = 0; i < Math.min(tabs.length, browser.maxTabsToRestore); ++i) {1470 for (var w = 0; w < windows.length; ++w) {
1398 var tab = createTabFromState(tabs[i])1471 var windowBrowser = browser
1399 internal.addTab(tab, i == 0)1472 if (w > 0) {
1473 var newWindow = browser.openUrlInNewWindow("")
1474 windowBrowser = newWindow.browser
1475 }
1476
1477 var tabs = windows[w].tabs
1478 if (tabs) {
1479 for (var t = 0; t < Math.min(tabs.length, windowBrowser.maxTabsToRestore); ++t) {
1480 var tab = createTabFromState(tabs[t], windowBrowser.tabContainer)
1481 windowBrowser.restoreTab(tab, t == 0)
1482 }
1483 }
1484
1485 if ('currentIndex' in windows[w]) {
1486 windowBrowser.currentTabIndex = windows[w].currentIndex
1487 }
1400 }1488 }
1401 }1489 }
1402 if ('currentIndex' in state) {
1403 publicTabsModel.currentIndex = state.currentIndex
1404 }
1405 }1490 }
1406 }1491 }
14071492
@@ -1417,7 +1502,7 @@
1417 return state1502 return state
1418 }1503 }
14191504
1420 function createTabFromState(state) {1505 function createTabFromState(state, container) {
1421 var properties = {'initialUrl': state.url, 'initialTitle': state.title}1506 var properties = {'initialUrl': state.url, 'initialTitle': state.title}
1422 if ('uniqueId' in state) {1507 if ('uniqueId' in state) {
1423 properties["uniqueId"] = state.uniqueId1508 properties["uniqueId"] = state.uniqueId
@@ -1432,7 +1517,7 @@
1432 properties['restoreState'] = state.savedState1517 properties['restoreState'] = state.savedState
1433 properties['restoreType'] = Oxide.WebView.RestoreLastSessionExitedCleanly1518 properties['restoreType'] = Oxide.WebView.RestoreLastSessionExitedCleanly
1434 }1519 }
1435 return tabComponent.createObject(tabContainer, properties)1520 return tabComponent.createObject(container, properties)
1436 }1521 }
1437 }1522 }
1438 Timer {1523 Timer {
14391524
=== modified file 'src/app/webbrowser/CMakeLists.txt'
--- src/app/webbrowser/CMakeLists.txt 2015-09-22 01:27:19 +0000
+++ src/app/webbrowser/CMakeLists.txt 2015-10-07 00:51:42 +0000
@@ -24,6 +24,7 @@
24 tabs-model.cpp24 tabs-model.cpp
25 text-search-filter-model.cpp25 text-search-filter-model.cpp
26 top-sites-model.cpp26 top-sites-model.cpp
27 windows-model.cpp
27)28)
2829
29set(WEBBROWSER_APP_MODELS webbrowser-app-models)30set(WEBBROWSER_APP_MODELS webbrowser-app-models)
3031
=== removed file 'src/app/webbrowser/HistoryModel.qml'
--- src/app/webbrowser/HistoryModel.qml 2015-08-10 15:22:00 +0000
+++ src/app/webbrowser/HistoryModel.qml 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1/*
2 * Copyright 2014-2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import webbrowserapp.private 0.1
21
22HistoryModel {
23 databasePath: dataLocation + "/history.sqlite"
24}
250
=== modified file 'src/app/webbrowser/webbrowser-app.cpp'
--- src/app/webbrowser/webbrowser-app.cpp 2015-08-19 13:16:06 +0000
+++ src/app/webbrowser/webbrowser-app.cpp 2015-10-07 00:51:42 +0000
@@ -32,6 +32,7 @@
32#include "text-search-filter-model.h"32#include "text-search-filter-model.h"
33#include "tabs-model.h"33#include "tabs-model.h"
34#include "top-sites-model.h"34#include "top-sites-model.h"
35#include "windows-model.h"
35#include "webbrowser-app.h"36#include "webbrowser-app.h"
3637
37// Qt38// Qt
@@ -64,24 +65,46 @@
64 return new CacheDeleter();65 return new CacheDeleter();
65}66}
6667
68static QObject* HistoryModel_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine)
69{
70 Q_UNUSED(engine);
71 Q_UNUSED(scriptEngine);
72 return new HistoryModel();
73}
74
75static QObject* BookmarksModel_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine)
76{
77 Q_UNUSED(engine);
78 Q_UNUSED(scriptEngine);
79 return new BookmarksModel();
80}
81
82static QObject* WindowsModel_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine)
83{
84 Q_UNUSED(engine);
85 Q_UNUSED(scriptEngine);
86 return new WindowsModel();
87}
88
67bool WebbrowserApp::initialize()89bool WebbrowserApp::initialize()
68{90{
69 const char* uri = "webbrowserapp.private";91 const char* uri = "webbrowserapp.private";
70 qmlRegisterType<HistoryModel>(uri, 0, 1, "HistoryModel");92 qmlRegisterSingletonType<BookmarksModel>(uri, 0, 1, "BookmarksModel", BookmarksModel_singleton_factory);
71 qmlRegisterType<HistoryTimeframeModel>(uri, 0, 1, "HistoryTimeframeModel");93 qmlRegisterSingletonType<CacheDeleter>(uri, 0, 1, "CacheDeleter", CacheDeleter_singleton_factory);
72 qmlRegisterType<TopSitesModel>(uri, 0 , 1, "TopSitesModel");94 qmlRegisterSingletonType<FileOperations>(uri, 0, 1, "FileOperations", FileOperations_singleton_factory);
95 qmlRegisterSingletonType<HistoryModel>(uri, 0, 1, "HistoryModel", HistoryModel_singleton_factory);
96 qmlRegisterSingletonType<WindowsModel>(uri, 0, 1, "WindowsModel", WindowsModel_singleton_factory);
97 qmlRegisterType<BookmarksFolderListModel>(uri, 0, 1, "BookmarksFolderListModel");
98 qmlRegisterType<HistoryDomainListChronologicalModel>(uri, 0, 1, "HistoryDomainListChronologicalModel");
73 qmlRegisterType<HistoryDomainListModel>(uri, 0, 1, "HistoryDomainListModel");99 qmlRegisterType<HistoryDomainListModel>(uri, 0, 1, "HistoryDomainListModel");
74 qmlRegisterType<HistoryDomainListChronologicalModel>(uri, 0, 1, "HistoryDomainListChronologicalModel");
75 qmlRegisterType<HistoryLastVisitDateListModel>(uri, 0, 1, "HistoryLastVisitDateListModel");100 qmlRegisterType<HistoryLastVisitDateListModel>(uri, 0, 1, "HistoryLastVisitDateListModel");
76 qmlRegisterType<HistoryLastVisitDateModel>(uri, 0, 1, "HistoryLastVisitDateModel");101 qmlRegisterType<HistoryLastVisitDateModel>(uri, 0, 1, "HistoryLastVisitDateModel");
102 qmlRegisterType<HistoryTimeframeModel>(uri, 0, 1, "HistoryTimeframeModel");
77 qmlRegisterType<LimitProxyModel>(uri, 0 , 1, "LimitProxyModel");103 qmlRegisterType<LimitProxyModel>(uri, 0 , 1, "LimitProxyModel");
104 qmlRegisterType<SearchEngine>(uri, 0, 1, "SearchEngine");
78 qmlRegisterType<TabsModel>(uri, 0, 1, "TabsModel");105 qmlRegisterType<TabsModel>(uri, 0, 1, "TabsModel");
79 qmlRegisterType<BookmarksModel>(uri, 0, 1, "BookmarksModel");
80 qmlRegisterType<BookmarksFolderListModel>(uri, 0, 1, "BookmarksFolderListModel");
81 qmlRegisterSingletonType<FileOperations>(uri, 0, 1, "FileOperations", FileOperations_singleton_factory);
82 qmlRegisterType<SearchEngine>(uri, 0, 1, "SearchEngine");
83 qmlRegisterSingletonType<CacheDeleter>(uri, 0, 1, "CacheDeleter", CacheDeleter_singleton_factory);
84 qmlRegisterType<TextSearchFilterModel>(uri, 0, 1, "TextSearchFilterModel");106 qmlRegisterType<TextSearchFilterModel>(uri, 0, 1, "TextSearchFilterModel");
107 qmlRegisterType<TopSitesModel>(uri, 0 , 1, "TopSitesModel");
85108
86 if (BrowserApplication::initialize("webbrowser/webbrowser-app.qml")) {109 if (BrowserApplication::initialize("webbrowser/webbrowser-app.qml")) {
87 QStringList searchEnginesSearchPaths;110 QStringList searchEnginesSearchPaths;
@@ -122,6 +145,14 @@
122int main(int argc, char** argv)145int main(int argc, char** argv)
123{146{
124 QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);147 QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
148
149 // Make sure that only a single instance of webbrowser is running
150 const char *sharedMemKey = "webbrowser-app";
151 QSharedMemory sharedMem(sharedMemKey);
152 if (!sharedMem.create(1, QSharedMemory::ReadOnly)) {
153 return 0;
154 }
155
125 WebbrowserApp app(argc, argv);156 WebbrowserApp app(argc, argv);
126 if (app.initialize()) {157 if (app.initialize()) {
127 return app.run();158 return app.run();
128159
=== modified file 'src/app/webbrowser/webbrowser-app.qml'
--- src/app/webbrowser/webbrowser-app.qml 2015-08-10 15:33:43 +0000
+++ src/app/webbrowser/webbrowser-app.qml 2015-10-07 00:51:42 +0000
@@ -24,11 +24,15 @@
24BrowserWindow {24BrowserWindow {
25 id: window25 id: window
2626
27 property bool incognito: false
27 property alias urls: browser.initialUrls28 property alias urls: browser.initialUrls
28 property alias newSession: browser.newSession29 property alias newSession: browser.newSession
30 property alias browser: browser
2931
30 currentWebview: browser.currentWebview32 currentWebview: browser.currentWebview
3133
34 onClosing: browser.closingWindow()
35
32 title: {36 title: {
33 if (browser.title) {37 if (browser.title) {
34 // TRANSLATORS: %1 refers to the current page’s title38 // TRANSLATORS: %1 refers to the current page’s title
@@ -44,9 +48,13 @@
44 webbrowserWindow: webbrowserWindowProxy48 webbrowserWindow: webbrowserWindowProxy
45 developerExtrasEnabled: window.developerExtrasEnabled49 developerExtrasEnabled: window.developerExtrasEnabled
4650
51 incognito: window.incognito
52
47 fullscreen: window.visibility === Window.FullScreen53 fullscreen: window.visibility === Window.FullScreen
4854
49 Component.onCompleted: i18n.domain = "webbrowser-app"55 Component.onCompleted: {
56 i18n.domain = "webbrowser-app"
57 }
5058
51 Keys.onPressed: {59 Keys.onPressed: {
52 if ((event.key === Qt.Key_F11) && (event.modifiers === Qt.NoModifier)) {60 if ((event.key === Qt.Key_F11) && (event.modifiers === Qt.NoModifier)) {
5361
=== added file 'src/app/webbrowser/windows-model.cpp'
--- src/app/webbrowser/windows-model.cpp 1970-01-01 00:00:00 +0000
+++ src/app/webbrowser/windows-model.cpp 2015-10-07 00:51:42 +0000
@@ -0,0 +1,106 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "windows-model.h"
20
21// Qt
22#include <QtCore/QDebug>
23#include <QtCore/QObject>
24
25/*!
26 \class WindowsModel
27 \brief List model that stores the list of currently open windows.
28
29 WindowsModel is a list model that stores the list of currently open windowss.
30 Each window holds a pointer to a Window and associated metadata (id).
31
32 The model doesn’t own the Window, so it is the responsibility of whoever
33 adds a window to instantiate the corresponding Window, and to destroy it after
34 it’s removed from the model.
35*/
36WindowsModel::WindowsModel(QObject* parent)
37 : QAbstractListModel(parent)
38{
39}
40
41WindowsModel::~WindowsModel()
42{
43}
44
45QHash<int, QByteArray> WindowsModel::roleNames() const
46{
47 static QHash<int, QByteArray> roles;
48 if (roles.isEmpty()) {
49 roles[TabsModel] = "tabsModel";
50 }
51 return roles;
52}
53
54int WindowsModel::rowCount(const QModelIndex& parent) const
55{
56 Q_UNUSED(parent);
57 return m_windows.count();
58}
59
60QVariant WindowsModel::data(const QModelIndex& index, int role) const
61{
62 if (!index.isValid()) {
63 return QVariant();
64 }
65 QObject* window = m_windows.at(index.row());
66 switch (role) {
67 case TabsModel:
68 return window->property("urls");
69 default:
70 return QVariant();
71 }
72}
73
74void WindowsModel::add(QObject* window)
75{
76 if (window == nullptr) {
77 qWarning() << "Invalid Window";
78 return;
79 }
80 int index = m_windows.count();
81 beginInsertRows(QModelIndex(), index, index);
82 m_windows.append(window);
83 endInsertRows();
84 Q_EMIT countChanged();
85}
86
87void WindowsModel::remove(QObject* window)
88{
89 int index = m_windows.indexOf(window);
90 if (index < 0) {
91 return;
92 }
93 beginRemoveRows(QModelIndex(), index, index);
94 m_windows.removeAt(index);
95 endRemoveRows();
96 Q_EMIT countChanged();
97}
98
99QObject* WindowsModel::get(int index) const
100{
101 if ((index < 0) || (index >= m_windows.count())) {
102 qWarning() << "Invalid window index:" << index;
103 return nullptr;
104 }
105 return m_windows.at(index);
106}
0107
=== added file 'src/app/webbrowser/windows-model.h'
--- src/app/webbrowser/windows-model.h 1970-01-01 00:00:00 +0000
+++ src/app/webbrowser/windows-model.h 2015-10-07 00:51:42 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __WINDOWS_MODEL_H__
20#define __WINDOWS_MODEL_H__
21
22// Qt
23#include <QtCore/QAbstractListModel>
24#include <QtCore/QList>
25
26class QObject;
27
28class WindowsModel : public QAbstractListModel
29{
30 Q_OBJECT
31
32 Q_ENUMS(Roles)
33
34 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
35
36public:
37 WindowsModel(QObject* parent=0);
38 ~WindowsModel();
39
40 enum Roles {
41 TabsModel = Qt::UserRole + 1,
42 };
43
44 // reimplemented from QAbstractListModel
45 QHash<int, QByteArray> roleNames() const;
46 int rowCount(const QModelIndex& parent=QModelIndex()) const;
47 QVariant data(const QModelIndex& index, int role) const;
48
49 Q_INVOKABLE void add(QObject* window);
50 Q_INVOKABLE void remove(QObject* window);
51 Q_INVOKABLE QObject* get(int index) const;
52
53Q_SIGNALS:
54 void countChanged() const;
55
56private:
57 QList<QObject*> m_windows;
58};
59
60#endif // __WINDOWS_MODEL_H__

Subscribers

People subscribed via source and target branches

to status/vote changes: