# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'decryptWindow.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QFileDialog, QPushButton, QMessageBox
from decrypt import filedecryptor

class Ui_decrypt(object):
        def setupUi(self, decrypt):
                decrypt.setObjectName("decrypt")
                decrypt.resize(556, 437)
                icon = QtGui.QIcon()
                icon.addPixmap(QtGui.QPixmap(":/images/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
                decrypt.setWindowIcon(icon)
                decrypt.setStyleSheet("background-color:rgb(255, 239, 255)")
                self.frame = QtWidgets.QFrame(decrypt)
                self.frame.setGeometry(QtCore.QRect(-10, -10, 571, 101))
                self.frame.setStyleSheet("background-color:rgb(0, 0, 74)")
                self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
                self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
                self.frame.setObjectName("frame")
                self.label_7 = QtWidgets.QLabel(self.frame)
                self.label_7.setEnabled(True)
                self.label_7.setGeometry(QtCore.QRect(20, 10, 541, 81))
                font = QtGui.QFont()
                font.setFamily("Showcard Gothic")
                font.setPointSize(-1)
                font.setBold(False)
                font.setItalic(False)
                font.setWeight(50)
                self.label_7.setFont(font)
                self.label_7.setStyleSheet("color: white;\n"
                "font-size: 30px;\n"
                "font: \"Segoe UI\";\n"
                "")
                self.label_7.setObjectName("label_7")
                self.step1GroupBox = QtWidgets.QGroupBox(decrypt)
                self.step1GroupBox.setGeometry(QtCore.QRect(30, 110, 391, 111))
                self.step1GroupBox.setStyleSheet("QGroupBox::title {\n"
                "    font-size: 32px;\n"
                "}")
                self.step1GroupBox.setFlat(False)
                self.step1GroupBox.setObjectName("step1GroupBox")
                self.locationLineEdit = QtWidgets.QLineEdit(self.step1GroupBox)
                self.locationLineEdit.setEnabled(True)
                self.locationLineEdit.setGeometry(QtCore.QRect(20, 40, 251, 31))
                self.locationLineEdit.setReadOnly(True)
                self.locationLineEdit.setObjectName("locationLineEdit")
                self.pickFileButton = QtWidgets.QPushButton(self.step1GroupBox)
                self.pickFileButton.setGeometry(QtCore.QRect(280, 40, 91, 31))
                self.pickFileButton.setStyleSheet("#pickFileButton {\n"
                "    border: 2px solid #1976D2;\n"
                "    background-color:rgb(0, 0, 127);\n"
                "    min-width: 80px;\n"
                "    color: white;\n"
                "}\n"
                "#pickFileButton:hover {\n"
                "    background-color:#a4ffa7;\n"
                "    \n"
                "}\n"
                "\n"
                "#pickFileButton:pressed {\n"
                "    background-color: #0D47A1;\n"
                "}\n"
                "\n"
                "#pickFileButton:flat {\n"
                "    border: none; /* no border for a flat push button */\n"
                "}\n"
                "\n"
                "#pickFileButton:default {\n"
                "    border-color: white; /* make the default button prominent */\n"
                "}\n"
                "\n"
                "#pickFileButton:disabled {\n"
                "    background-color: #E3F2FD;\n"
                "    border-color: #BBDEFB;\n"
                "}")
                self.pickFileButton.setObjectName("pickFileButton")
                self.pickFileButton.clicked.connect(self.browsefiles)
                self.groupBox = QtWidgets.QGroupBox(decrypt)
                self.groupBox.setGeometry(QtCore.QRect(30, 240, 391, 111))
                self.groupBox.setTitle("")
                self.groupBox.setObjectName("groupBox")
                self.unlockTextLabel = QtWidgets.QLabel(self.groupBox)
                self.unlockTextLabel.setGeometry(QtCore.QRect(10, 10, 351, 20))
                self.unlockTextLabel.setStyleSheet("#unlockTextLabel {\n"
                "    font-size: 16px;\n"
                "    \n"
                "    font-family: \"Segoe UI\";\n"
                "}")
                self.unlockTextLabel.setObjectName("unlockTextLabel")
                self.passwordLineEdit = QtWidgets.QLineEdit(self.groupBox)
                self.passwordLineEdit.setGeometry(QtCore.QRect(10, 40, 351, 41))
                self.passwordLineEdit.setInputMethodHints(QtCore.Qt.ImhHiddenText|QtCore.Qt.ImhNoAutoUppercase|QtCore.Qt.ImhNoPredictiveText|QtCore.Qt.ImhSensitiveData)
                self.passwordLineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
                self.passwordLineEdit.setObjectName("passwordLineEdit")
                self.decryptButton = QtWidgets.QPushButton(decrypt)
                self.decryptButton.setGeometry(QtCore.QRect(210, 370, 131, 41))
                font = QtGui.QFont()
                font.setFamily("MS Shell Dlg 2")
                font.setPointSize(15)
                font.setBold(False)
                font.setItalic(False)
                font.setWeight(50)
                self.decryptButton.setFont(font)
                self.decryptButton.setStyleSheet("#decryptButton {\n"
                "    font: 15pt \"MS Shell Dlg 2\";\n"
                "    border: 2px solid #1976D2;\n"
                "    background-color:rgb(0, 0, 127);\n"
                "    min-width: 80px;\n"
                "    color: white;\n"
                "}\n"
                "#decryptButton:hover {\n"
                "    background-color:rgb(164, 255, 167);\n"
                "    \n"
                "}\n"
                "\n"
                "#decryptButton:pressed {\n"
                "    background-color: #0D47A1;\n"
                "}\n"
                "\n"
                "#decryptButton:flat {\n"
                "    border: none; /* no border for a flat push button */\n"
                "}\n"
                "\n"
                "#decryptButton:default {\n"
                "    border-color: white; /* make the default button prominent */\n"
                "}\n"
                "\n"
                "#decryptButton:disabled {\n"
                "    background-color: #E3F2FD;\n"
                "    border-color: #BBDEFB;\n"
                "}")
                self.decryptButton.setObjectName("decryptButton")
                self.decryptButton.clicked.connect(self.decryptfile)
                self.frame.raise_()
                self.groupBox.raise_()
                self.decryptButton.raise_()
                self.step1GroupBox.raise_()

                self.retranslateUi(decrypt)
                QtCore.QMetaObject.connectSlotsByName(decrypt)

        def retranslateUi(self, decrypt):
                _translate = QtCore.QCoreApplication.translate
                decrypt.setWindowTitle(_translate("decrypt", "File Enrypter"))
                self.label_7.setText(_translate("decrypt", "<html><head/><body><p><span style=\" font-size:36pt; font-weight:600; color:#ffaa00;\">FILE ENCRYPTER</span></p></body></html>"))
                self.step1GroupBox.setTitle(_translate("decrypt", "Select a FILE to decrypt"))
                self.pickFileButton.setText(_translate("decrypt", "Pick EXE File"))
                self.unlockTextLabel.setText(_translate("decrypt", "Enter password to decrypt file:"))
                self.decryptButton.setText(_translate("decrypt", "DECRYPT"))
        
        def browsefiles(self):
                fname=QFileDialog.getOpenFileName(None, 'Open file')
                self.locationLineEdit.setText(fname[0])
        
        def successfullmessage(self):
                msgBox = QMessageBox()
                msgBox.setIcon(QMessageBox.Information)
                msgBox.setText("Decryption Successfull!!!")
                msgBox.setWindowTitle("Successufull!")
                returnValue = msgBox.exec()
        
        def pincorrect(self):
                msgBox = QMessageBox()
                msgBox.setIcon(QMessageBox.Information)
                msgBox.setText("Password is Incorrect")
                msgBox.setWindowTitle("Incorrect")
                returnValue = msgBox.exec()

        def decryptfile(self):
                textpass = self.passwordLineEdit.text()
                location = self.locationLineEdit.text()
                try:
                        file = filedecryptor.decryptfile(location, textpass)
                        self.successfullmessage()
                        
                except:
                        self.pincorrect()



if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    decrypt = QtWidgets.QDialog()
    ui = Ui_decrypt()
    ui.setupUi(decrypt)
    decrypt.show()
    sys.exit(app.exec_())
