From 04652f4e0e0abf11df62626b3291b1480375e295 Mon Sep 17 00:00:00 2001 From: Arnold Date: Sat, 29 Aug 2020 18:55:45 +0200 Subject: [PATCH] Updated version, Added app icon and some optimization --- Shower.pyw | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Shower.pyw b/Shower.pyw index 329d7e2..045b8ec 100644 --- a/Shower.pyw +++ b/Shower.pyw @@ -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): @@ -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() @@ -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 @@ -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 @@ -84,14 +100,14 @@ 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() @@ -99,17 +115,6 @@ class Shower(QMainWindow): 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()