Beispiel #1
0
    def __init__(self, main):
        QSplitter.__init__(self)
        CentralGeneric.__init__(self)
        self._main = main

        self._tabs = TabCentralWidget()
        self._tabs2 = TabCentralWidget()
        self.addWidget(self._tabs)
        self.addWidget(self._tabs2)
        self._tabs2.hide()

        shortChangeTab = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Tab), self._main)
        self.connect(shortChangeTab, SIGNAL("activated()"), self.actual_tab().change_tab)
        self.connect(self._tabs, SIGNAL("currentChanged(int)"), self._main._update_window_name)
        self.connect(self._tabs2, SIGNAL("currentChanged(int)"), self._main._update_window_name)
        self.connect(self._tabs, SIGNAL("changeActualTab(QTabWidget)"), self._change_actual)
        self.connect(self._tabs2, SIGNAL("changeActualTab(QTabWidget)"), self._change_actual)
        self.connect(self._tabs, SIGNAL("dropTab(QTabWidget)"), self._move_tab)
        self.connect(self._tabs2, SIGNAL("dropTab(QTabWidget)"), self._move_tab)
        self.connect(self._tabs, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs2, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs, SIGNAL("allTabsClosed()"), self._main.new_editor)
        self.connect(self._tabs2, SIGNAL("allTabsClosed()"), self.tabs2_without_tabs)
        self.connect(self._tabs, SIGNAL("editorFontChanged()"), self.update_editor_font)
        self.connect(self._tabs2, SIGNAL("editorFontChanged()"), self.update_editor_font)
        #refresh file
        self.connect(self._tabs, SIGNAL("emitReloadSignal()"), self._main.reload_file)
        self.connect(self._tabs2, SIGNAL("emitReloadSignal()"), self._main.reload_file)
Beispiel #2
0
    def __init__(self, main):
        QSplitter.__init__(self)
        CentralGeneric.__init__(self)
        self._main = main

        self._tabs = TabCentralWidget()
        self._tabs2 = TabCentralWidget()
        self.addWidget(self._tabs)
        self.addWidget(self._tabs2)
        self._tabs2.hide()

        shortChangeTab = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Tab),
                                   self._main)
        self.connect(shortChangeTab, SIGNAL("activated()"),
                     self.actual_tab().change_tab)
        self.connect(self._tabs, SIGNAL("currentChanged(int)"),
                     self._main._update_window_name)
        self.connect(self._tabs2, SIGNAL("currentChanged(int)"),
                     self._main._update_window_name)
        self.connect(self._tabs, SIGNAL("changeActualTab(QTabWidget)"),
                     self._change_actual)
        self.connect(self._tabs2, SIGNAL("changeActualTab(QTabWidget)"),
                     self._change_actual)
        self.connect(self._tabs, SIGNAL("dropTab(QTabWidget)"), self._move_tab)
        self.connect(self._tabs2, SIGNAL("dropTab(QTabWidget)"),
                     self._move_tab)
        self.connect(self._tabs, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs2, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs, SIGNAL("allTabsClosed()"),
                     self._main.new_editor)
        self.connect(self._tabs2, SIGNAL("allTabsClosed()"),
                     self.tabs2_without_tabs)
        self.connect(self._tabs, SIGNAL("editorFontChanged()"),
                     self.update_editor_font)
        self.connect(self._tabs2, SIGNAL("editorFontChanged()"),
                     self.update_editor_font)
        #refresh file
        self.connect(self._tabs, SIGNAL("emitReloadSignal()"),
                     self._main.reload_file)
        self.connect(self._tabs2, SIGNAL("emitReloadSignal()"),
                     self._main.reload_file)
