示例#1
0
        def change_style():
            change_style_form.cbStyles.clear()
            change_style_form.cbStyles.addItems(stylesheets.get_stylesheets())

            def validate_change_style():
                """
                Validates the information in order to change the app style.

                :return: Nothing.
                """
                style = change_style_form.cbStyles.currentText()
                style = style + ".qss"

                response = stylesheets.change_current_style(style)
                # Prompts the user based on the response returned by the function
                if response == "changed current style":
                    window_prompt(
                        "Success",
                        "Successfully changed the current style, "
                        + "in order for it to apply please restart the app!",
                    )
                    exit(0)
                else:
                    window_prompt("Error", cls.unknown_error)

            change_style_form.bChangeStyle.clicked.connect(validate_change_style)
            change_style_form.show()  # Windows only shown when fully initialized
            # Logging line
            cls.log.debug_log('"Change Style" window opened.', logger.get_lineno())
示例#2
0
        def add_style():
            """
            Initializes, manages and shows the "Add Style" window.

            :return: Nothing.
            """

            def validate_add_style():
                """
                Validates the info in order to add the new style for the app.

                :return: Nothing.
                """
                style_text = add_style_form.ptStyleText.toPlainText()
                style_name = add_style_form.StyleNameText.text()
                if style_name == "":
                    window_prompt("Error", "Style name can not be empty!")
                else:
                    response = stylesheets.add_style_sheet(style_name, style_text)
                    # Prompts the user based on the response returned by the function
                    if response == "style added":
                        window_prompt(
                            "Success",
                            "Successfully added style.\n"
                            + "Now you can go in change style window and apply it!",
                        )
                    else:
                        window_prompt("Error", cls.unknown_error)

            add_style_form.bAddStyle.clicked.connect(validate_add_style)
            add_style_form.show()  # Windows only shown when fully initialized
            # Logging line
            cls.log.debug_log('"Add Style" window opened.', logger.get_lineno())
示例#3
0
        def create_acc_folder(self):
            """
            Initializes, manages and shows the "Create Acc Folder" window.

            :return: Nothing.
            """

            # Initializes the window with the help of window_init file
            create_acc_folder_form = window_init.CreateAccFolderWindow()

            def validate_creation():
                """
                Validates if the info is right for creating the account folder.

                :return: Nothing.
                """

                folder_name = create_acc_folder_form.FolderNameInput.text()

                response = self.acc_folders.create_acc_folder(folder_name)
                # Based on the return of accounts.py function prompts the user with what happened
                if response == "folder already exists":
                    PyPassMan_init.window_prompt(
                        "Error",
                        "Acc Folder with name " + folder_name +
                        " already exists, try a different name!",
                    )
                    create_acc_folder_form.FolderNameInput.clear()
                elif response == "folder created":
                    PyPassMan_init.window_prompt(
                        "Success",
                        "Acc Folder " + folder_name +
                        " was created successfully!",
                    )
                elif response == "folder name can not be empty":
                    PyPassMan_init.window_prompt(
                        "Error", "Folder name can not be empty")
                elif response == self.banned_chars:
                    PyPassMan_init.window_prompt("Error",
                                                 self.banned_chars_error)
                    create_acc_folder_form.FolderNameInput.clear()
                elif response == self.user_acc_dir_not_found_error:
                    PyPassMan_init.window_prompt("Error",
                                                 self.user_acc_dir_error)
                else:
                    PyPassMan_init.window_prompt("Error", self.unknown_error)
                    create_acc_folder_form.close()

            create_acc_folder_form.bCreateAccFolder.clicked.connect(
                validate_creation)
            create_acc_folder_form.show(
            )  # Windows shown only after fully initialized
            # Logging line
            self.log.debug_log('"Create Acc Folder" window opened.',
                               logger.get_lineno())
