Warning, /plasma/bluedevil/src/kcm/ui/General.qml is written in an unsupported language. File is not indexed.
0001 /**
0002 * SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
0003 * SPDX-FileCopyrightText: 2021 Nate Graham <nate@kde.org>
0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006
0007 import QtQuick 2.2
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Controls 2.10 as QQC2
0010 import QtQuick.Dialogs
0011
0012 import org.kde.kirigami 2.10 as Kirigami
0013 import org.kde.kcmutils
0014 import org.kde.bluezqt 1.0 as BluezQt
0015 import org.kde.bluedevil.kcm 1.0
0016
0017 SimpleKCM {
0018
0019 title: i18n("Settings")
0020
0021 Kirigami.FormLayout {
0022 id: form
0023
0024 property QtObject adapter: BluezQt.Manager.adapters[box.currentIndex]
0025
0026 QQC2.ComboBox {
0027 id: box
0028 Kirigami.FormData.label: i18n("Device:")
0029 model: BluezQt.Manager.adapters
0030 textRole: "name"
0031 visible: count > 1
0032 }
0033
0034 QQC2.TextField {
0035 text: form.adapter.name
0036 Kirigami.FormData.label: i18n("Name:")
0037 onEditingFinished: form.adapter.name = text
0038 }
0039
0040 QQC2.Label {
0041 text: form.adapter.address
0042 Kirigami.FormData.label: i18n("Address:")
0043 }
0044
0045 QQC2.CheckBox {
0046 Kirigami.FormData.label: i18n("Enabled:")
0047 checked: form.adapter.powered
0048 onToggled: form.adapter.powered = checked
0049 }
0050
0051 QQC2.CheckBox {
0052 Kirigami.FormData.label: i18n("Visible:")
0053 checked: form.adapter.discoverable
0054 onToggled: form.adapter.discoverable = checked
0055 }
0056
0057 Kirigami.Separator {
0058 Kirigami.FormData.isSection: true
0059 }
0060
0061 QQC2.ButtonGroup {
0062 id: loginStateRadioGroup
0063 }
0064
0065 QQC2.RadioButton {
0066 Kirigami.FormData.label: i18n("On login:")
0067 text: i18n("Enable Bluetooth")
0068 QQC2.ButtonGroup.group: loginStateRadioGroup
0069 checked: kcm.bluetoothStatusAtLogin === "enable"
0070 onToggled: {
0071 if (enabled) {
0072 kcm.bluetoothStatusAtLogin = "enable";
0073 }
0074 }
0075 }
0076 QQC2.RadioButton {
0077 text: i18n("Disable Bluetooth")
0078 QQC2.ButtonGroup.group: loginStateRadioGroup
0079 checked: kcm.bluetoothStatusAtLogin === "disable"
0080 onToggled: {
0081 if (enabled) {
0082 kcm.bluetoothStatusAtLogin = "disable"
0083 }
0084 }
0085 }
0086 QQC2.RadioButton {
0087 text: i18n("Restore previous status")
0088 QQC2.ButtonGroup.group: loginStateRadioGroup
0089 checked: kcm.bluetoothStatusAtLogin === "remember"
0090 onToggled: {
0091 if (enabled) {
0092 kcm.bluetoothStatusAtLogin = "remember"
0093 }
0094 }
0095 }
0096
0097 Kirigami.Separator {
0098 Kirigami.FormData.isSection: true
0099 }
0100
0101 QQC2.ButtonGroup {
0102 id: receivingFilesRadioGroup
0103 }
0104
0105 QQC2.RadioButton {
0106 Kirigami.FormData.label: i18n("When receiving files:")
0107 checked: FileReceiverSettings.autoAccept === 0
0108 text: i18n("Ask for confirmation")
0109 QQC2.ButtonGroup.group: receivingFilesRadioGroup
0110 onClicked: {
0111 FileReceiverSettings.autoAccept = 0
0112 FileReceiverSettings.save()
0113 }
0114 }
0115
0116 QQC2.RadioButton {
0117 text: i18n("Accept for trusted devices")
0118 checked: FileReceiverSettings.autoAccept === 1
0119 QQC2.ButtonGroup.group: receivingFilesRadioGroup
0120 onClicked: {
0121 FileReceiverSettings.autoAccept = 1
0122 FileReceiverSettings.save()
0123 }
0124 }
0125
0126 QQC2.RadioButton {
0127 text: i18n("Always accept")
0128 QQC2.ButtonGroup.group: receivingFilesRadioGroup
0129 checked: FileReceiverSettings.autoAccept === 2
0130 onClicked: {
0131 FileReceiverSettings.autoAccept = 2
0132 FileReceiverSettings.save()
0133 }
0134 }
0135
0136 Row {
0137 Kirigami.FormData.label: i18n("Save files in:")
0138 QQC2.TextField {
0139 function urlToPath(urlString) {
0140 var s
0141 if (urlString.startsWith("file:///")) {
0142 var k = urlString.charAt(9) === ':' ? 8 : 7
0143 s = urlString.substring(k)
0144 } else {
0145 s = urlString
0146 }
0147 return decodeURIComponent(s);
0148 }
0149
0150 text: urlToPath(FileReceiverSettings.saveUrl.toString())
0151
0152 onEditingFinished: {
0153 FileReceiverSettings.saveUrl = Qt.resolvedUrl(text)
0154 FileReceiverSettings.save()
0155 }
0156 }
0157
0158 QQC2.Button {
0159 icon.name: "document-open-folder-symbolic"
0160 display: QQC2.AbstractButton.IconOnly
0161 text: i18n("Select folder")
0162 onClicked: folderDialogLoader.active = true
0163 }
0164
0165 Loader {
0166 id: folderDialogLoader
0167
0168 active: false
0169
0170 sourceComponent: FolderDialog {
0171 id: startupFileDialog
0172 title: i18n("Select folder")
0173
0174 currentFolder: FileReceiverSettings.saveUrl
0175
0176 onAccepted: {
0177 FileReceiverSettings.saveUrl = selectedFolder
0178 folderDialogLoader.active = false
0179 FileReceiverSettings.save()
0180 }
0181
0182 onRejected: folderDialogLoader.active = false
0183
0184 Component.onCompleted: open()
0185 }
0186 }
0187 }
0188 }
0189 }
0190