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

# Form implementation generated from reading ui file 'encryptWindow.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 encrypt import filencryptor


class Ui_encrypt(object):
        def setupUi(self, encrypt):
                encrypt.setObjectName("encrypt")
                encrypt.resize(578, 568)
                sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
                sizePolicy.setHorizontalStretch(0)
                sizePolicy.setVerticalStretch(0)
                sizePolicy.setHeightForWidth(encrypt.sizePolicy().hasHeightForWidth())
                encrypt.setSizePolicy(sizePolicy)
                font = QtGui.QFont()
                font.setFamily("Segoe UI Black")
                font.setBold(True)
                font.setWeight(75)
                encrypt.setFont(font)
                icon = QtGui.QIcon()
                icon.addPixmap(QtGui.QPixmap(":/images/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
                encrypt.setWindowIcon(icon)
                encrypt.setStyleSheet("background-color:rgb(255, 239, 255)")
                self.frame = QtWidgets.QFrame(encrypt)
                self.frame.setGeometry(QtCore.QRect(0, 0, 671, 91))
                self.frame.setMinimumSize(QtCore.QSize(421, 0))
                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.fontLabel = QtWidgets.QLabel(self.frame)
                self.fontLabel.setGeometry(QtCore.QRect(20, -10, 571, 121))
                font = QtGui.QFont()
                font.setFamily("Showcard Gothic")
                font.setPointSize(48)
                font.setBold(False)
                font.setWeight(50)
                self.fontLabel.setFont(font)
                self.fontLabel.setStyleSheet("#fontLabel {\n"
                "    color: RED;\n"
                "}")
                self.fontLabel.setObjectName("fontLabel")
                self.step1GroupBox = QtWidgets.QGroupBox(encrypt)
                self.step1GroupBox.setGeometry(QtCore.QRect(20, 110, 381, 91))
                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.lockButton = QtWidgets.QPushButton(encrypt)
                self.lockButton.setEnabled(True)
                self.lockButton.setGeometry(QtCore.QRect(230, 590, 111, 41))
                font = QtGui.QFont()
                font.setFamily("Segoe UI")
                font.setPointSize(12)
                font.setBold(True)
                font.setWeight(75)
                self.lockButton.setFont(font)
                self.lockButton.setStyleSheet("#lockButton {\n"
                "    border: 2px solid #1976D2;\n"
                "    background-color:rgb(0, 0, 127);\n"
                "    min-width: 80px;\n"
                "    color: white;\n"
                "}\n"
                "#lockButton:hover {\n"
                "    background-color:rgb(164, 255, 167);\n"
                "    \n"
                "}\n"
                "\n"
                "#lockButton:pressed {\n"
                "    background-color: #0D47A1;\n"
                "}\n"
                "\n"
                "#lockButton:flat {\n"
                "    border: none; /* no border for a flat push button */\n"
                "}\n"
                "\n"
                "#lockButton:default {\n"
                "    border-color: white; /* make the default button prominent */\n"
                "}\n"
                "\n"
                "#lockButton:disabled {\n"
                "    background-color: #E3F2FD;\n"
                "    border-color: #BBDEFB;\n"
                "}")
                icon1 = QtGui.QIcon()
                icon1.addPixmap(QtGui.QPixmap(":/images/lock.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
                self.lockButton.setIcon(icon1)
                self.lockButton.setFlat(False)
                self.lockButton.setObjectName("lockButton")
                self.label_6 = QtWidgets.QLabel(encrypt)
                self.label_6.setGeometry(QtCore.QRect(20, 600, 151, 31))
                self.label_6.setText("")
                self.label_6.setPixmap(QtGui.QPixmap(":/images/iceapps_logo.png"))
                self.label_6.setObjectName("label_6")
                self.groupBox = QtWidgets.QGroupBox(encrypt)
                self.groupBox.setGeometry(QtCore.QRect(20, 220, 481, 261))
                self.groupBox.setStyleSheet("font: 14pt \"MS Shell Dlg 2\";")
                self.groupBox.setObjectName("groupBox")
                self.label_2 = QtWidgets.QLabel(self.groupBox)
                self.label_2.setGeometry(QtCore.QRect(30, 40, 111, 16))
                self.label_2.setStyleSheet("font: 75 10pt \"Segoe UI\";")
                self.label_2.setObjectName("label_2")
                self.passwordLineEdit = QtWidgets.QLineEdit(self.groupBox)
                self.passwordLineEdit.setGeometry(QtCore.QRect(30, 60, 261, 31))
                self.passwordLineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
                self.passwordLineEdit.setObjectName("passwordLineEdit")
                self.label_3 = QtWidgets.QLabel(self.groupBox)
                self.label_3.setGeometry(QtCore.QRect(30, 120, 261, 16))
                self.label_3.setStyleSheet("font: 75 10pt \"Segoe UI\";")
                self.label_3.setObjectName("label_3")
                self.passwordAgainLineEdit = QtWidgets.QLineEdit(self.groupBox)
                self.passwordAgainLineEdit.setGeometry(QtCore.QRect(30, 140, 261, 31))
                self.passwordAgainLineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
                self.passwordAgainLineEdit.setObjectName("passwordAgainLineEdit")
                self.label_4 = QtWidgets.QLabel(self.groupBox)
                self.label_4.setGeometry(QtCore.QRect(90, 190, 321, 31))
                self.label_4.setStyleSheet("color: rgb(69, 112, 255);\n"
                "font-size: 14px;")
                self.label_4.setObjectName("label_4")
                self.label_5 = QtWidgets.QLabel(self.groupBox)
                self.label_5.setGeometry(QtCore.QRect(60, 220, 351, 31))
                self.label_5.setStyleSheet("color: red;\n"
                "font-size: 14px;")
                self.label_5.setObjectName("label_5")
                self.encryptButton = QtWidgets.QPushButton(encrypt)
                self.encryptButton.setGeometry(QtCore.QRect(230, 500, 121, 41))
                font = QtGui.QFont()
                font.setFamily("MS Shell Dlg 2")
                font.setPointSize(14)
                font.setBold(False)
                font.setItalic(False)
                font.setWeight(50)
                self.encryptButton.setFont(font)
                self.encryptButton.setStyleSheet("#encryptButton {\n"
                "    font: 14pt \"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"
                "#encryptButton:hover {\n"
                "    background-color:rgb(164, 255, 167);\n"
                "    \n"
                "}\n"
                "\n"
                "#encryptButton:pressed {\n"
                "    background-color: #0D47A1;\n"
                "}\n"
                "\n"
                "#encryptButton:flat {\n"
                "    border: none; /* no border for a flat push button */\n"
                "}\n"
                "\n"
                "#encryptButton:default {\n"
                "    border-color: white; /* make the default button prominent */\n"
                "}\n"
                "\n"
                "#encryptButton:disabled {\n"
                "    background-color: #E3F2FD;\n"
                "    border-color: #BBDEFB;\n"
                "}")
                self.encryptButton.setObjectName("encryptButton")
                self.encryptButton.clicked.connect(self.encryptfile)
                self.retranslateUi(encrypt)
                QtCore.QMetaObject.connectSlotsByName(encrypt)

        def retranslateUi(self, encrypt):
                _translate = QtCore.QCoreApplication.translate
                encrypt.setWindowTitle(_translate("encrypt", "File Entrypter"))
                self.frame.setToolTip(_translate("encrypt", "<html><head/><body><p><img src=\":/images/lock.png\"/></p></body></html>"))
                self.frame.setWhatsThis(_translate("encrypt", "<html><head/><body><p><img src=\":/images/lock.png\"/></p></body></html>"))
                self.fontLabel.setToolTip(_translate("encrypt", "<html><head/><body><p>LK</p></body></html>"))
                self.fontLabel.setText(_translate("encrypt", "<html><head/><body><p><span style=\" font-size:36pt; font-weight:600; color:#ffaa00;\">FILE ENCRYPTOR</span></p></body></html>"))
                self.step1GroupBox.setTitle(_translate("encrypt", "Select a FILE to encrypt"))
                self.pickFileButton.setText(_translate("encrypt", "Pick EXE File"))
                self.lockButton.setText(_translate("encrypt", "ENCRYPT"))
                self.groupBox.setTitle(_translate("encrypt", "Lock Options"))
                self.label_2.setText(_translate("encrypt", "Enter Password"))
                self.label_3.setText(_translate("encrypt", "Re-Enter Password"))
                self.label_4.setText(_translate("encrypt", "Password and Re-Enter Password must match."))
                self.label_5.setText(_translate("encrypt", "If you forget your password, data will not be recoverred."))
                self.encryptButton.setText(_translate("encrypt", "ENCRYPT"))
        
        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("Encryption Successfull!!!")
                msgBox.setWindowTitle("Successufull!")
                #msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
                #msgBox.buttonClicked.connect(encrypt.close)

                returnValue = msgBox.exec()

        def notmatchmessage(self):
                msgBox = QMessageBox()
                msgBox.setIcon(QMessageBox.Information)
                msgBox.setText("Password Does not match")
                msgBox.setWindowTitle("password")
                #msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
                msgBox.buttonClicked.connect(self.QtWidgets.qApp.quit)

                returnValue = msgBox.exec()

        def encryptfile(self):
                if self.checkPasswordMatch():
                        textpass = self.passwordLineEdit.text()
                        location = self.locationLineEdit.text()
                        file = filencryptor.encryptfile(location, textpass)
                        self.successfullmessage()
                else:
                        self.notmatchmessage()
       
        def checkPasswordMatch(self):
                if self._passwordNotEmpty() and self._passwordEquals():
                        self.label_4.setVisible(False)
                        return True
                else:
                        self.label_4.setVisible(True)
                        return False


        def _passwordNotEmpty(self):
                if len(self.passwordLineEdit.text()) == 0 or len(self.passwordAgainLineEdit.text()) == 0:
                        return False
                else:
                        return True


        def _passwordEquals(self):
                if self.passwordLineEdit.text() == self.passwordAgainLineEdit.text():
                        return True
                else:
                        return False



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