aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-27 20:18:21 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-27 20:18:21 +0000
commit0fe4790459f56c1fd3b207e67e81a5d0a52f5c55 (patch)
tree8714c0288fd2b004b47b9cd7b00d61d19b6097b2
parentshow dialog if no key is found for import (diff)
downloadgpg4usb-0fe4790459f56c1fd3b207e67e81a5d0a52f5c55.tar.gz
gpg4usb-0fe4790459f56c1fd3b207e67e81a5d0a52f5c55.zip
minor beautifying on keyimportdetaildialog
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@650 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--TODO2
-rw-r--r--gpg4usb.pro4
-rw-r--r--keyimportdetaildialog.cpp (renamed from importdetaildialog.cpp)95
-rw-r--r--keyimportdetaildialog.h (renamed from importdetaildialog.h)21
-rwxr-xr-xkeymgmt.cpp2
-rwxr-xr-xkeymgmt.h2
-rw-r--r--keyserverimportdialog.cpp4
7 files changed, 50 insertions, 80 deletions
diff --git a/TODO b/TODO
index 57104e5..ac7cd12 100644
--- a/TODO
+++ b/TODO
@@ -21,7 +21,7 @@ Release 0.3.2
- keyimport dialog should show reason for strike out
- key import should be more verbose: [DONE]
- show message, which keys are imported [DONE]
- - if import failed, because no key was found
+ - if import failed, because no key was found [DONE]
- if key is already in keyring
- for now done just for import from file and clipboard
- show message, when key export is successful (statusbar)
diff --git a/gpg4usb.pro b/gpg4usb.pro
index 07c023e..c7917db 100644
--- a/gpg4usb.pro
+++ b/gpg4usb.pro
@@ -19,7 +19,7 @@ HEADERS += attachments.h \
gpgcontext.h \
mainwindow.h \
fileencryptiondialog.h \
- importdetaildialog.h \
+ keyimportdetaildialog.h \
mime.h \
keygendialog.h \
keygenthread.h \
@@ -42,7 +42,7 @@ SOURCES += attachments.cpp \
mainwindow.cpp \
main.cpp \
fileencryptiondialog.cpp \
- importdetaildialog.cpp \
+ keyimportdetaildialog.cpp \
mime.cpp \
keygendialog.cpp \
keygenthread.cpp \
diff --git a/importdetaildialog.cpp b/keyimportdetaildialog.cpp
index 61b5972..4834852 100644
--- a/importdetaildialog.cpp
+++ b/keyimportdetaildialog.cpp
@@ -1,5 +1,5 @@
/*
- * importdetailsdialog.cpp
+ * keyimportdetailsdialog.cpp
*
* Copyright 2008 gpg4usb-team <[email protected]>
*
@@ -19,15 +19,16 @@
* along with gpg4usb. If not, see <http://www.gnu.org/licenses/>
*/
-#include "importdetaildialog.h"
+#include "keyimportdetaildialog.h"
-ImportDetailDialog::ImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList, gpgme_import_result_t result, QWidget *parent)
+KeyImportDetailDialog::KeyImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList, gpgme_import_result_t result, QWidget *parent)
: QDialog(parent)
{
mCtx = ctx;
mKeyList = keyList;
mResult = result;
+ // If no key for import found, just ahow a message
if (mResult->considered == 0) {
QMessageBox::information(0, tr("Key import details"), tr("No keys found to import"));
return;
@@ -36,38 +37,16 @@ ImportDetailDialog::ImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList,
mvbox = new QVBoxLayout();
this->createGeneralInfoBox();
+ this->createKeysTable();
this->createButtonBox();
- this->createKeyInfoBox();
-
- // Create ButtonBox for OK-Button
- //okButtonBox = new QDialogButtonBox(QDialogButtonBox::Close);
- //connect(okButtonBox, SIGNAL(rejected()), this, SLOT(close()));
- //mvbox->addWidget(okButtonBox);
-
- detailsShown=true;
this->setLayout(mvbox);
this->setWindowTitle(tr("Key import details"));
this->setModal(true);
- showHideDetails();
- this->exec();
-}
-
-void ImportDetailDialog::showHideDetails()
-{
- if (detailsShown) {
- detailButton->setText(tr("Show Details"));
- keyInfoBox->hide();
- detailsShown=false;
- } else {
- detailButton->setText(tr("Hide Details"));
- keyInfoBox->show();
- detailsShown=true;
- }
-
+ this->show();
}
-void ImportDetailDialog::createGeneralInfoBox()
+void KeyImportDetailDialog::createGeneralInfoBox()
{
// GridBox for general import information
generalInfoBox = new QGroupBox(tr("Genral key import info"));
@@ -109,47 +88,41 @@ void ImportDetailDialog::createGeneralInfoBox()
mvbox->addWidget(generalInfoBox);
}
-void ImportDetailDialog::createButtonBox()
-{
- detailButtonBox = new QWidget(this);
- QHBoxLayout *detailButtonBoxLayout = new QHBoxLayout(detailButtonBox);
-
- detailButton = new QPushButton(tr("Show Details"),detailButtonBox);
- detailButtonBoxLayout->addWidget(detailButton,Qt::AlignLeft);
- connect(detailButton, SIGNAL(clicked()), this, SLOT(showHideDetails()));
-
- QPushButton *closeButton = new QPushButton(tr("Close"),detailButtonBox);
- detailButtonBoxLayout->addWidget(closeButton,Qt::AlignRight);
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
-
- detailButtonBox->setLayout(detailButtonBoxLayout);
-
- mvbox->addWidget(detailButtonBox);
-}
-
-void ImportDetailDialog::createKeyInfoBox()
+void KeyImportDetailDialog::createKeysTable()
{
// get details for the imported keys;
gpgme_import_status_t status = mResult->imports;
- keyInfoBox = new QGroupBox(tr("Detailed key import info"));
- keyInfoBoxLayout = new QGridLayout(keyInfoBox);
-
- int keyrow=1;
-
- // process the whole list of keys
+ keysTable = new QTableWidget(this);
+ keysTable->setRowCount(0);
+ keysTable->setColumnCount(4);
+ keysTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ // Nothing is selectable
+ keysTable->setSelectionMode(QAbstractItemView::NoSelection);
+
+ QStringList headerLabels;
+ headerLabels << tr("Name") << tr("Email") << tr("KeyID") << tr("Status");
+ keysTable->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
+ keysTable->verticalHeader()->hide();
+ keysTable->setHorizontalHeaderLabels(headerLabels);
+ int row = 0;
while (status != NULL) {
+ keysTable->setRowCount(row+1);
GpgKey key = mKeyList->getKeyByFpr(status->fpr);
- keyInfoBoxLayout->addWidget(new QLabel(key.name),keyrow,2);
- keyInfoBoxLayout->addWidget(new QLabel(key.email),keyrow,3);
- keyInfoBoxLayout->addWidget(new QLabel(key.id),keyrow,4);
- keyInfoBoxLayout->addWidget(new QLabel(QString::number(status->status)),keyrow,5);
+ keysTable->setItem(row, 0, new QTableWidgetItem(key.name));
+ keysTable->setItem(row, 1, new QTableWidgetItem(key.email));
+ keysTable->setItem(row, 2, new QTableWidgetItem(key.id));
+ keysTable->setItem(row, 3, new QTableWidgetItem(QString::number(status->status)));
status=status->next;
- keyrow++;
+ row++;
}
-
- // Add the boxes to mainwidget
- mvbox->addWidget(keyInfoBox);
+ mvbox->addWidget(keysTable);
}
+void KeyImportDetailDialog::createButtonBox()
+{
+ buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(close()));
+ mvbox->addWidget(buttonBox);
+}
diff --git a/importdetaildialog.h b/keyimportdetaildialog.h
index 9396af6..bb5da6a 100644
--- a/importdetaildialog.h
+++ b/keyimportdetaildialog.h
@@ -1,5 +1,5 @@
/*
- * importdetailsdialog.h
+ * keyimportdetailsdialog.h
*
* Copyright 2008 gpg4usb-team <[email protected]>
*
@@ -19,8 +19,8 @@
* along with gpg4usb. If not, see <http://www.gnu.org/licenses/>
*/
-#ifndef __IMPORTDETAILSDIALOG_H__
-#define __IMPORTDETAILSDIALOG_H__
+#ifndef __KEYIMPORTDETAILSDIALOG_H__
+#define __KEYIMPORTDETAILSDIALOG_H__
#include "keylist.h"
#include <gpgme.h>
@@ -30,32 +30,29 @@ class QGridLayout;
class QDialogButtonBox;
QT_END_NAMESPACE
-class ImportDetailDialog : public QDialog
+class KeyImportDetailDialog : public QDialog
{
Q_OBJECT
public:
- ImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList, gpgme_import_result_t result, QWidget *parent = 0);
-
-private slots:
- void showHideDetails();
+ KeyImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList, gpgme_import_result_t result, QWidget *parent = 0);
private:
void createGeneralInfoBox();
void createKeyInfoBox();
+ void createKeysTable();
void createButtonBox();
+ QTableWidget *keysTable;
GpgME::GpgContext *mCtx;
KeyList *mKeyList;
QGroupBox *generalInfoBox;
QGroupBox *keyInfoBox;
+ QDialogButtonBox *buttonBox;
QVBoxLayout *mvbox;
- QPushButton *detailButton;
- QWidget *detailButtonBox;
QGridLayout *generalInfoBoxLayout;
QGridLayout *keyInfoBoxLayout;
gpgme_import_result_t mResult;
- bool detailsShown;
};
-#endif // __IMPORTDETAILSDIALOG_H__
+#endif // __KEYIMPORTDETAILSDIALOG_H__
diff --git a/keymgmt.cpp b/keymgmt.cpp
index c186b34..61cc3e6 100755
--- a/keymgmt.cpp
+++ b/keymgmt.cpp
@@ -158,7 +158,7 @@ void KeyMgmt::createToolBars()
void KeyMgmt::importKeys(QByteArray inBuffer)
{
gpgme_import_result_t result = mCtx->importKey(inBuffer);
- new ImportDetailDialog(mCtx, mKeyList, result, this);
+ new KeyImportDetailDialog(mCtx, mKeyList, result, this);
mCtx->sendKeyDBChanged();
}
diff --git a/keymgmt.h b/keymgmt.h
index 2018034..276f806 100755
--- a/keymgmt.h
+++ b/keymgmt.h
@@ -25,7 +25,7 @@
#include "keylist.h"
#include "keygenthread.h"
#include "keydetailsdialog.h"
-#include "importdetaildialog.h"
+#include "keyimportdetaildialog.h"
#include "keyserverimportdialog.h"
#include "keygendialog.h"
#include <QtGui>
diff --git a/keyserverimportdialog.cpp b/keyserverimportdialog.cpp
index 28db768..d333d5b 100644
--- a/keyserverimportdialog.cpp
+++ b/keyserverimportdialog.cpp
@@ -100,9 +100,11 @@ void KeyServerImportDialog::createKeysTable()
{
keysTable = new QTableWidget();
keysTable->setColumnCount(3);
+
// always a whole row is marked
keysTable->setSelectionBehavior(QAbstractItemView::SelectRows);
keysTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
// Make just one row selectable
keysTable->setSelectionMode(QAbstractItemView::SingleSelection);
@@ -230,7 +232,6 @@ void KeyServerImportDialog::searchFinished()
}
setMessage(tr("%1 keys found. Doubleclick a key to import it.").arg(row),false);
}
- //keysTree->insertTopLevelItems(0,items);
keysTable->resizeColumnsToContents();
}
reply->deleteLater();
@@ -241,7 +242,6 @@ void KeyServerImportDialog::import()
{
if ( keysTable->currentRow() > -1 ) {
QString keyid = keysTable->item(keysTable->currentRow(),2)->text();
-
QUrl url = keyServerComboBox->currentText();
import(QStringList(keyid), url);
}