From 0fe4790459f56c1fd3b207e67e81a5d0a52f5c55 Mon Sep 17 00:00:00 2001 From: nils Date: Sun, 27 Nov 2011 20:18:21 +0000 Subject: minor beautifying on keyimportdetaildialog git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@650 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- TODO | 2 +- gpg4usb.pro | 4 +- importdetaildialog.cpp | 155 ---------------------------------------------- importdetaildialog.h | 61 ------------------ keyimportdetaildialog.cpp | 128 ++++++++++++++++++++++++++++++++++++++ keyimportdetaildialog.h | 58 +++++++++++++++++ keymgmt.cpp | 2 +- keymgmt.h | 2 +- keyserverimportdialog.cpp | 4 +- 9 files changed, 193 insertions(+), 223 deletions(-) delete mode 100644 importdetaildialog.cpp delete mode 100644 importdetaildialog.h create mode 100644 keyimportdetaildialog.cpp create mode 100644 keyimportdetaildialog.h 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/importdetaildialog.cpp deleted file mode 100644 index 61b5972..0000000 --- a/importdetaildialog.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * importdetailsdialog.cpp - * - * Copyright 2008 gpg4usb-team - * - * This file is part of gpg4usb. - * - * Gpg4usb is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Gpg4usb is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with gpg4usb. If not, see - */ - -#include "importdetaildialog.h" - -ImportDetailDialog::ImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList, gpgme_import_result_t result, QWidget *parent) - : QDialog(parent) -{ - mCtx = ctx; - mKeyList = keyList; - mResult = result; - - if (mResult->considered == 0) { - QMessageBox::information(0, tr("Key import details"), tr("No keys found to import")); - return; - } - - mvbox = new QVBoxLayout(); - - this->createGeneralInfoBox(); - 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; - } - -} - -void ImportDetailDialog::createGeneralInfoBox() -{ - // GridBox for general import information - generalInfoBox = new QGroupBox(tr("Genral key import info")); - generalInfoBoxLayout = new QGridLayout(generalInfoBox); - - generalInfoBoxLayout->addWidget(new QLabel(tr("Considered:")),1,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->considered)),1,1); - int row=2; - if (mResult->unchanged){ - generalInfoBoxLayout->addWidget(new QLabel(tr("Unchanged:")),row,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->unchanged)),row,1); - row++; - } - if (mResult->imported){ - generalInfoBoxLayout->addWidget(new QLabel(tr("Imported:")),row,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->imported)),row,1); - row++; - } - if (mResult->not_imported){ - generalInfoBoxLayout->addWidget(new QLabel(tr("Not imported:")),row,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->not_imported)),row,1); - row++; - } - if (mResult->secret_read){ - generalInfoBoxLayout->addWidget(new QLabel(tr("Secret read:")),row,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->secret_read)),row,1); - row++; - } - if (mResult->secret_imported){ - generalInfoBoxLayout->addWidget(new QLabel(tr("Secret imported:")),row,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->secret_imported)),row,1); - row++; - } - if (mResult->secret_unchanged){ - generalInfoBoxLayout->addWidget(new QLabel(tr("Secret unchanged:")),row,0); - generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->secret_unchanged)),row,1); - row++; - } - 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() -{ - // 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 - while (status != NULL) { - 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); - - status=status->next; - keyrow++; - } - - // Add the boxes to mainwidget - mvbox->addWidget(keyInfoBox); -} - diff --git a/importdetaildialog.h b/importdetaildialog.h deleted file mode 100644 index 9396af6..0000000 --- a/importdetaildialog.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * importdetailsdialog.h - * - * Copyright 2008 gpg4usb-team - * - * This file is part of gpg4usb. - * - * Gpg4usb is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Gpg4usb is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with gpg4usb. If not, see - */ - -#ifndef __IMPORTDETAILSDIALOG_H__ -#define __IMPORTDETAILSDIALOG_H__ - -#include "keylist.h" -#include - -QT_BEGIN_NAMESPACE -class QGridLayout; -class QDialogButtonBox; -QT_END_NAMESPACE - -class ImportDetailDialog : public QDialog -{ - Q_OBJECT - -public: - ImportDetailDialog(GpgME::GpgContext* ctx, KeyList* keyList, gpgme_import_result_t result, QWidget *parent = 0); - -private slots: - void showHideDetails(); - -private: - void createGeneralInfoBox(); - void createKeyInfoBox(); - void createButtonBox(); - - GpgME::GpgContext *mCtx; - KeyList *mKeyList; - QGroupBox *generalInfoBox; - QGroupBox *keyInfoBox; - QVBoxLayout *mvbox; - QPushButton *detailButton; - QWidget *detailButtonBox; - QGridLayout *generalInfoBoxLayout; - QGridLayout *keyInfoBoxLayout; - gpgme_import_result_t mResult; - bool detailsShown; -}; - -#endif // __IMPORTDETAILSDIALOG_H__ diff --git a/keyimportdetaildialog.cpp b/keyimportdetaildialog.cpp new file mode 100644 index 0000000..4834852 --- /dev/null +++ b/keyimportdetaildialog.cpp @@ -0,0 +1,128 @@ +/* + * keyimportdetailsdialog.cpp + * + * Copyright 2008 gpg4usb-team + * + * This file is part of gpg4usb. + * + * Gpg4usb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gpg4usb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gpg4usb. If not, see + */ + +#include "keyimportdetaildialog.h" + +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; + } + + mvbox = new QVBoxLayout(); + + this->createGeneralInfoBox(); + this->createKeysTable(); + this->createButtonBox(); + + this->setLayout(mvbox); + this->setWindowTitle(tr("Key import details")); + this->setModal(true); + this->show(); +} + +void KeyImportDetailDialog::createGeneralInfoBox() +{ + // GridBox for general import information + generalInfoBox = new QGroupBox(tr("Genral key import info")); + generalInfoBoxLayout = new QGridLayout(generalInfoBox); + + generalInfoBoxLayout->addWidget(new QLabel(tr("Considered:")),1,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->considered)),1,1); + int row=2; + if (mResult->unchanged){ + generalInfoBoxLayout->addWidget(new QLabel(tr("Unchanged:")),row,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->unchanged)),row,1); + row++; + } + if (mResult->imported){ + generalInfoBoxLayout->addWidget(new QLabel(tr("Imported:")),row,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->imported)),row,1); + row++; + } + if (mResult->not_imported){ + generalInfoBoxLayout->addWidget(new QLabel(tr("Not imported:")),row,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->not_imported)),row,1); + row++; + } + if (mResult->secret_read){ + generalInfoBoxLayout->addWidget(new QLabel(tr("Secret read:")),row,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->secret_read)),row,1); + row++; + } + if (mResult->secret_imported){ + generalInfoBoxLayout->addWidget(new QLabel(tr("Secret imported:")),row,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->secret_imported)),row,1); + row++; + } + if (mResult->secret_unchanged){ + generalInfoBoxLayout->addWidget(new QLabel(tr("Secret unchanged:")),row,0); + generalInfoBoxLayout->addWidget(new QLabel(QString::number(mResult->secret_unchanged)),row,1); + row++; + } + mvbox->addWidget(generalInfoBox); +} + +void KeyImportDetailDialog::createKeysTable() +{ + // get details for the imported keys; + gpgme_import_status_t status = mResult->imports; + + 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); + 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; + row++; + } + mvbox->addWidget(keysTable); +} + +void KeyImportDetailDialog::createButtonBox() +{ + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(close())); + mvbox->addWidget(buttonBox); +} diff --git a/keyimportdetaildialog.h b/keyimportdetaildialog.h new file mode 100644 index 0000000..bb5da6a --- /dev/null +++ b/keyimportdetaildialog.h @@ -0,0 +1,58 @@ +/* + * keyimportdetailsdialog.h + * + * Copyright 2008 gpg4usb-team + * + * This file is part of gpg4usb. + * + * Gpg4usb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gpg4usb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gpg4usb. If not, see + */ + +#ifndef __KEYIMPORTDETAILSDIALOG_H__ +#define __KEYIMPORTDETAILSDIALOG_H__ + +#include "keylist.h" +#include + +QT_BEGIN_NAMESPACE +class QGridLayout; +class QDialogButtonBox; +QT_END_NAMESPACE + +class KeyImportDetailDialog : public QDialog +{ + Q_OBJECT + +public: + 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; + QGridLayout *generalInfoBoxLayout; + QGridLayout *keyInfoBoxLayout; + gpgme_import_result_t mResult; +}; + +#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 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); } -- cgit v1.2.3