default_column_widths = { "history":[40,140,350,140], "contacts":[350,330], "receive":[[370], [370,200,130]] }
class ElectrumWindow(QMainWindow):
+ def changeEvent(self, event):
+ flags = self.windowFlags();
+ if event and event.type() == QtCore.QEvent.WindowStateChange:
+ if self.windowState() & QtCore.Qt.WindowMinimized:
+ self.build_menu(True)
+ # The only way to toggle the icon in the window managers taskbar is to use the Qt.Tooltip flag
+ # The problem is that it somehow creates an (in)visible window that will stay active and prevent
+ # Electrum from closing.
+ # As for now I have no clue how to implement a proper 'hide to tray' functionality.
+ # self.setWindowFlags(flags & ~Qt.ToolTip)
+ elif event.oldState() & QtCore.Qt.WindowMinimized:
+ self.build_menu(False)
+ #self.setWindowFlags(flags | Qt.ToolTip)
+
+ def build_menu(self, is_hidden = False):
+ m = QMenu()
+ if self.isMinimized():
+ m.addAction(_("Show"), self.showNormal)
+ else:
+ m.addAction(_("Hide"), self.showMinimized)
+
+ m.addSeparator()
+ m.addAction(_("Exit Electrum"), self.close)
+ self.tray.setContextMenu(m)
+
+ def tray_activated(self, reason):
+ if reason == QSystemTrayIcon.DoubleClick:
+ self.showNormal()
def __init__(self, wallet, config):
QMainWindow.__init__(self)
+ self._close_electrum = False
self.lite = None
self.wallet = wallet
self.config = config
self.icon = QIcon(os.getcwd() + '/icons/electrum.png')
self.tray = QSystemTrayIcon(self.icon, self)
self.tray.setToolTip('Electrum')
+ self.tray.activated.connect(self.tray_activated)
- m = QMenu()
- m.addAction(_("Exit Electrum"), self.close)
- self.tray.setContextMenu(m)
-
+ self.build_menu()
self.tray.show()
self.init_plugins()
tabs.setCurrentIndex (n)
tabs.setCurrentIndex (0)
- # fix fee
- if self.wallet.fee < 50000:
- self.wallet.set_fee(50000)
- self.show_message("Note: Your default fee was raised to 0.0005 BTC/kilobyte")
-
# set initial message
self.console.showMessage(self.wallet.interface.banner)
# plugins that need to change the GUI do it here
self.run_hook('init_gui')
-
def select_wallet_file(self):
wallet_folder = self.wallet.config.path
re.sub("(\/\w*.dat)$", "", wallet_folder)
wallet_menu = menubar.addMenu(_("&Wallet"))
wallet_backup = wallet_menu.addAction(_("&Create backup"))
- wallet_backup.triggered.connect(backup_wallet)
+ wallet_backup.triggered.connect(lambda: backup_wallet(self.config.path))
show_menu = wallet_menu.addMenu(_("Show"))
new_contact = wallet_menu.addAction(_("&New contact"))
new_contact.triggered.connect(self.new_contact_dialog)
+ new_account = wallet_menu.addAction(_("&New account"))
+ new_account.triggered.connect(self.new_account_dialog)
+
import_menu = menubar.addMenu(_("&Import"))
in_labels = import_menu.addAction(_("&Labels"))
in_labels.triggered.connect(self.do_import_labels)
try:
tx = self.wallet.mktx( [(to_address, amount)], password, fee, account=self.current_account)
except BaseException, e:
+ traceback.print_exc(file=sys.stdout)
self.show_message(str(e))
return
account_items = []
for k, account in account_items:
- name = account.get('name',str(k))
+ name = account.get_name()
c,u = self.wallet.get_account_balance(k)
account_item = QTreeWidgetItem( [ name, '', self.format_amount(c+u), ''] )
l.addTopLevelItem(account_item)
is_red = False
gap = 0
- for address in account[is_change]:
+ for address in account.get_addresses(is_change):
h = self.wallet.history.get(address,[])
if h == []:
else:
QMessageBox.warning(self, _('Error'), _('Invalid Address'), _('OK'))
+ def new_account_dialog(self):
+ text, ok = QInputDialog.getText(self, _('New Account'), _('Name') + ':')
+ name = unicode(text)
+ if ok:
+ self.wallet.create_new_account(name)
+ self.wallet.synchronize()
+ self.update_contacts_tab()
+ self.update_history_tab()
+ self.update_completions()
+
def show_master_public_key(self):
dialog = QDialog(self)
dialog.setModal(1)