示例#1
0
 def printNote(self):
     printer = QPrinter(QPrinter.HighResolution)
     printer.setCreator(__appname__ + ' ' + __version__)
     printer.setDocName(self.notesTree.currentItem().text(0))
     printdialog = QPrintDialog(printer, self)
     if printdialog.exec() == QDialog.Accepted:
         self.notesView.print_(printer)
示例#2
0
 def printNote(self):
     printer = QPrinter(QPrinter.HighResolution)
     printer.setCreator(__appname__ + ' ' + __version__)
     printer.setDocName(self.notesTree.currentItem().text(0))
     printdialog = QPrintDialog(printer, self)
     if printdialog.exec() == QDialog.Accepted:
         self.notesView.print_(printer)
示例#3
0
 def printMail(self):
     printer = QPrinter(mode=QPrinter.HighResolution)
     printer.setCreator("Daaq Mail")
     title = 'Daaq Mail'
     #title = validateFileName(title)
     printer.setDocName(title)
     printer.setOutputFileName(DOC_DIR + title + ".pdf")
     print_dialog = QPrintPreviewDialog(printer, self)
     print_dialog.paintRequested.connect(self.textViewer.print_)
     print_dialog.exec_()
示例#4
0
def print_file(fileName, printFunction):
    """This method print a file

    This method print a file, fileName is the default fileName,
    and printFunction is a funcion that takes a QPrinter
    object and print the file,
    the print method
    More info on:http://doc.qt.nokia.com/latest/printing.html"""

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)

    preview = QPrintPreviewDialog(printer)
    preview.paintRequested[QPrinter].connect(printFunction)
    size = QApplication.instance().desktop().screenGeometry()
    width = size.width() - 100
    height = size.height() - 100
    preview.setMinimumSize(width, height)
    preview.exec_()
示例#5
0
def print_file(fileName, printFunction):
    """This method print a file

    This method print a file, fileName is the default fileName,
    and printFunction is a funcion that takes a QPrinter
    object and print the file,
    the print method
    More info on:http://doc.qt.nokia.com/latest/printing.html"""

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)

    preview = QPrintPreviewDialog(printer)
    preview.paintRequested[QPrinter].connect(printFunction)
    size = QApplication.instance().desktop().screenGeometry()
    width = size.width() - 100
    height = size.height() - 100
    preview.setMinimumSize(width, height)
    preview.exec_()
 def outPrint(
         self, iface, wdg, mdl,
         library):  # Postscript file rendering doesn't work properly yet.
     for i in range(0, mdl.rowCount()):
         if mdl.item(i, 0).data(Qt.CheckStateRole):
             name = str(mdl.item(i, 2).data(Qt.EditRole))
             #return
     fileName = QFileDialog.getSaveFileName(iface.mainWindow(), "Save As",
                                            "Profile of " + name + ".ps",
                                            "PostScript Format (*.ps)")
     if fileName:
         if library == "Qwt5" and has_qwt:
             printer = QPrinter()
             printer.setCreator("QGIS Profile Plugin")
             printer.setDocName("QGIS Profile")
             printer.setOutputFileName(fileName)
             printer.setColorMode(QPrinter.Color)
             printer.setOrientation(QPrinter.Portrait)
             dialog = QPrintDialog(printer)
             if dialog.exec_():
                 wdg.plotWdg.print_(printer)
         elif library == "Matplotlib" and has_mpl:
             wdg.plotWdg.figure.savefig(str(fileName))
示例#7
0
def print_file(fileName, printFunction):
    """This method print a file

    This method print a file, fileName is the default fileName,
    and printFunction is a funcion that takes a QPrinter
    object and print the file,
    the print method
    More info on:http://doc.qt.nokia.com/latest/printing.html"""
    #TODO: Make that the option it's taken from settings. maybe
    #this should be a class to manage all cases?

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)
#PRINT PREVIEW OPTIONS
#TODO: the follow imp. dipatch an error on execution time we need to review
#if the error belongs to qt
#    preview = QPrintPreviewDialog(printer)
#    preview.paintRequested[QPrinter].connect(printFunction)
#    preview.exec_()
    dialog = QPrintDialog(printer)
    if dialog.exec_():
        printFunction(printer)
