Warning, /network/angelfish/src/contents/ui/SettingsSearchEnginePage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 Rinigus <rinigus.git@gmail.com>
0002 // SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert <jbb@kaidan.im>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004
0005 import QtQuick 2.3
0006 import QtQuick.Controls 2.4 as Controls
0007 import QtQuick.Layouts 1.11
0008
0009 import org.kde.kirigami 2.7 as Kirigami
0010 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0011
0012 import org.kde.angelfish 1.0
0013
0014 Kirigami.ScrollablePage {
0015 id: root
0016 title: i18n("Search Engine")
0017
0018 leftPadding: 0
0019 rightPadding: 0
0020 topPadding: Kirigami.Units.gridUnit
0021 bottomPadding: Kirigami.Units.gridUnit
0022
0023 Kirigami.Theme.colorSet: Kirigami.Theme.Window
0024 Kirigami.Theme.inherit: false
0025
0026 property string baseUrl: Settings.searchBaseUrl
0027
0028 ColumnLayout {
0029 id: list
0030 spacing: 0
0031
0032 property string customName: i18n("Custom")
0033
0034 FormCard.FormHeader {
0035 title: root.title
0036 }
0037
0038 FormCard.FormCard {
0039 Layout.fillWidth: true
0040
0041 Repeater {
0042 model: ListModel {
0043 id: searchEngines
0044
0045 ListElement {
0046 title: "Bing"
0047 url: "https://www.bing.com/search?q="
0048 }
0049
0050 ListElement {
0051 title: "DuckDuckGo"
0052 url: "https://start.duckduckgo.com/?q="
0053 }
0054
0055 ListElement {
0056 title: "Ecosia"
0057 url: "https://www.ecosia.org/search?q="
0058 }
0059
0060 ListElement {
0061 title: "Google"
0062 url: "https://www.google.com/search?q="
0063 }
0064
0065 ListElement {
0066 title: "Lilo"
0067 url: "https://search.lilo.org/searchweb.php?q="
0068 }
0069
0070 ListElement {
0071 title: "Peekier"
0072 url: "https://peekier.com/#!"
0073 }
0074
0075 ListElement {
0076 title: "Qwant"
0077 url: "https://www.qwant.com/?q="
0078 }
0079
0080 ListElement {
0081 title: "Qwant Junior"
0082 url: "https://www.qwantjunior.com/?q="
0083 }
0084
0085 ListElement {
0086 title: "StartPage"
0087 url: "https://www.startpage.com/do/dsearch?query="
0088 }
0089
0090 ListElement {
0091 title: "Swisscows"
0092 url: "https://swisscows.com/web?query="
0093 }
0094
0095 ListElement {
0096 title: "Wikipedia"
0097 url: "https://wikipedia.org/wiki/Special:Search?search="
0098 }
0099 }
0100
0101 delegate: FormCard.FormRadioDelegate {
0102 checked: model.url === baseUrl
0103 text: model.title
0104 onClicked: {
0105 if (model.title !== list.customName)
0106 baseUrl = model.url;
0107 else {
0108 searchEnginePopup.open();
0109 }
0110 // restore property binding
0111 checked = Qt.binding(function() { return (model.url === baseUrl) });
0112 }
0113 }
0114 }
0115 }
0116
0117 // custom search engine input sheet
0118 InputSheet {
0119 id: searchEnginePopup
0120 title: i18n("Search Engine")
0121 description: i18n("Base URL of your preferred search engine")
0122 text: Settings.searchCustomUrl
0123 onAccepted: {
0124 const url = UrlUtils.urlFromUserInput(searchEnginePopup.text);
0125 Settings.searchCustomUrl = url;
0126 baseUrl = url;
0127 searchEngines.setProperty(searchEngines.count - 1, "url", url);
0128 }
0129 }
0130 }
0131
0132 onBaseUrlChanged: {
0133 Settings.searchBaseUrl = UrlUtils.urlFromUserInput(baseUrl);
0134 }
0135
0136 Component.onCompleted: {
0137 searchEngines.append({ "title": list.customName, "url": Settings.searchCustomUrl });
0138 }
0139 }