示例#4
0
    def login(cls):
        """
        Initializes, manages and shows the "Login" window.

        :return: Nothing.
        """
        # Initializes the windows with the help of window_init file
        login_account_form = window_init.LoginAccountWindow()
        locker_form = window_init.LockerWindow()

        def validate_login():
            """
            Validates the info in order to login user into their account.

            :return: Nothing.
            """
            username_input = login_account_form.UsernameInput.text()
            password_input = login_account_form.PasswordInput.text()

            response = accounts.PyPassManAcc.login(username_input, password_input)
            # Prompts the user based on the response returned by the function
            if response == "login successful":
                window_prompt(
                    "Success",
                    "Successfully logged into account " + username_input + ".",
                )
                login_account_form.close()
                MainForm.after_login(locker_form, username_input)
            elif response == "account not exist":
                window_prompt(
                    "Error",
                    "An account with username "
                    + username_input
                    + " does not exist. Try again!",
                )
                login_account_form.UsernameInput.clear()
            elif response == "incorrect password":
                window_prompt("Error", "Incorrect password!")
                login_account_form.PasswordInput.clear()
            elif response == cls.app_acc_dir_not_found_error:
                window_prompt("Error", cls.app_dir_error)
            else:
                window_prompt("Error", cls.unknown_error)
                login_account_form.close()

        login_account_form.bLogin.clicked.connect(validate_login)
        login_account_form.show()  # Windows only shown when fully initialized
        # Logging line
        cls.log.debug_log('"Login Account" window opened.', logger.get_lineno())
示例#5
0
        def list_acc_in_folder(self):
            """
            Initializes, manages and shows the "List Acc In Folder" window.

            :return: Nothing.
            """

            # Initializes the window with the help of window_init file
            acc_in_folder_list_form = window_init.AccInFolderListWindow()

            # Splits the folder list and adds each folder in the combo box
            folder_list = self.acc_folders.get_acc_folders().split("/    ")
            for folder in folder_list:
                if folder != "":
                    acc_in_folder_list_form.cbFolders.addItem(folder)

            def validate_list_acc():
                """
                Validates the info and displays the list of the accounts in the folder.

                :return: Nothing.
                """
                folder_name = acc_in_folder_list_form.cbFolders.currentText()

                response = self.acc_folders_content.get_acc_in_folder(
                    folder_name)
                # Prompts the user based on the response returned by the function
                if response == self.folder_not_found_error:
                    PyPassMan_init.window_prompt(
                        "Error", self.print_folder_not_found_error)
                elif response == self.user_acc_folder_not_found_error:
                    PyPassMan_init.window_prompt("Error",
                                                 self.user_acc_folder_error)
                elif isinstance(response, str):
                    acc_in_folder_list_form.AccInFolderListText.setPlainText(
                        response)
                else:
                    PyPassMan_init.window_prompt("Error", self.unknown_error)
                    acc_in_folder_list_form.close()

            acc_in_folder_list_form.bListAccounts.clicked.connect(
                validate_list_acc)
            acc_in_folder_list_form.show(
            )  # Windows are only shown after fully initialized
            # Logging line
            self.log.debug_log('"Acc In folder List" window opened.',
                               logger.get_lineno())
示例#6
0
        def clear_acc_in_folder(self):
            """
            Initializes, manages and shows the "Clear Acc In Folder" window.

            :return: Nothing.
            """

            clear_acc_in_folder_form = window_init.ClearAccInFolderWindow()

            # Splits folder list and adds each folder in the combo box
            folder_list = self.acc_folders.get_acc_folders().split("/    ")
            for folder in folder_list:
                if folder != "":
                    clear_acc_in_folder_form.cbFolders.addItem(folder)

            def validate_clear_acc():
                """
                Validates the info in order to clear the account folder.

                :return: Nothing.
                """
                folder_name = clear_acc_in_folder_form.cbFolders.currentText()

                response = self.acc_folders_content.clear_acc_folder(
                    folder_name)
                # Prompts the user based on the response returned by the function
                if response == self.folder_not_found_error:
                    PyPassMan_init.window_prompt(
                        "Error", self.print_folder_not_found_error)
                elif response == "acc folder cleared":
                    PyPassMan_init.window_prompt(
                        "Success", "Accounts folder successfully cleared!")
                elif response == self.user_acc_folder_not_found_error:
                    PyPassMan_init.window_prompt("Error",
                                                 self.user_acc_folder_error)
                else:
                    PyPassMan_init.window_prompt("Error", self.unknown_error)
                    clear_acc_in_folder_form.close()

            clear_acc_in_folder_form.bClearAccInFolder.clicked.connect(
                validate_clear_acc)
            clear_acc_in_folder_form.show(
            )  # Windows only shown when fully initialized
            # Logging line
            self.log.debug_log('"Clear Acc In Folder" window opened.',
                               logger.get_lineno())
