Skip to content

Commit

Permalink
Updated version, Added app icon and some optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
antarn88 committed Aug 29, 2020
1 parent 98521b2 commit 04652f4
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions Shower.pyw
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from sys import argv

from PySide2.QtCore import Qt
from PySide2.QtGui import QGuiApplication
from PySide2.QtGui import QGuiApplication, QIcon, QPixmap
from PySide2.QtWidgets import QMainWindow, QApplication, QVBoxLayout, QWidget, QTabWidget, QStyle, QMessageBox

from tabs.DecryptFileTab import DecryptFileTab
from tabs.EncryptFileTab import EncryptFileTab
from utilities.DecryptFileWorker import DecryptFileWorker
from utilities.EncryptFileWorker import EncryptFileWorker
from utilities.GetImages import app_icon


class Shower(QMainWindow):
Expand All @@ -32,7 +33,10 @@ class Shower(QMainWindow):
)

# The title of the program
self.setWindowTitle("Shower v0.5")
self.setWindowTitle("Shower v0.51")

# Set app icon
self.setWindowIcon(QIcon(QPixmap(app_icon())))

# Before using the main layout, need to create a central widget
central_widget = QWidget()
Expand All @@ -47,6 +51,8 @@ class Shower(QMainWindow):
self.tabwidget.addTab(self.dec_file_tab, "Decrypt file")
main_layout.addWidget(self.tabwidget)

self.enc_file_tab.input_field.setFocus()

def enc_action(self, child):
input_filename = child.input_filename
output_filename = child.output_filename
Expand All @@ -68,14 +74,24 @@ class Shower(QMainWindow):
self.decrypt_file_worker.written_bytes_raw_divided.connect(self.dec_file_tab.set_progressbar_value)
self.decrypt_file_worker.start()

def terminate_box(self, text):
msgbox = QMessageBox(self)
msgbox.setWindowTitle("Shower")
msgbox.setIcon(QMessageBox.Warning)
msgbox.setText(text)
msgbox.addButton("OK", QMessageBox.AcceptRole)
cancel_btn = msgbox.addButton("Cancel", QMessageBox.RejectRole)
msgbox.setDefaultButton(cancel_btn)
return msgbox.exec_()

def terminate_process(self):
text = "Are you sure you want to abort the process?\nTHE OUTPUT FILE WILL BE CORRUPTED!"
if self.encrypt_file_worker and self.encrypt_file_worker.isRunning() and terminate_box(text) == QMessageBox.AcceptRole:
if self.encrypt_file_worker and self.encrypt_file_worker.isRunning() and self.terminate_box(text) == QMessageBox.AcceptRole:
self.encrypt_file_worker.terminate()
self.encrypt_file_worker.wait()
self.encrypt_file_worker = None
self.enc_file_tab.encrypt_new_file_action(True)
elif self.decrypt_file_worker and self.decrypt_file_worker.isRunning() and terminate_box(text) == QMessageBox.AcceptRole:
elif self.decrypt_file_worker and self.decrypt_file_worker.isRunning() and self.terminate_box(text) == QMessageBox.AcceptRole:
self.decrypt_file_worker.terminate()
self.decrypt_file_worker.wait()
self.decrypt_file_worker = None
Expand All @@ -84,32 +100,21 @@ class Shower(QMainWindow):
def closeEvent(self, event):
text = "Are you sure you want to abort the process and exit?\nTHE OUTPUT FILE WILL BE CORRUPTED!"
if self.encrypt_file_worker and self.encrypt_file_worker.isRunning():
if terminate_box(text) == QMessageBox.AcceptRole:
if self.terminate_box(text) == QMessageBox.AcceptRole:
self.encrypt_file_worker.terminate()
self.encrypt_file_worker.wait()
event.accept()
else:
event.ignore()
elif self.decrypt_file_worker and self.decrypt_file_worker.isRunning():
if terminate_box(text) == QMessageBox.AcceptRole:
if self.terminate_box(text) == QMessageBox.AcceptRole:
self.decrypt_file_worker.terminate()
self.decrypt_file_worker.wait()
event.accept()
else:
event.ignore()


def terminate_box(text):
msgbox = QMessageBox()
msgbox.setWindowTitle("Are you sure?")
msgbox.setIcon(QMessageBox.Warning)
msgbox.setText(text)
msgbox.addButton("OK", QMessageBox.AcceptRole)
cancel_btn = msgbox.addButton("Cancel", QMessageBox.RejectRole)
msgbox.setDefaultButton(cancel_btn)
return msgbox.exec_()


if __name__ == '__main__':
app = QApplication(argv)
win = Shower()
Expand Down

0 comments on commit 04652f4

Please sign in to comment.