Esempio n. 1
0
    def __init__(self, parent):
        QAbstractItemModel.__init__(self, parent)
        Logger.__init__(self)
        self.parent = parent
        self.view = None  # type: HistoryList
        self.transactions = dict()
        self.tx_tree = list()
        self.expanded_groups = set()
        self.tx_status_cache = {}  # type: Dict[str, Tuple[int, str]]
        self.group_ps = self.parent.wallet.psman.group_history
        # read tx group control icons
        self.tx_group_expand_icn = read_QIcon('tx_group_expand.png')
        self.tx_group_collapse_icn = read_QIcon('tx_group_collapse.png')
        # setup bg thread to get updated data
        self.data_ready.connect(self.on_get_data, Qt.QueuedConnection)
        self.get_data_thread = GetDataThread(self, self.get_history_data,
                                             self.data_ready, self)
        self.get_data_thread.data_call_args = (self.group_ps, )
        self.get_data_thread.start()

        # sort keys methods for columns
        self.SORT_KEYS = {
            HistoryColumns.TX_GROUP: self.sort_ix,
            HistoryColumns.STATUS: self.sort_status,
            HistoryColumns.DIP2: self.sort_dip2,
            HistoryColumns.DESCRIPTION: self.sort_label,
            HistoryColumns.AMOUNT: self.sort_coin_value,
            HistoryColumns.BALANCE: self.sort_running_coin_balance,
            HistoryColumns.FIAT_VALUE: self.sort_fiat_value,
            HistoryColumns.FIAT_ACQ_PRICE: self.sort_fiat_acq_price,
            HistoryColumns.FIAT_CAP_GAINS: self.sort_fiat_cap_gains,
            HistoryColumns.TXID: self.sort_txid,
        }
Esempio n. 2
0
    def __init__(self, config: 'SimpleConfig', exctype, value, tb):
        BaseCrashReporter.__init__(self, exctype, value, tb)
        self.network = Network.get_instance()
        self.config = config

        QWidget.__init__(self)
        self.setWindowTitle('Firo Electrum - ' + _('An Error Occurred'))
        self.setMinimumSize(600, 300)

        Logger.__init__(self)

        main_box = QVBoxLayout()

        heading = QLabel('<h2>' + BaseCrashReporter.CRASH_TITLE + '</h2>')
        main_box.addWidget(heading)
        main_box.addWidget(QLabel(BaseCrashReporter.CRASH_MESSAGE))

        main_box.addWidget(QLabel(BaseCrashReporter.REQUEST_HELP_MESSAGE))

        collapse_info = QPushButton(_("Show report contents"))
        collapse_info.clicked.connect(
            lambda: self.msg_box(QMessageBox.NoIcon,
                                 self,
                                 _("Report contents"),
                                 self.get_report_string(),
                                 rich_text=True))

        main_box.addWidget(collapse_info)

        main_box.addWidget(QLabel(BaseCrashReporter.DESCRIBE_ERROR_MESSAGE))

        self.description_textfield = QTextEdit()
        self.description_textfield.setFixedHeight(50)
        self.description_textfield.setPlaceholderText(
            _("Do not enter sensitive/private information here. "
              "The report will be visible on the public issue tracker."))
        main_box.addWidget(self.description_textfield)

        main_box.addWidget(QLabel(BaseCrashReporter.ASK_CONFIRM_SEND))

        buttons = QHBoxLayout()

        report_button = QPushButton(_('Send Bug Report'))
        report_button.clicked.connect(self.send_report)
        report_button.setIcon(read_QIcon("tab_send.png"))
        buttons.addWidget(report_button)

        never_button = QPushButton(_('Never'))
        never_button.clicked.connect(self.show_never)
        buttons.addWidget(never_button)

        close_button = QPushButton(_('Not Now'))
        close_button.clicked.connect(self.close)
        buttons.addWidget(close_button)

        main_box.addLayout(buttons)

        self.setLayout(main_box)
        self.show()
Esempio n. 3
0
 def __init__(self, config: 'SimpleConfig', daemon: 'Daemon',
              plugins: 'Plugins'):
     Logger.__init__(self)
     self.logger.debug('ElectrumGUI: initialising')
     self.daemon = daemon
     self.network = daemon.network
     self.config = config
     self.plugins = plugins
Esempio n. 4
0
    def __init__(self, *, config: 'SimpleConfig'):
        QObject.__init__(self)
        Logger.__init__(self)
        assert self._INSTANCE is None, "Exception_Hook is supposed to be a singleton"
        self.config = config
        self.wallet_types_seen = set()  # type: Set[str]

        sys.excepthook = self.handler
        self._report_exception.connect(_show_window)
Esempio n. 5
0
 def __init__(self, imap_server, username, password, callback):
     threading.Thread.__init__(self)
     Logger.__init__(self)
     self.daemon = True
     self.username = username
     self.password = password
     self.imap_server = imap_server
     self.on_receive = callback
     self.M = None
     self.reset_connect_wait()