示例#7
0
    def after_login(cls, locker_form, user):
        """
        Initializes, manages and shows the "Locker" window.

        :return: Nothing.
        """
        user_acc_folders = locker_functions.Locker.UserAccFolders(user)
        user_acc_folders_content = locker_functions.Locker.UserAccFoldersContent(user)
        user_acc_manager = locker_functions.Locker.UserAccManager(user)

        locker_form.bCreateAccFolder.clicked.connect(
            lambda: user_acc_folders.create_acc_folder()
        )
        locker_form.bListAccFolder.clicked.connect(
            lambda: user_acc_folders.list_acc_folders()
        )
        locker_form.bRemoveAccFolder.clicked.connect(
            lambda: user_acc_folders.delete_acc_folder()
        )
        locker_form.bAddAccToFolder.clicked.connect(
            lambda: user_acc_folders_content.add_acc_to_folder()
        )
        locker_form.bGetAccInFolder.clicked.connect(
            lambda: user_acc_folders_content.list_acc_in_folder()
        )
        locker_form.bRemoveAccInFolder.clicked.connect(
            lambda: user_acc_folders_content.remove_acc_in_folder()
        )
        locker_form.bClearAccInFolder.clicked.connect(
            lambda: user_acc_folders_content.clear_acc_in_folder()
        )
        locker_form.bGeneratePass.clicked.connect(
            lambda: locker_functions.Locker.generate_strong_pass()
        )
        locker_form.bBackup.clicked.connect(lambda: user_acc_manager.backup_acc())
        locker_form.bRestore.clicked.connect(lambda: user_acc_manager.restore_acc())
        locker_form.bLogout.clicked.connect(locker_form.close)

        locker_form.show()  # Windows only shown after fully initialized
        # Logging line
        cls.log.debug_log('"Locker" window opened.', logger.get_lineno())
示例#8
0
        def list_acc_folders(self):
            """
            Initializes, manages and shows the "List Acc Folders" window.

            :return: Nothing.
            """

            # Initializes the window with the help of window_init file
            acc_folders_list_form = window_init.AccFolderListWindow()

            def get_folders():
                """
                Writes the folder list in the text box.

                :return: Nothing.
                """
                folder_list = self.acc_folders.get_acc_folders()
                if folder_list != "":
                    acc_folders_list_form.AccFolderListText.setPlainText(
                        folder_list)
                elif folder_list == self.user_acc_folder_not_found_error:
                    PyPassMan_init.window_prompt("Error",
                                                 self.user_acc_folder_error)
                else:
                    acc_folders_list_form.AccFolderListText.setPlainText(
                        "You don't have any account folders.")

            # Runs get_folders once to have them printed when opening the window
            get_folders()

            acc_folders_list_form.bRefresh.clicked.connect(get_folders)
            acc_folders_list_form.show(
            )  # Windows shown only after fully initialized
            # Logging line
            self.log.debug_log('"Acc Folder List" window opened.',
                               logger.get_lineno())