示例#8
0
def print_file(fileName, printFunction):
    """This method print a file

    This method print a file, fileName is the default fileName,
    and printFunction is a funcion that takes a QPrinter
    object and print the file,
    the print method
    More info on:http://doc.qt.nokia.com/latest/printing.html"""
    #TODO: Make that the option it's taken from settings. maybe
    #this should be a class to manage all cases?

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)
    #PRINT PREVIEW OPTIONS
    #TODO: the follow imp. dipatch an error on execution time we need to review
    #if the error belongs to qt
    #    preview = QPrintPreviewDialog(printer)
    #    preview.paintRequested[QPrinter].connect(printFunction)
    #    preview.exec_()
    dialog = QPrintDialog(printer)
    if dialog.exec_():
        printFunction(printer)
示例#9
0
class GanttPrintHandler(PrintHandler):
    def __init__(self, ganttWidget):
        super(GanttPrintHandler, self).__init__()
        self._printer = None
        self.ganttWidget = ganttWidget
        self._pri = Namespace()

    def printer(self):
        if self._printer is None:
            self._printer = QPrinter(QPrinter.HighResolution)
            self._printer.setOrientation(QtGui.QPrinter.Landscape)
            self._printer.setFullPage(True)
            #self.translate(-15, -15)
        self._printer.setDocName(self.ganttWidget.ganttModel.name)
        return self._printer

    def createPreviewDialog(self, printer):
        return MyPrintPreviewDialog(self.ganttWidget, printer)

    @property
    def horizontalPageCount(self):
        return settings.print.HORIZONTAL_PAGE_COUNT

    def pageCount(self):
        self.preparePrint(self.printer())
        return len(self._pageInfo)

    def preparePrint(self, printer):
        """druckenの前準備。派生クラスでオーバライド"""
        #drucken用のWidgetを用意する
        self._widget = GanttWidget()
        self._widget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._widget.ganttModel = self.ganttWidget.ganttModel

        self._pri = self.getPrintRectInfo(printer)
        self._widget.setGeometry(QRect(0, 0,
            self._pri.log.headerWidth + self._pri.log.bodyWidth,
            self._pri.log.headerHeight + self._pri.log.bodyHeight))

        #各ページの表示範囲を算出する
        self._pageInfo = []
        bh = self._pri.log.bodyHeight
        top = 0
        while bh > 0:
            if bh < self._pri.log.bodyHeightPerPage:
                height = bh
            else:
                height = self._pri.log.bodyHeightPerPage
            #----
            bw = self._pri.log.bodyWidth
            left = 0
            while bw > 0:
                if bw < self._pri.log.bodyWidthPerPage:
                    width = bw
                else:
                    width = self._pri.log.bodyWidthPerPage
                self._pageInfo.append(QRect(left, top, width, height))
                left += width
                bw -= width
            #----
            top += height
            bh -= height
        print("self._pageInfo:", self._pageInfo)

    def getPrintRectInfo(self, printer):
        bodyHeight = 0
        it = QtGui.QTreeWidgetItemIterator(self._widget,
                                    QtGui.QTreeWidgetItemIterator.NotHidden)
        while it.value():
            #rect = self.visualRect(self.indexFromItem(it.value()))
            #rowHeight = self.rowHeight(self.indexFromItem(it.value()))
            #print(rect, rowHeight)
            #visualRect, rowHeightで取得できる高さが実際の行高さよりも小さいので
            #定数値を足し込んでおくことにする
            bodyHeight += ROW_HEIGHT
            it += 1
        obj = Namespace()
        obj.dev = Namespace()
        obj.log = Namespace()
        obj.scl = Namespace()
        print("settings.columnWidth", settings.columnWidth)
        obj.log.headerWidth = settings.getHeaderWidth()
        obj.log.headerHeight = HEADER_HEIGHT
        obj.log.bodyWidth    = self._widget.preferableWidth()
        obj.log.bodyHeight   = bodyHeight
        obj.log.bodyWidthPerPage = obj.log.bodyWidth / self.horizontalPageCount
        obj.log.bodyHeightPerPage = ROW_HEIGHT * settings.print.ROWS_PER_PAGE
        obj.log.pageWidth = obj.log.headerWidth + obj.log.bodyWidthPerPage
        obj.log.pageHeight = obj.log.headerHeight + obj.log.bodyHeightPerPage
        pageRect = printer.pageRect()
        obj.dev.pageWidth = pageRect.width()
        obj.dev.pageHeight = pageRect.height()
        obj.dev.headerWidth = obj.dev.pageWidth * settings.print.HEADER_WIDTH_RATIO
        obj.dev.headerHeight = obj.dev.pageHeight * settings.print.HEADER_HEIGHT_RATIO
        obj.dev.bodyWidth    = obj.dev.pageWidth - obj.dev.headerWidth
        obj.dev.bodyHeight   = obj.dev.pageHeight - obj.dev.headerHeight
        obj.scl.headerWidth = obj.dev.headerWidth / obj.log.headerWidth
        obj.scl.headerHeight = obj.dev.headerHeight / obj.log.headerHeight
        obj.scl.bodyWidth = obj.dev.bodyWidth / obj.log.bodyWidthPerPage
        obj.scl.bodyHeight = obj.dev.bodyHeight / obj.log.bodyHeightPerPage
        #obj.header
        print(obj)
        return obj

    def printPage(self, painter, pageNo, pageCount):
        print("paintRect:", painter.device().pageRect(), painter.device().paperRect())
        painter.save()
        #-----------------------------------------------------------------------
        deviceRect = painter.device().pageRect()
        painter.translate(deviceRect.top(), deviceRect.left())
        #print(deviceRect)
        bodyRect = self._pageInfo[pageNo-1]
        #print(bodyRect)
        #データ部ヘッダ
        rect1 = self.renderDataHeader(painter, bodyRect)
        #データ部本体
        self.renderDataBody(painter, bodyRect)
        #chart部ヘッダ
        self.renderChartHeader(painter, bodyRect)
        #chart部本体
        self.renderChartBody(painter, bodyRect)
        #ページのframe
        painter.setPen(self._widget.pen4chartBoundary)
        log = self._pri.dev
        painter.drawRect(0,0,log.headerWidth,log.headerHeight)
        painter.drawRect(log.headerWidth,0,log.bodyWidth,log.headerHeight)
        painter.drawRect(0,log.headerHeight,log.headerWidth,log.bodyHeight)
        painter.drawRect(
                log.headerWidth,log.headerHeight,log.bodyWidth,log.bodyHeight)
        #-----------------------------------------------------------------------
        painter.restore()

    def renderDataHeader(self, painter, bodyRect):
        """データ部ヘッダ"""
        painter.save()
        #painter.translate(0, 0)
        painter.scale(self._pri.scl.headerWidth, self._pri.scl.headerHeight)
        rect = QRect(0,0,self._pri.log.headerWidth, self._pri.log.headerHeight)
        self._widget.render(painter, sourceRegion=QRegion(rect))
        painter.restore()


    def renderDataBody(self, painter, bodyRect):
        """データ部本体"""
        painter.save()
        painter.translate(0, self._pri.dev.headerHeight)
        painter.scale(self._pri.scl.headerWidth, self._pri.scl.bodyHeight)
        self._widget.render(painter, sourceRegion=QtGui.QRegion(
            0, self._pri.log.headerHeight + bodyRect.top(),
            self._pri.log.headerWidth, bodyRect.height()))
        painter.restore()

    def renderChartHeader(self, painter, bodyRect):
        """chart部ヘッダ"""
        painter.save()
        painter.translate(self._pri.dev.headerWidth, 0)
        painter.scale(self._pri.scl.bodyWidth, self._pri.scl.headerHeight)
        self._widget.render(painter, sourceRegion=QtGui.QRegion(
            self._pri.log.headerWidth + bodyRect.left(), 0,
            bodyRect.width(), self._pri.log.headerHeight))
        painter.restore()

    def renderChartBody(self, painter, bodyRect):
        """chart部本体"""
        painter.save()
        painter.translate(self._pri.dev.headerWidth, self._pri.dev.headerHeight)
        painter.scale(self._pri.scl.bodyWidth, self._pri.scl.bodyHeight)
        self._widget.render(painter, sourceRegion=QtGui.QRegion(
            self._pri.log.headerWidth + bodyRect.left(),
            self._pri.log.headerHeight + bodyRect.top(),
            bodyRect.width(),
            bodyRect.height()))
        painter.restore()
示例#10
0
class MainWindow(QWidget, MainWindowGeneric):

    def __init__(self, parent):
        QWidget.__init__(self)
        MainWindowGeneric.__init__(self)
        self._parent = parent

        self._vbox = QVBoxLayout(self)
        #Splitters
        self.splitterMain = QSplitter()
        self.splitterCentral = QSplitter(Qt.Vertical)
        #Properties Panel
        self._properties = PropertiesWidget(self)
        #Central
        self._central = CentralWidget(self)
        self.show_start_page()
        self.splitterCentral.addWidget(self._central)
        #Display Container
        self.container = DisplayContainer(self)
        self._hide_container()
        self.splitterCentral.addWidget(self.container)
        height = [(self.height() / 3) * 2, self.height() / 3]
        self.splitterCentral.setSizes([height[0], height[1]])
        #Size Central Splitter
        self.splitterMain.addWidget(self.splitterCentral)
        self.splitterMain.addWidget(self._properties)
        width = [(self.width() / 6) * 5, self.width() / 6]
        self.splitterMain.setSizes([width[0], width[1]])
        self._vbox.addWidget(self.splitterMain)

        #flag for reload_file
        self._reloading = False

        #Shortcuts
        shortCloseTab = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self)
        shortNew = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_N), self)
        shortNewProject = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_J), self)
        shortOpen = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_O), self)
        shortOpenProject = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_P), self)
        shortSave = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_S), self)
        shortSaveAll = QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_S), self)
        shortPrint = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_I), self)
        shortRedo = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Y), self)
        shortComment = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_D), self)
        shortHorizontalLine = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_R), self)
        shortTitleComment = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_T), self)
        shortIndentLess = QShortcut(QKeySequence(Qt.SHIFT + Qt.Key_Tab), self)
        shortHideContainer = QShortcut(QKeySequence(Qt.Key_F4), self)
        shortHideEditor = QShortcut(QKeySequence(Qt.Key_F3), self)
        shortHideExplorer = QShortcut(QKeySequence(Qt.Key_F2), self)
        shortRunFile = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_F6), self)
        shortRunProgram = QShortcut(QKeySequence(Qt.Key_F6), self)
        shortHideAll = QShortcut(QKeySequence(Qt.Key_F11), self)
        shortFind = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_F), self)
        shortFindReplace = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_H), self)
        shortHelp = QShortcut(QKeySequence(Qt.Key_F1), self)
        shortSplitHorizontal = QShortcut(QKeySequence(Qt.Key_F10), self)
        shortSplitVertical = QShortcut(QKeySequence(Qt.Key_F9), self)
        shortFollowMode = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_F10), self)
        shortReloadFile = QShortcut(QKeySequence(Qt.Key_F5), self)
        shortShowProjectsTree = QShortcut(QKeySequence(Qt.ALT + Qt.Key_1), self)
        shortShowSymbolsTree = QShortcut(QKeySequence(Qt.ALT + Qt.Key_2), self)
        #Signal -> Slot
        self.connect(shortCloseTab, SIGNAL("activated()"), self.close_actual_tab)
        self.connect(shortNew, SIGNAL("activated()"), self.new_editor)
        self.connect(shortNewProject, SIGNAL("activated()"), self.new_project)
        self.connect(shortOpen, SIGNAL("activated()"), self.open_file)
        self.connect(shortOpenProject, SIGNAL("activated()"), self.open_project_folder)
        self.connect(shortSave, SIGNAL("activated()"), self.save)
        self.connect(shortSaveAll, SIGNAL("activated()"), self.save_project)
        self.connect(shortPrint, SIGNAL("activated()"), self._print_file)
        self.connect(shortComment, SIGNAL("activated()"), lambda: self._central.obtain_editor().comment())
        self.connect(shortIndentLess, SIGNAL("activated()"), lambda: self._central.obtain_editor().indent_less())
        self.connect(shortHorizontalLine, SIGNAL("activated()"), lambda: self._central.obtain_editor().insert_horizontal_line())
        self.connect(shortTitleComment, SIGNAL("activated()"), lambda: self._central.obtain_editor().insert_title_comment())
        self.connect(shortRedo, SIGNAL("activated()"), lambda: self._central.obtain_editor().redo())
        self.connect(shortHideContainer, SIGNAL("activated()"), self._hide_container)
        self.connect(shortHideEditor, SIGNAL("activated()"), self._hide_editor)
        self.connect(shortHideExplorer, SIGNAL("activated()"), self._hide_explorer)
        self.connect(shortRunFile, SIGNAL("activated()"), self._run_code)
        self.connect(shortRunProgram, SIGNAL("activated()"), self._run_program)
        self.connect(shortHideAll, SIGNAL("activated()"), self._hide_all)
        self.connect(shortFind, SIGNAL("activated()"), self._open_find)
        self.connect(shortFindReplace, SIGNAL("activated()"), self._open_find_replace)
        self.connect(shortHelp, SIGNAL("activated()"), self._show_python_doc)
        self.connect(shortSplitHorizontal, SIGNAL("activated()"), lambda: self.split_tab(True))
        self.connect(shortSplitVertical, SIGNAL("activated()"), lambda: self.split_tab(False))
        self.connect(shortFollowMode, SIGNAL("activated()"), self._view_follow_mode)
        self.connect(shortReloadFile, SIGNAL("activated()"), lambda: self.reload_file())
        self.connect(shortShowProjectsTree, SIGNAL("activated()"), self.show_projects_tree)
        self.connect(shortShowSymbolsTree, SIGNAL("activated()"), self.show_symbols_tree)

    def change_window_title(self, title):
        self._parent.setWindowTitle('NINJA-IDE - ' + title)

    def _open_find(self):
        if not self._parent._status.isVisible():
            self._parent._status.show()
        self._parent._status.focus_find(self._central.obtain_editor())

    def _open_find_replace(self):
        if not self._parent._status.isVisible():
            self._parent._status.show()
        self._parent._status.replace_visibility(True)
        self._parent._status.focus_find(self._central.obtain_editor())

    def _print_file(self):
        self.printer = QPrinter(QPrinter.HighResolution)
        self.printer.setPageSize(QPrinter.A4)
        if self._central.obtain_editor().path:
            fileName = manage_files.get_basename(self._central.obtain_editor().path)
            fileName = fileName[:fileName.rfind('.')] + '.pdf'
        else:
            fileName = 'newDocument.pdf'
        self.printer.setOutputFileName(fileName)
        dialog = QPrintDialog(self.printer, self)
        if dialog.exec_():
            self.printer.setDocName(manage_files.get_basename(self._central.obtain_editor().path))
            self._central.obtain_editor().document().print_(self.printer)

    def _hide_container(self):
        if self.containerIsVisible:
            self.container.hide()
            self.containerIsVisible = False
            self._central.obtain_editor().setFocus()
        else:
            self.container.show()
            self.containerIsVisible = True
            self.container.gain_focus()

    def _hide_editor(self):
        if self._central.isVisible():
            self._central.hide()
        else:
            self._central.show()

    def _hide_explorer(self):
        if self._properties.isVisible():
            self._properties.hide()
        else:
            self._properties.show()

    def _splitter_central_orientation(self):
        if self.splitterCentral.orientation() == Qt.Horizontal:
            self.splitterCentral.setOrientation(Qt.Vertical)
        else:
            self.splitterCentral.setOrientation(Qt.Horizontal)

    def get_splitter_central_orientation(self):
        return self.splitterCentral.orientation()

    def _splitter_main_orientation(self):
        if self.splitterMain.orientation() == Qt.Horizontal:
            self.splitterMain.setOrientation(Qt.Vertical)
        else:
            self.splitterMain.setOrientation(Qt.Horizontal)

    def get_splitter_main_orientation(self):
        return self.splitterMain.orientation()

    def _splitter_main_rotate(self):
        w = self.splitterMain.widget(0)
        w1 = self.splitterMain.widget(1)
        if type(w) is PropertiesWidget:
            w.setTabPosition(QTabWidget.East)
        else:
            w1.setTabPosition(QTabWidget.West)
        self.splitterMain.insertWidget(0, w1)
        self.splitterMain.insertWidget(1, w)

    def get_splitter_main_position(self):
        w = self.splitterMain.widget(0)
        return w.__class__

    def _splitter_central_rotate(self):
        w = self.splitterCentral.widget(0)
        w1 = self.splitterCentral.widget(1)
        self.splitterCentral.insertWidget(0, w1)
        self.splitterCentral.insertWidget(1, w)

    def get_splitter_central_position(self):
        w = self.splitterCentral.widget(0)
        return w.__class__

    def get_splitter_position_0(self):
        return type(self.splitterCentral.widget(0))

    def get_splitter_main_position_0(self):
        return type(self.splitterMain.widget(0))

    def reload_panels_position(self):
        self.settings = QSettings('NINJA-IDE', 'Kunai')

        self.settings.beginGroup('Preferences')
        self.settings.beginGroup('Interface')

        #first with the splitterCentral
        c = self.splitterCentral.widget(0)
        c1 = self.splitterCentral.widget(1)
        if (type(c) == CentralWidget):
            self.splitterCentral.insertWidget(self.settings.value('central_tab_position', 0).toInt()[0], c)
            self.splitterCentral.insertWidget(self.settings.value('container_tab_position', 1).toInt()[0], c1)
        else:
            self.splitterCentral.insertWidget(self.settings.value('central_tab_position', 0).toInt()[0], c1)
            self.splitterCentral.insertWidget(self.settings.value('container_tab_position', 1).toInt()[0], c)
        #now with the splitterMain
        m = self.splitterMain.widget(0)
        m1 = self.splitterMain.widget(1)
        if (type(m) == QSplitter):
            self.splitterMain.insertWidget(self.settings.value('central_tab_position', 0).toInt()[0], m)
            self.splitterMain.insertWidget(self.settings.value('container_tab_position', 1).toInt()[0], m1)
        else:
            self.splitterMain.insertWidget(self.settings.value('central_tab_position', 0).toInt()[0], m1)
            self.splitterMain.insertWidget(self.settings.value('container_tab_position', 1).toInt()[0], m)

    def get_open_projects(self):
        return self._properties._treeProjects.get_open_projects()

    def _run_code(self):
        if self.save():
            self.container.show()
            self.containerIsVisible = True
            editor = self._central.obtain_editor()
            ext = self.get_file_extension(editor.path)
            if ext == 'html':
                height = self.height() / 3
                self.splitterCentral.setSizes([height, height * 2])
                self.container.render_web_page(editor.path)
            elif ext == 'py':
                height = self.height() / 3
                self.splitterCentral.setSizes([height * 2, height])
                self.container.run_application(editor.path)
            else:
                self.execute_file(editor.path, ext)

    def _run_program(self, actual=None):
        self.container.show()
        self.containerIsVisible = True
        if actual is None:
            actual = self._properties._treeProjects.actualProject
        if actual is None:
            return
        mainFile = actual.mainFile
        if mainFile == '':
            self._properties._treeProjects.open_project_properties()
            self.containerIsVisible = False
            self.container.hide()
            return
        path = manage_files.create_abs_path(actual.path, mainFile)
        self._central.save_project_files(actual.path)
        lang = actual.lang()
        type_ = actual.projectType
        if lang == 'html':
            height = self.height() / 3
            self.splitterCentral.setSizes([height, height * 2])
            self.container.render_web_page(path)
        elif lang == 'py':
            height = self.height() / 3
            self.splitterCentral.setSizes([height * 2, height])
            self.container.run_application(path, actual.pythonPath)
        else:
            self.execute_program(path, lang, type_)

    def _stop_program(self):
        self.container.kill_application()

    def _hide_all(self):
        if self._properties.isVisible():
            self._properties.hide()
            self.container.hide()
            self._parent._toolbar.hide()
        else:
            if self.containerIsVisible:
                self.container.show()
            self._properties.show()
            self._parent._toolbar.show()

    def show_start_page(self):
        startPage = Browser(resources.start_page_url, None, self)
        self.add_tab(startPage, 'Start Page')

    def show_report_bugs(self):
        bugsPage = Browser(resources.bugs_page)
        self.add_tab(bugsPage, 'Report Bugs!')

    def show_plugins_doc(self):
        bugsPage = Browser(resources.plugins_doc)
        self.add_tab(bugsPage, 'How to Write NINJA-IDE plugins')

    def _show_python_doc(self):
        process = runner.start_pydoc()
        docPage = Browser(process[1], process[0])
        self.add_tab(docPage, 'Python Documentation')

    def new_editor(self, lang='py'):
        if not self._reloading:
            editor = factory_editor(lang, self._central.actual_tab())
            self.add_tab(editor, 'New Document')

    def add_tab(self, component, title):
        self._central.actual_tab().add_tab(component, title)

    def split_tab(self, option):
        if option:
            self._central.show_split(Qt.Horizontal)
        else:
            self._central.show_split(Qt.Vertical)

    def _view_follow_mode(self):
        self._central._show_follow_mode()

    def new_project(self):
        project = WizardNewProject(self)
        project.show()

    def show_preferences(self):
        prefs = PreferencesWindow(self)
        prefs.show()

    def open_document(self, fileName, project=None):
        try:
            if not self._central.actual_tab().is_open(fileName):
                self._central.actual_tab().notOpening = False
                editor = factory_editor(fileName, self._central.actual_tab(), project)
                content = self.read_file_content(fileName)
                editor.setPlainText(content)
                editor.path = fileName
                editor.ask_if_externally_modified = True
                #self.add_tab(editor, self.get_file_name(fileName))
                if not editor.has_write_permission():
                    fileName += ' (Read-Only)'
                self.add_tab(editor, self.get_file_name(fileName))
                self.change_window_title(fileName)
                editor.find_errors_and_check_style()
            else:
                self._central.actual_tab().move_to_open(fileName)
        except Exception, reason:
            print reason
            QMessageBox.information(self, 'Incorrect File', 'The file couldn\'t be open')
        self._central.actual_tab().notOpening = True