add default request expiry to preferences/config
This commit is contained in:
@@ -148,6 +148,18 @@ Pane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Default request expiry')
|
||||||
|
Layout.fillWidth: false
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestExpiryComboBox {
|
||||||
|
onCurrentValueChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Config.requestExpiry = currentValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('PIN')
|
text: qsTr('PIN')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,26 +84,9 @@ ElDialog {
|
|||||||
Layout.fillWidth: false
|
Layout.fillWidth: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ElComboBox {
|
RequestExpiryComboBox {
|
||||||
id: expires
|
id: expires
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
|
|
||||||
textRole: 'text'
|
|
||||||
valueRole: 'value'
|
|
||||||
|
|
||||||
model: ListModel {
|
|
||||||
id: expiresmodel
|
|
||||||
Component.onCompleted: {
|
|
||||||
// we need to fill the model like this, as ListElement can't evaluate script
|
|
||||||
expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60})
|
|
||||||
expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60})
|
|
||||||
expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60})
|
|
||||||
expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60})
|
|
||||||
expiresmodel.append({'text': qsTr('1 month'), 'value': 31*24*60*60})
|
|
||||||
expiresmodel.append({'text': qsTr('Never'), 'value': 0})
|
|
||||||
expires.currentIndex = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { width: 1; height: 1; Layout.fillWidth: true }
|
Item { width: 1; height: 1; Layout.fillWidth: true }
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
|
import org.electrum 1.0
|
||||||
|
|
||||||
|
ElComboBox {
|
||||||
|
id: expires
|
||||||
|
|
||||||
|
textRole: 'text'
|
||||||
|
valueRole: 'value'
|
||||||
|
|
||||||
|
model: ListModel {
|
||||||
|
id: expiresmodel
|
||||||
|
Component.onCompleted: {
|
||||||
|
// we need to fill the model like this, as ListElement can't evaluate script
|
||||||
|
expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60})
|
||||||
|
expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60})
|
||||||
|
expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60})
|
||||||
|
expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60})
|
||||||
|
expiresmodel.append({'text': qsTr('1 month'), 'value': 31*24*60*60})
|
||||||
|
expiresmodel.append({'text': qsTr('Never'), 'value': 0})
|
||||||
|
expires.currentIndex = 0
|
||||||
|
for (let i=0; i < expiresmodel.count; i++) {
|
||||||
|
if (expiresmodel.get(i).value == Config.requestExpiry) {
|
||||||
|
expires.currentIndex = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCurrentValueChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Config.requestExpiry = currentValue
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ from decimal import Decimal
|
|||||||
|
|
||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.util import DECIMAL_POINT_DEFAULT, format_satoshis
|
from electrum.util import DECIMAL_POINT_DEFAULT, format_satoshis
|
||||||
|
from electrum.invoices import PR_DEFAULT_EXPIRATION_WHEN_CREATING
|
||||||
|
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
from .auth import AuthMixin, auth_protect
|
from .auth import AuthMixin, auth_protect
|
||||||
@@ -81,6 +82,18 @@ class QEConfig(AuthMixin, QObject):
|
|||||||
self.config.set_key('confirmed_only', not checked, True)
|
self.config.set_key('confirmed_only', not checked, True)
|
||||||
self.spendUnconfirmedChanged.emit()
|
self.spendUnconfirmedChanged.emit()
|
||||||
|
|
||||||
|
requestExpiryChanged = pyqtSignal()
|
||||||
|
@pyqtProperty(int, notify=requestExpiryChanged)
|
||||||
|
def requestExpiry(self):
|
||||||
|
a = self.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING)
|
||||||
|
self._logger.debug(f'request expiry {a}')
|
||||||
|
return a
|
||||||
|
|
||||||
|
@requestExpiry.setter
|
||||||
|
def requestExpiry(self, expiry):
|
||||||
|
self.config.set_key('request_expiry', expiry)
|
||||||
|
self.requestExpiryChanged.emit()
|
||||||
|
|
||||||
pinCodeChanged = pyqtSignal()
|
pinCodeChanged = pyqtSignal()
|
||||||
@pyqtProperty(str, notify=pinCodeChanged)
|
@pyqtProperty(str, notify=pinCodeChanged)
|
||||||
def pinCode(self):
|
def pinCode(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user