示例#9
0
    def generate_strong_pass(cls):
        """
        Initializes, manages and shows the "Generate Strong Pass" window.

        :return: Nothing.
        """

        # Initializes the window with the help of window_init file
        generate_strong_pass_form = window_init.GenerateStrongPasswordWindow()

        def generate():
            """
            Validates the info in order to generate a password.

            :return: Nothing.
            """

            chars_number = generate_strong_pass_form.NumberOfCharsInput.text()

            response = accounts.Locker.pass_gen(chars_number)
            # Prompts the user based on the response returned by the function
            if response == "invalid length":
                PyPassMan_init.window_prompt("Error", "Invalid length!")
                generate_strong_pass_form.NumberOfCharsInput.clear()
            elif isinstance(response, str):
                generate_strong_pass_form.OutputText.setText(response)
            else:
                PyPassMan_init.window_prompt("Error", cls.unknown_error)
                generate_strong_pass_form.close()

        generate_strong_pass_form.bGenerateStrongPass.clicked.connect(generate)
        generate_strong_pass_form.show(
        )  # Windows only shown when fully initialized
        # Logging line
        cls.log.debug_log('"Generate Strong Pass" window opened.',
                          logger.get_lineno())
示例#10
0
    def register(cls):
        """
        Initializes, manages and shows the "Register" window.

        :return: Nothing.
        """
        # Initializes the window with the help of window_init file
        register_account_form = window_init.RegisterAccountWindow()

        def validate_add_account():
            """
            Validates the info in order to add the account to the app.

            :return: Nothing.
            """
            username_input = register_account_form.UsernameInput.text()
            password_input = register_account_form.PasswordInput.text()
            password_again_input = register_account_form.PasswordAgainInput.text()

            if password_input == password_again_input and len(password_input) > 3:
                response = accounts.PyPassManAcc.register_acc(
                    username_input, password_input
                )
                # Prompts the user based on the response returned by the function
                if response == "created account":
                    window_prompt(
                        "Success",
                        "Successfully created account "
                        + username_input
                        + "! You can now Login",
                    )
                    register_account_form.close()
                elif response == "username exists":
                    window_prompt(
                        "Error",
                        "An account with username "
                        + username_input
                        + " already exists. Try again with a different username!",
                    )
                    register_account_form.UsernameInput.clear()
                elif response == "username empty":
                    window_prompt("Error", "Username can't be empty")
                elif response == cls.banned_chars:
                    window_prompt("Error", cls.banned_chars_error)
                    register_account_form.UsernameInput.clear()
                elif response == cls.app_acc_dir_not_found_error:
                    window_prompt("Error", cls.app_dir_error)
                elif response == cls.user_acc_dir_not_found_error:
                    window_prompt("Error", cls.user_acc_dir_error)
                elif response == "acc folder already exists":
                    window_prompt(
                        "Error",
                        "A folder with user is already present in the app! Any data this "
                        "folder had was not changed, if you did not want this you can "
                        "delete the acc and try recreate it.",
                    )
                else:
                    window_prompt("Error", cls.unknown_error)
                    register_account_form.close()
            elif password_input != password_again_input:
                window_prompt("Error", "The passwords don't match! Try again")
                register_account_form.PasswordInput.clear()
                register_account_form.PasswordAgainInput.clear()
            elif len(password_input) < 4:
                window_prompt("Error", "The password has to be 4 or more characters")
                register_account_form.PasswordInput.clear()
                register_account_form.PasswordAgainInput.clear()
            else:
                window_prompt("Error", cls.unknown_error)
                register_account_form.close()

        register_account_form.bRegisterAccount.clicked.connect(validate_add_account)
        register_account_form.show()  # Windows only shown when fully initialized
        # Logging line
        cls.log.debug_log('"Register Account" window opened.', logger.get_lineno())
