Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Show sections successive, so the user is less confused. #107

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 66 additions & 44 deletions app/ui/timestamp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<item>
<widget class="QGroupBox" name="gbox_processing_status">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="font">
<font>
Expand Down Expand Up @@ -118,7 +118,7 @@
<item>
<widget class="QGroupBox" name="gbox_verification">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="font">
<font>
Expand Down Expand Up @@ -183,7 +183,7 @@
<item>
<widget class="QGroupBox" name="gbox_timestamp">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="font">
<font>
Expand Down Expand Up @@ -226,50 +226,72 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_buttons" stretch="3,2,2">
<item>
<spacer name="spacer_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_reset">
<property name="font">
<font>
<family>Roboto Light</family>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_register">
<property name="font">
<font>
<family>Roboto Light</family>
</font>
</property>
<property name="text">
<string>Register Timestamp</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_registration_feedback">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Roboto Light</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_buttons" stretch="3,2,2">
<item>
<spacer name="spacer_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_reset">
<property name="font">
<font>
<family>Roboto Light</family>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_register">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<family>Roboto Light</family>
</font>
</property>
<property name="text">
<string>Register Timestamp</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_vertical">
<property name="orientation">
Expand Down
30 changes: 17 additions & 13 deletions app/widgets/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def __init__(self, *args, **kwargs):
self.current_filepath = None
self.current_comment = None

self.lbl_registration_feedback.setWordWrap(True)

# Ui Tweaks
self.table_verification.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)

Expand All @@ -67,7 +69,7 @@ def process_file(self, file_path):
log.debug('proccess file %s' % file_path)
self.current_filepath = file_path
self.button_dropzone.setText("Current File: %s" % os.path.basename(file_path))
self.gbox_processing_status.setEnabled(True)
self.gbox_processing_status.setVisible(True)
self.progress_bar.setMaximum(os.path.getsize(file_path))
self.progress_bar.setValue(0)
self.progress_bar.show()
Expand All @@ -79,6 +81,7 @@ def process_file(self, file_path):
# Disable dropzone
self.gbox_dropzone.setDisabled(True)
self.button_dropzone.setDisabled(True)
self.button_reset.setEnabled(True)

self.hash_thread.start()

Expand All @@ -103,7 +106,7 @@ def hash_thread_finished(self):

if timestamps:
self.label_verification.setText('Found existing timestamps for document:')
self.gbox_verification.setEnabled(True)
self.gbox_verification.setVisible(True)
self.table_verification.setRowCount(len(timestamps))
for row_id, row in enumerate(timestamps):
for col_id, col in enumerate(row):
Expand All @@ -118,21 +121,21 @@ def hash_thread_finished(self):

self.progress_bar.hide()
self.label_processing_status.setText('Fingerprint: %s' % self.current_fingerprint)
self.gbox_timestamp.setEnabled(True)
self.gbox_timestamp.setVisible(True)
self.button_register.setEnabled(True)

@pyqtSlot()
def register_timestamp(self):
self.button_register.setDisabled(True)
self.edit_comment.setDisabled(True)
self.lbl_registration_feedback.setVisible(True)
try:
txid = put_timestamp(self.current_fingerprint, self.edit_comment.text())
self.edit_comment.hide()
self.label_register_comment.setText(
self.lbl_registration_feedback.setText(
'Timestamp registered. Transaction ID is: %s' % txid
)
except Exception as e:
self.edit_comment.hide()
self.label_register_comment.setText(
self.lbl_registration_feedback.setText(
'Registration failed: %s' % e
)

Expand Down Expand Up @@ -204,27 +207,28 @@ def reset(self):

# Processing Status
self.gbox_processing_status.show()
self.gbox_processing_status.setDisabled(True)
self.gbox_processing_status.setVisible(False)
self.label_processing_status.setText('Waiting for document to process')
self.progress_bar.hide()

# Verification results
self.gbox_verification.setDisabled(True)
self.gbox_verification.setVisible(False)
self.label_verification.setText('Waiting for document to verify')
self.table_verification.clearContents()
self.table_verification.setRowCount(0)
self.table_verification.show()

self.lbl_registration_feedback.setVisible(False)

# Timestamp Form
self.gbox_timestamp.setDisabled(True)
self.gbox_timestamp.setVisible(False)
self.label_register_comment.setText(
'You may add a public comment to your timestamp if you wish'
)
self.edit_comment.clear()
self.edit_comment.show()
self.edit_comment.setEnabled(True)
self.button_reset.setEnabled(True)
self.button_register.setEnabled(True)
self.button_reset.setEnabled(False)
self.button_register.setEnabled(False)


if __name__ == '__main__':
Expand Down