diff options
Diffstat (limited to 'editorpage.cpp')
-rw-r--r-- | editorpage.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/editorpage.cpp b/editorpage.cpp index fbf6209..b057f8b 100644 --- a/editorpage.cpp +++ b/editorpage.cpp @@ -24,18 +24,21 @@ EditorPage::EditorPage(const QString &filePath, QWidget *parent) : QWidget(parent), fullFilePath(filePath) { + // Set the Textedit properties textPage = new QTextEdit(); textPage->setAcceptRichText(false); + + // Set the layout style mainLayout = new QVBoxLayout(); mainLayout->setSpacing(0); mainLayout->addWidget(textPage); mainLayout->setContentsMargins(0,0,0,0); setLayout(mainLayout); + setAttribute(Qt::WA_DeleteOnClose); textPage->setFocus(); //connect(textPage, SIGNAL(textChanged()), this, SLOT(formatGpgHeader())); - } const QString& EditorPage::getFilePath() const @@ -73,6 +76,8 @@ void EditorPage::closeNoteByClass(const char *className) void EditorPage::formatGpgHeader() { QString content = textPage->toPlainText(); + + // Get positions of the gpg-headers, if they exist int start = content.indexOf(GpgConstants::PGP_SIGNED_BEGIN); int startSig = content.indexOf(GpgConstants::PGP_SIGNATURE_BEGIN); int endSig = content.indexOf(GpgConstants::PGP_SIGNATURE_END); @@ -83,15 +88,18 @@ void EditorPage::formatGpgHeader() { signMarked = true; + // Set the fontstyle for the header QTextCharFormat signFormat; signFormat.setForeground(QBrush(QColor::fromRgb(80,80,80))); signFormat.setFontPointSize(9); + // set font style for the signature QTextCursor cursor(textPage->document()); cursor.setPosition(startSig, QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, endSig); cursor.setCharFormat(signFormat); + // set the font style for the header int headEnd = content.indexOf("\n\n", start); cursor.setPosition(start, QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, headEnd); |