Merge lp:~osomon/webbrowser-app/qt-labs-settings into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 940
Merged at revision: 956
Proposed branch: lp:~osomon/webbrowser-app/qt-labs-settings
Merge into: lp:webbrowser-app
Prerequisite: lp:~osomon/webbrowser-app/searchengine-qml
Diff against target: 357 lines (+49/-134)
10 files modified
README (+9/-2)
debian/control (+1/-0)
src/app/browserapplication.cpp (+1/-0)
src/app/config.h.in (+1/-3)
src/app/webbrowser/Browser.qml (+34/-12)
src/app/webbrowser/CMakeLists.txt (+0/-1)
src/app/webbrowser/settings.cpp (+0/-54)
src/app/webbrowser/settings.h (+0/-49)
src/app/webbrowser/webbrowser-app.cpp (+1/-7)
src/app/webbrowser/webbrowser-app.qml (+2/-6)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/qt-labs-settings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Riccardo Padovani (community) Approve
Ubuntu Phablet Team Pending
Review via email: mp+253889@code.launchpad.net

Commit message

Use Qt.labs.settings to read/write the browser settings. This adds qml-module-qt-labs-settings as a runtime dependency for webbrowser-app.

To post a comment you must log in.
937. By Olivier Tilloy

Merge the latest changes from trunk and resolve a conflict.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
938. By Olivier Tilloy

Add a restoreDefaults() method to the settings object.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Looks good to me

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
939. By Olivier Tilloy

Merge the latest changes from trunk and resolve a conflict.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
940. By Olivier Tilloy

