74 |
74 |
75 languageSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) |
75 languageSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) |
76 self.languageLayout.addItem(languageSpacer) |
76 self.languageLayout.addItem(languageSpacer) |
77 self.TRPreviewerLayout.addLayout(self.languageLayout) |
77 self.TRPreviewerLayout.addLayout(self.languageLayout) |
78 |
78 |
79 self.preview = WidgetWorkspace(self.cw) |
79 self.preview = WidgetArea(self.cw) |
80 self.preview.setObjectName("preview") |
80 self.preview.setObjectName("preview") |
81 self.TRPreviewerLayout.addWidget(self.preview) |
81 self.TRPreviewerLayout.addWidget(self.preview) |
82 self.preview.lastWidgetClosed.connect(self.__updateActions) |
82 self.preview.lastWidgetClosed.connect(self.__updateActions) |
83 |
83 |
84 self.setCentralWidget(self.cw) |
84 self.setCentralWidget(self.cw) |
211 self.tileAct.setStatusTip(self.trUtf8('Tile the windows')) |
211 self.tileAct.setStatusTip(self.trUtf8('Tile the windows')) |
212 self.tileAct.setWhatsThis(self.trUtf8( |
212 self.tileAct.setWhatsThis(self.trUtf8( |
213 """<b>Tile the windows</b>""" |
213 """<b>Tile the windows</b>""" |
214 """<p>Rearrange and resize the windows so that they are tiled.</p>""" |
214 """<p>Rearrange and resize the windows so that they are tiled.</p>""" |
215 )) |
215 )) |
216 self.tileAct.triggered[()].connect(self.preview.tile) |
216 self.tileAct.triggered[()].connect(self.preview.tileSubWindows) |
217 |
217 |
218 self.cascadeAct = QAction(self.trUtf8('&Cascade'), self) |
218 self.cascadeAct = QAction(self.trUtf8('&Cascade'), self) |
219 self.cascadeAct.setStatusTip(self.trUtf8('Cascade the windows')) |
219 self.cascadeAct.setStatusTip(self.trUtf8('Cascade the windows')) |
220 self.cascadeAct.setWhatsThis(self.trUtf8( |
220 self.cascadeAct.setWhatsThis(self.trUtf8( |
221 """<b>Cascade the windows</b>""" |
221 """<b>Cascade the windows</b>""" |
222 """<p>Rearrange and resize the windows so that they are cascaded.</p>""" |
222 """<p>Rearrange and resize the windows so that they are cascaded.</p>""" |
223 )) |
223 )) |
224 self.cascadeAct.triggered[()].connect(self.preview.cascade) |
224 self.cascadeAct.triggered[()].connect(self.preview.cascadeSubWindows) |
225 |
225 |
226 self.closeAct = QAction(UI.PixmapCache.getIcon("close.png"), |
226 self.closeAct = QAction(UI.PixmapCache.getIcon("close.png"), |
227 self.trUtf8('&Close'), self) |
227 self.trUtf8('&Close'), self) |
228 self.closeAct.setShortcut(QKeySequence(self.trUtf8("Ctrl+W","File|Close"))) |
228 self.closeAct.setShortcut(QKeySequence(self.trUtf8("Ctrl+W","File|Close"))) |
229 self.closeAct.setStatusTip(self.trUtf8('Close the current window')) |
229 self.closeAct.setStatusTip(self.trUtf8('Close the current window')) |
699 """ |
699 """ |
700 Private method to schedule a rebuild of the widget. |
700 Private method to schedule a rebuild of the widget. |
701 """ |
701 """ |
702 self.__timer.start(0) |
702 self.__timer.start(0) |
703 |
703 |
704 class WidgetWorkspace(QWorkspace): |
704 class WidgetArea(QMdiArea): |
705 """ |
705 """ |
706 Specialized workspace to show the loaded widgets. |
706 Specialized MDI area to show the loaded widgets. |
707 |
707 |
708 @signal lastWidgetClosed() emitted after last widget was closed |
708 @signal lastWidgetClosed() emitted after last widget was closed |
709 """ |
709 """ |
710 lastWidgetClosed = pyqtSignal() |
710 lastWidgetClosed = pyqtSignal() |
711 rebuildWidgets = pyqtSignal() |
711 rebuildWidgets = pyqtSignal() |
714 """ |
714 """ |
715 Constructor |
715 Constructor |
716 |
716 |
717 @param parent parent widget (QWidget) |
717 @param parent parent widget (QWidget) |
718 """ |
718 """ |
719 QWorkspace.__init__(self, parent) |
719 QMdiArea.__init__(self, parent) |
720 |
720 |
721 self.setScrollBarsEnabled(True) |
721 self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) |
|
722 self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) |
722 |
723 |
723 self.widgets = [] |
724 self.widgets = [] |
724 |
725 |
725 def loadWidget(self, uiFileName): |
726 def loadWidget(self, uiFileName): |
726 """ |
727 """ |
727 Public slot to load a UI file. |
728 Public slot to load a UI file. |
728 |
729 |
729 @param uiFileName name of the UI file to load (string) |
730 @param uiFileName name of the UI file to load (string) |
730 """ |
731 """ |
731 widget = self.__findWidget(uiFileName) |
732 wview = self.__findWidget(uiFileName) |
732 if widget is None: |
733 if wview is None: |
733 name = os.path.basename(uiFileName) |
734 name = os.path.basename(uiFileName) |
734 if not name: |
735 if not name: |
735 QMessageBox.warning(None, |
736 QMessageBox.warning(None, |
736 self.trUtf8("Load UI File"), |
737 self.trUtf8("Load UI File"), |
737 self.trUtf8("""<p>The file <b>{0}</b> could not be loaded.</p>""")\ |
738 self.trUtf8("""<p>The file <b>{0}</b> could not be loaded.</p>""")\ |
752 return |
753 return |
753 |
754 |
754 self.rebuildWidgets.connect(wview.buildWidget) |
755 self.rebuildWidgets.connect(wview.buildWidget) |
755 wview.installEventFilter(self) |
756 wview.installEventFilter(self) |
756 |
757 |
757 self.addWindow(wview) |
758 win = self.addSubWindow(wview) |
758 self.widgets.append(wview) |
759 self.widgets.append(win) |
759 |
760 |
760 wview.showNormal() |
761 wview.showNormal() |
761 |
762 |
762 def eventFilter(self, obj, ev): |
763 def eventFilter(self, obj, ev): |
763 """ |
764 """ |
834 Public method to handle the toggle of a window. |
835 Public method to handle the toggle of a window. |
835 |
836 |
836 @param act reference to the action that triggered (QAction) |
837 @param act reference to the action that triggered (QAction) |
837 """ |
838 """ |
838 idx = act.data() |
839 idx = act.data() |
839 self.__toggleWidget(self.widgets[idx]) |
840 if idx is not None: |
|
841 self.__toggleWidget(self.widgets[idx]) |
840 |
842 |
841 def __toggleWidget(self, w): |
843 def __toggleWidget(self, w): |
842 """ |
844 """ |
843 Private method to toggle a workspace window. |
845 Private method to toggle a workspace window. |
844 |
846 |