示例#11
0
    def style_manager(cls, style_manager_form):
        """
        Initializes, manages and shows the "Style Manager" window.

        :return: Nothing.
        """
        # Initializes the window with the help of window_init file
        change_style_form = window_init.ChangeStyleWindow()
        add_style_form = window_init.AddStyleWindow()

        def change_style():
            change_style_form.cbStyles.clear()
            change_style_form.cbStyles.addItems(stylesheets.get_stylesheets())

            def validate_change_style():
                """
                Validates the information in order to change the app style.

                :return: Nothing.
                """
                style = change_style_form.cbStyles.currentText()
                style = style + ".qss"

                response = stylesheets.change_current_style(style)
                # Prompts the user based on the response returned by the function
                if response == "changed current style":
                    window_prompt(
                        "Success",
                        "Successfully changed the current style, "
                        + "in order for it to apply please restart the app!",
                    )
                    exit(0)
                else:
                    window_prompt("Error", cls.unknown_error)

            change_style_form.bChangeStyle.clicked.connect(validate_change_style)
            change_style_form.show()  # Windows only shown when fully initialized
            # Logging line
            cls.log.debug_log('"Change Style" window opened.', logger.get_lineno())

        def add_style():
            """
            Initializes, manages and shows the "Add Style" window.

            :return: Nothing.
            """

            def validate_add_style():
                """
                Validates the info in order to add the new style for the app.

                :return: Nothing.
                """
                style_text = add_style_form.ptStyleText.toPlainText()
                style_name = add_style_form.StyleNameText.text()
                if style_name == "":
                    window_prompt("Error", "Style name can not be empty!")
                else:
                    response = stylesheets.add_style_sheet(style_name, style_text)
                    # Prompts the user based on the response returned by the function
                    if response == "style added":
                        window_prompt(
                            "Success",
                            "Successfully added style.\n"
                            + "Now you can go in change style window and apply it!",
                        )
                    else:
                        window_prompt("Error", cls.unknown_error)

            add_style_form.bAddStyle.clicked.connect(validate_add_style)
            add_style_form.show()  # Windows only shown when fully initialized
            # Logging line
            cls.log.debug_log('"Add Style" window opened.', logger.get_lineno())

        style_manager_form.bChangeStyle.clicked.connect(change_style)
        style_manager_form.bAddStyle.clicked.connect(add_style)
        style_manager_form.show()
        # Logging line
        cls.log.debug_log('"Style Manager" window opened.', logger.get_lineno())
示例#12
0
    def remove_acc(cls):
        """
        Initializes, manages and shows the "Remove Acc" window.

        :return: Nothing.
        """
        # Initializes the window with the help of window_init file
        remove_account_form = window_init.RemoveAccountWindow()

        def validate_remove_acc():
            """
            Validates the info in order to remove the app account.

            :return: Nothing.
            """
            username_input = remove_account_form.UsernameInput.text()
            password_input = remove_account_form.PasswordInput.text()
            password_again_input = remove_account_form.PasswordAgainInput.text()

            if password_input == password_again_input:
                response = accounts.PyPassManAcc.remove_acc(
                    username_input, password_input
                )
                # Prompts the user based on the response return by the function
                if response == "account deleted":
                    window_prompt(
                        "Success",
                        "Successfully removed account " + username_input + "!",
                    )
                elif response == "account with this username not exist":
                    window_prompt(
                        "Error",
                        "An account with username "
                        + username_input
                        + " does not exist. Try again!",
                    )
                    remove_account_form.UsernameInput.clear()
                elif response == "password incorrect":
                    window_prompt("Error", "The password is incorrect. Try again!")
                    remove_account_form.PasswordInput.clear()
                    remove_account_form.PasswordAgainInput.clear()
                elif response == cls.app_acc_dir_not_found_error:
                    window_prompt("Error", cls.app_dir_error)
                elif response == cls.user_acc_dir_not_found_error:
                    window_prompt("Error", cls.user_acc_dir_error)
                elif response == "user folder was not found":
                    window_prompt(
                        "Error",
                        "This user folder was not found, we just deleted it's metadata "
                        "and everything should be fine in theory!",
                    )
                else:
                    window_prompt("Error", cls.unknown_error)
                    remove_account_form.close()

            elif password_input != password_again_input:
                window_prompt("Error", "The passwords don't match! Try again")
                remove_account_form.PasswordInput.clear()
                remove_account_form.PasswordAgainInput.clear()
            else:
                window_prompt("Error", cls.unknown_error)
                remove_account_form.close()

        remove_account_form.bRemoveAccount.clicked.connect(validate_remove_acc)
        remove_account_form.show()  # Windows shown only when fully initialized
        # Logging line
        cls.log.debug_log('"Remove Account" window opened.', logger.get_lineno())
