Пример #1
0
    def __init__(self, config, daemon, plugins):
        super(__class__, self).__init__() # QObject init
        assert __class__.instance is None, "ElectrumGui is a singleton, yet an instance appears to already exist! FIXME!"
        __class__.instance = self
        set_language(config.get('language'))

        self.config = config
        self.daemon = daemon
        self.plugins = plugins
        self.windows = []

        # Uncomment this call to verify objects are being properly
        # GC-ed when windows are closed
        #if daemon.network:
        #    from electroncash.util import DebugMem
        #    from electroncash.wallet import Abstract_Wallet
        #    from electroncash.verifier import SPV
        #    from electroncash.synchronizer import Synchronizer
        #    daemon.network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
        #                                       ElectrumWindow], interval=5)])

        call_after_app = self._pre_and_post_app_setup()
        try:
            self.app = QApplication(sys.argv)
        finally:
            call_after_app()

        self._load_fonts()  # this needs to be done very early, before the font engine loads fonts.. out of paranoia
        self._exit_if_required_pyqt_is_missing()  # This may immediately exit the app if missing required PyQt5 modules, so it should also be done early.
        self.new_version_available = None
        self._set_icon()
        self.app.installEventFilter(self)
        self.timer = QTimer(self); self.timer.setSingleShot(False); self.timer.setInterval(500) #msec
        self.gc_timer = QTimer(self); self.gc_timer.setSingleShot(True); self.gc_timer.timeout.connect(ElectrumGui.gc); self.gc_timer.setInterval(500) #msec
        self.nd = None
        self._last_active_window = None  # we remember the last activated ElectrumWindow as a Weak.ref
        # Dark Theme -- ideally set this before any widgets are created.
        self.set_dark_theme_if_needed()
        # /
        self.update_checker = UpdateChecker()
        self.update_checker_timer = QTimer(self); self.update_checker_timer.timeout.connect(self.on_auto_update_timeout); self.update_checker_timer.setSingleShot(False)
        self.update_checker.got_new_version.connect(self.on_new_version)
        # init tray
        self.dark_icon = self.config.get("dark_icon", False)
        self.tray = QSystemTrayIcon(self.tray_icon(), self)
        self.tray.setToolTip('Electron Cash')
        self.tray.activated.connect(self.tray_activated)
        self.build_tray_menu()
        self.tray.show()
        self.new_window_signal.connect(self.start_new_window)
        if self.has_auto_update_check():
            self._start_auto_update_timer(first_run = True)
        self.app.focusChanged.connect(self.on_focus_change)  # track last window the user interacted with
        self.shutdown_signal.connect(self.close, Qt.QueuedConnection)
        run_hook('init_qt', self)
        # We did this once already in the set_dark_theme call, but we do this
        # again here just in case some plugin modified the color scheme.
        ColorScheme.update_from_widget(QWidget())

        self._check_and_warn_qt_version()
Пример #2
0
 def __init__(self, config, daemon, plugins):
     set_language(config.get('language'))
     # Uncomment this call to verify objects are being properly
     # GC-ed when windows are closed
     #network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
     #                            ElectrumWindow], interval=5)])
     QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
     self.config = config
     self.daemon = daemon
     self.plugins = plugins
     self.windows = []
     self.efilter = OpenFileEventFilter(self.windows)
     self.app = QElectrumApplication(sys.argv)
     self.app.installEventFilter(self.efilter)
     self.timer = Timer()
     self.nd = None
     self.network_updated_signal_obj = QNetworkUpdatedSignalObject()
     # init tray
     self.dark_icon = self.config.get("dark_icon", False)
     self.tray = QSystemTrayIcon(self.tray_icon(), None)
     self.tray.setToolTip('Electrum')
     self.tray.activated.connect(self.tray_activated)
     self.build_tray_menu()
     self.tray.show()
     self.app.new_window_signal.connect(self.start_new_window)
     run_hook('init_qt', self)
