Tools/TRPreviewer.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3030
4a0a82ddd9d2
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
155 155
156 def __initActions(self): 156 def __initActions(self):
157 """ 157 """
158 Private method to define the user interface actions. 158 Private method to define the user interface actions.
159 """ 159 """
160 self.openUIAct = QAction(UI.PixmapCache.getIcon("openUI.png"), 160 self.openUIAct = QAction(
161 self.trUtf8('&Open UI Files...'), self) 161 UI.PixmapCache.getIcon("openUI.png"),
162 self.trUtf8('&Open UI Files...'), self)
162 self.openUIAct.setStatusTip(self.trUtf8('Open UI files for display')) 163 self.openUIAct.setStatusTip(self.trUtf8('Open UI files for display'))
163 self.openUIAct.setWhatsThis(self.trUtf8( 164 self.openUIAct.setWhatsThis(self.trUtf8(
164 """<b>Open UI Files</b>""" 165 """<b>Open UI Files</b>"""
165 """<p>This opens some UI files for display.</p>""" 166 """<p>This opens some UI files for display.</p>"""
166 )) 167 ))
167 self.openUIAct.triggered[()].connect(self.__openWidget) 168 self.openUIAct.triggered[()].connect(self.__openWidget)
168 169
169 self.openQMAct = QAction(UI.PixmapCache.getIcon("openQM.png"), 170 self.openQMAct = QAction(
170 self.trUtf8('Open &Translation Files...'), self) 171 UI.PixmapCache.getIcon("openQM.png"),
172 self.trUtf8('Open &Translation Files...'), self)
171 self.openQMAct.setStatusTip(self.trUtf8( 173 self.openQMAct.setStatusTip(self.trUtf8(
172 'Open Translation files for display')) 174 'Open Translation files for display'))
173 self.openQMAct.setWhatsThis(self.trUtf8( 175 self.openQMAct.setWhatsThis(self.trUtf8(
174 """<b>Open Translation Files</b>""" 176 """<b>Open Translation Files</b>"""
175 """<p>This opens some translation files for display.</p>""" 177 """<p>This opens some translation files for display.</p>"""
176 )) 178 ))
177 self.openQMAct.triggered[()].connect(self.__openTranslation) 179 self.openQMAct.triggered[()].connect(self.__openTranslation)
178 180
179 self.reloadAct = QAction(UI.PixmapCache.getIcon("reload.png"), 181 self.reloadAct = QAction(
180 self.trUtf8('&Reload Translations'), self) 182 UI.PixmapCache.getIcon("reload.png"),
183 self.trUtf8('&Reload Translations'), self)
181 self.reloadAct.setStatusTip(self.trUtf8( 184 self.reloadAct.setStatusTip(self.trUtf8(
182 'Reload the loaded translations')) 185 'Reload the loaded translations'))
183 self.reloadAct.setWhatsThis(self.trUtf8( 186 self.reloadAct.setWhatsThis(self.trUtf8(
184 """<b>Reload Translations</b>""" 187 """<b>Reload Translations</b>"""
185 """<p>This reloads the translations for the loaded""" 188 """<p>This reloads the translations for the loaded"""
186 """ languages.</p>""" 189 """ languages.</p>"""
187 )) 190 ))
188 self.reloadAct.triggered[()].connect(self.translations.reload) 191 self.reloadAct.triggered[()].connect(self.translations.reload)
189 192
190 self.exitAct = QAction(UI.PixmapCache.getIcon("exit.png"), 193 self.exitAct = QAction(
191 self.trUtf8('&Quit'), self) 194 UI.PixmapCache.getIcon("exit.png"), self.trUtf8('&Quit'), self)
192 self.exitAct.setShortcut(QKeySequence( 195 self.exitAct.setShortcut(QKeySequence(
193 self.trUtf8("Ctrl+Q", "File|Quit"))) 196 self.trUtf8("Ctrl+Q", "File|Quit")))
194 self.exitAct.setStatusTip(self.trUtf8('Quit the application')) 197 self.exitAct.setStatusTip(self.trUtf8('Quit the application'))
195 self.exitAct.setWhatsThis(self.trUtf8( 198 self.exitAct.setWhatsThis(self.trUtf8(
196 """<b>Quit</b>""" 199 """<b>Quit</b>"""
197 """<p>Quit the application.</p>""" 200 """<p>Quit the application.</p>"""
198 )) 201 ))
199 self.exitAct.triggered[()].connect(qApp.closeAllWindows) 202 self.exitAct.triggered[()].connect(qApp.closeAllWindows)
200 203
201 self.whatsThisAct = QAction(UI.PixmapCache.getIcon("whatsThis.png"), 204 self.whatsThisAct = QAction(
202 self.trUtf8('&What\'s This?'), self) 205 UI.PixmapCache.getIcon("whatsThis.png"),
206 self.trUtf8('&What\'s This?'), self)
203 self.whatsThisAct.setShortcut(QKeySequence(self.trUtf8("Shift+F1"))) 207 self.whatsThisAct.setShortcut(QKeySequence(self.trUtf8("Shift+F1")))
204 self.whatsThisAct.setStatusTip(self.trUtf8('Context sensitive help')) 208 self.whatsThisAct.setStatusTip(self.trUtf8('Context sensitive help'))
205 self.whatsThisAct.setWhatsThis(self.trUtf8( 209 self.whatsThisAct.setWhatsThis(self.trUtf8(
206 """<b>Display context sensitive help</b>""" 210 """<b>Display context sensitive help</b>"""
207 """<p>In What's This? mode, the mouse cursor shows an arrow""" 211 """<p>In What's This? mode, the mouse cursor shows an arrow"""
246 """<p>Rearrange and resize the windows so that they are""" 250 """<p>Rearrange and resize the windows so that they are"""
247 """ cascaded.</p>""" 251 """ cascaded.</p>"""
248 )) 252 ))
249 self.cascadeAct.triggered[()].connect(self.preview.cascadeSubWindows) 253 self.cascadeAct.triggered[()].connect(self.preview.cascadeSubWindows)
250 254
251 self.closeAct = QAction(UI.PixmapCache.getIcon("close.png"), 255 self.closeAct = QAction(
252 self.trUtf8('&Close'), self) 256 UI.PixmapCache.getIcon("close.png"), self.trUtf8('&Close'), self)
253 self.closeAct.setShortcut(QKeySequence(self.trUtf8( 257 self.closeAct.setShortcut(QKeySequence(self.trUtf8(
254 "Ctrl+W", "File|Close"))) 258 "Ctrl+W", "File|Close")))
255 self.closeAct.setStatusTip(self.trUtf8('Close the current window')) 259 self.closeAct.setStatusTip(self.trUtf8('Close the current window'))
256 self.closeAct.setWhatsThis(self.trUtf8( 260 self.closeAct.setWhatsThis(self.trUtf8(
257 """<b>Close Window</b>""" 261 """<b>Close Window</b>"""
344 348
345 def __about(self): 349 def __about(self):
346 """ 350 """
347 Private slot to show the about information. 351 Private slot to show the about information.
348 """ 352 """
349 E5MessageBox.about(self, self.trUtf8("TR Previewer"), self.trUtf8( 353 E5MessageBox.about(
350 """<h3> About TR Previewer </h3>""" 354 self,
351 """<p>The TR Previewer loads and displays Qt User-Interface""" 355 self.trUtf8("TR Previewer"),
352 """ files and translation files and shows dialogs for a""" 356 self.trUtf8(
353 """ selected language.</p>""" 357 """<h3> About TR Previewer </h3>"""
354 )) 358 """<p>The TR Previewer loads and displays Qt User-Interface"""
359 """ files and translation files and shows dialogs for a"""
360 """ selected language.</p>"""
361 )
362 )
355 363
356 def __aboutQt(self): 364 def __aboutQt(self):
357 """ 365 """
358 Private slot to show info about Qt. 366 Private slot to show info about Qt.
359 """ 367 """
467 if not self.__haveFileName(fileName): 475 if not self.__haveFileName(fileName):
468 ntr = Translation() 476 ntr = Translation()
469 ntr.fileName = fileName 477 ntr.fileName = fileName
470 ntr.name = self.__uniqueName(fileName) 478 ntr.name = self.__uniqueName(fileName)
471 if ntr.name is None: 479 if ntr.name is None:
472 E5MessageBox.warning(self.parent(), 480 E5MessageBox.warning(
481 self.parent(),
473 self.trUtf8("Set Translator"), 482 self.trUtf8("Set Translator"),
474 self.trUtf8("""<p>The translation filename <b>{0}</b>""" 483 self.trUtf8(
484 """<p>The translation filename <b>{0}</b>"""
475 """ is invalid.</p>""").format(fileName)) 485 """ is invalid.</p>""").format(fileName))
476 return 486 return
477 487
478 ntr.translator = self.loadTransFile(fileName) 488 ntr.translator = self.loadTransFile(fileName)
479 if ntr.translator is None: 489 if ntr.translator is None:
495 nTranslator = None 505 nTranslator = None
496 506
497 if name != noTranslationName: 507 if name != noTranslationName:
498 trans = self.__findName(name) 508 trans = self.__findName(name)
499 if trans is None: 509 if trans is None:
500 E5MessageBox.warning(self.parent(), 510 E5MessageBox.warning(
511 self.parent(),
501 self.trUtf8("Set Translator"), 512 self.trUtf8("Set Translator"),
502 self.trUtf8( 513 self.trUtf8(
503 """<p>The translator <b>{0}</b> is not known.</p>""")\ 514 """<p>The translator <b>{0}</b> is not known.</p>""")\
504 .format(name)) 515 .format(name))
505 return 516 return
637 """ 648 """
638 tr = QTranslator() 649 tr = QTranslator()
639 if tr.load(transFileName): 650 if tr.load(transFileName):
640 return tr 651 return tr
641 652
642 E5MessageBox.warning(self.parent(), 653 E5MessageBox.warning(
654 self.parent(),
643 self.trUtf8("Load Translator"), 655 self.trUtf8("Load Translator"),
644 self.trUtf8("""<p>The translation file <b>{0}</b> could""" 656 self.trUtf8("""<p>The translation file <b>{0}</b> could"""
645 """ not be loaded.</p>""").format(transFileName)) 657 """ not be loaded.</p>""").format(transFileName))
646 return None 658 return None
647 659
710 self.__widget = uic.loadUi(self.__uiFileName) 722 self.__widget = uic.loadUi(self.__uiFileName)
711 except: 723 except:
712 pass 724 pass
713 725
714 if not self.__widget: 726 if not self.__widget:
715 E5MessageBox.warning(self, 727 E5MessageBox.warning(
728 self,
716 self.trUtf8("Load UI File"), 729 self.trUtf8("Load UI File"),
717 self.trUtf8( 730 self.trUtf8(
718 """<p>The file <b>{0}</b> could not be loaded.</p>""")\ 731 """<p>The file <b>{0}</b> could not be loaded.</p>""")\
719 .format(self.__uiFileName)) 732 .format(self.__uiFileName))
720 self.__valid = False 733 self.__valid = False
765 """ 778 """
766 wview = self.__findWidget(uiFileName) 779 wview = self.__findWidget(uiFileName)
767 if wview is None: 780 if wview is None:
768 name = os.path.basename(uiFileName) 781 name = os.path.basename(uiFileName)
769 if not name: 782 if not name:
770 E5MessageBox.warning(self, 783 E5MessageBox.warning(
784 self,
771 self.trUtf8("Load UI File"), 785 self.trUtf8("Load UI File"),
772 self.trUtf8( 786 self.trUtf8(
773 """<p>The file <b>{0}</b> could not be loaded.</p>""")\ 787 """<p>The file <b>{0}</b> could not be loaded.</p>""")\
774 .format(uiFileName)) 788 .format(uiFileName))
775 return 789 return

eric ide

mercurial