PrEditor 2.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. preditor/__init__.py +315 -0
  2. preditor/__main__.py +13 -0
  3. preditor/about_module.py +165 -0
  4. preditor/cli.py +192 -0
  5. preditor/config.py +318 -0
  6. preditor/constants.py +13 -0
  7. preditor/contexts.py +210 -0
  8. preditor/cores/__init__.py +0 -0
  9. preditor/cores/core.py +20 -0
  10. preditor/dccs/.hab.json +10 -0
  11. preditor/dccs/maya/PrEditor_maya.mod +1 -0
  12. preditor/dccs/maya/README.md +22 -0
  13. preditor/dccs/maya/plug-ins/PrEditor_maya.py +141 -0
  14. preditor/dccs/studiomax/PackageContents.xml +32 -0
  15. preditor/dccs/studiomax/PrEditor-PrEditor_Show.mcr +8 -0
  16. preditor/dccs/studiomax/README.md +17 -0
  17. preditor/dccs/studiomax/preditor.ms +16 -0
  18. preditor/dccs/studiomax/preditor_menu.mnx +7 -0
  19. preditor/debug.py +149 -0
  20. preditor/delayable_engine/__init__.py +302 -0
  21. preditor/delayable_engine/delayables.py +85 -0
  22. preditor/enum.py +728 -0
  23. preditor/excepthooks.py +165 -0
  24. preditor/gui/__init__.py +56 -0
  25. preditor/gui/app.py +163 -0
  26. preditor/gui/codehighlighter.py +289 -0
  27. preditor/gui/completer.py +237 -0
  28. preditor/gui/console.py +605 -0
  29. preditor/gui/console_base.py +911 -0
  30. preditor/gui/dialog.py +181 -0
  31. preditor/gui/drag_tab_bar.py +625 -0
  32. preditor/gui/editor_chooser.py +57 -0
  33. preditor/gui/errordialog.py +69 -0
  34. preditor/gui/find_files.py +137 -0
  35. preditor/gui/fuzzy_search/__init__.py +0 -0
  36. preditor/gui/fuzzy_search/fuzzy_search.py +97 -0
  37. preditor/gui/group_tab_widget/__init__.py +0 -0
  38. preditor/gui/group_tab_widget/group_tab_widget.py +528 -0
  39. preditor/gui/group_tab_widget/grouped_tab_menu.py +35 -0
  40. preditor/gui/group_tab_widget/grouped_tab_models.py +107 -0
  41. preditor/gui/group_tab_widget/grouped_tab_widget.py +223 -0
  42. preditor/gui/group_tab_widget/one_tab_widget.py +96 -0
  43. preditor/gui/level_buttons.py +358 -0
  44. preditor/gui/logger_window_handler.py +77 -0
  45. preditor/gui/logger_window_plugin.py +35 -0
  46. preditor/gui/loggerwindow.py +2405 -0
  47. preditor/gui/newtabwidget.py +69 -0
  48. preditor/gui/output_console.py +11 -0
  49. preditor/gui/qtdesigner/__init__.py +21 -0
  50. preditor/gui/qtdesigner/_log_plugin.py +29 -0
  51. preditor/gui/qtdesigner/console_base_plugin.py +48 -0
  52. preditor/gui/qtdesigner/console_predit_plugin.py +48 -0
  53. preditor/gui/set_text_editor_path_dialog.py +61 -0
  54. preditor/gui/status_label.py +99 -0
  55. preditor/gui/suggest_path_quotes_dialog.py +50 -0
  56. preditor/gui/ui/editor_chooser.ui +93 -0
  57. preditor/gui/ui/errordialog.ui +74 -0
  58. preditor/gui/ui/find_files.ui +140 -0
  59. preditor/gui/ui/loggerwindow.ui +1909 -0
  60. preditor/gui/ui/set_text_editor_path_dialog.ui +189 -0
  61. preditor/gui/ui/suggest_path_quotes_dialog.ui +225 -0
  62. preditor/gui/window.py +161 -0
  63. preditor/gui/workbox_mixin.py +1139 -0
  64. preditor/gui/workbox_text_edit.py +136 -0
  65. preditor/gui/workboxwidget.py +315 -0
  66. preditor/logging_config.py +55 -0
  67. preditor/osystem.py +401 -0
  68. preditor/plugins.py +118 -0
  69. preditor/prefs.py +381 -0
  70. preditor/resource/environment_variables.html +26 -0
  71. preditor/resource/error_mail.html +85 -0
  72. preditor/resource/error_mail_inline.html +41 -0
  73. preditor/resource/img/README.md +17 -0
  74. preditor/resource/img/arrow_forward.png +0 -0
  75. preditor/resource/img/check-bold.png +0 -0
  76. preditor/resource/img/chevron-down.png +0 -0
  77. preditor/resource/img/chevron-up.png +0 -0
  78. preditor/resource/img/close-thick.png +0 -0
  79. preditor/resource/img/comment-edit.png +0 -0
  80. preditor/resource/img/content-copy.png +0 -0
  81. preditor/resource/img/content-cut.png +0 -0
  82. preditor/resource/img/content-duplicate.png +0 -0
  83. preditor/resource/img/content-paste.png +0 -0
  84. preditor/resource/img/content-save.png +0 -0
  85. preditor/resource/img/debug_disabled.png +0 -0
  86. preditor/resource/img/eye-check.png +0 -0
  87. preditor/resource/img/file-plus.png +0 -0
  88. preditor/resource/img/file-remove.png +0 -0
  89. preditor/resource/img/format-align-left.png +0 -0
  90. preditor/resource/img/format-letter-case-lower.png +0 -0
  91. preditor/resource/img/format-letter-case-upper.png +0 -0
  92. preditor/resource/img/format-letter-case.svg +1 -0
  93. preditor/resource/img/information.png +0 -0
  94. preditor/resource/img/logging_critical.png +0 -0
  95. preditor/resource/img/logging_custom.png +0 -0
  96. preditor/resource/img/logging_debug.png +0 -0
  97. preditor/resource/img/logging_error.png +0 -0
  98. preditor/resource/img/logging_info.png +0 -0
  99. preditor/resource/img/logging_not_set.png +0 -0
  100. preditor/resource/img/logging_warning.png +0 -0
  101. preditor/resource/img/marker.png +0 -0
  102. preditor/resource/img/play.png +0 -0
  103. preditor/resource/img/playlist-play.png +0 -0
  104. preditor/resource/img/plus-minus-variant.png +0 -0
  105. preditor/resource/img/preditor.ico +0 -0
  106. preditor/resource/img/preditor.png +0 -0
  107. preditor/resource/img/preditor.psd +0 -0
  108. preditor/resource/img/preditor.svg +44 -0
  109. preditor/resource/img/regex.svg +1 -0
  110. preditor/resource/img/restart.svg +1 -0
  111. preditor/resource/img/skip-forward-outline.png +0 -0
  112. preditor/resource/img/skip-next-outline.png +0 -0
  113. preditor/resource/img/skip-next.png +0 -0
  114. preditor/resource/img/skip-previous.png +0 -0
  115. preditor/resource/img/subdirectory-arrow-right.png +0 -0
  116. preditor/resource/img/text-search-variant.png +0 -0
  117. preditor/resource/img/warning-big.png +0 -0
  118. preditor/resource/lang/python.json +30 -0
  119. preditor/resource/pref_updates/pref_updates.json +17 -0
  120. preditor/resource/settings.ini +25 -0
  121. preditor/resource/stylesheet/Bright.css +76 -0
  122. preditor/resource/stylesheet/Dark.css +210 -0
  123. preditor/scintilla/__init__.py +40 -0
  124. preditor/scintilla/delayables/__init__.py +11 -0
  125. preditor/scintilla/delayables/smart_highlight.py +97 -0
  126. preditor/scintilla/delayables/spell_check.py +174 -0
  127. preditor/scintilla/documenteditor.py +1924 -0
  128. preditor/scintilla/finddialog.py +68 -0
  129. preditor/scintilla/lang/__init__.py +80 -0
  130. preditor/scintilla/lang/config/bash.ini +15 -0
  131. preditor/scintilla/lang/config/batch.ini +14 -0
  132. preditor/scintilla/lang/config/cpp.ini +19 -0
  133. preditor/scintilla/lang/config/css.ini +19 -0
  134. preditor/scintilla/lang/config/eyeonscript.ini +17 -0
  135. preditor/scintilla/lang/config/html.ini +21 -0
  136. preditor/scintilla/lang/config/javascript.ini +24 -0
  137. preditor/scintilla/lang/config/lua.ini +16 -0
  138. preditor/scintilla/lang/config/maxscript.ini +20 -0
  139. preditor/scintilla/lang/config/mel.ini +18 -0
  140. preditor/scintilla/lang/config/mu.ini +22 -0
  141. preditor/scintilla/lang/config/nsi.ini +19 -0
  142. preditor/scintilla/lang/config/perl.ini +19 -0
  143. preditor/scintilla/lang/config/puppet.ini +19 -0
  144. preditor/scintilla/lang/config/python.ini +28 -0
  145. preditor/scintilla/lang/config/ruby.ini +19 -0
  146. preditor/scintilla/lang/config/sql.ini +7 -0
  147. preditor/scintilla/lang/config/xml.ini +21 -0
  148. preditor/scintilla/lang/config/yaml.ini +18 -0
  149. preditor/scintilla/lang/language.py +240 -0
  150. preditor/scintilla/lexers/__init__.py +0 -0
  151. preditor/scintilla/lexers/cpplexer.py +22 -0
  152. preditor/scintilla/lexers/javascriptlexer.py +27 -0
  153. preditor/scintilla/lexers/maxscriptlexer.py +235 -0
  154. preditor/scintilla/lexers/mellexer.py +369 -0
  155. preditor/scintilla/lexers/mulexer.py +33 -0
  156. preditor/scintilla/lexers/pythonlexer.py +42 -0
  157. preditor/scintilla/ui/finddialog.ui +160 -0
  158. preditor/settings.py +71 -0
  159. preditor/stream/__init__.py +72 -0
  160. preditor/stream/console_handler.py +169 -0
  161. preditor/stream/director.py +144 -0
  162. preditor/stream/manager.py +97 -0
  163. preditor/streamhandler_helper.py +46 -0
  164. preditor/utils/__init__.py +191 -0
  165. preditor/utils/call_stack.py +86 -0
  166. preditor/utils/cute.py +106 -0
  167. preditor/utils/stylesheets.py +54 -0
  168. preditor/utils/text_search.py +338 -0
  169. preditor/version.py +34 -0
  170. preditor/weakref.py +363 -0
  171. preditor-2.1.0.dist-info/METADATA +308 -0
  172. preditor-2.1.0.dist-info/RECORD +179 -0
  173. preditor-2.1.0.dist-info/WHEEL +5 -0
  174. preditor-2.1.0.dist-info/entry_points.txt +19 -0
  175. preditor-2.1.0.dist-info/licenses/LICENSE +165 -0
  176. preditor-2.1.0.dist-info/top_level.txt +3 -0
  177. tests/encodings/test_ecoding.py +33 -0
  178. tests/find_files/test_find_files.py +74 -0
  179. tests/ide/test_delayable_engine.py +171 -0
@@ -0,0 +1,189 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ui version="4.0">
3
+ <class>Dialog</class>
4
+ <widget class="QDialog" name="Dialog">
5
+ <property name="geometry">
6
+ <rect>
7
+ <x>0</x>
8
+ <y>0</y>
9
+ <width>1064</width>
10
+ <height>325</height>
11
+ </rect>
12
+ </property>
13
+ <property name="windowTitle">
14
+ <string>Set Text Editor Executable Path</string>
15
+ </property>
16
+ <layout class="QVBoxLayout" name="verticalLayout">
17
+ <property name="spacing">
18
+ <number>15</number>
19
+ </property>
20
+ <item>
21
+ <widget class="QWidget" name="widget" native="true">
22
+ <layout class="QVBoxLayout" name="verticalLayout_2">
23
+ <property name="spacing">
24
+ <number>3</number>
25
+ </property>
26
+ <property name="leftMargin">
27
+ <number>0</number>
28
+ </property>
29
+ <property name="topMargin">
30
+ <number>0</number>
31
+ </property>
32
+ <property name="rightMargin">
33
+ <number>0</number>
34
+ </property>
35
+ <property name="bottomMargin">
36
+ <number>0</number>
37
+ </property>
38
+ <item>
39
+ <widget class="QLabel" name="label">
40
+ <property name="sizePolicy">
41
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
42
+ <horstretch>0</horstretch>
43
+ <verstretch>0</verstretch>
44
+ </sizepolicy>
45
+ </property>
46
+ <property name="font">
47
+ <font>
48
+ <pointsize>10</pointsize>
49
+ </font>
50
+ </property>
51
+ <property name="text">
52
+ <string>Path to the executable of your preferred text editor</string>
53
+ </property>
54
+ </widget>
55
+ </item>
56
+ <item>
57
+ <widget class="QLineEdit" name="uiTextEditorExecutablePathLE">
58
+ <property name="font">
59
+ <font>
60
+ <pointsize>10</pointsize>
61
+ </font>
62
+ </property>
63
+ <property name="text">
64
+ <string>C:\Program Files\Sublime Text 3\sublime_text.exe</string>
65
+ </property>
66
+ </widget>
67
+ </item>
68
+ </layout>
69
+ </widget>
70
+ </item>
71
+ <item>
72
+ <widget class="QWidget" name="widget_2" native="true">
73
+ <layout class="QVBoxLayout" name="verticalLayout_3">
74
+ <property name="spacing">
75
+ <number>3</number>
76
+ </property>
77
+ <property name="leftMargin">
78
+ <number>0</number>
79
+ </property>
80
+ <property name="topMargin">
81
+ <number>0</number>
82
+ </property>
83
+ <property name="rightMargin">
84
+ <number>0</number>
85
+ </property>
86
+ <property name="bottomMargin">
87
+ <number>0</number>
88
+ </property>
89
+ <item>
90
+ <widget class="QLabel" name="label_2">
91
+ <property name="sizePolicy">
92
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
93
+ <horstretch>0</horstretch>
94
+ <verstretch>0</verstretch>
95
+ </sizepolicy>
96
+ </property>
97
+ <property name="font">
98
+ <font>
99
+ <pointsize>10</pointsize>
100
+ </font>
101
+ </property>
102
+ <property name="text">
103
+ <string>Command Prompt template (template of the Command Prompt command to launch your text editor, including how it may implement specifying line numbers).
104
+ Use these template strings: &quot;{exePath}&quot;, &quot;{modulePath}&quot;, {lineNum}. Include quotes around exePath and modulePath to handle filepaths which contain spaces.</string>
105
+ </property>
106
+ <property name="wordWrap">
107
+ <bool>true</bool>
108
+ </property>
109
+ </widget>
110
+ </item>
111
+ <item>
112
+ <widget class="QLineEdit" name="uiTextEditorCommandPatternLE">
113
+ <property name="font">
114
+ <font>
115
+ <pointsize>10</pointsize>
116
+ </font>
117
+ </property>
118
+ <property name="toolTip">
119
+ <string/>
120
+ </property>
121
+ <property name="text">
122
+ <string>&quot;{exePath}&quot; &quot;{modulePath}&quot;:{lineNum}</string>
123
+ </property>
124
+ </widget>
125
+ </item>
126
+ </layout>
127
+ </widget>
128
+ </item>
129
+ <item>
130
+ <spacer name="verticalSpacer">
131
+ <property name="orientation">
132
+ <enum>Qt::Vertical</enum>
133
+ </property>
134
+ <property name="sizeHint" stdset="0">
135
+ <size>
136
+ <width>20</width>
137
+ <height>40</height>
138
+ </size>
139
+ </property>
140
+ </spacer>
141
+ </item>
142
+ <item>
143
+ <widget class="QDialogButtonBox" name="uiDialogButtonBox">
144
+ <property name="orientation">
145
+ <enum>Qt::Horizontal</enum>
146
+ </property>
147
+ <property name="standardButtons">
148
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
149
+ </property>
150
+ </widget>
151
+ </item>
152
+ </layout>
153
+ </widget>
154
+ <resources/>
155
+ <connections>
156
+ <connection>
157
+ <sender>uiDialogButtonBox</sender>
158
+ <signal>accepted()</signal>
159
+ <receiver>Dialog</receiver>
160
+ <slot>accept()</slot>
161
+ <hints>
162
+ <hint type="sourcelabel">
163
+ <x>248</x>
164
+ <y>254</y>
165
+ </hint>
166
+ <hint type="destinationlabel">
167
+ <x>157</x>
168
+ <y>274</y>
169
+ </hint>
170
+ </hints>
171
+ </connection>
172
+ <connection>
173
+ <sender>uiDialogButtonBox</sender>
174
+ <signal>rejected()</signal>
175
+ <receiver>Dialog</receiver>
176
+ <slot>reject()</slot>
177
+ <hints>
178
+ <hint type="sourcelabel">
179
+ <x>316</x>
180
+ <y>260</y>
181
+ </hint>
182
+ <hint type="destinationlabel">
183
+ <x>286</x>
184
+ <y>274</y>
185
+ </hint>
186
+ </hints>
187
+ </connection>
188
+ </connections>
189
+ </ui>
@@ -0,0 +1,225 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ui version="4.0">
3
+ <class>uiSuggestPathQuotesDLG</class>
4
+ <widget class="QDialog" name="uiSuggestPathQuotesDLG">
5
+ <property name="geometry">
6
+ <rect>
7
+ <x>0</x>
8
+ <y>0</y>
9
+ <width>716</width>
10
+ <height>342</height>
11
+ </rect>
12
+ </property>
13
+ <property name="windowTitle">
14
+ <string>Set Text Editor Executable Path</string>
15
+ </property>
16
+ <layout class="QVBoxLayout" name="verticalLayout">
17
+ <property name="spacing">
18
+ <number>15</number>
19
+ </property>
20
+ <item>
21
+ <widget class="QWidget" name="widget" native="true">
22
+ <layout class="QVBoxLayout" name="verticalLayout_2">
23
+ <property name="spacing">
24
+ <number>3</number>
25
+ </property>
26
+ <property name="leftMargin">
27
+ <number>0</number>
28
+ </property>
29
+ <property name="topMargin">
30
+ <number>0</number>
31
+ </property>
32
+ <property name="rightMargin">
33
+ <number>0</number>
34
+ </property>
35
+ <property name="bottomMargin">
36
+ <number>0</number>
37
+ </property>
38
+ <item>
39
+ <widget class="QLabel" name="label">
40
+ <property name="sizePolicy">
41
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
42
+ <horstretch>0</horstretch>
43
+ <verstretch>0</verstretch>
44
+ </sizepolicy>
45
+ </property>
46
+ <property name="font">
47
+ <font>
48
+ <pointsize>10</pointsize>
49
+ </font>
50
+ </property>
51
+ <property name="text">
52
+ <string>It is recommended to wrap filepaths in double-quotes in case of spaces in the paths. Would you like to update the command template from:</string>
53
+ </property>
54
+ <property name="wordWrap">
55
+ <bool>true</bool>
56
+ </property>
57
+ </widget>
58
+ </item>
59
+ <item>
60
+ <widget class="QLineEdit" name="uiTextEditorOldCommandPatternLE">
61
+ <property name="enabled">
62
+ <bool>false</bool>
63
+ </property>
64
+ <property name="font">
65
+ <font>
66
+ <pointsize>10</pointsize>
67
+ </font>
68
+ </property>
69
+ <property name="toolTip">
70
+ <string/>
71
+ </property>
72
+ <property name="text">
73
+ <string>uiTextEditorOldCommandPatternLE</string>
74
+ </property>
75
+ </widget>
76
+ </item>
77
+ </layout>
78
+ </widget>
79
+ </item>
80
+ <item>
81
+ <widget class="QWidget" name="widget_3" native="true">
82
+ <layout class="QVBoxLayout" name="verticalLayout_4">
83
+ <property name="spacing">
84
+ <number>3</number>
85
+ </property>
86
+ <property name="leftMargin">
87
+ <number>0</number>
88
+ </property>
89
+ <property name="topMargin">
90
+ <number>0</number>
91
+ </property>
92
+ <property name="rightMargin">
93
+ <number>0</number>
94
+ </property>
95
+ <property name="bottomMargin">
96
+ <number>0</number>
97
+ </property>
98
+ <item>
99
+ <widget class="QLabel" name="label_2">
100
+ <property name="sizePolicy">
101
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
102
+ <horstretch>0</horstretch>
103
+ <verstretch>0</verstretch>
104
+ </sizepolicy>
105
+ </property>
106
+ <property name="font">
107
+ <font>
108
+ <pointsize>10</pointsize>
109
+ </font>
110
+ </property>
111
+ <property name="text">
112
+ <string>to:</string>
113
+ </property>
114
+ <property name="wordWrap">
115
+ <bool>true</bool>
116
+ </property>
117
+ </widget>
118
+ </item>
119
+ <item>
120
+ <widget class="QLineEdit" name="uiTextEditorNewCommandPatternLE">
121
+ <property name="font">
122
+ <font>
123
+ <pointsize>10</pointsize>
124
+ </font>
125
+ </property>
126
+ <property name="toolTip">
127
+ <string/>
128
+ </property>
129
+ <property name="text">
130
+ <string/>
131
+ </property>
132
+ </widget>
133
+ </item>
134
+ </layout>
135
+ </widget>
136
+ </item>
137
+ <item>
138
+ <widget class="QWidget" name="widget_4" native="true">
139
+ <layout class="QVBoxLayout" name="verticalLayout_5">
140
+ <property name="spacing">
141
+ <number>3</number>
142
+ </property>
143
+ <property name="leftMargin">
144
+ <number>0</number>
145
+ </property>
146
+ <property name="topMargin">
147
+ <number>0</number>
148
+ </property>
149
+ <property name="rightMargin">
150
+ <number>0</number>
151
+ </property>
152
+ <property name="bottomMargin">
153
+ <number>0</number>
154
+ </property>
155
+ </layout>
156
+ </widget>
157
+ </item>
158
+ <item>
159
+ <spacer name="verticalSpacer">
160
+ <property name="orientation">
161
+ <enum>Qt::Vertical</enum>
162
+ </property>
163
+ <property name="sizeHint" stdset="0">
164
+ <size>
165
+ <width>20</width>
166
+ <height>40</height>
167
+ </size>
168
+ </property>
169
+ </spacer>
170
+ </item>
171
+ <item>
172
+ <widget class="QCheckBox" name="uiDontAskAgainCHK">
173
+ <property name="text">
174
+ <string>Don't Ask Again</string>
175
+ </property>
176
+ </widget>
177
+ </item>
178
+ <item>
179
+ <widget class="QDialogButtonBox" name="uiDialogButtonBox">
180
+ <property name="orientation">
181
+ <enum>Qt::Horizontal</enum>
182
+ </property>
183
+ <property name="standardButtons">
184
+ <set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
185
+ </property>
186
+ </widget>
187
+ </item>
188
+ </layout>
189
+ </widget>
190
+ <resources/>
191
+ <connections>
192
+ <connection>
193
+ <sender>uiDialogButtonBox</sender>
194
+ <signal>accepted()</signal>
195
+ <receiver>uiSuggestPathQuotesDLG</receiver>
196
+ <slot>accept()</slot>
197
+ <hints>
198
+ <hint type="sourcelabel">
199
+ <x>248</x>
200
+ <y>254</y>
201
+ </hint>
202
+ <hint type="destinationlabel">
203
+ <x>157</x>
204
+ <y>274</y>
205
+ </hint>
206
+ </hints>
207
+ </connection>
208
+ <connection>
209
+ <sender>uiDialogButtonBox</sender>
210
+ <signal>rejected()</signal>
211
+ <receiver>uiSuggestPathQuotesDLG</receiver>
212
+ <slot>reject()</slot>
213
+ <hints>
214
+ <hint type="sourcelabel">
215
+ <x>316</x>
216
+ <y>260</y>
217
+ </hint>
218
+ <hint type="destinationlabel">
219
+ <x>286</x>
220
+ <y>274</y>
221
+ </hint>
222
+ </hints>
223
+ </connection>
224
+ </connections>
225
+ </ui>
preditor/gui/window.py ADDED
@@ -0,0 +1,161 @@
1
+ from __future__ import absolute_import
2
+
3
+ from Qt.QtCore import Qt
4
+ from Qt.QtWidgets import QMainWindow
5
+
6
+ from .. import config, relativePath
7
+
8
+
9
+ class Window(QMainWindow):
10
+ _instance = None
11
+
12
+ @classmethod
13
+ def instance(cls, parent=None):
14
+ """If you only want to have one instance of a window, use this
15
+ method instead of creating a new window. It will only create a
16
+ new instance of the class if the class variable _instance is
17
+ none.
18
+
19
+ Args:
20
+ parent (QWidget, optional): The parent widget
21
+
22
+ Returns:
23
+ Window:
24
+ """
25
+ if not cls._instance:
26
+ cls._instance = cls(parent=parent)
27
+ # protect the memory
28
+ cls._instance.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, False)
29
+ return cls._instance
30
+
31
+ def __init__(self, parent=None, flags=0):
32
+ # if there is no root, create
33
+ if not parent:
34
+ parent = config.root_window()
35
+
36
+ # create a QMainWindow
37
+ if flags:
38
+ QMainWindow.__init__(self, parent, flags)
39
+ else:
40
+ QMainWindow.__init__(self, parent)
41
+
42
+ # INFO
43
+ #
44
+ # As far as we can tell, the purpose for this class is keeping live
45
+ # references to the subclasses so they don't get garbage collected, all while
46
+ # getting around having to actively maintain a list of running dialogs.
47
+ #
48
+ # Generally, setting WA_DeleteOnClose to False, and keeping the _instance
49
+ # variable around
50
+ # will do the trick for pseudo-singleton dialogs. (created with instance=True)
51
+ #
52
+ # However, for non-instanced dialogs where multiples are allowed, deleteOnClose
53
+ # is set to True and no _instance variable is set. Because there are no live
54
+ # references to the dialog, it is closed and garbage collected almost
55
+ # immediately in certain programs (xsi, maya).
56
+ #
57
+ # The current workaround is to manually set WA_DeleteOnClose to False, however
58
+ # this causes any subclasses to stick around in memory even when the
59
+ # window/dialog is closed. So you also have to manually set WA_DeleteOnClose to
60
+ # True in the sub-classed .closeEvent() method before you call super()
61
+ #
62
+ # It is completely possible to write some code that would automatically handle
63
+ # this, and it is CERTAINLY something we can/will be doing in the future, but
64
+ # for now we're not quite sure how that would affect the production tools.
65
+ # Technically this is a problem, but there are currently no consequences from an
66
+ # artist standpoint because we have more than enough memory to hold all those
67
+ # dead dialogs
68
+
69
+ # set the delete attribute to clean up the window once it is closed
70
+ self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)
71
+ # If this value is set to False calling setGeometry on this window will not
72
+ # adjust the geometry to ensure the window is on a valid screen.
73
+ self.checkScreenGeo = True
74
+ # attempt to set the dialog icon
75
+ import os
76
+ import sys
77
+
78
+ from Qt.QtGui import QIcon
79
+
80
+ try:
81
+ path = relativePath(
82
+ os.path.abspath(sys.modules[self.__class__.__module__].__file__),
83
+ 'img/icon.png',
84
+ )
85
+ if os.path.exists(path):
86
+ self.setWindowIcon(QIcon(path))
87
+ except (KeyError, AttributeError):
88
+ pass
89
+
90
+ def _shouldDisableAccelerators(self, old, now):
91
+ """Used to enable typing in DCC's that require it(Max 2018).
92
+
93
+ Args:
94
+ old (QWidget or None): The QWidget that lost focus.
95
+ new (QWidget or None): The QWidget that gained focus.
96
+
97
+ Returns:
98
+ bool: If accelerators should be disabled.
99
+ """
100
+ # By default we always want to disable accelerators.
101
+ return True
102
+
103
+ def closeEvent(self, event):
104
+ # ensure this object gets deleted
105
+ wwidget = None
106
+ if self.testAttribute(Qt.WidgetAttribute.WA_DeleteOnClose):
107
+ # collect the win widget to uncache it
108
+ if self.parent() and self.parent().inherits('QWinWidget'):
109
+ wwidget = self.parent()
110
+
111
+ QMainWindow.closeEvent(self, event)
112
+
113
+ # uncache the win widget if necessary
114
+ if wwidget:
115
+ from .winwidget import WinWidget
116
+
117
+ WinWidget.uncache(wwidget)
118
+
119
+ def setGeometry(self, *args):
120
+ """
121
+ Sets the window's geometry, It will also check if the geometry is visible on any
122
+ monitors. If it is not it will move the window so it is visible. This can be
123
+ disabled by setting self.checkScreenGeo to False
124
+ """
125
+ super(Window, self).setGeometry(*args)
126
+ if self.checkScreenGeo:
127
+ from ..utils.cute import ensureWindowIsVisible
128
+
129
+ ensureWindowIsVisible(self)
130
+
131
+ def shutdown(self):
132
+ # use a @classmethod to make inheritance magically work
133
+ self._shutdown(self)
134
+
135
+ @classmethod
136
+ def _shutdown(cls, this):
137
+ """
138
+ If this item is the class instance properly close it and remove it from memory
139
+ so it can be recreated.
140
+ """
141
+ # allow the global instance to be cleared
142
+ if this == cls._instance:
143
+ cls._instance = None
144
+ this.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)
145
+ try:
146
+ this.close()
147
+ except RuntimeError:
148
+ pass
149
+
150
+ @classmethod
151
+ def instance_shutdown(cls):
152
+ """Call shutdown on this class instance only if the class was instantiated.
153
+
154
+ Returns:
155
+ bool: if cls.instance().shutdown() needed to be called.
156
+ """
157
+ instance = cls._instance
158
+ if instance:
159
+ instance.shutdown()
160
+ return True
161
+ return False