diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-12-07 00:15:35 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-12-07 00:15:35 +0000 |
commit | 6e6d17140d414985b34e8d8bebe812d7dad27f25 (patch) | |
tree | c6160aac9f689cd4e34e3496cf94656fc64271f3 | |
parent | functions for removing or adding gpg headers (diff) | |
download | gpg4usb-6e6d17140d414985b34e8d8bebe812d7dad27f25.tar.gz gpg4usb-6e6d17140d414985b34e8d8bebe812d7dad27f25.zip |
change appeareance of gpg signatures to play with new format possibilities in textedit ;-)
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@675 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | editorpage.cpp | 32 | ||||
-rw-r--r-- | editorpage.h | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/editorpage.cpp b/editorpage.cpp index acf1dcd..4679bfe 100644 --- a/editorpage.cpp +++ b/editorpage.cpp @@ -33,6 +33,9 @@ EditorPage::EditorPage(const QString &filePath, QWidget *parent) : QWidget(paren setLayout(mainLayout); setAttribute(Qt::WA_DeleteOnClose); textPage->setFocus(); + + connect(textPage, SIGNAL(textChanged()), this, SLOT(formatGpgHeader())); + } const QString& EditorPage::getFilePath() const @@ -66,3 +69,32 @@ void EditorPage::closeNoteByClass(const char *className) } } } + +void EditorPage::formatGpgHeader() { + + QString content = textPage->toPlainText(); + int start = content.indexOf(GpgConstants::PGP_SIGNED_BEGIN); + int startSig = content.indexOf(GpgConstants::PGP_SIGNATURE_BEGIN); + int endSig = content.indexOf(GpgConstants::PGP_SIGNATURE_END); + + if(start < 0 || startSig < 0 || endSig < 0 || signMarked) { + return; + } + + signMarked = true; + + QTextCharFormat signFormat; + signFormat.setForeground(QBrush(QColor::fromRgb(80,80,80))); + signFormat.setFontPointSize(9); + + QTextCursor cursor(textPage->document()); + cursor.setPosition(startSig, QTextCursor::MoveAnchor); + cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, endSig); + cursor.setCharFormat(signFormat); + + int headEnd = content.indexOf("\n\n", start); + cursor.setPosition(start, QTextCursor::MoveAnchor); + cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, headEnd); + cursor.setCharFormat(signFormat); + +} diff --git a/editorpage.h b/editorpage.h index ef8928f..52513b4 100644 --- a/editorpage.h +++ b/editorpage.h @@ -22,6 +22,7 @@ #ifndef __EDITORPAGE_H__ #define __EDITORPAGE_H__ +#include "gpgconstants.h" #include <QTextEdit> #include <QtGui> @@ -89,6 +90,10 @@ private: QMenu *verifyMenu; /** The menu in the notifiaction widget */ QString fullFilePath; /** The path to the file handled in the tab */ QLabel *verifyLabel; /** The label of the verify-notification widget */ + bool signMarked; + +private slots: + void formatGpgHeader(); }; #endif // __TEXTPAGE_H__ |