aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-06 22:03:58 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-06 22:03:58 +0000
commiteaa4e699ebe9739cb353751286006480413d5594 (patch)
tree81e4dc2b368db42aa569a6fe51c969de45494328
parentshow keyring files in importkeyfromfile-dialog (diff)
downloadgpg4usb-eaa4e699ebe9739cb353751286006480413d5594.tar.gz
gpg4usb-eaa4e699ebe9739cb353751286006480413d5594.zip
fixed a lot of bugs, where app crached, when no tab is opened (liek save as, quote, undo, copy...) or when no key is selected (keydetails)
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@602 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--TODO4
-rw-r--r--keygendialog.cpp1
-rwxr-xr-xkeymgmt.cpp4
-rw-r--r--mainwindow.cpp42
-rw-r--r--textedit.cpp45
-rw-r--r--textedit.h1
6 files changed, 91 insertions, 6 deletions
diff --git a/TODO b/TODO
index 07be1c8..a42be43 100644
--- a/TODO
+++ b/TODO
@@ -30,7 +30,8 @@ Release 0.3.2
- refactoring and cleanup: [DONE]
- gpgwin.cpp -> mainwindow.cpp [DONE]
- context.cpp -> gpgcontext.cpp [DONE]
-- show keyrings (files with .gpg) in import from file dialog too
+- show keyrings (files with .gpg) in import from file dialog too [DONE]
+- Wizard on first start (Create Key, Import from older gpg4usb, import from gnupg)
- set gpgme error language to chosen language (context.cpp:49)
- import from keyserver doesn't end, if network-connection is available, but no connection to keyserver (?)
- minimal steganography option: remove or add pgp-headers on demand
@@ -43,7 +44,6 @@ Release 0.3.2
Release 0.3.3
- Change private key password (catch bad passphrase message)
-- Wizard on first start (Create Key, Import from older gpg4usb, import from gnupg)
- css
- key should blink short in keylist after import
- check and add missing statusbar messages
diff --git a/keygendialog.cpp b/keygendialog.cpp
index cad510a..20e08ff 100644
--- a/keygendialog.cpp
+++ b/keygendialog.cpp
@@ -35,7 +35,6 @@ KeyGenDialog::KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent)
void KeyGenDialog::generateKeyDialog()
{
-
nameLabel = new QLabel(tr("Name:"));
emailLabel = new QLabel(tr("E-Mailaddress::"));
commentLabel = new QLabel(tr("Comment:"));
diff --git a/keymgmt.cpp b/keymgmt.cpp
index 9227392..2250996 100755
--- a/keymgmt.cpp
+++ b/keymgmt.cpp
@@ -222,6 +222,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/mainwindow.cpp b/mainwindow.cpp
index 8dc1e6a..20f093c 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -502,7 +502,6 @@ void MainWindow::createTrayIcon() {
}*/
trayIcon->setProperty("_qt_sni_category", qApp->applicationDirPath() + "/tmp");
trayIcon->setContextMenu(trayIconMenu);
-
}
void MainWindow::showTrayMessage(QString title, QString body) {
@@ -683,6 +682,10 @@ void MainWindow::checkAttachmentFolder() {
void MainWindow::importKeyFromEdit()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
mCtx->importKey(edit->curTextPage()->toPlainText().toAscii());
}
@@ -695,6 +698,10 @@ void MainWindow::openKeyManagement()
void MainWindow::encrypt()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QStringList *uidList = mKeyList->getChecked();
QByteArray *tmp = new QByteArray();
@@ -706,6 +713,10 @@ void MainWindow::encrypt()
void MainWindow::sign()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QStringList *uidList = mKeyList->getPrivateChecked();
QByteArray *tmp = new QByteArray();
@@ -718,6 +729,10 @@ void MainWindow::sign()
void MainWindow::decrypt()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QByteArray *decrypted = new QByteArray();
QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here?
mCtx->preventNoDataErr(&text);
@@ -753,6 +768,10 @@ void MainWindow::decrypt()
void MainWindow::verify()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
// At first close verifynotification, if existing
edit->curPage()->closeNoteByClass("verifyNotification");
@@ -811,6 +830,10 @@ void MainWindow::importKeyDialog()
*/
void MainWindow::appendSelectedKeys()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QByteArray *keyArray = new QByteArray();
mCtx->exportKeys(mKeyList->getSelected(), keyArray);
edit->curTextPage()->appendPlainText(*keyArray);
@@ -818,6 +841,10 @@ void MainWindow::appendSelectedKeys()
void MainWindow::copyMailAddressToClipboard()
{
+ if (mKeyList->getSelected()->isEmpty()) {
+ return;
+ }
+
gpgme_key_t key = mCtx->getKeyDetails(mKeyList->getSelected()->first());
QClipboard *cb = QApplication::clipboard();
QString mail = key->uids->email;
@@ -826,9 +853,14 @@ void MainWindow::copyMailAddressToClipboard()
void MainWindow::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 MainWindow::fileEncryption()
@@ -859,6 +891,10 @@ void MainWindow::openSettingsDialog()
void MainWindow::cleanDoubleLinebreaks()
{
+ if (edit->tabCount()==0) {
+ return;
+ }
+
QString content = edit->curTextPage()->toPlainText();
content.replace("\n\n", "\n");
edit->fillTextEditWithText(content);
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
*/