From 365aa189f274970ef2f4446f6e89b429e41b4ae5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 8 Nov 2019 15:22:11 +0100 Subject: [PATCH] qt FileDialogs for transactions: better file extension filter --- electrum/gui/qt/main_window.py | 5 +++-- electrum/gui/qt/transaction_dialog.py | 6 ++++-- electrum/gui/qt/util.py | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 9f7d0da1f..aff6aec8c 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -89,7 +89,7 @@ from .util import (read_QIcon, ColorScheme, text_dialog, icon_path, WaitingDialo CloseButton, HelpButton, MessageBoxMixin, EnterButton, ButtonsLineEdit, CopyCloseButton, import_meta_gui, export_meta_gui, filename_field, address_field, char_width_in_lineedit, webopen, - MONOSPACE_FONT) + MONOSPACE_FONT, TRANSACTION_FILE_EXTENSION_FILTER) from .util import ButtonsTextEdit from .installwizard import WIF_HELP_TEXT from .history_list import HistoryList, HistoryModel @@ -2751,7 +2751,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.show_transaction(tx) def read_tx_from_file(self) -> Optional[Transaction]: - fileName = self.getOpenFileName(_("Select your transaction file"), "*.txn;;*.psbt") + fileName = self.getOpenFileName(_("Select your transaction file"), + TRANSACTION_FILE_EXTENSION_FILTER) if not fileName: return try: diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py index 951069875..410e39a19 100644 --- a/electrum/gui/qt/transaction_dialog.py +++ b/electrum/gui/qt/transaction_dialog.py @@ -47,7 +47,7 @@ from electrum.logging import get_logger from .util import (MessageBoxMixin, read_QIcon, Buttons, CopyButton, icon_path, MONOSPACE_FONT, ColorScheme, ButtonsLineEdit, text_dialog, - char_width_in_lineedit) + char_width_in_lineedit, TRANSACTION_FILE_EXTENSION_FILTER) if TYPE_CHECKING: from .main_window import ElectrumWindow @@ -287,7 +287,9 @@ class TxDialog(QDialog, MessageBoxMixin): name = 'signed_%s.txn' % (tx.txid()[0:8]) else: name = self.wallet.basename() + time.strftime('-%Y%m%d-%H%M.psbt') - fileName = self.main_window.getSaveFileName(_("Select where to save your signed transaction"), name, "*.txn;;*.psbt") + fileName = self.main_window.getSaveFileName(_("Select where to save your signed transaction"), + name, + TRANSACTION_FILE_EXTENSION_FILTER) if not fileName: return if tx.is_complete(): # network tx hex diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py index 9a578aaaa..d3e348e71 100644 --- a/electrum/gui/qt/util.py +++ b/electrum/gui/qt/util.py @@ -50,6 +50,8 @@ pr_icons = { } +# filter tx files in QFileDialog: +TRANSACTION_FILE_EXTENSION_FILTER = "Transaction (*.txn *.psbt);;All files (*)" class EnterButton(QPushButton):