From 6331448860f04d6f067ba618cdcc5f58bcb07e15 Mon Sep 17 00:00:00 2001 From: Josh Geden Date: Sat, 23 Nov 2024 21:44:02 -0800 Subject: [PATCH] qml: add config setting for max brightness on qr display --- electrum/gui/qml/components/Preferences.qml | 21 +++++++++++++++++-- .../gui/qml/components/controls/QRImage.qml | 5 +++-- electrum/gui/qml/qeapp.py | 4 ++++ electrum/gui/qml/qeconfig.py | 9 ++++++++ electrum/simple_config.py | 1 + 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index 641ae4e66..8c43dc984 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -231,6 +231,24 @@ Pane { } } + 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 + } + } + PrefsHeading { Layout.columnSpan: 2 text: qsTr('Wallet behavior') @@ -423,10 +441,8 @@ Pane { } } } - } } - } Component { @@ -447,6 +463,7 @@ Pane { useFallbackAddress.checked = Config.useFallbackAddress enableDebugLogs.checked = Config.enableDebugLogs alwaysAllowScreenshots.checked = Config.alwaysAllowScreenshots + setMaxBrightnessOnQrDisplay.checked = Config.setMaxBrightnessOnQrDisplay useRecoverableChannels.checked = Config.useRecoverableChannels syncLabels.checked = AppController.isPluginEnabled('labels') } diff --git a/electrum/gui/qml/components/controls/QRImage.qml b/electrum/gui/qml/components/controls/QRImage.qml index 4ac41d98d..67190a138 100644 --- a/electrum/gui/qml/components/controls/QRImage.qml +++ b/electrum/gui/qml/components/controls/QRImage.qml @@ -78,10 +78,11 @@ Item { onVisibleChanged: { if (root.visible) { // set max brightness to make qr code easier to scan - AppController.setMaxScreenBrightness() + if (AppController.isMaxBrightnessOnQrDisplayEnabled()) { + AppController.setMaxScreenBrightness() + } } else { AppController.resetScreenBrightness() } } - } diff --git a/electrum/gui/qml/qeapp.py b/electrum/gui/qml/qeapp.py index f0c1197f8..6a8334082 100644 --- a/electrum/gui/qml/qeapp.py +++ b/electrum/gui/qml/qeapp.py @@ -210,6 +210,10 @@ class QEAppController(BaseCrashReporter, QObject): it = jIntent.createChooser(sendIntent, cast('java.lang.CharSequence', jString(title))) jpythonActivity.startActivity(it) + @pyqtSlot() + def isMaxBrightnessOnQrDisplayEnabled(self): + return self.config.GUI_QML_SET_MAX_BRIGHTNESS_ON_QR_DISPLAY + @pyqtSlot() def setMaxScreenBrightness(self): self._set_screen_brightness(1.0) diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py index 7eb6c9715..bb27c95f0 100644 --- a/electrum/gui/qml/qeconfig.py +++ b/electrum/gui/qml/qeconfig.py @@ -189,6 +189,15 @@ class QEConfig(AuthMixin, QObject): self.config.GUI_QML_ALWAYS_ALLOW_SCREENSHOTS = enable self.alwaysAllowScreenshotsChanged.emit() + setMaxBrightnessOnQrDisplayChanged = pyqtSignal() + @pyqtProperty(bool, notify=setMaxBrightnessOnQrDisplayChanged) + def setMaxBrightnessOnQrDisplay(self): + return self.config.GUI_QML_SET_MAX_BRIGHTNESS_ON_QR_DISPLAY + + @setMaxBrightnessOnQrDisplay.setter + def setMaxBrightnessOnQrDisplay(self, enable): + self.config.GUI_QML_SET_MAX_BRIGHTNESS_ON_QR_DISPLAY = enable + useRecoverableChannelsChanged = pyqtSignal() @pyqtProperty(bool, notify=useRecoverableChannelsChanged) def useRecoverableChannels(self): diff --git a/electrum/simple_config.py b/electrum/simple_config.py index 9a022deb1..c8c537071 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -1121,6 +1121,7 @@ Warning: setting this to too low will result in lots of payment failures."""), GUI_QML_ADDRESS_LIST_SHOW_TYPE = ConfigVar('address_list_show_type', default=1, type_=int) GUI_QML_ADDRESS_LIST_SHOW_USED = ConfigVar('address_list_show_used', default=False, type_=bool) GUI_QML_ALWAYS_ALLOW_SCREENSHOTS = ConfigVar('android_always_allow_screenshots', default=False, type_=bool) + GUI_QML_SET_MAX_BRIGHTNESS_ON_QR_DISPLAY = ConfigVar('android_set_max_brightness_on_qr_display', default=True, type_=bool) BTC_AMOUNTS_DECIMAL_POINT = ConfigVar('decimal_point', default=DECIMAL_POINT_DEFAULT, type_=int) BTC_AMOUNTS_FORCE_NZEROS_AFTER_DECIMAL_POINT = ConfigVar(