Пример #3
0
 def __init__(self, config, daemon, plugins):
     set_language(config.get('language'))
     # Uncomment this call to verify objects are being properly
     # GC-ed when windows are closed
     #network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
     #                            ElectrumWindow], interval=5)])
     QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
     if hasattr(QtCore.Qt, "AA_ShareOpenGLContexts"):
         QtCore.QCoreApplication.setAttribute(
             QtCore.Qt.AA_ShareOpenGLContexts)
     if hasattr(QGuiApplication, 'setDesktopFileName'):
         QGuiApplication.setDesktopFileName('electron-cash.desktop')
     self.config = config
     self.daemon = daemon
     self.plugins = plugins
     self.windows = []
     self.efilter = OpenFileEventFilter(self.windows)
     self.app = QElectrumApplication(sys.argv)
     self.app.installEventFilter(self.efilter)
     self.timer = QTimer(self.app)
     self.timer.setSingleShot(False)
     self.timer.setInterval(500)  #msec
     self.nd = None
     self.network_updated_signal_obj = QNetworkUpdatedSignalObject()
     # init tray
     self.dark_icon = self.config.get("dark_icon", False)
     self.tray = QSystemTrayIcon(self.tray_icon(), None)
     self.tray.setToolTip('Electron Cash')
     self.tray.activated.connect(self.tray_activated)
     self.build_tray_menu()
     self.tray.show()
     self.app.new_window_signal.connect(self.start_new_window)
     run_hook('init_qt', self)
     ColorScheme.update_from_widget(QWidget())
Пример #4
0
def init_qapplication(config):
    global app
    i18n.set_language(config.get('language'))
    call_after_app = _pre_and_post_app_setup(config)
    try:
        app = QtWidgets.QApplication(sys.argv)
    finally:
        call_after_app()
Пример #5
0
 def __init__(self, config, daemon, plugins):
     super(__class__, self).__init__() # QObject init
     assert __class__.instance is None, "ElectrumGui is a singleton, yet an instance appears to already exist! FIXME!"
     __class__.instance = self
     set_language(config.get('language'))
     # Uncomment this call to verify objects are being properly
     # GC-ed when windows are closed
     #if daemon.network:
     #    from electroncash.util import DebugMem
     #    from electroncash.wallet import Abstract_Wallet
     #    from electroncash.verifier import SPV
     #    from electroncash.synchronizer import Synchronizer
     #    daemon.network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
     #                                       ElectrumWindow], interval=5)])
     QCoreApplication.setAttribute(Qt.AA_X11InitThreads)
     if hasattr(Qt, "AA_ShareOpenGLContexts"):
         QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
     if hasattr(QGuiApplication, 'setDesktopFileName'):
         QGuiApplication.setDesktopFileName('electron-cash.desktop')
     self.config = config
     self.daemon = daemon
     self.plugins = plugins
     self.windows = []
     self.app = QApplication(sys.argv)
     self._set_icon()
     self.app.installEventFilter(self)
     self.timer = QTimer(self); self.timer.setSingleShot(False); self.timer.setInterval(500) #msec
     self.gc_timer = QTimer(self); self.gc_timer.setSingleShot(True); self.gc_timer.timeout.connect(ElectrumGui.gc); self.gc_timer.setInterval(500) #msec
     self.nd = None
     # Dark Theme -- ideally set this before any widgets are created.
     self.set_dark_theme_if_needed()
     # /
     # Wallet Password Cache
     # wallet -> (password, QTimer) map for some plugins (like CashShuffle)
     # that need wallet passwords to operate, and we don't want to prompt
     # for pw twice right after the InstallWizard runs (see #106).
     # Entries in this map are deleted after 10 seconds by the QTimer (which
     # also deletes itself)
     self._wallet_password_cache = Weak.KeyDictionary()
     # /
     self.update_checker = UpdateChecker()
     self.update_checker_timer = QTimer(self); self.update_checker_timer.timeout.connect(self.on_auto_update_timeout); self.update_checker_timer.setSingleShot(False)
     self.update_checker.got_new_version.connect(lambda x: self.show_update_checker(parent=None, skip_check=True))
     # init tray
     self.dark_icon = self.config.get("dark_icon", False)
     self.tray = QSystemTrayIcon(self.tray_icon(), self)
     self.tray.setToolTip('Electron Cash')
     self.tray.activated.connect(self.tray_activated)
     self.build_tray_menu()
     self.tray.show()
     self.new_window_signal.connect(self.start_new_window)
     if self.has_auto_update_check():
         self._start_auto_update_timer(first_run = True)
     run_hook('init_qt', self)
     # We did this once already in the set_dark_theme call, but we do this
     # again here just in case some plugin modified the color scheme.
     ColorScheme.update_from_widget(QWidget())
