Esempio n. 1
0
 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)
Esempio n. 2
0
    def save(self):
        editor = self._central.obtain_editor()
        try:
            if editor.newDocument or not editor.has_write_permission():
                return self.save_as()

            fileName = editor.path
            fileName = self.store_file_content(fileName, editor.get_text())
            self._central.actual_tab().setTabText(self._central.actual_tab().currentIndex(),
                self.get_file_name(fileName))
            editor.register_syntax(fileName)
            self.change_window_title(fileName)
            editor.path = fileName
            self._central.actual_tab().mark_as_saved()
            editor.ask_if_externally_modified = True
            self.emit(SIGNAL("fileSaved(QString)"), 'File Saved: ' + fileName)
            editor.find_errors_and_check_style()
            self._properties._treeSymbols.refresh(manage_files.get_folder(fileName),
                manage_files.get_basename(fileName))
            return True
        except Exception, reason:
            print reason
            QMessageBox.information(self, 'Save Error', "The file couldn't be saved!")
            return False
Esempio n. 3
0
    def __init__(self, parent, item):
        QDialog.__init__(self, parent)
        self.setModal(True)
        self._item = item
        self.setWindowTitle('Project Properties')
        grid = QGridLayout(self)
        grid.addWidget(QLabel('Name:'), 0, 0)
        self.name = QLineEdit()
        if self._item.name == '':
            self.name.setText(manage_files.get_basename(self._item.path))
        else:
            self.name.setText(self._item.name)
        grid.addWidget(self.name, 0, 1)
        grid.addWidget(QLabel('Project Type:'), 1, 0)
        self.txtType = TextProjectType()
        self.txtType.setText(self._item.projectType)
        grid.addWidget(self.txtType, 1, 1)
        grid.addWidget(QLabel('Description:'), 2, 0)
        self.description = QPlainTextEdit()
        self.description.setPlainText(self._item.description)
        grid.addWidget(self.description, 2, 1)
        grid.addWidget(QLabel('URL:'), 3, 0)
        self.url = QLineEdit()
        self.url.setText(self._item.url)
        grid.addWidget(self.url, 3, 1)
        grid.addWidget(QLabel('Licence:'), 4, 0)
        self.cboLicense = QComboBox()
        self.cboLicense.addItem('Apache License 2.0')
        self.cboLicense.addItem('Artistic License/GPL')
        self.cboLicense.addItem('Eclipse Public License 1.0')
        self.cboLicense.addItem('GNU General Public License v2')
        self.cboLicense.addItem('GNU General Public License v3')
        self.cboLicense.addItem('GNU Lesser General Public License')
        self.cboLicense.addItem('MIT License')
        self.cboLicense.addItem('Mozilla Public License 1.1')
        self.cboLicense.addItem('New BSD License')
        self.cboLicense.addItem('Other Open Source')
        self.cboLicense.addItem('Other')
        self.cboLicense.setCurrentIndex(4)
        index = self.cboLicense.findText(self._item.license)
        self.cboLicense.setCurrentIndex(index)
        grid.addWidget(self.cboLicense, 4, 1)
        grid.addWidget(QLabel('Main File:'), 5, 0)
        self.path = QLineEdit()
        self.path.setText(self._item.mainFile)
        self.path.setReadOnly(True)
        self.btnBrowse = QPushButton('Browse')
        hbox = QHBoxLayout()
        hbox.addWidget(self.path)
        hbox.addWidget(self.btnBrowse)
        grid.addLayout(hbox, 5, 1)

        self.txtExtensions = QLineEdit()
        self.txtExtensions.setText(str(', '.join(self._item.extensions)))
        grid.addWidget(QLabel('Supported Extensions:'), 6, 0)
        grid.addWidget(self.txtExtensions, 6, 1)

        self.txtPythonPath = QLineEdit()
        self.txtPythonPath.setText(self._item.pythonPath)
        self.btnPythonPath = QPushButton(QIcon(resources.images['open']), '')
        grid.addWidget(QLabel('Python Path:'), 7, 0)
        grid.addWidget(self.txtPythonPath, 7, 1)
        grid.addWidget(self.btnPythonPath, 7, 2)

        self.btnSave = QPushButton('Save')
        self.btnCancel = QPushButton('Cancel')
        hbox3 = QHBoxLayout()
        hbox3.addWidget(self.btnCancel)
        hbox3.addWidget(self.btnSave)
        grid.addLayout(hbox3, 8, 1)

        self.connect(self.btnBrowse, SIGNAL("clicked()"), self.select_file)
        self.connect(self.btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(self.btnSave, SIGNAL("clicked()"), self.save_properties)
        self.connect(self.btnPythonPath, SIGNAL("clicked()"), self._load_python_path)