Merge lp:~fboucault/webbrowser-app/save_window_size into lp:webbrowser-app/staging

Proposed by Florian Boucault
Status: Merged
Merged at revision: 1620
Proposed branch: lp:~fboucault/webbrowser-app/save_window_size
Merge into: lp:webbrowser-app/staging
Diff against target: 34 lines (+10/-4)
1 file modified
src/app/webbrowser/webbrowser-app.qml (+10/-4)
To merge this branch: bzr merge lp:~fboucault/webbrowser-app/save_window_size
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
Review via email: mp+317467@code.launchpad.net

Commit message

Store and restore on startup the size of each window.

Description of the change

Store and restore on startup the size of each window.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Wouldn’t it be better to pass width and height as properties to windowFactory.createObject(…) in restoreWindowState(), instead of setting the properties after the window is created?

1610. By Florian Boucault

Merged from staging

1611. By Florian Boucault

Pass width/height at Window creation time.

Revision history for this message
Olivier Tilloy (osomon) wrote :

LGTM, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/webbrowser/webbrowser-app.qml'
--- src/app/webbrowser/webbrowser-app.qml 2017-02-16 10:55:50 +0000
+++ src/app/webbrowser/webbrowser-app.qml 2017-02-20 13:42:34 +0000
@@ -306,8 +306,6 @@
306 property var session: SessionStorage {306 property var session: SessionStorage {
307 dataFile: dataLocation + "/session.json"307 dataFile: dataLocation + "/session.json"
308308
309 // TODO: do we want to save/restore window positions too (https://launchpad.net/bugs/1312892)?
310
311 function save() {309 function save() {
312 if (!locked || restoring) {310 if (!locked || restoring) {
313 return311 return
@@ -366,11 +364,19 @@
366 for (var i = 0; i < window.tabsModel.count; ++i) {364 for (var i = 0; i < window.tabsModel.count; ++i) {
367 tabs.push(window.serializeTabState(window.tabsModel.get(i)))365 tabs.push(window.serializeTabState(window.tabsModel.get(i)))
368 }366 }
369 return {tabs: tabs, currentIndex: window.tabsModel.currentIndex}367 return {tabs: tabs, currentIndex: window.tabsModel.currentIndex,
368 width: window.width, height: window.height}
370 }369 }
371370
372 function restoreWindowState(state) {371 function restoreWindowState(state) {
373 var window = windowFactory.createObject(null)372 var windowProperties = {}
373 if (state.width) {
374 windowProperties["width"] = state.width
375 }
376 if (state.height) {
377 windowProperties["height"] = state.height
378 }
379 var window = windowFactory.createObject(null, windowProperties)
374 for (var i in state.tabs) {380 for (var i in state.tabs) {
375 window.tabsModel.add(window.restoreTabState(state.tabs[i]))381 window.tabsModel.add(window.restoreTabState(state.tabs[i]))
376 }382 }

Subscribers

People subscribed via source and target branches