Merge lp:~rpadovani/webbrowser-app/settings-page into lp:webbrowser-app

Proposed by Riccardo Padovani
Status: Superseded
Proposed branch: lp:~rpadovani/webbrowser-app/settings-page
Merge into: lp:webbrowser-app
Diff against target: 915 lines (+427/-209)
15 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/AddressBar.qml (+2/-11)
src/app/webbrowser/Browser.qml (+63/-7)
src/app/webbrowser/CMakeLists.txt (+0/-1)
src/app/webbrowser/SettingsPage.qml (+266/-0)
src/app/webbrowser/searchengine.cpp (+51/-45)
src/app/webbrowser/searchengine.h (+17/-17)
src/app/webbrowser/settings.cpp (+0/-57)
src/app/webbrowser/settings.h (+0/-51)
src/app/webbrowser/urlManagement.js (+12/-0)
src/app/webbrowser/webbrowser-app.cpp (+2/-9)
src/app/webbrowser/webbrowser-app.qml (+2/-6)
To merge this branch: bzr merge lp:~rpadovani/webbrowser-app/settings-page
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+253974@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-24.

Commit message

Add settings page (clear history, set homepage, open tabs in background, restore previous session)

Description of the change

Add settings page. It still misses the search engine model, so if we want to land this we should hide the searchengine setting.

To post a comment you must log in.
940. By Riccardo Padovani

Added copyright header to urlManagement.js

941. By Riccardo Padovani

Add divider between title and settings page itself

942. By Riccardo Padovani

Improved bad english

943. By Riccardo Padovani

Improve management of historyModel in SettingsPage, expose count property of historyModel

944. By Riccardo Padovani

Add flickable to columns

945. By Riccardo Padovani

Fix rowCount() signal

946. By Riccardo Padovani

Use AbstractButton for back button in the header

947. By Riccardo Padovani

Add test to history model to check count property

948. By Riccardo Padovani

Fix encapsulation

949. By Riccardo Padovani

Move use strict after copyright header

950. By Riccardo Padovani

Avoid useless redrawing of the webview when settings or history are open

951. By Riccardo Padovani

Add separator after the last element

952. By Riccardo Padovani

Add QSignalSpy to count property test in history model

953. By Riccardo Padovani

Add search engine choice

954. By Riccardo Padovani

Add dependency to debian/control, update search engine page

955. By Riccardo Padovani

Merge from upstream

956. By Riccardo Padovani

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

957. By Riccardo Padovani

Fix settings maanagement, hide search engine optinn whene there are < 2 engines

958. By Riccardo Padovani

Split the settings page header in a different component

959. By Riccardo Padovani

Make subpages as separate components to manage them dinamically

960. By Riccardo Padovani

Make divider part of SettingsPageHeader

961. By Riccardo Padovani

Explict bindings of switchs

962. By Riccardo Padovani

Use current search engine name instead of the filename

963. By Riccardo Padovani

Revert blank lines changes

964. By Riccardo Padovani

Improve SettingsPageHeader

965. By Riccardo Padovani

Fix all issues raised in the review (but SettingsPage visibility)

966. By Riccardo Padovani

Address new comments in the review

967. By Riccardo Padovani

Fix CMakeLists.txt

968. By Riccardo Padovani

Address Bill's comments

969. By Riccardo Padovani

Check if a domain is valid in the homepage setting before saving it

970. By Riccardo Padovani

Merge from trunk and resolve conflicts

