2023-07-17 10:49:06 +02:00
import QtQuick
import QtQuick . Layouts
import QtQuick . Controls
import QtQuick . Controls . Material
2022-03-23 13:54:26 +01:00
import org . electrum 1.0
2022-07-22 11:29:03 +02:00
import "controls"
2022-03-23 13:54:26 +01:00
Pane {
2022-07-06 16:23:29 +02:00
id: preferences
2023-04-17 15:35:39 +02:00
objectName: 'Properties'
2022-07-06 16:23:29 +02:00
2022-03-23 13:54:26 +01:00
property string title: qsTr ( "Preferences" )
2022-09-08 12:19:38 +02:00
padding: 0
2022-07-22 11:29:03 +02:00
property var _baseunits : [ 'BTC' , 'mBTC' , 'bits' , 'sat' ]
2022-09-08 12:19:38 +02:00
ColumnLayout {
2022-03-23 13:54:26 +01:00
anchors.fill: parent
2022-10-05 18:00:51 +02:00
Flickable {
Layout.fillHeight: true
2022-09-08 12:19:38 +02:00
Layout.fillWidth: true
2022-03-23 13:54:26 +01:00
2022-10-05 18:00:51 +02:00
contentHeight: prefsPane . height
interactive: height < contentHeight
clip: true
2022-03-23 13:54:26 +01:00
2022-10-05 18:00:51 +02:00
Pane {
id: prefsPane
2023-01-03 18:22:59 +01:00
width: parent . width
2022-10-05 18:00:51 +02:00
GridLayout {
columns: 2
width: parent . width
2022-03-23 13:54:26 +01:00
2023-01-03 18:22:59 +01:00
PrefsHeading {
Layout.columnSpan: 2
text: qsTr ( 'User Interface' )
}
2022-10-05 18:00:51 +02:00
Label {
text: qsTr ( 'Language' )
}
2022-03-23 13:54:26 +01:00
2022-10-05 18:00:51 +02:00
ElComboBox {
id: language
2023-01-30 14:01:29 +01:00
textRole: 'text'
valueRole: 'value'
model: Config . languagesAvailable
onCurrentValueChanged: {
if ( activeFocus ) {
if ( Config . language != currentValue ) {
Config . language = currentValue
var dialog = app . messageDialog . createObject ( app , {
text: qsTr ( 'Please restart Electrum to activate the new GUI settings' )
} )
dialog . open ( )
}
}
}
2022-10-05 18:00:51 +02:00
}
2022-03-23 13:54:26 +01:00
2022-10-05 18:00:51 +02:00
Label {
text: qsTr ( 'Base unit' )
}
2022-03-23 13:54:26 +01:00
2022-10-05 18:00:51 +02:00
ElComboBox {
id: baseUnit
model: _baseunits
onCurrentValueChanged: {
if ( activeFocus )
Config . baseUnit = currentValue
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-04-05 13:57:42 +02:00
2023-01-03 18:22:59 +01:00
RowLayout {
2022-10-05 18:00:51 +02:00
Layout.columnSpan: 2
2023-01-03 18:22:59 +01:00
Layout.fillWidth: true
spacing: 0
Switch {
id: thousands
onCheckedChanged: {
if ( activeFocus )
Config . thousandsSeparator = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Add thousands separators to bitcoin amounts' )
wrapMode: Text . Wrap
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-04-05 13:57:42 +02:00
2023-01-03 18:22:59 +01:00
RowLayout {
spacing: 0
Switch {
id: fiatEnable
onCheckedChanged: {
if ( activeFocus )
Daemon . fx . enabled = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Fiat Currency' )
wrapMode: Text . Wrap
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-06-01 13:10:58 +02:00
2022-10-05 18:00:51 +02:00
ElComboBox {
id: currencies
model: Daemon . fx . currencies
enabled: Daemon . fx . enabled
onCurrentValueChanged: {
if ( activeFocus )
Daemon . fx . fiatCurrency = currentValue
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-07-04 18:14:15 +02:00
2023-01-03 18:22:59 +01:00
RowLayout {
2022-10-05 18:00:51 +02:00
Layout.columnSpan: 2
2023-01-03 18:22:59 +01:00
Layout.fillWidth: true
spacing: 0
Switch {
id: historicRates
enabled: Daemon . fx . enabled
onCheckedChanged: {
if ( activeFocus )
Daemon . fx . historicRates = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Historic rates' )
wrapMode: Text . Wrap
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-07-06 16:23:29 +02:00
2022-10-05 18:00:51 +02:00
Label {
2023-01-03 18:22:59 +01:00
text: qsTr ( 'Exchange rate provider' )
2022-10-05 18:00:51 +02:00
enabled: Daemon . fx . enabled
}
2022-07-06 16:23:29 +02:00
2022-10-05 18:00:51 +02:00
ElComboBox {
id: rateSources
enabled: Daemon . fx . enabled
model: Daemon . fx . rateSources
onModelChanged: {
currentIndex = rateSources . indexOfValue ( Daemon . fx . rateSource )
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
onCurrentValueChanged: {
if ( activeFocus )
Daemon . fx . rateSource = currentValue
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-09-08 12:19:38 +02:00
2022-10-05 18:00:51 +02:00
RowLayout {
2023-03-03 10:41:06 +01:00
Layout.fillWidth: true
spacing: 0
Switch {
id: usePin
checked: Config . pinCode
onCheckedChanged: {
if ( activeFocus ) {
console . log ( 'PIN active ' + checked )
if ( checked ) {
var dialog = pinSetup . createObject ( preferences , { mode: 'enter' } )
dialog . accepted . connect ( function ( ) {
Config . pinCode = dialog . pincode
dialog . close ( )
} )
dialog . rejected . connect ( function ( ) {
checked = false
} )
dialog . open ( )
} else {
focus = false
Config . pinCode = ''
// re-add binding, pincode still set if auth failed
checked = Qt . binding ( function ( ) { return Config . pinCode } )
}
}
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2023-03-03 10:41:06 +01:00
Label {
Layout.fillWidth: true
2023-03-16 09:11:48 +01:00
text: qsTr ( 'PIN protect payments' )
2023-03-03 10:41:06 +01:00
wrapMode: Text . Wrap
2022-10-05 18:00:51 +02:00
}
2023-03-03 10:41:06 +01:00
}
2023-03-03 15:50:13 +01:00
Pane {
background: Rectangle { color: Material . dialogColor }
padding: 0
2023-03-03 10:41:06 +01:00
visible: Config . pinCode != ''
2023-03-03 15:50:13 +01:00
FlatButton {
text: qsTr ( 'Modify' )
onClicked: {
var dialog = pinSetup . createObject ( preferences , {
mode: 'change' ,
pincode: Config . pinCode
} )
dialog . accepted . connect ( function ( ) {
Config . pinCode = dialog . pincode
dialog . close ( )
} )
dialog . open ( )
}
2022-09-08 12:19:38 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-09-08 12:19:38 +02:00
2023-07-11 12:51:37 +02:00
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
spacing: 0
Switch {
id: syncLabels
onCheckedChanged: {
if ( activeFocus )
AppController . setPluginEnabled ( 'labels' , checked )
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Synchronize labels' )
wrapMode: Text . Wrap
}
}
2024-11-23 21:44:02 -08:00
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
spacing: 0
Switch {
id: setMaxBrightnessOnQrDisplay
onCheckedChanged: {
if ( activeFocus )
Config . setMaxBrightnessOnQrDisplay = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Set display to max brightness when displaying QR codes' )
wrapMode: Text . Wrap
}
}
2023-03-09 15:38:29 +01:00
PrefsHeading {
Layout.columnSpan: 2
text: qsTr ( 'Wallet behavior' )
}
2023-01-03 18:22:59 +01:00
RowLayout {
Layout.columnSpan: 2
spacing: 0
Switch {
id: spendUnconfirmed
onCheckedChanged: {
if ( activeFocus )
Config . spendUnconfirmed = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Spend unconfirmed' )
wrapMode: Text . Wrap
}
}
2025-04-07 12:07:23 +02:00
RowLayout {
Layout.columnSpan: 2
spacing: 0
Switch {
id: freezeReusedAddressUtxos
onCheckedChanged: {
if ( activeFocus )
Config . freezeReusedAddressUtxos = checked
}
}
Label {
Layout.fillWidth: true
text: Config . shortDescFor ( 'WALLET_FREEZE_REUSED_ADDRESS_UTXOS' )
wrapMode: Text . Wrap
}
}
2023-01-03 18:22:59 +01:00
PrefsHeading {
Layout.columnSpan: 2
text: qsTr ( 'Lightning' )
}
2024-05-09 12:31:51 +02:00
Label {
Layout.fillWidth: true
text: Config . shortDescFor ( 'LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS' )
wrapMode: Text . Wrap
}
Label {
Layout.fillWidth: true
text: qsTr ( '<b>%1%</b> of payment' ) . arg ( maxfeeslider . _fees [ maxfeeslider . value ] / 10000 )
wrapMode: Text . Wrap
}
Slider {
id: maxfeeslider
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.leftMargin: constants . paddingXLarge
Layout.rightMargin: constants . paddingXLarge
property var _fees : [ 500 , 1000 , 3000 , 5000 , 10000 , 20000 , 30000 , 50000 ]
snapMode: Slider . SnapOnRelease
stepSize: 1
from: 0
to: _fees . length - 1
onValueChanged: {
if ( activeFocus )
Config . lightningPaymentFeeMaxMillionths = _fees [ value ]
}
Component.onCompleted: {
value = _fees . indexOf ( Config . lightningPaymentFeeMaxMillionths )
}
}
2023-01-06 14:40:39 +01:00
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
spacing: 0
Switch {
id: useTrampolineRouting
onCheckedChanged: {
if ( activeFocus ) {
if ( ! checked ) {
var dialog = app . messageDialog . createObject ( app , {
2023-04-18 14:07:41 +02:00
title: qsTr ( 'Are you sure?' ) ,
text: qsTr ( 'Electrum will have to download the Lightning Network graph, which is not recommended on mobile.' ) ,
2023-01-06 14:40:39 +01:00
yesno: true
} )
2023-04-11 10:22:48 +02:00
dialog . accepted . connect ( function ( ) {
2023-01-06 14:40:39 +01:00
Config . useGossip = true
} )
2023-01-09 17:37:23 +01:00
dialog . rejected . connect ( function ( ) {
2023-01-06 14:40:39 +01:00
checked = true // revert
} )
dialog . open ( )
} else {
Config . useGossip = ! checked
}
}
}
2022-09-08 12:19:38 +02:00
}
2023-01-06 14:40:39 +01:00
Label {
Layout.fillWidth: true
text: qsTr ( 'Trampoline routing' )
wrapMode: Text . Wrap
2022-09-29 13:18:13 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-09-29 13:18:13 +02:00
2023-01-03 18:22:59 +01:00
RowLayout {
2022-10-05 18:00:51 +02:00
Layout.columnSpan: 2
2023-01-03 18:22:59 +01:00
Layout.fillWidth: true
spacing: 0
Switch {
id: useRecoverableChannels
onCheckedChanged: {
2023-04-14 14:18:49 +02:00
if ( activeFocus ) {
if ( ! checked ) {
var dialog = app . messageDialog . createObject ( app , {
2023-04-18 14:07:41 +02:00
title: qsTr ( 'Are you sure?' ) ,
text: qsTr ( 'This option allows you to recover your lightning funds if you lose your device, or if you uninstall this app while lightning channels are active. Do not disable it unless you know how to recover channels from backups.' ) ,
2023-04-14 14:18:49 +02:00
yesno: true
} )
dialog . accepted . connect ( function ( ) {
2023-04-17 11:40:09 +02:00
Config . useRecoverableChannels = false
2023-04-14 14:18:49 +02:00
} )
dialog . rejected . connect ( function ( ) {
checked = true // revert
} )
dialog . open ( )
} else {
Config . useRecoverableChannels = checked
}
}
2023-01-03 18:22:59 +01:00
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Create recoverable channels' )
wrapMode: Text . Wrap
2022-10-04 14:14:03 +02:00
}
2022-10-05 18:00:51 +02:00
}
2022-10-04 14:14:03 +02:00
2023-01-03 18:22:59 +01:00
PrefsHeading {
2022-10-07 20:28:52 +00:00
Layout.columnSpan: 2
2023-01-03 18:22:59 +01:00
text: qsTr ( 'Advanced' )
2022-10-07 20:28:52 +00:00
}
2023-01-03 18:22:59 +01:00
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
spacing: 0
Switch {
id: enableDebugLogs
onCheckedChanged: {
if ( activeFocus )
Config . enableDebugLogs = checked
}
enabled: Config . canToggleDebugLogs
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Enable debug logs (for developers)' )
wrapMode: Text . Wrap
}
}
2023-12-27 07:28:39 +00:00
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
spacing: 0
Switch {
id: alwaysAllowScreenshots
onCheckedChanged: {
if ( activeFocus )
Config . alwaysAllowScreenshots = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr ( 'Always allow screenshots' )
wrapMode: Text . Wrap
}
}
2022-07-22 11:29:03 +02:00
}
2022-03-23 13:54:26 +01:00
}
}
}
2022-07-06 16:23:29 +02:00
Component {
id: pinSetup
Pin { }
}
2022-03-23 13:54:26 +01:00
Component.onCompleted: {
2023-01-30 14:01:29 +01:00
language . currentIndex = language . indexOfValue ( Config . language )
2022-07-22 11:29:03 +02:00
baseUnit . currentIndex = _baseunits . indexOf ( Config . baseUnit )
2022-03-23 13:54:26 +01:00
thousands . checked = Config . thousandsSeparator
2022-04-05 13:57:42 +02:00
currencies . currentIndex = currencies . indexOfValue ( Daemon . fx . fiatCurrency )
2022-04-07 16:37:57 +02:00
historicRates . checked = Daemon . fx . historicRates
2022-04-05 13:57:42 +02:00
rateSources . currentIndex = rateSources . indexOfValue ( Daemon . fx . rateSource )
2022-04-07 16:37:57 +02:00
fiatEnable . checked = Daemon . fx . enabled
2022-07-04 18:14:15 +02:00
spendUnconfirmed . checked = Config . spendUnconfirmed
2025-04-07 12:07:23 +02:00
freezeReusedAddressUtxos . checked = Config . freezeReusedAddressUtxos
2023-01-06 14:40:39 +01:00
useTrampolineRouting . checked = ! Config . useGossip
2022-10-07 20:28:52 +00:00
enableDebugLogs . checked = Config . enableDebugLogs
2023-12-27 07:28:39 +00:00
alwaysAllowScreenshots . checked = Config . alwaysAllowScreenshots
2024-11-23 21:44:02 -08:00
setMaxBrightnessOnQrDisplay . checked = Config . setMaxBrightnessOnQrDisplay
2022-10-17 17:24:46 +02:00
useRecoverableChannels . checked = Config . useRecoverableChannels
2023-07-11 12:51:37 +02:00
syncLabels . checked = AppController . isPluginEnabled ( 'labels' )
2022-03-23 13:54:26 +01:00
}
}