| 323 | |
| 324 | @staticmethod |
| 325 | def SetFont(): |
| 326 | try: |
| 327 | from tools.log import Log |
| 328 | from config.setting import Setting |
| 329 | from PySide6.QtGui import QFont |
| 330 | f = QFont() |
| 331 | from tools.langconv import Converter |
| 332 | if Converter('zh-hans').convert(Setting.FontName.value) == "默认": |
| 333 | Setting.FontName.InitValue("", "FontName") |
| 334 | |
| 335 | if not Setting.FontName.value and sys.platform == "win32": |
| 336 | Setting.FontName.InitValue("微软雅黑", "FontName") |
| 337 | |
| 338 | if Converter('zh-hans').convert(str(Setting.FontSize.value)) == "默认": |
| 339 | Setting.FontSize.InitValue("", "FontSize") |
| 340 | |
| 341 | if Converter('zh-hans').convert(str(Setting.FontStyle.value)) == "默认": |
| 342 | Setting.FontStyle.InitValue(0, "FontStyle") |
| 343 | |
| 344 | if not Setting.FontName.value and not Setting.FontSize.value and not Setting.FontStyle.value: |
| 345 | return |
| 346 | |
| 347 | if Setting.FontName.value: |
| 348 | f = QFont(Setting.FontName.value) |
| 349 | |
| 350 | if Setting.FontSize.value and Setting.FontSize.value != "Defalut": |
| 351 | f.setPointSize(int(Setting.FontSize.value)) |
| 352 | |
| 353 | if Setting.FontStyle.value: |
| 354 | fontStyleList = [QFont.Light, QFont.Normal, QFont.DemiBold, QFont.Bold, QFont.Black] |
| 355 | f.setWeight(fontStyleList[Setting.FontStyle.value - 1]) |
| 356 | |
| 357 | QtOwner().app.setFont(f) |
| 358 | |
| 359 | except Exception as es: |
| 360 | Log.Error(es) |
| 361 | |
| 362 | # def ShowMsg(self, data): |
| 363 | # return self.owner.msgForm.ShowMsg(data) |