Skip to content

Commit

Permalink
Add a Qt eventFilter to listen for QFileOpenEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Aug 11, 2013
1 parent 164c746 commit b2ebd35
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions gui/gui_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2247,18 +2247,28 @@ def closeEvent(self, event):
self.config.set_key("console-history",self.console.history[-50:])
event.accept()




class OpenFileEventFilter(QObject):
def __init__(self, windows):
self.windows = windows
super(OpenFileEventFilter, self).__init__()

def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.FileOpen:
if len(self.windows) >= 1:
self.windows[0].set_url(event.url().toString())
return True
return False

class ElectrumGui:

def __init__(self, wallet, config, app=None):
self.wallet = wallet
self.config = config
self.windows = []
self.efilter = OpenFileEventFilter(self.windows)
if app is None:
self.app = QApplication(sys.argv)

self.app.installEventFilter(self.efilter)

def restore_or_create(self):
msg = _("Wallet file not found.")+"\n"+_("Do you want to create a new wallet, or to restore an existing one?")
Expand Down Expand Up @@ -2373,6 +2383,7 @@ def main(self,url):
s = Timer()
s.start()
w = ElectrumWindow(self.wallet, self.config)
self.windows.append(w)
if url: w.set_url(url)
w.app = self.app
w.connect_slots(s)
Expand Down

0 comments on commit b2ebd35

Please sign in to comment.