1
0

Merge pull request #9795 from f321x/followup_tos_qt

followup: qt terms of use scrollbar and regtest mode
This commit is contained in:
ThomasV
2025-05-07 19:33:05 +02:00
committed by GitHub
2 changed files with 14 additions and 5 deletions

View File

@@ -72,6 +72,7 @@ from electrum.simple_config import SimpleConfig
from electrum.wizard import WizardViewState
from electrum.keystore import load_keystore
from electrum.bip32 import is_xprv
from electrum import constants
from electrum.gui.common_qt.i18n import ElectrumTranslator
from electrum.gui.messages import TERMS_OF_USE_LATEST_VERSION
@@ -505,7 +506,8 @@ class ElectrumGui(BaseElectrumGui, Logger):
"""Ask the user to accept the terms of use.
This is only shown if the user has not accepted them yet.
"""
if self.config.TERMS_OF_USE_ACCEPTED >= TERMS_OF_USE_LATEST_VERSION:
if self.config.TERMS_OF_USE_ACCEPTED >= TERMS_OF_USE_LATEST_VERSION\
or constants.net.NET_NAME == "regtest":
return
from electrum.gui.qt.wizard.terms_of_use import QETermsOfUseWizard
dialog = QETermsOfUseWizard(self.config, self.app)

View File

@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
from PyQt6.QtCore import QTimer
from PyQt6.QtCore import QTimer, QEvent
from PyQt6.QtGui import QPixmap
from PyQt6.QtWidgets import QLabel, QHBoxLayout, QScrollArea
@@ -55,11 +55,18 @@ class WCTermsOfUseScreen(WizardComponent):
# Find the scroll area and connect to its scrollbar
QTimer.singleShot(0, self.check_scroll_position)
self.window().installEventFilter(self)
def eventFilter(self, obj, event):
if obj == self.window() and event.type() == QEvent.Type.Resize:
# catch window resize events to check if the scrollbar is visible
QTimer.singleShot(100, self.check_scroll_position)
return super().eventFilter(obj, event)
def check_scroll_position(self):
# Find the scroll area
scroll_area = self.window().findChild(QScrollArea)
if scroll_area and scroll_area.verticalScrollBar():
if scroll_area and scroll_area.verticalScrollBar() \
and scroll_area.verticalScrollBar().isVisible():
scrollbar = scroll_area.verticalScrollBar()
def on_scroll_change(value):
if value >= scrollbar.maximum() - 5: # Allow 5 pixel margin
@@ -67,7 +74,7 @@ class WCTermsOfUseScreen(WizardComponent):
self.on_updated()
scrollbar.valueChanged.connect(on_scroll_change)
else:
# Fallback if the scroll area is not detected
# scrollbar is not visible or not found
self._valid = True
self.on_updated()