示例#13
0
        def remove_acc_in_folder(self):
            """
            Initializes, manages and shows the "Remove Acc In Folder" window.

            :return: Nothing.
            """
            # Initializes the window with the help of window_init file
            remove_acc_in_folder_form = window_init.RemoveAccInFolderWindow()

            # Splits the folder list and adds each folder in the combo box
            folder_list = self.acc_folders.get_acc_folders().split("/    ")
            for folder in folder_list:
                if folder != "":
                    remove_acc_in_folder_form.cbFolders.addItem(folder)

            def get_acc_in_folder():
                """
                Gets the available accounts for deletion.

                :return: Available accounts for deletion.
                """
                remove_acc_in_folder_form.cbAccounts.clear()
                account = ""
                folder_name = remove_acc_in_folder_form.cbFolders.currentText()
                accounts_list = self.acc_folders_content.get_acc_in_folder(
                    folder_name)
                if accounts_list == self.user_acc_folder_not_found_error:
                    PyPassMan_init.window_prompt("Error",
                                                 self.user_acc_folder_error)
                    return "user acc folder not found"
                else:
                    accounts_list = accounts_list.split("\n\n")
                for account_item in accounts_list:
                    if account_item != "":
                        account_item = account_item.split("\n")
                        for account_part in account_item:
                            if ("password: "******"username: "******" "
                            elif "password: "******"":
                        remove_acc_in_folder_form.cbAccounts.addItem(account)
                    account = ""

            def validate_remove_acc():
                """
                Validates the given info in order to delete the specified account.

                :return: Nothing.
                """

                folder_name = remove_acc_in_folder_form.cbFolders.currentText()
                acc_number = remove_acc_in_folder_form.cbAccounts.currentText(
                ).split(".")[0]
                acc_username = remove_acc_in_folder_form.cbAccounts.currentText(
                ).split("username: "******"Error", self.print_folder_not_found_error)
                elif response == "account not found":
                    PyPassMan_init.window_prompt("Error", "Account not found!")
                elif response == "account removed":
                    PyPassMan_init.window_prompt(
                        "Success", "Account successfully removed!")
                else:
                    PyPassMan_init.window_prompt("Error", self.unknown_error)
                    remove_acc_in_folder_form.close()

                get_acc_in_folder(
                )  # this is run to display the accounts in the selected folder

            remove_acc_in_folder_form.bGetAcc.clicked.connect(
                get_acc_in_folder)
            remove_acc_in_folder_form.bRemoveAccInFolder.clicked.connect(
                validate_remove_acc)
            remove_acc_in_folder_form.show(
            )  # Windows only shown when fully initialized
            # Logging line
            self.log.debug_log('"Remove Acc In Folder" window opened.',
                               logger.get_lineno())
示例#14
0
        def add_acc_to_folder(self):
            """
            Initializes, manages and shows the "Add Acc To Folder" window.

            :return: Nothing.
            """

            # Initializes the window with the help of window_init file
            add_acc_to_folder_form = window_init.AddAccToFolderWindow()

            # Splits the folder list and adds each folder to the combo box
            folder_list = self.acc_folders.get_acc_folders().split("/    ")
            for folder in folder_list:
                if folder != "":
                    add_acc_to_folder_form.cbFolders.addItem(folder)

            def validate_acc_add():
                """
                Validates if the info is right in order to add the account to the folder.

                :return: Nothing.
                """

                folder_name = add_acc_to_folder_form.cbFolders.currentText()
                label = add_acc_to_folder_form.LabelInput.text()
                acc_username = add_acc_to_folder_form.UsernameInput.text()
                password = add_acc_to_folder_form.PasswordInput.text()
                password_again = add_acc_to_folder_form.PasswordAgainInput.text(
                )

                if "username: "******"Error",
                        'Username can not contain "username: "******"" or password == "":
                    PyPassMan_init.window_prompt(
                        "Error", "Username and password can not be empty!")
                elif password == password_again:
                    if label == "":
                        label = "0"
                        response = self.acc_folders_content.add_acc_to_folder(
                            label, folder_name, acc_username, password)
                    elif label == "0":
                        PyPassMan_init.window_prompt("Error",
                                                     "Label can not be 0!")
                        return "label can not be 0"
                    else:
                        response = self.acc_folders_content.add_acc_to_folder(
                            label, folder_name, acc_username, password)

                    # Prompts the user based on the response returned by the function
                    if response == self.folder_not_found_error:
                        PyPassMan_init.window_prompt(
                            "Error", self.print_folder_not_found_error)
                    elif response == "added acc to folder":
                        PyPassMan_init.window_prompt(
                            "Success", "Account was added successfully!")
                    elif response == "folder name can not be empty":
                        PyPassMan_init.window_prompt(
                            "Error", "Folder name can't be empty!")
                    elif response == self.user_acc_folder_not_found_error:
                        PyPassMan_init.window_prompt(
                            "Error", self.user_acc_folder_error)
                    elif response == "username contains digit_separator":
                        PyPassMan_init.window_prompt(
                            "Error",
                            "Username can not contain the following phrase:\n\t\t///!@#$%^&*()\\\\\\",
                        )
                    elif response == "password contains label_separator":
                        PyPassMan_init.window_prompt(
                            "Error",
                            "Password can not contain the following phrase:\n\t\t\\\\\\)(*&^%$#@!///",
                        )
                    else:
                        PyPassMan_init.window_prompt("Error",
                                                     self.unknown_error)
                        add_acc_to_folder_form.close()
                elif password != password_again:
                    PyPassMan_init.window_prompt("Error",
                                                 "Passwords do not match!")
                    add_acc_to_folder_form.PasswordInput.clear()
                    add_acc_to_folder_form.PasswordAgainInput.clear()
                else:
                    PyPassMan_init.window_prompt("Error", self.unknown_error)
                    add_acc_to_folder_form.close()

            add_acc_to_folder_form.bAddAccToFolder.clicked.connect(
                validate_acc_add)
            add_acc_to_folder_form.show(
            )  # Windows only shown after fully initialized
            # Logging line
            self.log.debug_log('"Add Acc To Folder" window opened.',
                               logger.get_lineno())
示例#15
0
        def delete_acc_folder(self):
            """
            Initializes, manages and shows the "Delete Acc Folder" window.

            :return: Nothing.
            """

            # Initializes the window with the help of window_init file
            delete_acc_folder_form = window_init.DeleteAccFolderWindow()

            # Makes a list out of the folders string and assigns it to the combo box
            folder_list = self.acc_folders.get_acc_folders().split("/    ")
            for folder in folder_list:
                if folder != "":
                    delete_acc_folder_form.cbFolders.addItem(folder)

            def validate_deletion():
                """
                Validates if info is right for deleting the account folder.

                :return: Nothing.
                """

                folder_name = delete_acc_folder_form.cbFolders.currentText()

                response = self.acc_folders.remove_acc_folder(folder_name)
                # Prompts user based on the response returned by the function
                if response == self.folder_not_found_error:
                    PyPassMan_init.window_prompt(
                        "Error",
                        "Acc Folder with name " + folder_name +
                        " does not exist, try a different one.",
                    )
                elif response == "deleted acc folder":
                    PyPassMan_init.window_prompt(
                        "Success",
                        "Acc Folder with name " + folder_name +
                        " was successfully deleted!",
                    )
                elif response == self.user_acc_folder_not_found_error:
                    PyPassMan_init.window_prompt("Error",
                                                 self.user_acc_folder_error)
                else:
                    PyPassMan_init.window_prompt("Error", self.unknown_error)
                    delete_acc_folder_form.close()

                # Clears the combo box before adding new values
                delete_acc_folder_form.cbFolders.clear()

                # Splits the string with the folders list and adds them to the combo box
                new_folder_list = self.acc_folders.get_acc_folders().split(
                    "/    ")
                for new_folder in new_folder_list:
                    if new_folder != "":
                        delete_acc_folder_form.cbFolders.addItem(new_folder)

            delete_acc_folder_form.bDeleteAccFolder.clicked.connect(
                validate_deletion)
            delete_acc_folder_form.show(
            )  # Windows only shown after fully initialized
            # Logging line
            self.log.debug_log('"Delete Acc Folder" window opened',
                               logger.get_lineno())