Add generic preferences for every systems
offlate/manager.py
96 | 96 | self.writeProjects() | |
97 | 97 | ||
98 | 98 | def loadProject(self, name, lang, system, data): | |
99 | + | if not "Generic" in self.settings.conf: | |
100 | + | self.settings.conf["Generic"] = {} | |
99 | 101 | if system == TRANSLATION_PROJECT: | |
100 | 102 | if not "TP" in self.settings.conf: | |
101 | 103 | self.settings.conf["TP"] = {} | |
102 | - | proj = TPProject(self.settings.conf["TP"], name, lang, data) | |
104 | + | settings = self.settings.conf["TP"] | |
105 | + | for s in self.settings.conf["Generic"].keys(): | |
106 | + | settings[s] = self.settings.conf["Generic"][s] | |
107 | + | proj = TPProject(settings, name, lang, data) | |
103 | 108 | if system == TRANSIFEX: | |
104 | 109 | if not 'Transifex' in self.settings.conf: | |
105 | 110 | self.settings.conf['Transifex'] = {} | |
106 | - | proj = TransifexProject(self.settings.conf['Transifex'], name, lang, data) | |
111 | + | settings = self.settings.conf["Transifex"] | |
112 | + | for s in self.settings.conf["Generic"].keys(): | |
113 | + | settings[s] = self.settings.conf["Generic"][s] | |
114 | + | proj = TransifexProject(settings, name, lang, data) | |
107 | 115 | if system == GITLAB: | |
108 | 116 | if not 'Gitlab' in self.settings.conf: | |
109 | 117 | self.settings.conf['Gitlab'] = {} | |
110 | - | proj = GitlabProject(self.settings.conf['Gitlab'], name, lang, data) | |
118 | + | settings = self.settings.conf["Gitlab"] | |
119 | + | for s in self.settings.conf["Generic"].keys(): | |
120 | + | settings[s] = self.settings.conf["Generic"][s] | |
121 | + | proj = GitlabProject(settings, name, lang, data) | |
111 | 122 | self.project_list[name] = proj | |
112 | 123 | return proj | |
113 | 124 |
offlate/ui/settings.py
31 | 31 | vbox = QVBoxLayout() | |
32 | 32 | ||
33 | 33 | tab = QTabWidget() | |
34 | + | self.addGenericTab(tab) | |
34 | 35 | self.addTPTab(tab) | |
35 | 36 | self.addTransifexTab(tab) | |
36 | 37 | self.addGitlabTab(tab) | |
… | |||
77 | 78 | self.data["Transifex"] = {} | |
78 | 79 | self.data["Transifex"]["token"] = self.TransifexToken.text() | |
79 | 80 | ||
81 | + | def addGenericTab(self, tab): | |
82 | + | formBox = QGroupBox(self.tr("Generic Settings")) | |
83 | + | formLayout = QFormLayout() | |
84 | + | self.genericFullname = QLineEdit() | |
85 | + | self.genericFullname.setPlaceholderText(self.tr("John Doe <john@doe.me>")) | |
86 | + | ||
87 | + | if not "Generic" in self.data: | |
88 | + | self.data["Generic"] = {} | |
89 | + | if 'fullname' in self.data['Generic']: | |
90 | + | self.genericFullname.setText(self.data["Generic"]["fullname"]) | |
91 | + | ||
92 | + | formLayout.addRow(QLabel(self.tr("Full Name:")), self.genericFullname) | |
93 | + | ||
94 | + | self.genericFullname.textChanged.connect(self.updateGeneric) | |
95 | + | ||
96 | + | formBox.setLayout(formLayout) | |
97 | + | tab.addTab(formBox, self.tr("Generic")) | |
98 | + | ||
99 | + | def updateGeneric(self): | |
100 | + | self.data["Generic"] = {} | |
101 | + | self.data["Generic"]["fullname"] = self.genericFullname.text() | |
102 | + | ||
80 | 103 | def addTPTab(self, tab): | |
81 | 104 | formBox = QGroupBox(self.tr("Translation Project")) | |
82 | 105 | formLayout = QFormLayout() | |
… | |||
84 | 107 | self.TPemail = QLineEdit() | |
85 | 108 | self.TPuser = QLineEdit() | |
86 | 109 | self.TPserver = QLineEdit() | |
87 | - | self.TPfullname = QLineEdit() | |
88 | 110 | ||
89 | 111 | if not "TP" in self.data: | |
90 | 112 | self.data["TP"] = {} | |
… | |||
95 | 117 | self.TPuser.setText(self.data["TP"]["user"]) | |
96 | 118 | if 'server' in self.data['TP']: | |
97 | 119 | self.TPserver.setText(self.data["TP"]["server"]) | |
98 | - | if 'fullname' in self.data['TP']: | |
99 | - | self.TPfullname.setText(self.data["TP"]["fullname"]) | |
100 | 120 | ||
101 | 121 | self.TPemail.textChanged.connect(self.updateTP) | |
102 | 122 | self.TPuser.textChanged.connect(self.updateTP) | |
103 | 123 | self.TPserver.textChanged.connect(self.updateTP) | |
104 | - | self.TPfullname.textChanged.connect(self.updateTP) | |
105 | 124 | ||
106 | 125 | formLayout.addRow(QLabel(self.tr("Email:")), self.TPemail) | |
107 | 126 | formLayout.addRow(QLabel(self.tr("Server:")), self.TPserver) | |
108 | 127 | formLayout.addRow(QLabel(self.tr("User Name:")), self.TPuser) | |
109 | - | formLayout.addRow(QLabel(self.tr("Full Name (John Doe <john@doe.me>):")), self.TPfullname) | |
110 | 128 | ||
111 | 129 | formBox.setLayout(formLayout) | |
112 | 130 | tab.addTab(formBox, "TP") | |
… | |||
116 | 134 | self.data["TP"]["email"] = self.TPemail.text() | |
117 | 135 | self.data["TP"]["user"] = self.TPuser.text() | |
118 | 136 | self.data["TP"]["server"] = self.TPserver.text() | |
119 | - | self.data["TP"]["fullname"] = self.TPfullname.text() | |
120 | 137 | ||
121 | 138 | def ok(self): | |
122 | 139 | self.done = True |