Remove top-level properties for settings.
Instead, properties should be set on the Settings instance directly, and the Settings instance is meant to be shared between views.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2015-02-27 09:28:41 +0000
3+++ README 2015-03-27 10:06:40 +0000
4@@ -74,7 +74,7 @@
5 webbrowser-app supports a limited set of custom settings, currently not exposed
6 in the UI. The settings are persisted on disk in the following INI-like file:
7
8- $HOME/.config/webbrowser-app/settings.conf
9+ $HOME/.config/webbrowser-app/webbrowser-app.conf
10
11 The following keys are supported:
12
13@@ -86,4 +86,11 @@
14 the OpenSearch document description format
15 (http://www.opensearch.org/Specifications/OpenSearch/1.1)
16
17-If any of those keys are not specified, the default hardcoded value is used.
18+ - 'allowOpenInBackgroundTab': whether to offer an option to open a link in a
19+ new background tab in the contextual menu. Possible values are "true",
20+ "false", and "default" (which resolves to true on desktop and false on
21+ mobile).
22+
23+ - restoreSession: whether to restore the previous browsing session at startup
24+ (defaults to true)
25+
26
27=== modified file 'debian/control'
28--- debian/control 2015-03-23 07:49:08 +0000
29+++ debian/control 2015-03-27 10:06:40 +0000
30@@ -36,6 +36,7 @@
31 fonts-liberation,
32 liboxideqt-qmlplugin (>= 1.5),
33 libqt5sql5-sqlite,
34+ qml-module-qt-labs-settings,
35 qml-module-qtquick2 (>= 5.4) | qtdeclarative5-qtquick2-plugin (>= 5.4),
36 qml-module-qtquick-dialogs | qtdeclarative5-dialogs-plugin,
37 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,
38
39=== modified file 'src/app/browserapplication.cpp'
40--- src/app/browserapplication.cpp 2015-03-02 12:21:27 +0000
41+++ src/app/browserapplication.cpp 2015-03-27 10:06:40 +0000
42@@ -128,6 +128,7 @@
43 QStringList appIdParts =
44 QString::fromUtf8(qgetenv("APP_ID")).split('_');
45 QCoreApplication::setApplicationName(appIdParts.first());
46+ QCoreApplication::setOrganizationDomain(QCoreApplication::applicationName());
47 // Get also the the first two components of the app ID: <package>_<app>,
48 // which is needed by Online Accounts.
49 QString unversionedAppId = QStringList(appIdParts.mid(0, 2)).join('_');
50
51=== modified file 'src/app/config.h.in'
52--- src/app/config.h.in 2014-06-30 10:40:59 +0000
53+++ src/app/config.h.in 2015-03-27 10:06:40 +0000
54@@ -1,5 +1,5 @@
55 /*
56- * Copyright 2013 Canonical Ltd.
57+ * Copyright 2013-2015 Canonical Ltd.
58 *
59 * This file is part of webbrowser-app.
60 *
61@@ -24,10 +24,8 @@
62 #include <QtCore/QString>
63
64 #define APP_ID "webbrowser-app"
65-#define DEFAULT_HOMEPAGE "http://start.ubuntu.com"
66 #define REMOTE_INSPECTOR_PORT 9221
67
68-#define DEFAULT_SEARCH_ENGINE "google"
69 #define DEFAULT_SEARCH_NAME "Google Search"
70 #define DEFAULT_SEARCH_DESC "Use google.com to search the Web"
71 #define DEFAULT_SEARCH_TEMPLATE "https://google.com/search?client=ubuntu&q={searchTerms}&ie=utf-8&oe=utf-8"
72
73=== modified file 'src/app/webbrowser/Browser.qml'
74--- src/app/webbrowser/Browser.qml 2015-03-23 07:49:13 +0000
75+++ src/app/webbrowser/Browser.qml 2015-03-27 10:06:40 +0000
76@@ -18,6 +18,7 @@
77
78 import QtQuick 2.0
79 import QtQuick.Window 2.0
80+import Qt.labs.settings 1.0
81 import com.canonical.Oxide 1.5 as Oxide
82 import Ubuntu.Components 1.1
83 import webbrowserapp.private 0.1
84@@ -29,16 +30,12 @@
85 BrowserView {
86 id: browser
87
88- property bool restoreSession: true
89-
90 currentWebview: tabsModel.currentTab ? tabsModel.currentTab.webview : null
91
92 property var historyModel: (historyModelLoader.status == Loader.Ready) ? historyModelLoader.item : null
93 property var bookmarksModel: (bookmarksModelLoader.status == Loader.Ready) ? bookmarksModelLoader.item : null
94
95- property url homepage
96- property string searchEngine
97- property string allowOpenInBackgroundTab
98+ property bool newSession: false
99
100 // XXX: we might want to tweak this value depending
101 // on the form factor and/or the available memory
102@@ -78,6 +75,31 @@
103 }
104 ]
105
106+ Settings {
107+ id: settings
108+
109+ property url homepage: settingsDefaults.homepage
110+ property string searchEngine: settingsDefaults.searchEngine
111+ property string allowOpenInBackgroundTab: settingsDefaults.allowOpenInBackgroundTab
112+ property bool restoreSession: settingsDefaults.restoreSession
113+
114+ function restoreDefaults() {
115+ homepage = settingsDefaults.homepage
116+ searchEngine = settingsDefaults.searchEngine
117+ allowOpenInBackgroundTab = settingsDefaults.allowOpenInBackgroundTab
118+ restoreSession = settingsDefaults.restoreSession
119+ }
120+ }
121+
122+ QtObject {
123+ id: settingsDefaults
124+
125+ readonly property url homepage: "http://start.ubuntu.com"
126+ readonly property string searchEngine: "google"
127+ readonly property string allowOpenInBackgroundTab: "default"
128+ readonly property bool restoreSession: true
129+ }
130+
131 Item {
132 anchors.fill: parent
133
134@@ -137,8 +159,8 @@
135 }
136
137 SearchEngine {
138- id: searchEngine
139- filename: browser.searchEngine
140+ id: currentSearchEngine
141+ filename: settings.searchEngine
142 }
143
144 Chrome {
145@@ -147,7 +169,7 @@
146 visible: !recentView.visible
147
148 webview: browser.currentWebview
149- searchUrl: searchEngine.urlTemplate
150+ searchUrl: currentSearchEngine.urlTemplate
151
152 function isCurrentUrlBookmarked() {
153 return ((webview && browser.bookmarksModel) ? browser.bookmarksModel.contains(webview.url) : false)
154@@ -527,8 +549,8 @@
155 onTriggered: browser.openUrlInNewTab(contextualData.href, true)
156 }
157 Actions.OpenLinkInNewBackgroundTab {
158- enabled: contextualData.href.toString() && ((browser.allowOpenInBackgroundTab === "true") ||
159- ((browser.allowOpenInBackgroundTab === "default") && (formFactor === "desktop")))
160+ enabled: contextualData.href.toString() && ((settings.allowOpenInBackgroundTab === "true") ||
161+ ((settings.allowOpenInBackgroundTab === "default") && (formFactor === "desktop")))
162 onTriggered: browser.openUrlInNewTab(contextualData.href, false)
163 }
164 Actions.BookmarkLink {
165@@ -786,7 +808,7 @@
166 running: true
167 interval: 1
168 onTriggered: {
169- if (browser.restoreSession) {
170+ if (!browser.newSession && settings.restoreSession) {
171 session.restore()
172 }
173 // Sanity check
174@@ -796,7 +818,7 @@
175 browser.openUrlInNewTab(browser.initialUrls[i], true, false)
176 }
177 if (tabsModel.count == 0) {
178- browser.openUrlInNewTab(browser.homepage, true, false)
179+ browser.openUrlInNewTab(settings.homepage, true, false)
180 }
181 tabsModel.currentTab.load()
182 if (!tabsModel.currentTab.url.toString() && !tabsModel.currentTab.restoreState && (formFactor == "desktop")) {
183
184=== modified file 'src/app/webbrowser/CMakeLists.txt'
185--- src/app/webbrowser/CMakeLists.txt 2015-02-18 21:37:39 +0000
186+++ src/app/webbrowser/CMakeLists.txt 2015-03-27 10:06:40 +0000
187@@ -28,7 +28,6 @@
188 set(WEBBROWSER_APP_SRC
189 file-operations.cpp
190 searchengine.cpp
191- settings.cpp
192 webbrowser-app.cpp
193 )
194
195
196=== removed file 'src/app/webbrowser/settings.cpp'
197--- src/app/webbrowser/settings.cpp 2015-03-19 11:58:33 +0000
198+++ src/app/webbrowser/settings.cpp 1970-01-01 00:00:00 +0000
199@@ -1,54 +0,0 @@
200-/*
201- * Copyright 2013-2015 Canonical Ltd.
202- *
203- * This file is part of webbrowser-app.
204- *
205- * webbrowser-app is free software; you can redistribute it and/or modify
206- * it under the terms of the GNU General Public License as published by
207- * the Free Software Foundation; version 3.
208- *
209- * webbrowser-app is distributed in the hope that it will be useful,
210- * but WITHOUT ANY WARRANTY; without even the implied warranty of
211- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212- * GNU General Public License for more details.
213- *
214- * You should have received a copy of the GNU General Public License
215- * along with this program. If not, see <http://www.gnu.org/licenses/>.
216- */
217-
218-// local
219-#include "settings.h"
220-#include "config.h"
221-
222-// Qt
223-#include <QtCore/QSettings>
224-
225-Settings::Settings(QObject* parent)
226- : QObject(parent)
227-{
228- QSettings settings(QCoreApplication::applicationName(), "settings");
229- m_homepage = settings.value("homepage", QUrl(DEFAULT_HOMEPAGE)).toUrl();
230- m_searchengine = settings.value("searchengine", QString(DEFAULT_SEARCH_ENGINE)).toString();
231- m_allowOpenInBackgroundTab = settings.value("allowOpenInBackgroundTab", "default").toString().toLower();
232- m_restoreSession = settings.value("restoreSession", true).toBool();
233-}
234-
235-const QUrl& Settings::homepage() const
236-{
237- return m_homepage;
238-}
239-
240-const QString& Settings::searchEngine() const
241-{
242- return m_searchengine;
243-}
244-
245-const QString& Settings::allowOpenInBackgroundTab() const
246-{
247- return m_allowOpenInBackgroundTab;
248-}
249-
250-bool Settings::restoreSession() const
251-{
252- return m_restoreSession;
253-}
254
255=== removed file 'src/app/webbrowser/settings.h'
256--- src/app/webbrowser/settings.h 2015-03-19 11:58:33 +0000
257+++ src/app/webbrowser/settings.h 1970-01-01 00:00:00 +0000
258@@ -1,49 +0,0 @@
259-/*
260- * Copyright 2013-2015 Canonical Ltd.
261- *
262- * This file is part of webbrowser-app.
263- *
264- * webbrowser-app is free software; you can redistribute it and/or modify
265- * it under the terms of the GNU General Public License as published by
266- * the Free Software Foundation; version 3.
267- *
268- * webbrowser-app is distributed in the hope that it will be useful,
269- * but WITHOUT ANY WARRANTY; without even the implied warranty of
270- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
271- * GNU General Public License for more details.
272- *
273- * You should have received a copy of the GNU General Public License
274- * along with this program. If not, see <http://www.gnu.org/licenses/>.
275- */
276-
277-#ifndef __SETTINGS_H__
278-#define __SETTINGS_H__
279-
280-// Qt
281-#include <QtCore/QObject>
282-#include <QtCore/QUrl>
283-
284-/*
285- * Temporary helper class for read-only settings
286- * until Settings support lands in the SDK.
287- */
288-class Settings : public QObject
289-{
290- Q_OBJECT
291-
292-public:
293- Settings(QObject* parent=0);
294-
295- const QUrl& homepage() const;
296- const QString& searchEngine() const;
297- const QString& allowOpenInBackgroundTab() const;
298- bool restoreSession() const;
299-
300-private:
301- QUrl m_homepage;
302- QString m_searchengine;
303- QString m_allowOpenInBackgroundTab; //"true" for enabled, "default" for form factor dependend behaviour (currently desktop only), anything else disables the option
304- bool m_restoreSession; // true by default
305-};
306-
307-#endif // __SETTINGS_H__
308
309=== modified file 'src/app/webbrowser/webbrowser-app.cpp'
310--- src/app/webbrowser/webbrowser-app.cpp 2015-03-19 11:58:33 +0000
311+++ src/app/webbrowser/webbrowser-app.cpp 2015-03-27 10:06:40 +0000
312@@ -27,7 +27,6 @@
313 #include "history-domainlist-chronological-model.h"
314 #include "limit-proxy-model.h"
315 #include "searchengine.h"
316-#include "settings.h"
317 #include "tabs-model.h"
318 #include "webbrowser-app.h"
319
320@@ -95,12 +94,7 @@
321 qmlRegisterType<SearchEngine>(uri, 0, 1, "SearchEngine");
322
323 if (BrowserApplication::initialize("webbrowser/webbrowser-app.qml")) {
324- Settings settings;
325- m_window->setProperty("homepage", settings.homepage());
326- m_window->setProperty("searchEngine", settings.searchEngine());
327- m_window->setProperty("allowOpenInBackgroundTab", settings.allowOpenInBackgroundTab());
328- m_window->setProperty("restoreSession", settings.restoreSession() &&
329- !m_arguments.contains("--new-session"));
330+ m_window->setProperty("newSession", m_arguments.contains("--new-session"));
331 QVariantList urls;
332 Q_FOREACH(const QUrl& url, this->urls()) {
333 urls.append(url);
334
335=== modified file 'src/app/webbrowser/webbrowser-app.qml'
336--- src/app/webbrowser/webbrowser-app.qml 2015-01-29 22:25:54 +0000
337+++ src/app/webbrowser/webbrowser-app.qml 2015-03-27 10:06:40 +0000
338@@ -1,5 +1,5 @@
339 /*
340- * Copyright 2013-2014 Canonical Ltd.
341+ * Copyright 2013-2015 Canonical Ltd.
342 *
343 * This file is part of webbrowser-app.
344 *
345@@ -23,12 +23,8 @@
346 BrowserWindow {
347 id: window
348
349- property alias searchEngine: browser.searchEngine
350- property alias restoreSession: browser.restoreSession
351- property alias allowOpenInBackgroundTab: browser.allowOpenInBackgroundTab
352-
353- property alias homepage: browser.homepage
354 property alias urls: browser.initialUrls
355+ property alias newSession: browser.newSession
356
357 currentWebview: browser.currentWebview
358

Subscribers

People subscribed via source and target branches

to status/vote changes: