-from i18n import _
+from electrum.i18n import _
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import os.path
apply(self.func,())
-def waiting_dialog(f):
+def waiting_dialog(f, w=None):
s = Timer()
s.start()
- w = QDialog()
- w.resize(200, 70)
- w.setWindowTitle('Electrum')
+ if not w:
+ w = QDialog()
+ w.resize(200, 70)
+ w.setWindowTitle('Electrum')
+ else:
+ if w.layout(): QWidget().setLayout(w.layout())
+
l = QLabel('')
- vbox = QVBoxLayout()
+ vbox = QVBoxLayout(w)
vbox.addWidget(l)
- w.setLayout(vbox)
w.show()
def ff():
s = f()
if s: l.setText(s)
- else: w.close()
+ else: w.accept()
w.connect(s, SIGNAL('timersignal'), ff)
w.exec_()
- w.destroy()
+ #w.destroy()
class HelpButton(QPushButton):
-def backup_wallet(path):
- import shutil
- directory, fileName = os.path.split(path)
- try:
- otherpath = unicode( QFileDialog.getOpenFileName(QWidget(), _('Enter a filename for the copy of your wallet'), directory) )
- if otherpath and path!=otherpath:
- shutil.copy2(path, otherpath)
- QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(otherpath))
- except (IOError, os.error), reason:
- QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason))
+
+def close_button(dialog, label=_("Close") ):
+ hbox = QHBoxLayout()
+ hbox.addStretch(1)
+ b = QPushButton(label)
+ hbox.addWidget(b)
+ b.clicked.connect(dialog.close)
+ b.setDefault(True)
+ return hbox
def ok_cancel_buttons(dialog, ok_label=_("OK") ):
hbox = QHBoxLayout()
if dialog.exec_():
return unicode(txt.toPlainText())
+
+class MyTreeWidget(QTreeWidget):
+ def __init__(self, parent):
+ QTreeWidget.__init__(self, parent)
+ self.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.connect(self, SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self.itemactivated)
+
+ def itemactivated(self, item):
+ if not item: return
+ for i in range(0,self.viewport().height()/5):
+ if self.itemAt(QPoint(0,i*5)) == item:
+ break
+ else:
+ return
+ for j in range(0,30):
+ if self.itemAt(QPoint(0,i*5 + j)) != item:
+ break
+ self.emit(SIGNAL('customContextMenuRequested(const QPoint&)'), QPoint(50, i*5 + j - 1))
+