Beispiel #3
0
class CentralWidget(QSplitter, CentralGeneric):
    def __init__(self, main):
        QSplitter.__init__(self)
        CentralGeneric.__init__(self)
        self._main = main

        self._tabs = TabCentralWidget()
        self._tabs2 = TabCentralWidget()
        self.addWidget(self._tabs)
        self.addWidget(self._tabs2)
        self._tabs2.hide()

        shortChangeTab = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Tab),
                                   self._main)
        self.connect(shortChangeTab, SIGNAL("activated()"),
                     self.actual_tab().change_tab)
        self.connect(self._tabs, SIGNAL("currentChanged(int)"),
                     self._main._update_window_name)
        self.connect(self._tabs2, SIGNAL("currentChanged(int)"),
                     self._main._update_window_name)
        self.connect(self._tabs, SIGNAL("changeActualTab(QTabWidget)"),
                     self._change_actual)
        self.connect(self._tabs2, SIGNAL("changeActualTab(QTabWidget)"),
                     self._change_actual)
        self.connect(self._tabs, SIGNAL("dropTab(QTabWidget)"), self._move_tab)
        self.connect(self._tabs2, SIGNAL("dropTab(QTabWidget)"),
                     self._move_tab)
        self.connect(self._tabs, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs2, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs, SIGNAL("allTabsClosed()"),
                     self._main.new_editor)
        self.connect(self._tabs2, SIGNAL("allTabsClosed()"),
                     self.tabs2_without_tabs)
        self.connect(self._tabs, SIGNAL("editorFontChanged()"),
                     self.update_editor_font)
        self.connect(self._tabs2, SIGNAL("editorFontChanged()"),
                     self.update_editor_font)
        #refresh file
        self.connect(self._tabs, SIGNAL("emitReloadSignal()"),
                     self._main.reload_file)
        self.connect(self._tabs2, SIGNAL("emitReloadSignal()"),
                     self._main.reload_file)

    def tabs2_without_tabs(self):
        self.show_split(self.orientation())
        if self._tabs.count() == 0:
            self._main.new_editor()

    def update_editor_font(self):
        self._tabs.set_editor_font()
        self._tabs2.set_editor_font()

    def show_split(self, orientation):
        if self._tabs2.isVisible() and orientation == self.orientation():
            self._tabs2.hide()
            for i in xrange(self._tabs2.count()):
                editor = self._tabs2.obtain_editor()
                editor.parent = self._tabs
                name = self._tabs2.tabText(i)
                self._tabs.add_tab(editor, name)
                if editor.textModified:
                    self._tabs.mark_as_changed(True)
            self._mainTabSelected = True
        elif not self._tabs2.isVisible():
            editor = self._tabs.obtain_editor()
            editor.parent = self._tabs2
            name = self._tabs.tabText(self._tabs.currentIndex())
            self._tabs2.add_tab(editor, name)
            if editor.textModified:
                self._tabs2.mark_as_changed(True)
            self._tabs2.show()
            self.setSizes([1, 1])
            self._mainTabSelected = False
        self.setOrientation(orientation)

    def _move_tab(self, tab):
        if tab == self._tabs2:
            editor = self._tabs.obtain_editor()
            editor.parent = self._tabs2
            name = self._tabs.tabText(self._tabs.currentIndex())
            self._tabs2.add_tab(editor, name)
            if editor.textModified:
                self._tabs2.mark_as_changed(True)
        else:
            editor = self._tabs2.obtain_editor()
            if editor is not None:
                editor.parent = self._tabs
                name = self._tabs2.tabText(self._tabs2.currentIndex())
                self._tabs.add_tab(editor, name)
                if editor.textModified:
                    self._tabs.mark_as_changed(True)

    def check_for_unsaved(self):
        return self._tabs.check_for_unsaved() or self._tabs2.check_for_unsaved(
        )

    def save_project_files(self, path):
        for i in xrange(self._tabs.count()):
            editor = self._tabs.widget(i)
            fileName = editor.path if editor != 0 else ' '
            if fileName.startswith(path) and type(editor) == Editor:
                self._tabs.setCurrentIndex(i)
                self._main.save()
