aboutsummaryrefslogtreecommitdiffstats
path: root/gpgwin.cpp
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-07-16 09:27:55 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-07-16 09:27:55 +0000
commit447ea1a8e40edb2b708bb112a06fb28c5eb6d45f (patch)
treed957fa475e0c3694b1a0270d0d6b773bb15ac23d /gpgwin.cpp
parentuse css for verifyLabel (diff)
downloadgpg4usb-447ea1a8e40edb2b708bb112a06fb28c5eb6d45f.tar.gz
gpg4usb-447ea1a8e40edb2b708bb112a06fb28c5eb6d45f.zip
add action for cleaning double linebreaks
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@498 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'gpgwin.cpp')
-rw-r--r--gpgwin.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/gpgwin.cpp b/gpgwin.cpp
index 0028c38..2cad727 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -214,6 +214,12 @@ void GpgWin::createActions()
selectallAct->setToolTip(tr("Select the whole text"));
connect(selectallAct, SIGNAL(triggered()), edit, SLOT(selectAll()));
+ cleanDoubleLinebreaksAct = new QAction(tr("Remove double &Linebreaks"), this);
+ //cleanDoubleLineBreaksAct->setIcon(QIcon(iconPath + "edit.png"));
+ //cleanDoubleLineBreaksAct->setShortcut(QKeySequence::SelectAll);
+ cleanDoubleLinebreaksAct->setToolTip(tr("Remove double linebreaks, e.g. in pasted text from webmailer"));
+ connect(cleanDoubleLinebreaksAct, SIGNAL(triggered()), this, SLOT(cleanDoubleLinebreaks()));
+
openSettingsAct = new QAction(tr("Se&ttings"), this);
openSettingsAct->setToolTip(tr("Open settings dialog"));
openSettingsAct->setShortcut(QKeySequence::Preferences);
@@ -344,6 +350,7 @@ void GpgWin::createMenus()
editMenu->addAction(pasteAct);
editMenu->addAction(selectallAct);
editMenu->addAction(quoteAct);
+ editMenu->addAction(cleanDoubleLinebreaksAct);
editMenu->addSeparator();
editMenu->addAction(openSettingsAct);
@@ -790,3 +797,14 @@ void GpgWin::openSettingsDialog()
Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt());
this->setToolButtonStyle(buttonStyle);
}
+
+void GpgWin::cleanDoubleLinebreaks() {
+ QString content = edit->curTextPage()->toPlainText();
+ content.replace("\n\n", "\n");
+ QTextCursor cursor(edit->curTextPage()->document());
+ // TODO: own utils method for following:
+ cursor.beginEditBlock();
+ edit->curTextPage()->selectAll();
+ edit->curTextPage()->insertPlainText(content);
+ cursor.endEditBlock();
+}