Added calculate and copy icons.

This commit is contained in:
Dain Nilsson 2015-06-03 11:27:21 +02:00
parent 0e2cab218c
commit 669fbeeab9
3 changed files with 14 additions and 4 deletions

BIN
qt_resources/calc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

BIN
qt_resources/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

View File

@ -94,11 +94,13 @@ class Code(QtGui.QWidget):
layout.addLayout(labels)
layout.addStretch()
self._calc_btn = QtGui.QPushButton('Calc')
self._calc_btn = QtGui.QPushButton(QtGui.QIcon(':/calc.png'), None)
self._calc_btn.clicked.connect(self._calc)
layout.addWidget(self._calc_btn)
if cred.cred_type not in [CredentialType.TOUCH, CredentialType.HOTP]:
self._calc_btn.setVisible(False)
self._copy_btn = QtGui.QPushButton('Copy')
self._copy_btn = QtGui.QPushButton(QtGui.QIcon(':/copy.png'), None)
self._copy_btn.clicked.connect(self._copy)
layout.addWidget(self._copy_btn)
@ -115,15 +117,21 @@ class Code(QtGui.QWidget):
name_fmt = '<b style="color: gray;">%s</b>'
else:
name_fmt = '<b>%s</b>'
if self.cred.cred_type is CredentialType.TOUCH:
self._calc_btn.setEnabled(self.expired)
self._code_lbl.setText(name_fmt % (self.cred.code.code))
self._copy_btn.setEnabled(bool(self.cred.code.code))
self._on_change()
def _copy(self):
print "TODO: copy", self.cred.code.code
def _calc(self):
if self.cred.cred_type in [CredentialType.TOUCH, CredentialType.HOTP]:
self.cred.calculate()
if self.cred.cred_type is CredentialType.HOTP:
self._calc_btn.setDisabled(True)
QtCore.QTimer.singleShot(5000,
lambda: self._calc_btn.setEnabled(True))
self.cred.calculate()
class CodesList(QtGui.QWidget):
@ -137,6 +145,8 @@ class CodesList(QtGui.QWidget):
for cred in credentials:
layout.addWidget(Code(cred, timer, on_change))
layout.addStretch()
class CodesWidget(QtGui.QWidget):