Esempio n. 6
0
 def __init__(self, text="", allow_multi=False, *, config: SimpleConfig):
     ButtonsTextEdit.__init__(self, text)
     Logger.__init__(self)
     self.allow_multi = allow_multi
     self.config = config
     self.setReadOnly(False)
     self.addButton("file.png", self.file_input, _("Read file"))
     icon = "camera_white.png" if ColorScheme.dark_scheme else "camera_dark.png"
     self.addButton(icon, self.qr_input, _("Read QR code"))
     run_hook('scan_text_edit', self)
Esempio n. 7
0
 def __init__(self, parent):
     super(UTXOModel, self).__init__(parent)
     Logger.__init__(self)
     self.parent = parent
     self.wallet = self.parent.wallet
     self.coin_items = list()
     # setup bg thread to get updated data
     self.data_ready.connect(self.on_get_data, Qt.QueuedConnection)
     self.get_data_thread = GetDataThread(self, self.get_coins,
                                          self.data_ready, self)
     self.get_data_thread.start()
Esempio n. 8
0
 def __init__(self, handler, plugin, proto):
     assert hasattr(self, 'tx_api')  # ProtocolMixin already constructed?
     HardwareClientBase.__init__(self, plugin=plugin)
     self.proto = proto
     self.device = plugin.device
     self.handler = handler
     self.tx_api = plugin
     self.types = plugin.types
     self.msg = None
     self.creating_wallet = False
     Logger.__init__(self)
     self.used()
Esempio n. 9
0
 def __init__(self, main_window):
     base.ExceptionHandler.__init__(self)
     Logger.__init__(self)
     self.main_window = main_window
     if not main_window.electrum_config.get(BaseCrashReporter.config_key,
                                            default=False):
         return
     # For exceptions in Kivy:
     base.ExceptionManager.add_handler(self)
     # For everything else:
     sys.excepthook = lambda exctype, value, tb: self.handle_exception(value
                                                                       )
Esempio n. 10
0
    def __init__(self, transport, handler, plugin):
        HardwareClientBase.__init__(self, plugin=plugin)
        if plugin.is_outdated_fw_ignored():
            TrezorClient.is_outdated = lambda *args, **kwargs: False
        self.client = TrezorClient(transport, ui=self)
        self.device = plugin.device
        self.handler = handler
        Logger.__init__(self)

        self.msg = None
        self.creating_wallet = False

        self.in_flow = False

        self.used()