Пример #6
0
 def __init__(self, config, daemon, plugins):
     super(__class__, self).__init__()  # QObject init
     set_language(config.get('language'))
     # Uncomment this call to verify objects are being properly
     # GC-ed when windows are closed
     #if daemon.network:
     #    from electroncash.util import DebugMem
     #    from electroncash.wallet import Abstract_Wallet
     #    from electroncash.verifier import SPV
     #    from electroncash.synchronizer import Synchronizer
     #    daemon.network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
     #                                       ElectrumWindow], interval=5)])
     QCoreApplication.setAttribute(Qt.AA_X11InitThreads)
     if hasattr(Qt, "AA_ShareOpenGLContexts"):
         QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
     if hasattr(QGuiApplication, 'setDesktopFileName'):
         QGuiApplication.setDesktopFileName('electron-cash.desktop')
     self.config = config
     self.daemon = daemon
     self.plugins = plugins
     self.windows = []
     self.weak_windows = []
     self.app = QApplication(sys.argv)
     self.app.installEventFilter(self)
     self.timer = QTimer(self)
     self.timer.setSingleShot(False)
     self.timer.setInterval(500)  #msec
     self.gc_timer = QTimer(self)
     self.gc_timer.setSingleShot(True)
     self.gc_timer.timeout.connect(ElectrumGui.gc)
     self.gc_timer.setInterval(333)  #msec
     self.nd = None
     self.update_checker = UpdateChecker()
     self.update_checker_timer = QTimer(self)
     self.update_checker_timer.timeout.connect(self.on_auto_update_timeout)
     self.update_checker_timer.setSingleShot(False)
     self.update_checker.got_new_version.connect(
         lambda x: self.show_update_checker(parent=None, skip_check=True))
     # init tray
     self.dark_icon = self.config.get("dark_icon", False)
     self.tray = QSystemTrayIcon(self.tray_icon(), None)
     self.tray.setToolTip('Electron Cash')
     self.tray.activated.connect(self.tray_activated)
     self.build_tray_menu()
     self.tray.show()
     self.new_window_signal.connect(self.start_new_window)
     self.set_dark_theme_if_needed()
     if self.has_auto_update_check():
         self._start_auto_update_timer(first_run=True)
     run_hook('init_qt', self)
     ColorScheme.update_from_widget(QWidget())
Пример #7
0
    def __init__(self, config, daemon, plugins):
        super(__class__, self).__init__() # QObject init
        assert __class__.instance is None, "ElectrumGui is a singleton, yet an instance appears to already exist! FIXME!"
        __class__.instance = self
        i18n.set_language(config.get('language'))

        self.config = config
        self.daemon = daemon
        self.plugins = plugins
        self.windows = []

        self._setup_do_in_main_thread_handler()

        # Uncomment this call to verify objects are being properly
        # GC-ed when windows are closed
        #if daemon.network:
        #    from electroncash.util import DebugMem
        #    from electroncash.wallet import Abstract_Wallet
        #    from electroncash.verifier import SPV
        #    from electroncash.synchronizer import Synchronizer
        #    daemon.network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
        #                                       ElectrumWindow], interval=5)])

        call_after_app = self._pre_and_post_app_setup()
        try:
            # Fixme: instantiating the QApplication inside the __init__ of
            #        a QObject is probably the reason for segfault on exit.
            self.app = QApplication(sys.argv)
            if locale.getlocale(locale.LC_NUMERIC) == (None, None):
                # On some OS, instantiating the QApplication sets the locale.
                # But on Windows, doing it manually seems to be required.
                set_locale()
        finally:
            call_after_app()

        self._load_fonts()  # this needs to be done very early, before the font engine loads fonts.. out of paranoia
        self._exit_if_required_pyqt_is_missing()  # This may immediately exit the app if missing required PyQt5 modules, so it should also be done early.
        self.new_version_available = None
        self._set_icon()
        self.app.installEventFilter(self)
        self.timer = QTimer(self); self.timer.setSingleShot(False); self.timer.setInterval(500) #msec
        self.gc_timer = QTimer(self); self.gc_timer.setSingleShot(True); self.gc_timer.timeout.connect(ElectrumGui.gc); self.gc_timer.setInterval(500) #msec
        self.nd = None
        self._last_active_window = None  # we remember the last activated ElectrumWindow as a Weak.ref
        Address.set_address_format(self.get_config_addr_format())
        # Dark Theme -- ideally set this before any widgets are created.
        self.set_dark_theme_if_needed()
        # /
        # Wallet Password Cache
        # wallet -> (password, QTimer) map for some plugins (like CashShuffle)
        # that need wallet passwords to operate, and we don't want to prompt
        # for pw twice right after the InstallWizard runs (see #106).
        # Entries in this map are deleted after 10 seconds by the QTimer (which
        # also deletes itself)
        self._wallet_password_cache = Weak.KeyDictionary()
        # /
        self.update_checker = UpdateChecker()
        self.update_checker_timer = QTimer(self)
        self.update_checker_timer.timeout.connect(self.on_auto_update_timeout)
        self.update_checker_timer.setSingleShot(False)
        self.update_checker.got_new_version.connect(self.on_new_version)
        # init tray
        self.dark_icon = self.config.get("dark_icon", False)
        self.tray = QSystemTrayIcon(self.tray_icon(), self)
        self.tray.setToolTip(f'{PROJECT_NAME}')
        self.tray.activated.connect(self.tray_activated)
        self.build_tray_menu()
        self.tray.show()
        self.new_window_signal.connect(self.start_new_window)
        if self.has_auto_update_check():
            self._start_auto_update_timer(first_run=True)
        self.app.focusChanged.connect(self.on_focus_change)  # track last window the user interacted with
        self.shutdown_signal.connect(self.close, Qt.QueuedConnection)
        run_hook('init_qt', self)
        # We did this once already in the set_dark_theme call, but we do this
        # again here just in case some plugin modified the color scheme.
        ColorScheme.update_from_widget(QWidget())

        self._check_and_warn_qt_version()
