Exemple #1
0
    def __init__(self, parent, fileName, previewState=PreviewDisabled):
        QObject.__init__(self, parent)
        self.p = parent
        self.fileName = fileName
        self.editBox = ReTextEdit(self)
        self.previewBox = self.createPreviewBox(self.editBox)
        self.markup = self.getMarkup()
        self.previewState = previewState
        self.previewBlocked = False

        textDocument = self.editBox.document()
        self.highlighter = ReTextHighlighter(textDocument)
        if enchant_available and parent.actionEnableSC.isChecked():
            self.highlighter.dictionary = enchant.Dict(parent.sl or None)
            self.highlighter.rehighlight()
        self.highlighter.docType = self.markup.name

        self.editBox.textChanged.connect(self.updateLivePreviewBox)
        self.editBox.undoAvailable.connect(parent.actionUndo.setEnabled)
        self.editBox.redoAvailable.connect(parent.actionRedo.setEnabled)
        self.editBox.copyAvailable.connect(parent.actionCopy.setEnabled)

        textDocument.modificationChanged.connect(parent.modificationChanged)

        self.updateBoxesVisibility()
Exemple #2
0
	def createTab(self, fileName):
		self.previewBlocked = False
		self.editBoxes.append(ReTextEdit(self))
		self.highlighters.append(ReTextHighlighter(self.editBoxes[-1].document()))
		if enchant_available and self.actionEnableSC.isChecked():
			self.highlighters[-1].dictionary = \
			enchant.Dict(self.sl) if self.sl else enchant.Dict()
			self.highlighters[-1].rehighlight()
		if self.useWebKit:
			self.previewBoxes.append(self.getWebView())
		else:
			self.previewBoxes.append(QTextBrowser())
			self.previewBoxes[-1].setOpenExternalLinks(True)
		self.previewBoxes[-1].setVisible(False)
		self.fileNames.append(fileName)
		markupClass = self.getMarkupClass(fileName)
		self.markups.append(self.getMarkup(fileName))
		self.highlighters[-1].docType = (markupClass.name if markupClass else '')
		liveMode = self.restorePreviewState and self.livePreviewEnabled
		self.apc.append(liveMode)
		self.alpc.append(liveMode)
		self.aptc.append(False)
		metrics = QFontMetrics(self.editBoxes[-1].font())
		self.editBoxes[-1].setTabStopWidth(self.tabWidth*metrics.width(' '))
		self.connect(self.editBoxes[-1], SIGNAL('textChanged()'), self.updateLivePreviewBox)
		self.connect(self.editBoxes[-1], SIGNAL('undoAvailable(bool)'), self.actionUndo,
			SLOT('setEnabled(bool)'))
		self.connect(self.editBoxes[-1], SIGNAL('redoAvailable(bool)'), self.actionRedo,
			SLOT('setEnabled(bool)'))
		self.connect(self.editBoxes[-1], SIGNAL('copyAvailable(bool)'), self.enableCopy)
		self.connect(self.editBoxes[-1].document(), SIGNAL('modificationChanged(bool)'),
			self.modificationChanged)
		return self.getSplitter(-1)
Exemple #3
0
	def createTab(self, fileName):
		self.previewBlocked = False
		self.editBoxes.append(ReTextEdit(self))
		self.highlighters.append(ReTextHighlighter(self.editBoxes[-1].document()))
		if enchant_available and self.actionEnableSC.isChecked():
			self.highlighters[-1].dictionary = \
			enchant.Dict(self.sl) if self.sl else enchant.Dict()
			self.highlighters[-1].rehighlight()
		if globalSettings.useWebKit:
			self.previewBoxes.append(self.getWebView())
		else:
			self.previewBoxes.append(QTextBrowser())
			self.previewBoxes[-1].setOpenExternalLinks(True)
		self.previewBoxes[-1].setVisible(False)
		self.fileNames.append(fileName)
		markupClass = self.getMarkupClass(fileName)
		self.markups.append(self.getMarkup(fileName))
		self.highlighters[-1].docType = (markupClass.name if markupClass else '')
		liveMode = globalSettings.restorePreviewState and globalSettings.previewState
		self.actionPreviewChecked.append(liveMode)
		self.actionLivePreviewChecked.append(liveMode)
		metrics = QFontMetrics(self.editBoxes[-1].font())
		self.editBoxes[-1].setTabStopWidth(globalSettings.tabWidth * metrics.width(' '))
		self.editBoxes[-1].textChanged.connect(self.updateLivePreviewBox)
		self.editBoxes[-1].undoAvailable.connect(self.actionUndo.setEnabled)
		self.editBoxes[-1].redoAvailable.connect(self.actionRedo.setEnabled)
		self.editBoxes[-1].copyAvailable.connect(self.enableCopy)
		self.editBoxes[-1].document().modificationChanged.connect(self.modificationChanged)
		if globalSettings.useFakeVim:
			self.installFakeVimHandler(self.editBoxes[-1])
		return self.getSplitter(-1)
Exemple #4
0
 def __init__(self, parent=None):
     QDialog.__init__(self, parent)
     self.resize(700, 600)
     verticalLayout = QVBoxLayout(self)
     self.textEdit = QTextEdit(self)
     self.textEdit.setReadOnly(True)
     self.textEdit.setFont(globalSettings.editorFont)
     self.hl = ReTextHighlighter(self.textEdit.document())
     self.hl.docType = 'html'
     verticalLayout.addWidget(self.textEdit)
     buttonBox = QDialogButtonBox(self)
     buttonBox.setStandardButtons(QDialogButtonBox.Close)
     buttonBox.rejected.connect(self.close)
     verticalLayout.addWidget(buttonBox)
Exemple #5
0
 def __init__(self, parent=None):
     QDialog.__init__(self, parent)
     self.resize(700, 600)
     self.verticalLayout = QVBoxLayout(self)
     self.textEdit = QTextEdit(self)
     self.textEdit.setReadOnly(True)
     self.textEdit.setFont(monofont)
     hl = ReTextHighlighter(self.textEdit.document())
     hl.docType = DOCTYPE_HTML
     self.verticalLayout.addWidget(self.textEdit)
     self.buttonBox = QDialogButtonBox(self)
     self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
     self.connect(self.buttonBox, SIGNAL("clicked(QAbstractButton*)"),
                  self.doClose)
     self.verticalLayout.addWidget(self.buttonBox)
Exemple #6
0
    def __init__(self,
                 parent,
                 fileName,
                 defaultMarkup,
                 previewState=PreviewDisabled):
        super(QSplitter, self).__init__(Qt.Horizontal, parent=parent)
        self.p = parent
        self._fileName = fileName
        self.editBox = ReTextEdit(self)
        self.previewBox = self.createPreviewBox(self.editBox)
        self.defaultMarkupClass = defaultMarkup
        self.activeMarkupClass = None
        self.markup = None
        self.converted = None
        self.previewState = previewState
        self.previewOutdated = False
        self.conversionPending = False

        self.converterProcess = converterprocess.ConverterProcess()
        self.converterProcess.conversionDone.connect(self.updatePreviewBox)

        textDocument = self.editBox.document()
        self.highlighter = ReTextHighlighter(textDocument)
        if enchant is not None and parent.actionEnableSC.isChecked():
            self.highlighter.dictionary = enchant.Dict(parent.sl or None)
            # Rehighlighting is tied to the change in markup class that
            # happens at the end of this function

        self.editBox.textChanged.connect(self.triggerPreviewUpdate)
        self.editBox.undoAvailable.connect(parent.actionUndo.setEnabled)
        self.editBox.redoAvailable.connect(parent.actionRedo.setEnabled)
        self.editBox.copyAvailable.connect(parent.actionCopy.setEnabled)

        # Give both boxes a minimum size so the minimumSizeHint will be
        # ignored when splitter.setSizes is called below
        for widget in self.editBox, self.previewBox:
            widget.setMinimumWidth(125)
            self.addWidget(widget)
        self.setSizes((50, 50))
        self.setChildrenCollapsible(False)

        textDocument.modificationChanged.connect(
            self.handleModificationChanged)

        self.updateActiveMarkupClass()