Esempio n. 11
0
    def __init__(self, config: 'SimpleConfig', daemon: 'Daemon',
                 plugins: 'Plugins'):
        set_language(config.get('language', get_default_language()))
        Logger.__init__(self)
        self.logger.info(
            f"Qt GUI starting up... Qt={QtCore.QT_VERSION_STR}, PyQt={QtCore.PYQT_VERSION_STR}"
        )
        # 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('electrum-firo.desktop')
        self.gui_thread = threading.current_thread()
        self.config = config
        self.daemon = daemon
        self.plugins = plugins
        self.windows = []  # type: List[ElectrumWindow]
        self.efilter = OpenFileEventFilter(self.windows)
        self.app = QElectrumApplication(sys.argv)
        self.app.installEventFilter(self.efilter)
        self.app.setWindowIcon(read_QIcon("electrum-dash.png"))
        # timer
        self.timer = QTimer(self.app)
        self.timer.setSingleShot(False)
        self.timer.setInterval(500)  # msec

        self.network_dialog = None
        self.dash_net_dialog = None
        self.network_updated_signal_obj = QNetworkUpdatedSignalObject()
        self.dash_net_sobj = QDashNetSignalsObject()
        self._num_wizards_in_progress = 0
        self._num_wizards_lock = threading.Lock()
        # init tray
        self.dark_icon = self.config.get("dark_icon", False)
        self.tray = QSystemTrayIcon(self.tray_icon(), None)
        self.tray.setToolTip('Firo 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)
        self.set_dark_theme_if_needed()
        run_hook('init_qt', self)
Esempio n. 12
0
 def __init__(self, win: Union[ElectrumWindow, InstallWizard], device: str):
     QObject.__init__(self)
     Logger.__init__(self)
     assert win.gui_thread == threading.current_thread(
     ), 'must be called from GUI thread'
     self.clear_signal.connect(self.clear_dialog)
     self.error_signal.connect(self.error_dialog)
     self.message_signal.connect(self.message_dialog)
     self.passphrase_signal.connect(self.passphrase_dialog)
     self.word_signal.connect(self.word_dialog)
     self.query_signal.connect(self.win_query_choice)
     self.yes_no_signal.connect(self.win_yes_no_question)
     self.status_signal.connect(self._update_status)
     self.win = win
     self.device = device
     self.dialog = None
     self.done = threading.Event()
Esempio n. 13
0
 def __init__(self, win: 'ElectrumWindow'):
     CompletionTextEdit.__init__(self)
     ScanQRTextEdit.__init__(self, config=win.config)
     Logger.__init__(self)
     self.win = win
     self.amount_edit = win.amount_e
     self.setFont(QFont(MONOSPACE_FONT))
     self.document().contentsChanged.connect(self.update_size)
     self.heightMin = 0
     self.heightMax = 250
     self.c = None
     self.textChanged.connect(self.check_text)
     self.outputs = []  # type: List[PartialTxOutput]
     self.errors = []  # type: List[PayToLineError]
     self.is_pr = False
     self.is_alias = False
     self.update_size()
     self.payto_scriptpubkey = None  # type: Optional[bytes]
     self.lightning_invoice = None
     self.previous_payto = ''
Esempio n. 14
0
 def __init__(self):
     QThread.__init__(self)
     Logger.__init__(self)
     self.network = Network.get_instance()
Esempio n. 15
0
 def __init__(self, **kwargs):
     CScreen.__init__(self, **kwargs)
     Logger.__init__(self)
     self.is_max = False
Esempio n. 16
0
    def __init__(self, parent, *, config: SimpleConfig):
        ''' Note: make sure parent is a "top_level_window()" as per
        MessageBoxMixin API else bad things can happen on macOS. '''
        QDialog.__init__(self, parent=parent)
        Logger.__init__(self)

        self.validator: AbstractQrReaderValidator = None
        self.frame_id: int = 0
        self.qr_crop: QRect = None
        self.qrreader_res: List[QrCodeResult] = []
        self.validator_res: QrReaderValidatorResult = None
        self.last_stats_time: float = 0.0
        self.frame_counter: int = 0
        self.qr_frame_counter: int = 0
        self.last_qr_scan_ts: float = 0.0
        self.camera: QCamera = None
        self._error_message: str = None
        self._ok_done: bool = False
        self.camera_sc_conn = None
        self.resolution: QSize = None

        self.config = config

        # Try to get the QR reader for this system
        self.qrreader = get_qr_reader()
        if not self.qrreader:
            raise MissingQrDetectionLib(
                _("The platform QR detection library is not available."))

        # Set up the window, add the maximize button
        flags = self.windowFlags()
        flags = flags | Qt.WindowMaximizeButtonHint
        self.setWindowFlags(flags)
        self.setWindowTitle(_("Scan QR Code"))
        self.setWindowModality(
            Qt.WindowModal if parent else Qt.ApplicationModal)

        # Create video widget and fixed aspect ratio layout to contain it
        self.video_widget = QrReaderVideoWidget()
        self.video_overlay = QrReaderVideoOverlay()
        self.video_layout = FixedAspectRatioLayout()
        self.video_layout.addWidget(self.video_widget)
        self.video_layout.addWidget(self.video_overlay)

        # Create root layout and add the video widget layout to it
        vbox = QVBoxLayout()
        self.setLayout(vbox)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.addLayout(self.video_layout)

        self.lowres_label = QLabel(
            _("Note: This camera generates frames of relatively low resolution; QR scanning accuracy may be affected"
              ))
        self.lowres_label.setWordWrap(True)
        self.lowres_label.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)
        vbox.addWidget(self.lowres_label)
        self.lowres_label.setHidden(True)

        # Create a layout for the controls
        controls_layout = QHBoxLayout()
        controls_layout.addStretch(2)
        controls_layout.setContentsMargins(10, 10, 10, 10)
        controls_layout.setSpacing(10)
        vbox.addLayout(controls_layout)

        # Flip horizontally checkbox with default coming from global config
        self.flip_x = QCheckBox()
        self.flip_x.setText(_("&Flip horizontally"))
        self.flip_x.setChecked(bool(self.config.get('qrreader_flip_x', True)))
        self.flip_x.stateChanged.connect(self._on_flip_x_changed)
        controls_layout.addWidget(self.flip_x)

        close_but = QPushButton(_("&Close"))
        close_but.clicked.connect(self.reject)
        controls_layout.addWidget(close_but)

        # Create the video surface and receive events when new frames arrive
        self.video_surface = QrReaderVideoSurface(self)
        self.video_surface.frame_available.connect(self._on_frame_available)

        # Create the crop blur effect
        self.crop_blur_effect = QrReaderCropBlurEffect(self)
        self.image_effect = ImageGraphicsEffect(self, self.crop_blur_effect)

        # Note these should stay as queued connections becasue we use the idiom
        # self.reject() and self.accept() in this class to kill the scan --
        # and we do it from within callback functions. If you don't use
        # queued connections here, bad things can happen.
        self.finished.connect(self._boilerplate_cleanup, Qt.QueuedConnection)
        self.finished.connect(self._on_finished, Qt.QueuedConnection)