Thu, 30 Dec 2021 11:17:58 +0100
Updated copyright for 2022.
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8415
diff
changeset
|
3 | # Copyright (c) 2003 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the font dialog wizard dialog. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import os |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
12 | from PyQt6.QtCore import pyqtSlot |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
13 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QFontDialog |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
15 | from .Ui_FontDialogWizardDialog import Ui_FontDialogWizardDialog |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
17 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | class FontDialogWizardDialog(QDialog, Ui_FontDialogWizardDialog): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Class implementing the font dialog wizard dialog. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | It displays a dialog for entering the parameters |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | for the QFontDialog code generator. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
8324
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
25 | FontWeight2Code = { |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
26 | 100: "Thin", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
27 | 200: "ExtraLight", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
28 | 300: "Light", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
29 | 400: "Normal", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
30 | 500: "Medium", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
31 | 600: "DemiBold", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
32 | 700: "Bold", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
33 | 800: "ExtraBold", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
34 | 900: "Black", |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
35 | } |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
36 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | def __init__(self, parent=None): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | @param parent parent widget (QWidget) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
43 | super().__init__(parent) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.setupUi(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
2893
150de635fa29
Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
46 | self.bTest = self.buttonBox.addButton( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
47 | self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | self.font = None |
8410
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
50 | self.fontOptions = { |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
51 | "noNativeDialog": False, |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
52 | "scalableFonts": False, |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
53 | "nonScalableFonts": False, |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
54 | "monospacedFonts": False, |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
55 | "proportionalFonts": False, |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
56 | } |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | |
3366
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
58 | msh = self.minimumSizeHint() |
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
59 | self.resize(max(self.width(), msh.width()), msh.height()) |
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
60 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | def on_buttonBox_clicked(self, button): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Private slot called by a button of the button box clicked. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | @param button button that was clicked (QAbstractButton) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | if button == self.bTest: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | self.on_bTest_clicked() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | def on_bTest_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | Private method to test the selected options. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | if self.font is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | QFontDialog.getFont() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | else: |
8413
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
78 | options = QFontDialog.FontDialogOption(0) |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
79 | if any(self.fontOptions.values()): |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
80 | if self.fontOptions["noNativeDialog"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
81 | options |= QFontDialog.FontDialogOption.DontUseNativeDialog |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
82 | if self.fontOptions["scalableFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
83 | options |= QFontDialog.FontDialogOption.ScalableFonts |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
84 | if self.fontOptions["nonScalableFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
85 | options |= QFontDialog.FontDialogOption.NonScalableFonts |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
86 | if self.fontOptions["monospacedFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
87 | options |= QFontDialog.FontDialogOption.MonospacedFonts |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
88 | if self.fontOptions["proportionalFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
89 | options |= QFontDialog.FontDialogOption.ProportionalFonts |
8410
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
90 | QFontDialog.getFont( |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
91 | self.font, |
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
92 | self, |
8413
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
93 | self.eCaption.text(), |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
94 | options |
8410
f8d97f05f883
Started improving the Font Dialog Wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
95 | ) |
8413
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
96 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | def on_eVariable_textChanged(self, text): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | Private slot to handle the textChanged signal of eVariable. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | @param text the new text (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | if not text: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | self.bTest.setEnabled(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | self.bTest.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | def on_fontButton_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | """ |
2893
150de635fa29
Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
111 | Private slot to handle the button press to select a font via a |
150de635fa29
Some changes to code generation wizards.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
112 | font selection dialog. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | if self.font is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | font, ok = QFontDialog.getFont() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | font, ok = QFontDialog.getFont(self.font) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | if ok: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.font = font |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | self.font = None |
8413
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
122 | |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
123 | @pyqtSlot() |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
124 | def on_optionsButton_clicked(self): |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
125 | """ |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
126 | Private slot to handle the selection of font dialog options. |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
127 | """ |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
128 | from .FontDialogOptionsDialog import FontDialogOptionsDialog |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
129 | dlg = FontDialogOptionsDialog(self.fontOptions, self) |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
130 | if dlg.exec() == QDialog.DialogCode.Accepted: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
131 | self.fontOptions = dlg.getOptions() |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
132 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | def getCode(self, indLevel, indString): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | Public method to get the source code. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | @param indLevel indentation level (int) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | @param indString string used for indentation (space or tab) (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | @return generated code (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | """ |
3125
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
141 | # calculate our indentation level and the indentation string |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
142 | il = indLevel + 1 |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
143 | istring = il * indString |
446
69aac6eeba9b
Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
425
diff
changeset
|
144 | estring = os.linesep + indLevel * indString |
69aac6eeba9b
Changed the wizards code generation to eliminate not needed backslashes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
425
diff
changeset
|
145 | |
96
9624a110667d
Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
146 | # generate the code |
3124
a01e410893ac
Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2893
diff
changeset
|
147 | resvar = self.eResultVar.text() |
a01e410893ac
Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2893
diff
changeset
|
148 | if not resvar: |
a01e410893ac
Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2893
diff
changeset
|
149 | resvar = "font" |
3125
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
150 | title = self.eCaption.text() |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
151 | if self.parentSelf.isChecked(): |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
152 | parent = "self" |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
153 | elif self.parentNone.isChecked(): |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
154 | parent = "None" |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
155 | elif self.parentOther.isChecked(): |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
156 | parent = self.parentEdit.text() |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
157 | if parent == "": |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
158 | parent = "None" |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
159 | |
3124
a01e410893ac
Extended the dialog wizards to generate code for the result variable(s).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2893
diff
changeset
|
160 | code = '{0}, ok = QFontDialog.getFont('.format(resvar) |
3125
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
161 | if self.eVariable.text() or self.font is not None: |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
162 | if title or parent != "None": |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
163 | code += '{0}{1}'.format(os.linesep, istring) |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
164 | if not self.eVariable.text(): |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
165 | if self.font is not None: |
8324
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
166 | code += ( |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
167 | 'QFont(["{0}"], {1:d}, QFont.Weight.{2}, {3})' |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
168 | .format( |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
169 | self.font.family(), |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
170 | self.font.pointSize(), |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
171 | FontDialogWizardDialog.FontWeight2Code[ |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
172 | self.font.weight()], |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
173 | "True" if self.font.italic() else "False") |
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
174 | ) |
3125
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
175 | else: |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
176 | code += self.eVariable.text() |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
177 | if title: |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
178 | code += ',{0}{1}{2}'.format( |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
179 | os.linesep, istring, parent) |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
180 | code += ',{0}{1}self.tr("{2}")'.format( |
3125
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
181 | os.linesep, istring, title) |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
182 | elif parent != "None": |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
183 | code += ',{0}{1}{2}'.format( |
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
184 | os.linesep, istring, parent) |
8413
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
185 | if any(self.fontOptions.values()): |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
186 | options = [] |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
187 | if self.fontOptions["noNativeDialog"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
188 | options.append( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
189 | "QFontDialog.FontDialogOption.DontUseNativeDialog") |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
190 | if self.fontOptions["scalableFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
191 | options.append( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
192 | "QFontDialog.FontDialogOption.ScalableFonts") |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
193 | if self.fontOptions["nonScalableFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
194 | options.append( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
195 | "QFontDialog.FontDialogOption.NonScalableFonts") |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
196 | if self.fontOptions["monospacedFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
197 | options.append( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
198 | "QFontDialog.FontDialogOption.MonospacedFonts") |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
199 | if self.fontOptions["proportionalFonts"]: |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
200 | options.append( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
201 | "QFontDialog.FontDialogOption.ProportionalFonts") |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
202 | fontOptionsString = ( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
203 | ' |{0}{1}'.format(os.linesep, istring).join(options) |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
204 | ) |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
205 | code += ',{0}{1}{2}'.format( |
65ed18753c40
Font Dialog Wizard: enhanced the wizard to allow the selection of font dialog options.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8410
diff
changeset
|
206 | os.linesep, istring, fontOptionsString) |
8415
c6236bed1b50
Wizards: changed the generated code slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8413
diff
changeset
|
207 | code += '{0}){0}'.format(estring) |
3125
385a62b53725
Extended some dialog wizards to generate code for the parent widget and extended the QFontDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3124
diff
changeset
|
208 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | return code |