21 import UI.Config |
21 import UI.Config |
22 |
22 |
23 |
23 |
24 noTranslationName = QApplication.translate("TRPreviewer", "<No translation>") |
24 noTranslationName = QApplication.translate("TRPreviewer", "<No translation>") |
25 |
25 |
|
26 |
26 class TRPreviewer(QMainWindow): |
27 class TRPreviewer(QMainWindow): |
27 """ |
28 """ |
28 Class implementing the UI Previewer main window. |
29 Class implementing the UI Previewer main window. |
29 """ |
30 """ |
30 def __init__(self, filenames = [], parent = None, name = None): |
31 def __init__(self, filenames=[], parent=None, name=None): |
31 """ |
32 """ |
32 Constructor |
33 Constructor |
33 |
34 |
34 @param filenames filenames of form and/or translation files to load |
35 @param filenames filenames of form and/or translation files to load |
35 @param parent parent widget of this window (QWidget) |
36 @param parent parent widget of this window (QWidget) |
139 |
140 |
140 def __initActions(self): |
141 def __initActions(self): |
141 """ |
142 """ |
142 Private method to define the user interface actions. |
143 Private method to define the user interface actions. |
143 """ |
144 """ |
144 self.openUIAct = QAction(UI.PixmapCache.getIcon("openUI.png"), |
145 self.openUIAct = QAction(UI.PixmapCache.getIcon("openUI.png"), |
145 self.trUtf8('&Open UI Files...'), self) |
146 self.trUtf8('&Open UI Files...'), self) |
146 self.openUIAct.setStatusTip(self.trUtf8('Open UI files for display')) |
147 self.openUIAct.setStatusTip(self.trUtf8('Open UI files for display')) |
147 self.openUIAct.setWhatsThis(self.trUtf8( |
148 self.openUIAct.setWhatsThis(self.trUtf8( |
148 """<b>Open UI Files</b>""" |
149 """<b>Open UI Files</b>""" |
149 """<p>This opens some UI files for display.</p>""" |
150 """<p>This opens some UI files for display.</p>""" |
150 )) |
151 )) |
151 self.openUIAct.triggered[()].connect(self.__openWidget) |
152 self.openUIAct.triggered[()].connect(self.__openWidget) |
152 |
153 |
153 self.openQMAct = QAction(UI.PixmapCache.getIcon("openQM.png"), |
154 self.openQMAct = QAction(UI.PixmapCache.getIcon("openQM.png"), |
154 self.trUtf8('Open &Translation Files...'), self) |
155 self.trUtf8('Open &Translation Files...'), self) |
155 self.openQMAct.setStatusTip(self.trUtf8('Open Translation files for display')) |
156 self.openQMAct.setStatusTip(self.trUtf8('Open Translation files for display')) |
156 self.openQMAct.setWhatsThis(self.trUtf8( |
157 self.openQMAct.setWhatsThis(self.trUtf8( |
157 """<b>Open Translation Files</b>""" |
158 """<b>Open Translation Files</b>""" |
158 """<p>This opens some translation files for display.</p>""" |
159 """<p>This opens some translation files for display.</p>""" |
159 )) |
160 )) |
160 self.openQMAct.triggered[()].connect(self.__openTranslation) |
161 self.openQMAct.triggered[()].connect(self.__openTranslation) |
161 |
162 |
162 self.reloadAct = QAction(UI.PixmapCache.getIcon("reload.png"), |
163 self.reloadAct = QAction(UI.PixmapCache.getIcon("reload.png"), |
163 self.trUtf8('&Reload Translations'), self) |
164 self.trUtf8('&Reload Translations'), self) |
164 self.reloadAct.setStatusTip(self.trUtf8('Reload the loaded translations')) |
165 self.reloadAct.setStatusTip(self.trUtf8('Reload the loaded translations')) |
165 self.reloadAct.setWhatsThis(self.trUtf8( |
166 self.reloadAct.setWhatsThis(self.trUtf8( |
166 """<b>Reload Translations</b>""" |
167 """<b>Reload Translations</b>""" |
167 """<p>This reloads the translations for the loaded languages.</p>""" |
168 """<p>This reloads the translations for the loaded languages.</p>""" |
168 )) |
169 )) |
169 self.reloadAct.triggered[()].connect(self.translations.reload) |
170 self.reloadAct.triggered[()].connect(self.translations.reload) |
170 |
171 |
171 self.exitAct = QAction(UI.PixmapCache.getIcon("exit.png"), |
172 self.exitAct = QAction(UI.PixmapCache.getIcon("exit.png"), |
172 self.trUtf8('&Quit'), self) |
173 self.trUtf8('&Quit'), self) |
173 self.exitAct.setShortcut(QKeySequence(self.trUtf8("Ctrl+Q","File|Quit"))) |
174 self.exitAct.setShortcut(QKeySequence(self.trUtf8("Ctrl+Q", "File|Quit"))) |
174 self.exitAct.setStatusTip(self.trUtf8('Quit the application')) |
175 self.exitAct.setStatusTip(self.trUtf8('Quit the application')) |
175 self.exitAct.setWhatsThis(self.trUtf8( |
176 self.exitAct.setWhatsThis(self.trUtf8( |
176 """<b>Quit</b>""" |
177 """<b>Quit</b>""" |
177 """<p>Quit the application.</p>""" |
178 """<p>Quit the application.</p>""" |
178 )) |
179 )) |
225 )) |
226 )) |
226 self.cascadeAct.triggered[()].connect(self.preview.cascadeSubWindows) |
227 self.cascadeAct.triggered[()].connect(self.preview.cascadeSubWindows) |
227 |
228 |
228 self.closeAct = QAction(UI.PixmapCache.getIcon("close.png"), |
229 self.closeAct = QAction(UI.PixmapCache.getIcon("close.png"), |
229 self.trUtf8('&Close'), self) |
230 self.trUtf8('&Close'), self) |
230 self.closeAct.setShortcut(QKeySequence(self.trUtf8("Ctrl+W","File|Close"))) |
231 self.closeAct.setShortcut(QKeySequence(self.trUtf8("Ctrl+W", "File|Close"))) |
231 self.closeAct.setStatusTip(self.trUtf8('Close the current window')) |
232 self.closeAct.setStatusTip(self.trUtf8('Close the current window')) |
232 self.closeAct.setWhatsThis(self.trUtf8( |
233 self.closeAct.setWhatsThis(self.trUtf8( |
233 """<b>Close Window</b>""" |
234 """<b>Close Window</b>""" |
234 """<p>Close the current window.</p>""" |
235 """<p>Close the current window.</p>""" |
235 )) |
236 )) |
422 QObject.__init__(self, parent) |
425 QObject.__init__(self, parent) |
423 |
426 |
424 self.selector = selector |
427 self.selector = selector |
425 self.currentTranslator = None |
428 self.currentTranslator = None |
426 self.selector.addItem(noTranslationName) |
429 self.selector.addItem(noTranslationName) |
427 self.translations = [] # list of Translation objects |
430 self.translations = [] # list of Translation objects |
428 |
431 |
429 def add(self, fileName, setTranslation = True): |
432 def add(self, fileName, setTranslation=True): |
430 """ |
433 """ |
431 Public method to add a translation to the list. |
434 Public method to add a translation to the list. |
432 |
435 |
433 If the translation file (*.qm) has not been loaded yet, it will |
436 If the translation file (*.qm) has not been loaded yet, it will |
434 be loaded automatically. |
437 be loaded automatically. |
622 |
625 |
623 @return flag signaling if any translation was loaded (boolean) |
626 @return flag signaling if any translation was loaded (boolean) |
624 """ |
627 """ |
625 return len(self.translations) > 0 |
628 return len(self.translations) > 0 |
626 |
629 |
|
630 |
627 class WidgetView(QWidget): |
631 class WidgetView(QWidget): |
628 """ |
632 """ |
629 Class to show a dynamically loaded widget (or dialog). |
633 Class to show a dynamically loaded widget (or dialog). |
630 """ |
634 """ |
631 def __init__(self, uiFileName, parent = None, name = None): |
635 def __init__(self, uiFileName, parent=None, name=None): |
632 """ |
636 """ |
633 Constructor |
637 Constructor |
634 |
638 |
635 @param uiFileName name of the UI file to load (string) |
639 @param uiFileName name of the UI file to load (string) |
636 @param parent parent widget (QWidget) |
640 @param parent parent widget (QWidget) |
701 """ |
705 """ |
702 Private method to schedule a rebuild of the widget. |
706 Private method to schedule a rebuild of the widget. |
703 """ |
707 """ |
704 self.__timer.start(0) |
708 self.__timer.start(0) |
705 |
709 |
|
710 |
706 class WidgetArea(QMdiArea): |
711 class WidgetArea(QMdiArea): |
707 """ |
712 """ |
708 Specialized MDI area to show the loaded widgets. |
713 Specialized MDI area to show the loaded widgets. |
709 |
714 |
710 @signal lastWidgetClosed() emitted after last widget was closed |
715 @signal lastWidgetClosed() emitted after last widget was closed |
711 """ |
716 """ |
712 lastWidgetClosed = pyqtSignal() |
717 lastWidgetClosed = pyqtSignal() |
713 rebuildWidgets = pyqtSignal() |
718 rebuildWidgets = pyqtSignal() |
714 |
719 |
715 def __init__(self, parent = None): |
720 def __init__(self, parent=None): |
716 """ |
721 """ |
717 Constructor |
722 Constructor |
718 |
723 |
719 @param parent parent widget (QWidget) |
724 @param parent parent widget (QWidget) |
720 """ |
725 """ |