Пример #8
0
    def __init__(self, config, daemon, plugins):
        super(__class__, self).__init__()  # QObject init
        assert __class__.instance is None, "ElectrumGui is a singleton, yet an instance appears to already exist! FIXME!"
        __class__.instance = self
        set_language(config.get('language'))

        self.config = config
        self.daemon = daemon
        self.plugins = plugins
        self.windows = []

        if self.windows_qt_use_freetype:
            # Use FreeType for font rendering on Windows. This fixes rendering
            # of the Schnorr sigil and allows us to load the Noto Color Emoji
            # font if needed.
            os.environ['QT_QPA_PLATFORM'] = 'windows:fontengine=freetype'

        # Uncomment this call to verify objects are being properly
        # GC-ed when windows are closed
        #if daemon.network:
        #    from electroncash.util import DebugMem
        #    from electroncash.wallet import Abstract_Wallet
        #    from electroncash.verifier import SPV
        #    from electroncash.synchronizer import Synchronizer
        #    daemon.network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
        #                                       ElectrumWindow], interval=5)])
        QCoreApplication.setAttribute(Qt.AA_X11InitThreads)
        if hasattr(Qt, "AA_ShareOpenGLContexts"):
            QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
        if sys.platform not in ('darwin', ) and hasattr(
                Qt, "AA_EnableHighDpiScaling"):
            # The below only applies to non-macOS. On macOS this setting is
            # never used (because it is implicitly auto-negotiated by the OS
            # in a differernt way).
            #
            # qt_disable_highdpi will be set to None by default, or True if
            # specified on command-line.  The command-line override is intended
            # to supporess high-dpi mode just for this run for testing.
            #
            # The more permanent setting is qt_enable_highdpi which is the GUI
            # preferences option, so we don't enable highdpi if it's explicitly
            # set to False in the GUI.
            #
            # The default on Linux, Windows, etc is to enable high dpi
            disable_scaling = config.get('qt_disable_highdpi', False)
            enable_scaling = config.get('qt_enable_highdpi', True)
            if not disable_scaling and enable_scaling:
                QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
        if hasattr(Qt, "AA_UseHighDpiPixmaps"):
            QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
        if hasattr(QGuiApplication, 'setDesktopFileName'):
            QGuiApplication.setDesktopFileName('electron-cash.desktop')
        self.app = QApplication(sys.argv)
        self._load_fonts(
        )  # this needs to be done very early, before the font engine loads fonts.. out of paranoia
        self._exit_if_required_pyqt_is_missing(
        )  # This may immediately exit the app if missing required PyQt5 modules, so it should also be done early.
        self.new_version_available = None
        self._set_icon()
        self.app.installEventFilter(self)
        self.timer = QTimer(self)
        self.timer.setSingleShot(False)
        self.timer.setInterval(500)  #msec
        self.gc_timer = QTimer(self)
        self.gc_timer.setSingleShot(True)
        self.gc_timer.timeout.connect(ElectrumGui.gc)
        self.gc_timer.setInterval(500)  #msec
        self.nd = None
        self._last_active_window = None  # we remember the last activated ElectrumWindow as a Weak.ref
        Address.show_cashaddr(self.is_cashaddr())
        # Dark Theme -- ideally set this before any widgets are created.
        self.set_dark_theme_if_needed()
        # /
        # Wallet Password Cache
        # wallet -> (password, QTimer) map for some plugins (like CashShuffle)
        # that need wallet passwords to operate, and we don't want to prompt
        # for pw twice right after the InstallWizard runs (see #106).
        # Entries in this map are deleted after 10 seconds by the QTimer (which
        # also deletes itself)
        self._wallet_password_cache = Weak.KeyDictionary()
        # /
        self.update_checker = UpdateChecker()
        self.update_checker_timer = QTimer(self)
        self.update_checker_timer.timeout.connect(self.on_auto_update_timeout)
        self.update_checker_timer.setSingleShot(False)
        self.update_checker.got_new_version.connect(self.on_new_version)
        # init tray
        self.dark_icon = self.config.get("dark_icon", False)
        self.tray = QSystemTrayIcon(self.tray_icon(), self)
        self.tray.setToolTip('Electron Cash')
        self.tray.activated.connect(self.tray_activated)
        self.build_tray_menu()
        self.tray.show()
        self.new_window_signal.connect(self.start_new_window)
        if self.has_auto_update_check():
            self._start_auto_update_timer(first_run=True)
        self.app.focusChanged.connect(
            self.on_focus_change)  # track last window the user interacted with
        run_hook('init_qt', self)
        # We did this once already in the set_dark_theme call, but we do this
        # again here just in case some plugin modified the color scheme.
        ColorScheme.update_from_widget(QWidget())

        self._check_and_warn_qt_version()