Skip to content

Instantly share code, notes, and snippets.

@seiichiro0185
Created December 23, 2013 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seiichiro0185/8094341 to your computer and use it in GitHub Desktop.
Save seiichiro0185/8094341 to your computer and use it in GitHub Desktop.
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.configuration 1.0
import org.sailfishos.browser.settings 1.0
Page {
function name2index(name) {
switch (name) {
case "Google": return 0
case "Bing": return 1
case "Yahoo": return 2
case "DuckDuckGo": return 3
default: return 0
}
}
RemorsePopup {
id: clearDataRemorse
}
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: contentColumn.height
Column {
id: contentColumn
width: parent.width
spacing: Theme.paddingMedium
PageHeader {
//% "Browser"
title: qsTrId("settings_browser-ph-browser")
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
//% "Clear private data"
text: qsTrId("settings_browser-bt-clear_private_data")
onClicked: {
//: Remorse item for clearing private date
//% "Clearing"
clearDataRemorse.execute(qsTrId("settings_browser-la-clearing_private_data"), function() { clearPrivateDataConfig.value = true});
}
}
ComboBox {
id: searchEngine
width: parent.width
//: Label for combobox that sets search engine used in browser
//% "Search engine"
label: qsTrId("settings_browser-la-search_engine")
currentIndex: name2index(searchEngineConfig.value)
menu: ContextMenu {
MenuItem {
text: "Google"
}
MenuItem {
text: "Bing"
}
MenuItem {
text: "Yahoo"
}
MenuItem {
text: "DuckDuckGo"
}
}
onCurrentItemChanged: {
if (currentItem.text !== searchEngineConfig.value) {
searchEngineConfig.value = currentItem.text
}
}
}
}
}
// TODO: enable it when browser daemon is implemented
/*
BrowserSettings {
id: settings
}
*/
ConfigurationValue {
id: clearPrivateDataConfig
key: "/apps/sailfish-browser/actions/clear_private_data"
defaultValue: false
}
ConfigurationValue {
id: searchEngineConfig
key: "/apps/sailfish-browser/settings/search_engine"
defaultValue: "Google"
onValueChanged: {
if (searchEngine.currentItem.text !== value) {
searchEngine.currentIndex = name2index(value)
}
}
}
}
@tanghus
Copy link

tanghus commented Dec 25, 2013

For those not wanting to overwrite the file, here's the diff (I've set DDG as default in this though):

--- browser.qml.orig    2013-12-25 20:56:50.651426137 +0100
+++ browser.qml.ddg     2013-12-25 21:08:31.080078444 +0100
@@ -10,6 +10,7 @@
             case "Google": return 0
             case "Bing": return 1
             case "Yahoo": return 2
+            case "DuckDuckGo": return 3
             default: return 0
         }
     }
@@ -65,6 +66,9 @@
                     MenuItem {
                         text: "Yahoo"
                     }
+                    MenuItem {
+                        text: "DuckDuckGo"
+                    }
                 }

                 onCurrentItemChanged: {
@@ -94,7 +98,7 @@
         id: searchEngineConfig

         key: "/apps/sailfish-browser/settings/search_engine"
-        defaultValue: "Google"
+        defaultValue: "DuckDuckGo"

         onValueChanged: {
             if (searchEngine.currentItem.text !== value) {

@smyru
Copy link

smyru commented Feb 5, 2015

Would be nice to post this as a patch for PatchManager into OpenRepos together with the XML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment