<gh_stars>0
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mainpassword.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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.
import os

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(QtWidgets.QMainWindow):
    send_password_signal = QtCore.pyqtSignal()
    create_new_signal = QtCore.pyqtSignal()

    def __init__(self, parent, *args):
        super(Ui_MainWindow, self).__init__(*args)
        self.parent = parent
        self.setObjectName("MainWindow")
        self.setFixedSize(391, 167)
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.verticalLayoutWidget.setGeometry(QtCore.QRect(9, 9, 371, 151))
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.passwordInput = QtWidgets.QLineEdit(self.verticalLayoutWidget)
        self.passwordInput.setEchoMode(QtWidgets.QLineEdit.Password)
        self.passwordInput.setObjectName("lineEdit")
        self.verticalLayout.addWidget(self.passwordInput)
        self.OKButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.OKButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.OKButton)
        self.createNewButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.createNewButton.setObjectName("pushButton_2")
        self.verticalLayout.addWidget(self.createNewButton)
        self.setCentralWidget(self.centralwidget)

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

    def retranslateUi(self):
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("MainWindow", "Введите пароль"))
        self.OKButton.setText(_translate("MainWindow", "ОК"))
        self.createNewButton.setText(_translate("MainWindow", "Создать новую базу паролей"))

    def build_handlers(self):
        self.OKButton.clicked.connect(self.enter_master_password)
        self.createNewButton.clicked.connect(self.cancel_master_password)

    def enter_master_password(self):
        self.parent.main_password = self.passwordInput.text()
        self.send_password_signal.emit()
        self.close()

    def cancel_master_password(self):
        if 'pwd.bin' in os.listdir():
            mb = QtWidgets.QMessageBox()
            mb.setWindowTitle("Создание новой базы")
            mb.setText("Имеющаяся база будет удалена! Вы уверены?")
            button_ok = mb.addButton("Да", QtWidgets.QMessageBox.AcceptRole)
            button_cancel = mb.addButton("Нет", QtWidgets.QMessageBox.RejectRole)
            mb.exec()

            if mb.clickedButton() == button_ok:
                self.create_new_signal.emit()
                self.close()

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

# Form implementation generated from reading ui file 'mainpassword.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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.
import os

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(QtWidgets.QMainWindow):
    send_password_signal = QtCore.pyqtSignal()
    create_new_signal = QtCore.pyqtSignal()

    def __init__(self, parent, *args):
        super(Ui_MainWindow, self).__init__(*args)
        self.parent = parent
        self.setObjectName("MainWindow")
        self.setFixedSize(391, 167)
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.verticalLayoutWidget.setGeometry(QtCore.QRect(9, 9, 371, 151))
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.passwordInput = QtWidgets.QLineEdit(self.verticalLayoutWidget)
        self.passwordInput.setEchoMode(QtWidgets.QLineEdit.Password)
        self.passwordInput.setObjectName("lineEdit")
        self.verticalLayout.addWidget(self.passwordInput)
        self.OKButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.OKButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.OKButton)
        self.createNewButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.createNewButton.setObjectName("pushButton_2")
        self.verticalLayout.addWidget(self.createNewButton)
        self.setCentralWidget(self.centralwidget)

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

    def retranslateUi(self):
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("MainWindow", "Введите пароль"))
        self.OKButton.setText(_translate("MainWindow", "ОК"))
        self.createNewButton.setText(_translate("MainWindow", "Создать новую базу паролей"))

    def build_handlers(self):
        self.OKButton.clicked.connect(self.enter_master_password)
        self.createNewButton.clicked.connect(self.cancel_master_password)

    def enter_master_password(self):
        self.parent.main_password = self.passwordInput.text()
        self.send_password_signal.emit()
        self.close()

    def cancel_master_password(self):
        if 'pwd.bin' in os.listdir():
            mb = QtWidgets.QMessageBox()
            mb.setWindowTitle("Создание новой базы")
            mb.setText("Имеющаяся база будет удалена! Вы уверены?")
            button_ok = mb.addButton("Да", QtWidgets.QMessageBox.AcceptRole)
            button_cancel = mb.addButton("Нет", QtWidgets.QMessageBox.RejectRole)
            mb.exec()

            if mb.clickedButton() == button_ok:
                self.create_new_signal.emit()
                self.close()
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'mainpassword.ui' # # Created by: PyQt5 UI code generator 5.15.0 # # 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.