Skip to content

Commit

Permalink
qt FileDialogs for transactions: better file extension filter
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Nov 8, 2019
1 parent 9ff7d2c commit 365aa18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions electrum/gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
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
Expand Down Expand Up @@ -2751,7 +2751,8 @@ def read_tx_from_qrcode(self):
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:
Expand Down
6 changes: 4 additions & 2 deletions electrum/gui/qt/transaction_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

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
Expand Down Expand Up @@ -287,7 +287,9 @@ def export_to_file(self, *, tx: Transaction = None):
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
Expand Down
2 changes: 2 additions & 0 deletions electrum/gui/qt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
}


# filter tx files in QFileDialog:
TRANSACTION_FILE_EXTENSION_FILTER = "Transaction (*.txn *.psbt);;All files (*)"


class EnterButton(QPushButton):
Expand Down

0 comments on commit 365aa18

Please sign in to comment.