qml: initial plugin support, with labelsync mostly implemented
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Material 2.0
|
||||
|
||||
import org.electrum 1.0
|
||||
@@ -12,175 +12,212 @@ Pane {
|
||||
|
||||
property string title: qsTr("Preferences")
|
||||
|
||||
padding: 0
|
||||
|
||||
property var _baseunits: ['BTC','mBTC','bits','sat']
|
||||
|
||||
Flickable {
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
contentHeight: rootLayout.height
|
||||
interactive: height < contentHeight
|
||||
|
||||
GridLayout {
|
||||
id: rootLayout
|
||||
columns: 2
|
||||
width: parent.width
|
||||
|
||||
Label {
|
||||
text: qsTr('Language')
|
||||
TabBar {
|
||||
id: tabbar
|
||||
Layout.fillWidth: true
|
||||
currentIndex: swipeview.currentIndex
|
||||
TabButton {
|
||||
text: qsTr('Preferences')
|
||||
font.pixelSize: constants.fontSizeLarge
|
||||
}
|
||||
|
||||
ElComboBox {
|
||||
id: language
|
||||
enabled: false
|
||||
TabButton {
|
||||
text: qsTr('Plugins')
|
||||
font.pixelSize: constants.fontSizeLarge
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Base unit')
|
||||
}
|
||||
SwipeView {
|
||||
id: swipeview
|
||||
|
||||
ElComboBox {
|
||||
id: baseUnit
|
||||
model: _baseunits
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Config.baseUnit = currentValue
|
||||
}
|
||||
}
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
currentIndex: tabbar.currentIndex
|
||||
|
||||
Switch {
|
||||
id: thousands
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr('Add thousands separators to bitcoin amounts')
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Config.thousandsSeparator = checked
|
||||
}
|
||||
}
|
||||
Flickable {
|
||||
contentHeight: prefsPane.height
|
||||
interactive: height < contentHeight
|
||||
clip: true
|
||||
|
||||
Switch {
|
||||
id: checkSoftware
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr('Automatically check for software updates')
|
||||
enabled: false
|
||||
}
|
||||
Pane {
|
||||
id: prefsPane
|
||||
GridLayout {
|
||||
columns: 2
|
||||
width: parent.width
|
||||
|
||||
Switch {
|
||||
id: fiatEnable
|
||||
text: qsTr('Fiat Currency')
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.enabled = checked
|
||||
}
|
||||
}
|
||||
Label {
|
||||
text: qsTr('Language')
|
||||
}
|
||||
|
||||
ElComboBox {
|
||||
id: currencies
|
||||
model: Daemon.fx.currencies
|
||||
enabled: Daemon.fx.enabled
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.fiatCurrency = currentValue
|
||||
}
|
||||
}
|
||||
ElComboBox {
|
||||
id: language
|
||||
enabled: false
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: historicRates
|
||||
text: qsTr('Historic rates')
|
||||
enabled: Daemon.fx.enabled
|
||||
Layout.columnSpan: 2
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.historicRates = checked
|
||||
}
|
||||
}
|
||||
Label {
|
||||
text: qsTr('Base unit')
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Source')
|
||||
enabled: Daemon.fx.enabled
|
||||
}
|
||||
ElComboBox {
|
||||
id: baseUnit
|
||||
model: _baseunits
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Config.baseUnit = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
ElComboBox {
|
||||
id: rateSources
|
||||
enabled: Daemon.fx.enabled
|
||||
model: Daemon.fx.rateSources
|
||||
onModelChanged: {
|
||||
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
|
||||
}
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.rateSource = currentValue
|
||||
}
|
||||
}
|
||||
Switch {
|
||||
id: thousands
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr('Add thousands separators to bitcoin amounts')
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Config.thousandsSeparator = checked
|
||||
}
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: spendUnconfirmed
|
||||
text: qsTr('Spend unconfirmed')
|
||||
Layout.columnSpan: 2
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Config.spendUnconfirmed = checked
|
||||
}
|
||||
}
|
||||
Switch {
|
||||
id: checkSoftware
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr('Automatically check for software updates')
|
||||
enabled: false
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('PIN')
|
||||
}
|
||||
Switch {
|
||||
id: fiatEnable
|
||||
text: qsTr('Fiat Currency')
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.enabled = checked
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Label {
|
||||
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On')
|
||||
color: Material.accentColor
|
||||
Layout.rightMargin: constants.paddingMedium
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Enable')
|
||||
visible: Config.pinCode == ''
|
||||
onClicked: {
|
||||
var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
|
||||
dialog.accepted.connect(function() {
|
||||
Config.pinCode = dialog.pincode
|
||||
dialog.close()
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Change')
|
||||
visible: Config.pinCode != ''
|
||||
onClicked: {
|
||||
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
|
||||
dialog.accepted.connect(function() {
|
||||
Config.pinCode = dialog.pincode
|
||||
dialog.close()
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Remove')
|
||||
visible: Config.pinCode != ''
|
||||
onClicked: {
|
||||
Config.pinCode = ''
|
||||
ElComboBox {
|
||||
id: currencies
|
||||
model: Daemon.fx.currencies
|
||||
enabled: Daemon.fx.enabled
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.fiatCurrency = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: historicRates
|
||||
text: qsTr('Historic rates')
|
||||
enabled: Daemon.fx.enabled
|
||||
Layout.columnSpan: 2
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.historicRates = checked
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Source')
|
||||
enabled: Daemon.fx.enabled
|
||||
}
|
||||
|
||||
ElComboBox {
|
||||
id: rateSources
|
||||
enabled: Daemon.fx.enabled
|
||||
model: Daemon.fx.rateSources
|
||||
onModelChanged: {
|
||||
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
|
||||
}
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.rateSource = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: spendUnconfirmed
|
||||
text: qsTr('Spend unconfirmed')
|
||||
Layout.columnSpan: 2
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Config.spendUnconfirmed = checked
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('PIN')
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Label {
|
||||
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On')
|
||||
color: Material.accentColor
|
||||
Layout.rightMargin: constants.paddingMedium
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Enable')
|
||||
visible: Config.pinCode == ''
|
||||
onClicked: {
|
||||
var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
|
||||
dialog.accepted.connect(function() {
|
||||
Config.pinCode = dialog.pincode
|
||||
dialog.close()
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Change')
|
||||
visible: Config.pinCode != ''
|
||||
onClicked: {
|
||||
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
|
||||
dialog.accepted.connect(function() {
|
||||
Config.pinCode = dialog.pincode
|
||||
dialog.close()
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr('Remove')
|
||||
visible: Config.pinCode != ''
|
||||
onClicked: {
|
||||
Config.pinCode = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Lightning Routing')
|
||||
}
|
||||
|
||||
ElComboBox {
|
||||
id: lnRoutingType
|
||||
enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning
|
||||
|
||||
valueRole: 'key'
|
||||
textRole: 'label'
|
||||
model: ListModel {
|
||||
ListElement { key: 'gossip'; label: qsTr('Gossip') }
|
||||
ListElement { key: 'trampoline'; label: qsTr('Trampoline') }
|
||||
}
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Config.useGossip = currentValue == 'gossip'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Lightning Routing')
|
||||
}
|
||||
|
||||
ElComboBox {
|
||||
id: lnRoutingType
|
||||
enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning
|
||||
|
||||
valueRole: 'key'
|
||||
textRole: 'label'
|
||||
model: ListModel {
|
||||
ListElement { key: 'gossip'; label: qsTr('Gossip') }
|
||||
ListElement { key: 'trampoline'; label: qsTr('Trampoline') }
|
||||
}
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Config.useGossip = currentValue == 'gossip'
|
||||
Pane {
|
||||
ColumnLayout {
|
||||
id: pluginsRootLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,6 +229,19 @@ Pane {
|
||||
Pin {}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: pluginHeader
|
||||
RowLayout {
|
||||
property QtObject plugin
|
||||
Switch {
|
||||
checked: plugin.pluginEnabled
|
||||
}
|
||||
Label {
|
||||
text: plugin.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
baseUnit.currentIndex = _baseunits.indexOf(Config.baseUnit)
|
||||
thousands.checked = Config.thousandsSeparator
|
||||
@@ -201,5 +251,15 @@ Pane {
|
||||
fiatEnable.checked = Daemon.fx.enabled
|
||||
spendUnconfirmed.checked = Config.spendUnconfirmed
|
||||
lnRoutingType.currentIndex = Config.useGossip ? 0 : 1
|
||||
|
||||
var labelsPlugin = AppController.plugin('labels')
|
||||
if (labelsPlugin) {
|
||||
pluginHeader.createObject(pluginsRootLayout, { plugin: labelsPlugin })
|
||||
// console.log(Qt.resolvedUrl(labelsPlugin.settingsComponent()))
|
||||
if (labelsPlugin.settingsComponent()) {
|
||||
var component = Qt.createComponent(Qt.resolvedUrl(labelsPlugin.settingsComponent()))
|
||||
component.createObject(pluginsRootLayout, {plugin: labelsPlugin})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user