FreeCAD

Форк
0
/
addonmanager_devmode_person_editor.py 
72 строки · 3.4 Кб
1
# SPDX-License-Identifier: LGPL-2.1-or-later
2
# ***************************************************************************
3
# *                                                                         *
4
# *   Copyright (c) 2022 FreeCAD Project Association                        *
5
# *                                                                         *
6
# *   This file is part of FreeCAD.                                         *
7
# *                                                                         *
8
# *   FreeCAD is free software: you can redistribute it and/or modify it    *
9
# *   under the terms of the GNU Lesser General Public License as           *
10
# *   published by the Free Software Foundation, either version 2.1 of the  *
11
# *   License, or (at your option) any later version.                       *
12
# *                                                                         *
13
# *   FreeCAD is distributed in the hope that it will be useful, but        *
14
# *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
15
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      *
16
# *   Lesser General Public License for more details.                       *
17
# *                                                                         *
18
# *   You should have received a copy of the GNU Lesser General Public      *
19
# *   License along with FreeCAD. If not, see                               *
20
# *   <https://www.gnu.org/licenses/>.                                      *
21
# *                                                                         *
22
# ***************************************************************************
23

24
""" Contains a class to handle editing a person (from a Metadata standpoint). """
25

26
import os
27
from typing import Tuple  # Needed until Py 3.9, when tuple supports this directly
28

29
from PySide.QtWidgets import QDialog
30

31
import FreeCAD
32
import FreeCADGui
33

34
translate = FreeCAD.Qt.translate
35

36

37
class PersonEditor:
38
    """Create or edit a maintainer or author record."""
39

40
    def __init__(self):
41

42
        self.dialog = FreeCADGui.PySideUic.loadUi(
43
            os.path.join(os.path.dirname(__file__), "developer_mode_people.ui")
44
        )
45
        self.dialog.comboBox.clear()
46
        self.dialog.comboBox.addItem(
47
            translate("AddonsInstaller", "Maintainer"), userData="maintainer"
48
        )
49
        self.dialog.comboBox.addItem(translate("AddonsInstaller", "Author"), userData="author")
50

51
    def exec(self) -> Tuple[str, str, str]:
52
        """Run the dialog, and return a tuple of the person's record type, their name, and their
53
        email address. Email may be None. If the others are None it's because the user cancelled
54
        the interaction."""
55
        result = self.dialog.exec()
56
        if result == QDialog.Accepted:
57
            return (
58
                self.dialog.comboBox.currentData(),
59
                self.dialog.nameLineEdit.text(),
60
                self.dialog.emailLineEdit.text(),
61
            )
62
        return "", "", ""
63

64
    def setup(self, person_type: str = "maintainer", name: str = "", email: str = "") -> None:
65
        """Configure the dialog"""
66
        index = self.dialog.comboBox.findData(person_type)
67
        if index == -1:
68
            FreeCAD.Console.PrintWarning(f"Internal Error: unrecognized person type {person_type}")
69
            index = 0
70
        self.dialog.comboBox.setCurrentIndex(index)
71
        self.dialog.nameLineEdit.setText(name)
72
        self.dialog.emailLineEdit.setText(email)
73

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.