Unmerged revisions

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-24 15:51:06 +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-02 12:21:27 +0000
29+++ debian/control 2015-03-24 15:51:06 +0000
30@@ -36,6 +36,7 @@
31 fonts-liberation,
32 liboxideqt-qmlplugin (>= 1.4),
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-24 15:51:06 +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-24 15:51:06 +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/AddressBar.qml'
74--- src/app/webbrowser/AddressBar.qml 2015-01-23 10:30:19 +0000
75+++ src/app/webbrowser/AddressBar.qml 2015-03-24 15:51:06 +0000
76@@ -21,6 +21,7 @@
77 import Ubuntu.Components.Popups 1.0
78 import com.canonical.Oxide 1.0 as Oxide
79 import ".."
80+import "urlManagement.js" as UrlManagement
81
82 FocusScope {
83 id: addressbar
84@@ -257,16 +258,6 @@
85 return false
86 }
87
88- function fixUrl(address) {
89- var url = address
90- if (address.substr(0, 1) == "/") {
91- url = "file://" + address
92- } else if (address.indexOf("://") == -1) {
93- url = "http://" + address
94- }
95- return url
96- }
97-
98 function escapeHtmlEntities(query) {
99 return query.replace(/\W/, encodeURIComponent)
100 }
101@@ -279,7 +270,7 @@
102 function validate() {
103 var query = text.trim()
104 if (internal.looksLikeAUrl(query)) {
105- requestedUrl = internal.fixUrl(query)
106+ requestedUrl = UrlManagement.fixUrl(query)
107 } else {
108 requestedUrl = internal.buildSearchUrl(query)
109 }
110
111=== modified file 'src/app/webbrowser/Browser.qml'
112--- src/app/webbrowser/Browser.qml 2015-03-20 12:19:51 +0000
113+++ src/app/webbrowser/Browser.qml 2015-03-24 15:51:06 +0000
114@@ -18,6 +18,7 @@
115
116 import QtQuick 2.0
117 import QtQuick.Window 2.0
118+import Qt.labs.settings 1.0
119 import com.canonical.Oxide 1.4 as Oxide
120 import Ubuntu.Components 1.1
121 import webbrowserapp.private 0.1
122@@ -29,16 +30,17 @@
123 BrowserView {
124 id: browser
125
126- property bool restoreSession: true
127-
128 currentWebview: tabsModel.currentTab ? tabsModel.currentTab.webview : null
129
130 property var historyModel: (historyModelLoader.status == Loader.Ready) ? historyModelLoader.item : null
131 property var bookmarksModel: (bookmarksModelLoader.status == Loader.Ready) ? bookmarksModelLoader.item : null
132
133- property url homepage
134- property QtObject searchEngine
135- property string allowOpenInBackgroundTab
136+ property url homepage: settingsDefaults.homepage
137+ property string searchEngine: settingsDefaults.searchEngine
138+ property string allowOpenInBackgroundTab: settingsDefaults.allowOpenInBackgroundTab
139+ property bool restoreSession: settingsDefaults.restoreSession
140+
141+ property bool newSession: false
142
143 // XXX: we might want to tweak this value depending
144 // on the form factor and/or the available memory
145@@ -78,6 +80,31 @@
146 }
147 ]
148
149+ Settings {
150+ id: settings
151+
152+ property alias homepage: browser.homepage
153+ property alias searchEngine: browser.searchEngine
154+ property alias allowOpenInBackgroundTab: browser.allowOpenInBackgroundTab
155+ property alias restoreSession: browser.restoreSession
156+
157+ function restoreDefaults() {
158+ browser.homepage = settingsDefaults.homepage
159+ browser.searchEngine = settingsDefaults.searchEngine
160+ browser.allowOpenInBackgroundTab = settingsDefaults.allowOpenInBackgroundTab
161+ browser.restoreSession = settingsDefaults.restoreSession
162+ }
163+ }
164+
165+ QtObject {
166+ id: settingsDefaults
167+
168+ readonly property url homepage: "http://start.ubuntu.com"
169+ readonly property string searchEngine: "google"
170+ readonly property string allowOpenInBackgroundTab: "default"
171+ readonly property bool restoreSession: true
172+ }
173+
174 Item {
175 anchors.fill: parent
176
177@@ -136,13 +163,18 @@
178 asynchronous: true
179 }
180
181+ SearchEngine {
182+ id: searchEngine
183+ filename: browser.searchEngine
184+ }
185+
186 Chrome {
187 id: chrome
188
189 visible: !recentView.visible
190
191 webview: browser.currentWebview
192- searchUrl: browser.searchEngine ? browser.searchEngine.template : ""
193+ searchUrl: searchEngine.urlTemplate
194
195 function isCurrentUrlBookmarked() {
196 return ((webview && browser.bookmarksModel) ? browser.bookmarksModel.contains(webview.url) : false)
197@@ -210,6 +242,12 @@
198 iconName: "tab-new"
199 enabled: formFactor != "mobile"
200 onTriggered: browser.openUrlInNewTab("", true)
201+ },
202+ Action {
203+ objectName: "settings"
204+ text: i18n.tr("Settings")
205+ iconName: "settings"
206+ onTriggered: settingsComponent.createObject(settingsContainer)
207 }
208 ]
209
210@@ -471,6 +509,24 @@
211 }
212 }
213
214+ Item {
215+ id: settingsContainer
216+
217+ visible: children.length > 0
218+ anchors.fill: parent
219+
220+ Component {
221+ id: settingsComponent
222+
223+ SettingsPage {
224+ anchors.fill: parent
225+ onHistoryRemoved: browser.historyModel.clearAll()
226+ onRestoreDefaults: settings.restoreDefaults()
227+ onDone: destroy()
228+ }
229+ }
230+ }
231+
232 TabsModel {
233 id: tabsModel
234
235@@ -783,7 +839,7 @@
236 running: true
237 interval: 1
238 onTriggered: {
239- if (browser.restoreSession) {
240+ if (!browser.newSession && browser.restoreSession) {
241 session.restore()
242 }
243 // Sanity check
244
245=== modified file 'src/app/webbrowser/CMakeLists.txt'
246--- src/app/webbrowser/CMakeLists.txt 2015-02-18 21:37:39 +0000
247+++ src/app/webbrowser/CMakeLists.txt 2015-03-24 15:51:06 +0000
248@@ -28,7 +28,6 @@
249 set(WEBBROWSER_APP_SRC
250 file-operations.cpp
251 searchengine.cpp
252- settings.cpp
253 webbrowser-app.cpp
254 )
255
256
257=== added file 'src/app/webbrowser/SettingsPage.qml'
258--- src/app/webbrowser/SettingsPage.qml 1970-01-01 00:00:00 +0000
259+++ src/app/webbrowser/SettingsPage.qml 2015-03-24 15:51:06 +0000
260@@ -0,0 +1,266 @@
261+/*
262+ * Copyright 2015 Canonical Ltd.
263+ *
264+ * This file is part of webbrowser-app.
265+ *
266+ * webbrowser-app is free software; you can redistribute it and/or modify
267+ * it under the terms of the GNU General Public License as published by
268+ * the Free Software Foundation; version 3.
269+ *
270+ * webbrowser-app is distributed in the hope that it will be useful,
271+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
272+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
273+ * GNU General Public License for more details.
274+ *
275+ * You should have received a copy of the GNU General Public License
276+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
277+ */
278+
279+import QtQuick 2.0
280+import Ubuntu.Components 1.1
281+import Ubuntu.Components.Popups 1.0
282+import Ubuntu.Components.ListItems 1.0 as ListItem
283+
284+import "urlManagement.js" as UrlManagement
285+
286+Item {
287+ id: settings
288+
289+ signal historyRemoved()
290+ signal restoreDefaults()
291+ signal done()
292+
293+ Rectangle {
294+ anchors.fill: parent
295+ color: "#f6f6f6"
296+ }
297+
298+ ListItem.Empty {
299+ id: title
300+ anchors {
301+ top: parent.top
302+ left: parent.left
303+ right: parent.right
304+ }
305+
306+ highlightWhenPressed: false
307+
308+ Icon {
309+ id: backButton
310+ name: "back"
311+
312+ anchors {
313+ top: parent.top
314+ bottom: parent.bottom
315+ left: parent.left
316+ margins: units.gu(2)
317+ }
318+
319+ width: height
320+
321+ MouseArea {
322+ anchors.fill: parent
323+
324+ onClicked: settings.done()
325+ }
326+ }
327+
328+ Label {
329+ anchors {
330+ top: parent.top
331+ bottom: parent.bottom
332+ left: backButton.right
333+ margins: units.gu(2)
334+ }
335+ text: i18n.tr("Settings")
336+ }
337+ }
338+
339+ Column {
340+ anchors {
341+ top: title.bottom
342+ left: parent.left
343+ right: parent.right
344+ bottom: parent.bottom
345+ }
346+
347+ ListItem.Subtitled {
348+ text: i18n.tr("Search engine")
349+ subText: browser.searchEngine
350+ visible: false
351+
352+ action: Action {
353+ onTriggered: {
354+ searchEngineItem.visible = true;
355+ }
356+ }
357+ }
358+
359+ ListItem.Subtitled {
360+ text: i18n.tr("Homepage")
361+ subText: browser.homepage
362+
363+ action: Action {
364+ onTriggered: PopupUtils.open(homepageDialog)
365+ }
366+ }
367+
368+ ListItem.Standard {
369+ text: i18n.tr("Restore old session on startup")
370+ highlightWhenPressed: false
371+ control: Switch {
372+ checked: browser.restoreSession
373+ onClicked: browser.restoreSession = checked;
374+ }
375+ }
376+
377+ ListItem.Standard {
378+ text: i18n.tr("Open new tab in background")
379+ highlightWhenPressed: false
380+ control: Switch {
381+ checked: browser.allowOpenInBackgroundTab
382+ onClicked: browser.allowOpenInBackgroundTab = checked;
383+ }
384+ }
385+
386+ ListItem.Standard {
387+ text: i18n.tr("Privacy")
388+
389+ action: Action {
390+ onTriggered: privacyItem.visible = true;
391+ }
392+ }
393+
394+ ListItem.Standard {
395+ text: i18n.tr("Reset browser settings")
396+ showDivider: false
397+ onClicked: {
398+ settings.restoreDefaults();
399+ }
400+ }
401+ }
402+
403+ Item {
404+ id: searchEngineItem
405+ anchors.fill: parent
406+ visible: false
407+
408+ Rectangle {
409+ anchors.fill: parent
410+ color: "#f6f6f6"
411+ }
412+
413+ ListView {
414+ anchors.fill: parent
415+ model: 5
416+ delegate: ListItem.Standard {
417+ text: index
418+ action: Action {
419+ onTriggered: {
420+ browser.searchEngine = text;
421+ searchEngineItem.visible = false;
422+ }
423+ }
424+ }
425+ }
426+ }
427+
428+ Item {
429+ id: privacyItem
430+ anchors.fill: parent
431+ visible: false
432+
433+ Rectangle {
434+ anchors.fill: parent
435+ color: "#f6f6f6"
436+ }
437+
438+ ListItem.Empty {
439+ id: privacyTitle
440+ anchors {
441+ top: parent.top
442+ left: parent.left
443+ right: parent.right
444+ }
445+
446+ highlightWhenPressed: false
447+
448+ Icon {
449+ id: privacyBackButton
450+ name: "back"
451+
452+ anchors {
453+ top: parent.top
454+ bottom: parent.bottom
455+ left: parent.left
456+ margins: units.gu(2)
457+ }
458+
459+ width: height
460+
461+ MouseArea {
462+ anchors.fill: parent
463+
464+ onClicked: privacyItem.visible = false;
465+ }
466+ }
467+
468+ Label {
469+ anchors {
470+ top: parent.top
471+ bottom: parent.bottom
472+ left: privacyBackButton.right
473+ margins: units.gu(2)
474+ }
475+ text: i18n.tr("Privacy")
476+ }
477+ }
478+
479+ Column {
480+ anchors {
481+ top: privacyTitle.bottom
482+ left: parent.left
483+ right: parent.right
484+ bottom: parent.bottom
485+ }
486+
487+ ListItem.Standard {
488+ text: i18n.tr("Clear Browsing History")
489+ onClicked: {
490+ settings.historyRemoved();
491+ opacity = 0.5
492+ }
493+ }
494+ }
495+ }
496+
497+ Component {
498+ id: homepageDialog
499+ Dialog {
500+ id: dialogue
501+ title: i18n.tr("Homepage")
502+
503+ TextField {
504+ id: homepageTextField
505+ text: browser.homepage
506+ }
507+
508+ Button {
509+ anchors { left: parent.left; right: parent.right }
510+ text: i18n.tr("Cancel")
511+ onClicked: PopupUtils.close(dialogue);
512+ }
513+
514+ Button {
515+ anchors { left: parent.left; right: parent.right }
516+ text: i18n.tr("Save")
517+ color: "#3fb24f"
518+ onClicked: {
519+ browser.homepage = UrlManagement.fixUrl(homepageTextField.text);
520+ PopupUtils.close(dialogue);
521+ }
522+ }
523+ }
524+ }
525+}
526+
527
528=== modified file 'src/app/webbrowser/searchengine.cpp'
529--- src/app/webbrowser/searchengine.cpp 2014-06-30 11:01:27 +0000
530+++ src/app/webbrowser/searchengine.cpp 2015-03-24 15:51:06 +0000
531@@ -1,5 +1,5 @@
532 /*
533- * Copyright 2014 Canonical Ltd.
534+ * Copyright 2014-2015 Canonical Ltd.
535 *
536 * This file is part of webbrowser-app.
537 *
538@@ -17,41 +17,71 @@
539 */
540
541 // local
542+#include "config.h"
543 #include "searchengine.h"
544
545 // Qt
546-#include <QtCore/QDir>
547 #include <QtCore/QFile>
548 #include <QtCore/QStandardPaths>
549 #include <QtCore/QXmlStreamReader>
550
551-SearchEngine::SearchEngine(const QString& name, QObject* parent)
552+SearchEngine::SearchEngine(QObject* parent)
553 : QObject(parent)
554 , m_name(DEFAULT_SEARCH_NAME)
555 , m_description(DEFAULT_SEARCH_DESC)
556 , m_template(DEFAULT_SEARCH_TEMPLATE)
557 {
558- QString searchenginesSubDir("searchengines");
559- QString filename = searchenginesSubDir + "/" + name + ".xml";
560- m_path = QStandardPaths::locate(QStandardPaths::DataLocation, filename);
561- if (!m_path.isEmpty()) {
562- parseOpenSearchDescription();
563+}
564+
565+const QString& SearchEngine::filename() const
566+{
567+ return m_filename;
568+}
569+
570+void SearchEngine::setFilename(const QString& filename)
571+{
572+ if (filename != m_filename) {
573+ m_filename = filename;
574+ Q_EMIT filenameChanged();
575+
576+ m_name = DEFAULT_SEARCH_NAME;
577+ m_description = DEFAULT_SEARCH_DESC;
578+ m_template = DEFAULT_SEARCH_TEMPLATE;
579+
580+ if (!filename.isEmpty()) {
581+ QString filepath = QStandardPaths::locate(QStandardPaths::DataLocation,
582+ "searchengines/" + filename + ".xml");
583+ if (!filepath.isEmpty()) {
584+ QFile file(filepath);
585+ if (file.open(QIODevice::ReadOnly)) {
586+ // Parse OpenSearch description file
587+ // (http://www.opensearch.org/Specifications/OpenSearch/1.1)
588+ QXmlStreamReader parser(&file);
589+ while (!parser.atEnd()) {
590+ parser.readNext();
591+ if (parser.isStartElement()) {
592+ QStringRef name = parser.name();
593+ if (name == "ShortName") {
594+ m_name = parser.readElementText();
595+ } else if (name == "Description") {
596+ m_description = parser.readElementText();
597+ } else if (name == "Url") {
598+ if (parser.attributes().value("type") == "text/html") {
599+ m_template = parser.attributes().value("template").toString();
600+ }
601+ }
602+ }
603+ }
604+ }
605+ }
606+ }
607+
608+ Q_EMIT nameChanged();
609+ Q_EMIT descriptionChanged();
610+ Q_EMIT urlTemplateChanged();
611 }
612 }
613
614-SearchEngine::SearchEngine(const SearchEngine& other)
615-{
616- m_path = other.m_path;
617- m_name = other.m_name;
618- m_description = other.m_description;
619- m_template = other.m_template;
620-}
621-
622-bool SearchEngine::isValid() const
623-{
624- return (!m_name.isEmpty() && !m_template.isEmpty());
625-}
626-
627 const QString& SearchEngine::name() const
628 {
629 return m_name;
630@@ -66,27 +96,3 @@
631 {
632 return m_template;
633 }
634-
635-void SearchEngine::parseOpenSearchDescription()
636-{
637- QFile file(m_path);
638- if (!file.open(QIODevice::ReadOnly)) {
639- return;
640- }
641- QXmlStreamReader parser(&file);
642- while (!parser.atEnd()) {
643- parser.readNext();
644- if (parser.isStartElement()) {
645- QStringRef name = parser.name();
646- if (name == "ShortName") {
647- m_name = parser.readElementText();
648- } else if (name == "Description") {
649- m_description = parser.readElementText();
650- } else if (name == "Url") {
651- if (parser.attributes().value("type") == "text/html") {
652- m_template = parser.attributes().value("template").toString();
653- }
654- }
655- }
656- }
657-}
658
659=== modified file 'src/app/webbrowser/searchengine.h'
660--- src/app/webbrowser/searchengine.h 2014-06-30 10:40:59 +0000
661+++ src/app/webbrowser/searchengine.h 2015-03-24 15:51:06 +0000
662@@ -1,5 +1,5 @@
663 /*
664- * Copyright 2014 Canonical Ltd.
665+ * Copyright 2014-2015 Canonical Ltd.
666 *
667 * This file is part of webbrowser-app.
668 *
669@@ -19,11 +19,7 @@
670 #ifndef __SEARCH_ENGINE_H__
671 #define __SEARCH_ENGINE_H__
672
673-// local
674-#include "config.h"
675-
676 // Qt
677-#include <QtCore/QMetaType>
678 #include <QtCore/QObject>
679 #include <QtCore/QString>
680
681@@ -31,28 +27,32 @@
682 {
683 Q_OBJECT
684
685- Q_PROPERTY(QString name READ name CONSTANT)
686- Q_PROPERTY(QString description READ description CONSTANT)
687- Q_PROPERTY(QString template READ urlTemplate CONSTANT)
688+ Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
689+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
690+ Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
691+ Q_PROPERTY(QString urlTemplate READ urlTemplate NOTIFY urlTemplateChanged)
692
693 public:
694- SearchEngine(const QString& name=DEFAULT_SEARCH_ENGINE, QObject* parent=0);
695- SearchEngine(const SearchEngine& other);
696-
697- bool isValid() const;
698+ SearchEngine(QObject* parent=0);
699+
700+ const QString& filename() const;
701+ void setFilename(const QString& filename);
702+
703 const QString& name() const;
704 const QString& description() const;
705 const QString& urlTemplate() const;
706
707+Q_SIGNALS:
708+ void filenameChanged() const;
709+ void nameChanged() const;
710+ void descriptionChanged() const;
711+ void urlTemplateChanged() const;
712+
713 private:
714- QString m_path;
715+ QString m_filename;
716 QString m_name;
717 QString m_description;
718 QString m_template;
719-
720- void parseOpenSearchDescription();
721 };
722
723-Q_DECLARE_METATYPE(SearchEngine);
724-
725 #endif // __SEARCH_ENGINE_H__
726
727=== removed file 'src/app/webbrowser/settings.cpp'
728--- src/app/webbrowser/settings.cpp 2015-02-09 10:16:16 +0000
729+++ src/app/webbrowser/settings.cpp 1970-01-01 00:00:00 +0000
730@@ -1,57 +0,0 @@
731-/*
732- * Copyright 2013-2015 Canonical Ltd.
733- *
734- * This file is part of webbrowser-app.
735- *
736- * webbrowser-app is free software; you can redistribute it and/or modify
737- * it under the terms of the GNU General Public License as published by
738- * the Free Software Foundation; version 3.
739- *
740- * webbrowser-app is distributed in the hope that it will be useful,
741- * but WITHOUT ANY WARRANTY; without even the implied warranty of
742- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
743- * GNU General Public License for more details.
744- *
745- * You should have received a copy of the GNU General Public License
746- * along with this program. If not, see <http://www.gnu.org/licenses/>.
747- */
748-
749-// local
750-#include "settings.h"
751-#include "config.h"
752-#include "searchengine.h"
753-
754-// Qt
755-#include <QtCore/QSettings>
756-
757-Settings::Settings(QObject* parent)
758- : QObject(parent)
759- , m_searchengine(NULL)
760-{
761- QSettings settings(QCoreApplication::applicationName(), "settings");
762- m_homepage = settings.value("homepage", QUrl(DEFAULT_HOMEPAGE)).toUrl();
763- QString name = settings.value("searchengine", QString(DEFAULT_SEARCH_ENGINE)).toString();
764- m_searchengine = new SearchEngine(name, this);
765- m_allowOpenInBackgroundTab = settings.value("allowOpenInBackgroundTab", "default").toString().toLower();
766- m_restoreSession = settings.value("restoreSession", true).toBool();
767-}
768-
769-const QUrl& Settings::homepage() const
770-{
771- return m_homepage;
772-}
773-
774-SearchEngine* Settings::searchEngine() const
775-{
776- return m_searchengine;
777-}
778-
779-const QString& Settings::allowOpenInBackgroundTab() const
780-{
781- return m_allowOpenInBackgroundTab;
782-}
783-
784-bool Settings::restoreSession() const
785-{
786- return m_restoreSession;
787-}
788
789=== removed file 'src/app/webbrowser/settings.h'
790--- src/app/webbrowser/settings.h 2015-02-09 10:16:16 +0000
791+++ src/app/webbrowser/settings.h 1970-01-01 00:00:00 +0000
792@@ -1,51 +0,0 @@
793-/*
794- * Copyright 2013-2015 Canonical Ltd.
795- *
796- * This file is part of webbrowser-app.
797- *
798- * webbrowser-app is free software; you can redistribute it and/or modify
799- * it under the terms of the GNU General Public License as published by
800- * the Free Software Foundation; version 3.
801- *
802- * webbrowser-app is distributed in the hope that it will be useful,
803- * but WITHOUT ANY WARRANTY; without even the implied warranty of
804- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
805- * GNU General Public License for more details.
806- *
807- * You should have received a copy of the GNU General Public License
808- * along with this program. If not, see <http://www.gnu.org/licenses/>.
809- */
810-
811-#ifndef __SETTINGS_H__
812-#define __SETTINGS_H__
813-
814-// Qt
815-#include <QtCore/QObject>
816-#include <QtCore/QUrl>
817-
818-class SearchEngine;
819-
820-/*
821- * Temporary helper class for read-only settings
822- * until Settings support lands in the SDK.
823- */
824-class Settings : public QObject
825-{
826- Q_OBJECT
827-
828-public:
829- Settings(QObject* parent=0);
830-
831- const QUrl& homepage() const;
832- SearchEngine* searchEngine() const;
833- const QString& allowOpenInBackgroundTab() const;
834- bool restoreSession() const;
835-
836-private:
837- QUrl m_homepage;
838- SearchEngine* m_searchengine;
839- QString m_allowOpenInBackgroundTab; //"true" for enabled, "default" for form factor dependend behaviour (currently desktop only), anything else disables the option
840- bool m_restoreSession; // true by default
841-};
842-
843-#endif // __SETTINGS_H__
844
845=== added file 'src/app/webbrowser/urlManagement.js'
846--- src/app/webbrowser/urlManagement.js 1970-01-01 00:00:00 +0000
847+++ src/app/webbrowser/urlManagement.js 2015-03-24 15:51:06 +0000
848@@ -0,0 +1,12 @@
849+'use strict'
850+
851+function fixUrl(address) {
852+ var url = address
853+ if (address.substr(0, 1) == "/") {
854+ url = "file://" + address
855+ } else if (address.indexOf("://") == -1) {
856+ url = "http://" + address
857+ }
858+ return url
859+}
860+
861
862=== modified file 'src/app/webbrowser/webbrowser-app.cpp'
863--- src/app/webbrowser/webbrowser-app.cpp 2015-02-27 09:28:41 +0000
864+++ src/app/webbrowser/webbrowser-app.cpp 2015-03-24 15:51:06 +0000
865@@ -27,7 +27,6 @@
866 #include "history-domainlist-chronological-model.h"
867 #include "limit-proxy-model.h"
868 #include "searchengine.h"
869-#include "settings.h"
870 #include "tabs-model.h"
871 #include "webbrowser-app.h"
872
873@@ -92,16 +91,10 @@
874 qmlRegisterType<TabsModel>(uri, 0, 1, "TabsModel");
875 qmlRegisterType<BookmarksModel>(uri, 0, 1, "BookmarksModel");
876 qmlRegisterSingletonType<FileOperations>(uri, 0, 1, "FileOperations", FileOperations_singleton_factory);
877+ qmlRegisterType<SearchEngine>(uri, 0, 1, "SearchEngine");
878
879 if (BrowserApplication::initialize("webbrowser/webbrowser-app.qml")) {
880- Settings settings;
881- SearchEngine* searchEngine = settings.searchEngine();
882- searchEngine->setParent(m_window);
883- m_window->setProperty("homepage", settings.homepage());
884- m_window->setProperty("searchEngine", QVariant::fromValue(searchEngine));
885- m_window->setProperty("allowOpenInBackgroundTab", settings.allowOpenInBackgroundTab());
886- m_window->setProperty("restoreSession", settings.restoreSession() &&
887- !m_arguments.contains("--new-session"));
888+ m_window->setProperty("newSession", m_arguments.contains("--new-session"));
889 QVariantList urls;
890 Q_FOREACH(const QUrl& url, this->urls()) {
891 urls.append(url);
892
893=== modified file 'src/app/webbrowser/webbrowser-app.qml'
894--- src/app/webbrowser/webbrowser-app.qml 2015-01-29 22:25:54 +0000
895+++ src/app/webbrowser/webbrowser-app.qml 2015-03-24 15:51:06 +0000
896@@ -1,5 +1,5 @@
897 /*
898- * Copyright 2013-2014 Canonical Ltd.
899+ * Copyright 2013-2015 Canonical Ltd.
900 *
901 * This file is part of webbrowser-app.
902 *
903@@ -23,12 +23,8 @@
904 BrowserWindow {
905 id: window
906
907- property alias searchEngine: browser.searchEngine
908- property alias restoreSession: browser.restoreSession
909- property alias allowOpenInBackgroundTab: browser.allowOpenInBackgroundTab
910-
911- property alias homepage: browser.homepage
912 property alias urls: browser.initialUrls
913+ property alias newSession: browser.newSession
914
915 currentWebview: browser.currentWebview
916

Subscribers

People subscribed via source and target branches

to status/vote changes: