diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-12-06 22:32:19 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-12-06 22:32:19 +0000 |
commit | 6a360340812eedb66988bf7b0d782cff51c78f4e (patch) | |
tree | 6a593246329801159eb4dce0593b9ed174f3a0ff /mainwindow.cpp | |
parent | add option for steganography to settingsdialog (diff) | |
download | gpg4usb-6a360340812eedb66988bf7b0d782cff51c78f4e.tar.gz gpg4usb-6a360340812eedb66988bf7b0d782cff51c78f4e.zip |
functions for removing or adding gpg headers
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@674 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r-- | mainwindow.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index 21a82f0..e6242c0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -400,11 +400,22 @@ void MainWindow::createMenus() viewMenu = menuBar()->addMenu(tr("&View")); + if(settings.value("general/steganography").toBool()) { + steganoMenu = menuBar()->addMenu(tr("&Steganography")); + QAction* cutPgpHeaderAct = new QAction(tr("Remove PGP Header"), this); + connect(cutPgpHeaderAct, SIGNAL(triggered()), this, SLOT(cutPgpHeader())); + QAction* addPgpHeaderAct = new QAction(tr("Add PGP Header"), this); + connect(addPgpHeaderAct, SIGNAL(triggered()), this, SLOT(addPgpHeader())); + steganoMenu->addAction(cutPgpHeaderAct); + steganoMenu->addAction(addPgpHeaderAct); + } + helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(openTutorialAct); helpMenu->addAction(openTranslateAct); helpMenu->addAction(startWizardAct); helpMenu->addAction(aboutAct); + } void MainWindow::createToolBars() @@ -858,3 +869,41 @@ void MainWindow::cleanDoubleLinebreaks() content.replace("\n\n", "\n"); edit->fillTextEditWithText(content); } + +void MainWindow::addPgpHeader() { + if (edit->tabCount()==0 || edit->curPage() == 0) { + return; + } + + QString content = edit->curTextPage()->toPlainText().trimmed(); + + content.prepend("\n\n").prepend(GpgConstants::PGP_CRYPT_BEGIN); + content.append("\n").append(GpgConstants::PGP_CRYPT_END); + + edit->fillTextEditWithText(content); +} + +void MainWindow::cutPgpHeader() { + + if (edit->tabCount()==0 || edit->curPage() == 0) { + return; + } + + QString content = edit->curTextPage()->toPlainText(); + int start = content.indexOf(GpgConstants::PGP_CRYPT_BEGIN); + int end = content.indexOf(GpgConstants::PGP_CRYPT_END); + + if(start < 0 || end < 0) { + return; + } + + // remove head + int headEnd = content.indexOf("\n\n", start) + 2 ; + content.remove(start, headEnd-start); + + // remove tail + end = content.indexOf(GpgConstants::PGP_CRYPT_END); + content.remove(end, QString(GpgConstants::PGP_CRYPT_END).size()); + + edit->fillTextEditWithText(content.trimmed()); +} |