aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-13 13:00:15 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-13 13:00:15 +0000
commitde8af118283e04de27fa5fd77f513c0ccc157b0c (patch)
tree70bf6d3833eb43ae0e113e133196262933bc27d4
parentupdated german translation (diff)
downloadgpg4usb-de8af118283e04de27fa5fd77f513c0ccc157b0c.tar.gz
gpg4usb-de8af118283e04de27fa5fd77f513c0ccc157b0c.zip
port of nils bugfix from trunk rev 602
git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.3.1@609 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--gpgwin.cpp37
-rwxr-xr-xkeymgmt.cpp4
-rw-r--r--textedit.cpp45
-rw-r--r--textedit.h1
4 files changed, 85 insertions, 2 deletions
diff --git a/gpgwin.cpp b/gpgwin.cpp
index dac830d..c30877b 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -612,6 +612,10 @@ void GpgWin::openKeyManagement()
void GpgWin::encrypt()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QStringList *uidList = mKeyList->getChecked();
QByteArray *tmp = new QByteArray();
@@ -623,6 +627,10 @@ void GpgWin::encrypt()
void GpgWin::sign()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QStringList *uidList = mKeyList->getPrivateChecked();
QByteArray *tmp = new QByteArray();
@@ -635,6 +643,10 @@ void GpgWin::sign()
void GpgWin::decrypt()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QByteArray *decrypted = new QByteArray();
QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here?
mCtx->preventNoDataErr(&text);
@@ -670,6 +682,10 @@ void GpgWin::decrypt()
void GpgWin::verify()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
// At first close verifynotification, if existing
edit->curPage()->closeNoteByClass("verifyNotification");
@@ -728,6 +744,10 @@ void GpgWin::importKeyDialog()
*/
void GpgWin::appendSelectedKeys()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QByteArray *keyArray = new QByteArray();
mCtx->exportKeys(mKeyList->getSelected(), keyArray);
edit->curTextPage()->appendPlainText(*keyArray);
@@ -735,6 +755,10 @@ void GpgWin::appendSelectedKeys()
void GpgWin::copyMailAddressToClipboard()
{
+ if (mKeyList->getSelected()->isEmpty()) {
+ return;
+ }
+
gpgme_key_t key = mCtx->getKeyDetails(mKeyList->getSelected()->first());
QClipboard *cb = QApplication::clipboard();
QString mail = key->uids->email;
@@ -743,9 +767,14 @@ void GpgWin::copyMailAddressToClipboard()
void GpgWin::showKeyDetails()
{
- // TODO: first...?
+ if (mKeyList->getSelected()->isEmpty()) {
+ return;
+ }
+
gpgme_key_t key = mCtx->getKeyDetails(mKeyList->getSelected()->first());
- new KeyDetailsDialog(mCtx, key, this);
+ if (key) {
+ new KeyDetailsDialog(mCtx, key, this);
+ }
}
void GpgWin::fileEncryption()
@@ -776,6 +805,10 @@ void GpgWin::openSettingsDialog()
void GpgWin::cleanDoubleLinebreaks()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QString content = edit->curTextPage()->toPlainText();
content.replace("\n\n", "\n");
edit->fillTextEditWithText(content);
diff --git a/keymgmt.cpp b/keymgmt.cpp
index 451eaf7..7b58583 100755
--- a/keymgmt.cpp
+++ b/keymgmt.cpp
@@ -214,6 +214,10 @@ void KeyMgmt::deleteKeysWithWarning(QStringList *uidList)
void KeyMgmt::showKeyDetails()
{
+ if (mKeyList->getSelected()->isEmpty()) {
+ return;
+ }
+
// TODO: first...?
gpgme_key_t key = mCtx->getKeyDetails(mKeyList->getSelected()->first());
diff --git a/textedit.cpp b/textedit.cpp
index 57a91e9..b60c28d 100644
--- a/textedit.cpp
+++ b/textedit.cpp
@@ -89,6 +89,10 @@ void TextEdit::open()
void TextEdit::save()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
QString fileName = curPage()->getFilePath();
if (fileName.isEmpty()) {
@@ -137,6 +141,10 @@ bool TextEdit::saveFile(const QString &fileName)
bool TextEdit::saveAs()
{
+ if (tabWidget->count() == 0) {
+ return true;
+ }
+
EditorPage *page = curPage();
QString path;
if(page->getFilePath() != "") {
@@ -296,6 +304,11 @@ QPlainTextEdit* TextEdit::curTextPage()
}
+int TextEdit::tabCount()
+{
+ return tabWidget->count();
+}
+
EditorPage* TextEdit::curPage()
{
EditorPage *curPage = qobject_cast<EditorPage *>(tabWidget->currentWidget());
@@ -304,6 +317,10 @@ EditorPage* TextEdit::curPage()
void TextEdit::quote()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
QTextCursor cursor(curTextPage()->document());
// beginEditBlock and endEditBlock() let operation look like single undo/redo operation
@@ -355,6 +372,10 @@ QString TextEdit::strippedName(const QString &fullFileName)
void TextEdit::print()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
#ifndef QT_NO_PRINTER
QTextDocument *document = curTextPage()->document();
QPrinter printer;
@@ -415,31 +436,55 @@ QHash<int, QString> TextEdit::unsavedDocuments() {
void TextEdit::cut()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->cut();
}
void TextEdit::copy()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->copy();
}
void TextEdit::paste()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->paste();
}
void TextEdit::undo()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->undo();
}
void TextEdit::redo()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->redo();
}
void TextEdit::selectAll()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->selectAll();
}
diff --git a/textedit.h b/textedit.h
index 0f91f86..0ae2689 100644
--- a/textedit.h
+++ b/textedit.h
@@ -73,6 +73,7 @@ public:
*/
bool maybeSaveAnyTab();
+ int tabCount();
/**
* @details textpage of the currently activated tab
*/