Warning, /network/angelfish/src/contents/ui/SettingsAdblock.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004
0005 import QtQuick 2.7
0006 import QtQuick.Layouts 1.0
0007 import QtQuick.Controls 2.5 as Controls
0008 import org.kde.kirigami 2.12 as Kirigami
0009 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0010
0011 import org.kde.angelfish 1.0
0012
0013 Kirigami.ScrollablePage {
0014 id: adblockSettings
0015
0016 leftPadding: 0
0017 rightPadding: 0
0018 topPadding: Kirigami.Units.gridUnit
0019 bottomPadding: Kirigami.Units.gridUnit
0020
0021 title: i18n("Adblock settings")
0022
0023 Kirigami.Theme.colorSet: Kirigami.Settings.isMobile ? Kirigami.Theme.View : Kirigami.Theme.Window
0024
0025 actions: [
0026 Kirigami.Action {
0027 icon.name: "list-add"
0028 onTriggered: addSheet.open()
0029 enabled: AdblockUrlInterceptor.adblockSupported
0030 },
0031 Kirigami.Action {
0032 text: i18n("Update lists")
0033 icon.name: "view-refresh"
0034 enabled: AdblockUrlInterceptor.adblockSupported
0035 onTriggered: {
0036 adblockSettings.refreshing = true
0037 filterlistModel.refreshLists()
0038 }
0039 }
0040 ]
0041
0042 supportsRefreshing: true
0043 onRefreshingChanged: {
0044 if (refreshing) {
0045 filterlistModel.refreshLists();
0046 }
0047 }
0048
0049 Kirigami.PlaceholderMessage {
0050 anchors.centerIn: parent
0051 visible: !AdblockUrlInterceptor.adblockSupported
0052 width: parent.width - (Kirigami.Units.largeSpacing * 4)
0053
0054 text: i18n("The adblock functionality isn't included in this build.")
0055 }
0056
0057 Kirigami.OverlaySheet {
0058 id: addSheet
0059
0060 header: Kirigami.Heading { text: i18n("Add filterlist") }
0061 contentItem: ColumnLayout {
0062 Layout.preferredWidth: adblockSettings.width
0063 Controls.Label {
0064 Layout.fillWidth: true
0065 text: i18n("Name")
0066 }
0067 Controls.TextField {
0068 id: nameInput
0069 Layout.fillWidth: true
0070 }
0071
0072 Controls.Label {
0073 Layout.fillWidth: true
0074 text: i18n("Url")
0075 }
0076 Controls.TextField {
0077 id: urlInput
0078 Layout.fillWidth: true
0079 inputMethodHints: Qt.ImhUrlCharactersOnly
0080 }
0081
0082 Controls.Button {
0083 Layout.alignment: Qt.AlignRight
0084 text: i18n("Add")
0085 onClicked: {
0086 filterlistModel.addFilterList(nameInput.text, urlInput.text)
0087 adblockSettings.refreshing = true
0088 filterlistModel.refreshLists()
0089 addSheet.close()
0090 }
0091 }
0092 }
0093 }
0094 ColumnLayout {
0095 spacing: 0
0096
0097 FormCard.FormHeader {
0098 title: adblockSettings.title
0099 }
0100
0101 FormCard.FormCard {
0102 id: card
0103 visible: AdblockUrlInterceptor.adblockSupported
0104 Layout.fillWidth: true
0105
0106 Repeater {
0107 id: listView
0108 model: AdblockFilterListsModel {
0109 id: filterlistModel
0110 onRefreshFinished: adblockSettings.refreshing = false
0111 }
0112
0113 delegate: FormCard.AbstractFormDelegate {
0114 required property string displayName
0115 required property url url
0116 required property int index
0117
0118 implicitHeight: layout.implicitHeight
0119 implicitWidth: card.implicitWidth
0120
0121 RowLayout {
0122 id: layout
0123 anchors.fill: parent
0124 spacing: Kirigami.Units.largeSpacing
0125
0126 ColumnLayout {
0127 Layout.leftMargin: 20
0128 Layout.margins: 10
0129
0130 Controls.Label {
0131 Layout.fillWidth: true
0132 text: displayName
0133 elide: Text.ElideRight
0134 }
0135 Controls.Label {
0136 Layout.fillWidth: true
0137 text: url
0138 elide: Text.ElideRight
0139 color: Kirigami.Theme.disabledTextColor
0140 }
0141 }
0142
0143 Controls.ToolButton {
0144 Layout.margins: 10
0145 icon.name: "list-remove"
0146 display: Controls.AbstractButton.IconOnly
0147 onClicked: filterlistModel.removeFilterList(index)
0148 text: i18n("Remove this filter list")
0149
0150 }
0151 }
0152 }
0153 }
0154
0155 FormCard.FormDelegateSeparator { above: addSource}
0156
0157 FormCard.FormButtonDelegate {
0158 id: addSource
0159 text: i18n("add Filterlist")
0160 leading: Kirigami.Icon{
0161 source: "list-add"
0162 implicitHeight: Kirigami.Units.gridUnit
0163 }
0164 onClicked: addSheet.open()
0165 }
0166 }
0167 }
0168 }