diff options
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | keygendialog.cpp | 1 | ||||
-rwxr-xr-x | keymgmt.cpp | 4 | ||||
-rw-r--r-- | mainwindow.cpp | 42 | ||||
-rw-r--r-- | textedit.cpp | 45 | ||||
-rw-r--r-- | textedit.h | 1 |
6 files changed, 91 insertions, 6 deletions
@@ -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(); } @@ -73,6 +73,7 @@ public: */ bool maybeSaveAnyTab(); + int tabCount(); /** * @details textpage of the currently activated tab */ |