Beispiel #4
0
class CentralWidget(QSplitter, CentralGeneric):

    def __init__(self, main):
        QSplitter.__init__(self)
        CentralGeneric.__init__(self)
        self._main = main

        self._tabs = TabCentralWidget()
        self._tabs2 = TabCentralWidget()
        self.addWidget(self._tabs)
        self.addWidget(self._tabs2)
        self._tabs2.hide()

        shortChangeTab = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Tab), self._main)
        self.connect(shortChangeTab, SIGNAL("activated()"), self.actual_tab().change_tab)
        self.connect(self._tabs, SIGNAL("currentChanged(int)"), self._main._update_window_name)
        self.connect(self._tabs2, SIGNAL("currentChanged(int)"), self._main._update_window_name)
        self.connect(self._tabs, SIGNAL("changeActualTab(QTabWidget)"), self._change_actual)
        self.connect(self._tabs2, SIGNAL("changeActualTab(QTabWidget)"), self._change_actual)
        self.connect(self._tabs, SIGNAL("dropTab(QTabWidget)"), self._move_tab)
        self.connect(self._tabs2, SIGNAL("dropTab(QTabWidget)"), self._move_tab)
        self.connect(self._tabs, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs2, SIGNAL("emitSaveSignal()"), self._main.save)
        self.connect(self._tabs, SIGNAL("allTabsClosed()"), self._main.new_editor)
        self.connect(self._tabs2, SIGNAL("allTabsClosed()"), self.tabs2_without_tabs)
        self.connect(self._tabs, SIGNAL("editorFontChanged()"), self.update_editor_font)
        self.connect(self._tabs2, SIGNAL("editorFontChanged()"), self.update_editor_font)
        #refresh file
        self.connect(self._tabs, SIGNAL("emitReloadSignal()"), self._main.reload_file)
        self.connect(self._tabs2, SIGNAL("emitReloadSignal()"), self._main.reload_file)

    def tabs2_without_tabs(self):
        self.show_split(self.orientation())
        if self._tabs.count() == 0:
            self._main.new_editor()

    def update_editor_font(self):
        self._tabs.set_editor_font()
        self._tabs2.set_editor_font()

    def show_split(self, orientation):
        if self._tabs2.isVisible() and orientation == self.orientation():
            self._tabs2.hide()
            for i in xrange(self._tabs2.count()):
                editor = self._tabs2.obtain_editor()
                editor.parent = self._tabs
                name = self._tabs2.tabText(i)
                self._tabs.add_tab(editor, name)
                if editor.textModified:
                    self._tabs.mark_as_changed(True)
            self._mainTabSelected = True
        elif not self._tabs2.isVisible():
            editor = self._tabs.obtain_editor()
            editor.parent = self._tabs2
            name = self._tabs.tabText(self._tabs.currentIndex())
            self._tabs2.add_tab(editor, name)
            if editor.textModified:
                self._tabs2.mark_as_changed(True)
            self._tabs2.show()
            self.setSizes([1, 1])
            self._mainTabSelected = False
        self.setOrientation(orientation)

    def _move_tab(self, tab):
        if tab == self._tabs2:
            editor = self._tabs.obtain_editor()
            editor.parent = self._tabs2
            name = self._tabs.tabText(self._tabs.currentIndex())
            self._tabs2.add_tab(editor, name)
            if editor.textModified:
                self._tabs2.mark_as_changed(True)
        else:
            editor = self._tabs2.obtain_editor()
            if editor is not None:
                editor.parent = self._tabs
                name = self._tabs2.tabText(self._tabs2.currentIndex())
                self._tabs.add_tab(editor, name)
                if editor.textModified:
                    self._tabs.mark_as_changed(True)

    def check_for_unsaved(self):
        return self._tabs.check_for_unsaved() or self._tabs2.check_for_unsaved()

    def save_project_files(self, path):
        for i in xrange(self._tabs.count()):
            editor = self._tabs.widget(i)
            fileName = editor.path if editor != 0 else ' '
            if fileName.startswith(path) and type(editor) == Editor:
                self._tabs.setCurrentIndex(i)
                self._main.save()