diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2010-12-30 02:36:50 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2010-12-30 02:36:50 +0000 |
commit | 9d717d8ac6c138182fdc3a8d4e8464b544f42d3f (patch) | |
tree | 917db4ed76451411cc775330a1a4729621db40e8 | |
parent | added quote icon and quote action to toolbar (diff) | |
download | gpg4usb-9d717d8ac6c138182fdc3a8d4e8464b544f42d3f.tar.gz gpg4usb-9d717d8ac6c138182fdc3a8d4e8464b544f42d3f.zip |
added confirmation box for import keys through drop in keylist. Also added the appropriate setting in settings dialog.
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@412 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | gpgwin.cpp | 2 | ||||
-rw-r--r-- | keylist.cpp | 72 | ||||
-rw-r--r-- | keylist.h | 2 | ||||
-rwxr-xr-x | settingsdialog.cpp | 21 | ||||
-rwxr-xr-x | settingsdialog.h | 2 |
6 files changed, 82 insertions, 21 deletions
@@ -32,7 +32,9 @@ attachments: - add tab for editor options, like font-size, line-break, tab-width, line-numbers,.. - update gpgme-library - clean header if quoted printable decoded - +- add quote button +- fix overwrite file bug in file encryption [DONE] +- add drag'n'drop features for keys [DONE] Release 0.3 - PGP-MIME, find and show inline encrypted files @@ -189,7 +189,7 @@ void GpgWin::createActions() quoteAct = new QAction(tr("&Quote"), this); quoteAct->setIcon(QIcon(iconPath + "quote.png")); - quoteAct->setToolTip(tr("Insert > in front of every line")); + quoteAct->setToolTip(tr("Insert \">\" in front of every line")); connect(quoteAct, SIGNAL(triggered()), edit, SLOT(quote())); selectallAct = new QAction(tr("Select &All"), this); diff --git a/keylist.cpp b/keylist.cpp index 58c6a7b..23bc10a 100644 --- a/keylist.cpp +++ b/keylist.cpp @@ -19,6 +19,7 @@ * MA 02110-1301, USA. */ + #include "keylist.h" KeyList::KeyList(GpgME::Context *ctx, QString iconpath, QWidget *parent) @@ -163,28 +164,69 @@ void KeyList::addMenuAction(QAction *act) } void KeyList::dropEvent(QDropEvent* event) { - //foreach (QUrl tmp, event->mimeData()->urls()) +// importKeyDialog(); + QSettings settings; + + QDialog *dialog = new QDialog(); + + dialog->setWindowTitle(tr("Import Keys")); + dialog->setModal(true); + QLabel *label; + label = new QLabel(tr("Import keys from dropped files, if possible?")); + + // "always import keys"-CheckBox + QCheckBox *checkBox = new QCheckBox(tr("Don't Ask Me Again.")); + if (settings.value("general/confirmImportKeys").toBool()) checkBox->setCheckState(Qt::Unchecked); + + // Buttons for ok and cancel + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); + + QVBoxLayout *vbox = new QVBoxLayout(); + vbox->addWidget(label); + vbox->addWidget(checkBox); + vbox->addWidget(buttonBox); + + dialog->setLayout(vbox); + + if (settings.value("general/confirmImportKeys",Qt::Checked).toBool()) + { + dialog->exec(); + } + + if (dialog->result() == QDialog::Rejected) { + return; + } + + if (checkBox->isChecked()){ + settings.setValue("general/confirmImportKeys", Qt::Unchecked); + } else { + settings.setValue("general/confirmImportKeys", Qt::Checked); + } + if (event->mimeData()->hasUrls()) { foreach (QUrl tmp, event->mimeData()->urls()) { - QFile file; - file.setFileName(tmp.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) { - qDebug() << tr("Couldn't Open File: ") + tmp.toString(); - } - QByteArray inBuffer = file.readAll(); + QFile file; + file.setFileName(tmp.toLocalFile()); + if (!file.open(QIODevice::ReadOnly)) { + qDebug() << tr("Couldn't Open File: ") + tmp.toString(); + } + QByteArray inBuffer = file.readAll(); + mCtx->importKey(inBuffer); + + qDebug() << tmp.toString(); + } + } else { + QByteArray inBuffer(event->mimeData()->text().toUtf8()); mCtx->importKey(inBuffer); - qDebug() << tmp.toString(); - } - } else - { - QByteArray inBuffer(event->mimeData()->text().toUtf8()); - mCtx->importKey(inBuffer); + qDebug() << event->mimeData()->text(); + } + - qDebug() << event->mimeData()->text(); - } } @@ -39,10 +39,10 @@ class KeyList : public QWidget Q_OBJECT public: + KeyList(GpgME::Context *ctx, QString iconpath, QWidget *parent = 0); void setColumnWidth(int row, int size); void addMenuAction(QAction *act); - KeyList(GpgME::Context *ctx, QString iconpath, QWidget *parent = 0); QStringList *getChecked(); QStringList *getPrivateChecked(); void setChecked(QStringList *keyIds); diff --git a/settingsdialog.cpp b/settingsdialog.cpp index b4d17b1..8e97928 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -97,6 +97,15 @@ class QGroupBox; saveCheckedKeysBox->setLayout(saveCheckedKeysBoxLayout); /***************************************** + * Key-Impport-Confirmation Box + *****************************************/ + QGroupBox *importConfirmationBox = new QGroupBox(tr("Confirm key import")); + QHBoxLayout *importConfirmationBoxLayout = new QHBoxLayout(); + importConfirmationCheckBox= new QCheckBox(tr("Ask for confirmation to import, if keyfiles are dropped on the keylist."), this); + importConfirmationBoxLayout->addWidget(importConfirmationCheckBox); + importConfirmationBox->setLayout(importConfirmationBoxLayout); + + /***************************************** * Language Select Box *****************************************/ QGroupBox *langBox = new QGroupBox(tr("Language")); @@ -115,8 +124,9 @@ class QGroupBox; QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(rememberPasswordBox); - mainLayout->addWidget(saveCheckedKeysBox); - mainLayout->addWidget(langBox); + mainLayout->addWidget(saveCheckedKeysBox); + mainLayout->addWidget(importConfirmationBox); + mainLayout->addWidget(langBox); setSettings(); mainLayout->addStretch(1); setLayout(mainLayout); @@ -136,12 +146,16 @@ class QGroupBox; // Remember Password if (settings.value("general/rememberPassword").toBool()) rememberPasswordCheckBox->setCheckState(Qt::Checked); - //Language setting + // Language setting QString langKey = settings.value("int/lang").toString(); QString langValue = lang.value(langKey); if (langKey != "") { langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); } + // Ask for confirmation to import, if keyfiles are dropped on keylist + if (settings.value("general/confirmImportKeys",Qt::Checked).toBool()){ + importConfirmationCheckBox->setCheckState(Qt::Checked); + } } /*********************************** @@ -155,6 +169,7 @@ class QGroupBox; // TODO: clear passwordCache instantly on unset rememberPassword settings.setValue("general/rememberPassword", rememberPasswordCheckBox->isChecked()); settings.setValue("int/lang", lang.key(langSelectBox->currentText())); + settings.setValue("general/confirmImportKeys", importConfirmationCheckBox->isChecked()); } // http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3 diff --git a/settingsdialog.h b/settingsdialog.h index 5c96788..2e39328 100755 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -47,7 +47,9 @@ private: QCheckBox *rememberPasswordCheckBox; + QCheckBox *importConfirmationcheckBox; QCheckBox *saveCheckedKeysCheckBox; + QCheckBox *importConfirmationCheckBox; QComboBox *langSelectBox; QHash<QString, QString> lang; |