diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2013-10-15 22:42:42 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2013-10-15 22:42:42 +0000 |
commit | e3af44efea5b406684efb32db491c34138101d19 (patch) | |
tree | 588a013c6e519de0179c9480526863265f0af853 | |
parent | beautified keydetail widget (diff) | |
download | gpg4usb-e3af44efea5b406684efb32db491c34138101d19.tar.gz gpg4usb-e3af44efea5b406684efb32db491c34138101d19.zip |
some cleanup
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1064 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | keydetailsdialog.cpp | 240 | ||||
-rw-r--r-- | keydetailsdialog.h | 88 | ||||
-rwxr-xr-x | keymgmt.cpp | 346 | ||||
-rwxr-xr-x | keymgmt.h | 95 | ||||
-rw-r--r-- | qml/ImageButton.qml | 71 |
5 files changed, 71 insertions, 769 deletions
diff --git a/keydetailsdialog.cpp b/keydetailsdialog.cpp deleted file mode 100644 index 8550446..0000000 --- a/keydetailsdialog.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/* - * keydetailsdialog.cpp - * - * Copyright 2008 gpg4usb-team <[email protected]> - * - * 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 <http://www.gnu.org/licenses/> - */ - -#include "keydetailsdialog.h" -#include "kgpg/transactions/kgpgexport.h" -#include "kgpg/core/convert.h" - -KeyDetailsDialog::KeyDetailsDialog(GpgME::GpgContext* ctx, KgpgCore::KgpgKey key, QWidget *parent) - : QDialog(parent) -{ - mCtx = ctx; - keyid = new QString(key.id()); - - ownerBox = new QGroupBox(tr("Owner details")); - keyBox = new QGroupBox(tr("Key details")); - fingerprintBox = new QGroupBox(tr("Fingerprint")); - additionalUidBox = new QGroupBox(tr("Additional Uids")); - buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); - - nameVarLabel = new QLabel(key.name()); - nameVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - emailVarLabel = new QLabel(key.email()); - emailVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - - commentVarLabel = new QLabel(key.comment()); - commentVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - keyidVarLabel = new QLabel(key.id()); - keyidVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - - QString keySizeVal, keyExpireVal, keyCreatedVal, keyAlgoVal; - - if (key.expirationDate().isNull()) { - keyExpireVal = tr("Never"); - } else { - keyExpireVal = KgpgCore::Convert::toString(key.expirationDate().date()); - } - - keyAlgoVal = KgpgCore::Convert::toString(key.algorithm()) + QLatin1String( " / " ) + KgpgCore::Convert::toString(key.encryptionAlgorithm()); - keyCreatedVal = KgpgCore::Convert::toString(key.creationDate().date()); - - keySizeVal = QString::number(key.size()) + "/" + QString::number(key.encryptionSize()); - - keySizeVarLabel = new QLabel(keySizeVal); - keySizeVarLabel->setWhatsThis(tr("<qt>The left part is the algorithm used by the <b>signature</b> key. The right part is the algorithm used by the <b>encryption</b> key.</qt>")); - expireVarLabel = new QLabel(keyExpireVal); - createdVarLabel = new QLabel(keyCreatedVal); - algorithmVarLabel = new QLabel(keyAlgoVal); - - QVBoxLayout *mvbox = new QVBoxLayout(); - QGridLayout *vboxKD = new QGridLayout(); - QGridLayout *vboxOD = new QGridLayout(); - - vboxOD->addWidget(new QLabel(tr("Name:")), 0, 0); - vboxOD->addWidget(new QLabel(tr("Email address:")), 1, 0); - vboxOD->addWidget(new QLabel(tr("Comment:")), 2, 0); - vboxOD->addWidget(nameVarLabel, 0, 1); - vboxOD->addWidget(emailVarLabel, 1, 1); - vboxOD->addWidget(commentVarLabel, 2, 1); - - vboxKD->addWidget(new QLabel(tr("Key size:")), 0, 0); - vboxKD->addWidget(new QLabel(tr("Expires on: ")), 1, 0); - vboxKD->addWidget(new QLabel(tr("Algorithm: ")), 3, 0); - vboxKD->addWidget(new QLabel(tr("Created on: ")), 4, 0); - vboxKD->addWidget(new QLabel(tr("Key ID: ")), 5, 0); - vboxKD->addWidget(keySizeVarLabel, 0, 1); - vboxKD->addWidget(expireVarLabel, 1, 1); - vboxKD->addWidget(algorithmVarLabel, 3, 1); - vboxKD->addWidget(createdVarLabel, 4, 1); - vboxKD->addWidget(keyidVarLabel, 5, 1); - - ownerBox->setLayout(vboxOD); - mvbox->addWidget(ownerBox); - - keyBox->setLayout(vboxKD); - mvbox->addWidget(keyBox); - - fingerPrintVarLabel = new QLabel(key.fingerprintBeautified()); - fingerPrintVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - fingerPrintVarLabel->setStyleSheet("margin-left: 20; margin-right: 20;"); - QHBoxLayout *hboxFP = new QHBoxLayout(); - - hboxFP->addWidget(fingerPrintVarLabel); - QIcon ico(":button_copy.png"); - - QPushButton copyFingerprintButton(QIcon(ico.pixmap(12, 12)), ""); - //copyFingerprintButton.setStyleSheet("QPushButton {border: 0px; } QPushButton:Pressed {} "); - copyFingerprintButton.setFlat(true); - copyFingerprintButton.setToolTip(tr("copy fingerprint to clipboard")); - connect(©FingerprintButton, SIGNAL(clicked()), this, SLOT(slotCopyFingerprint())); - - hboxFP->addWidget(©FingerprintButton); - - fingerprintBox->setLayout(hboxFP); - mvbox->addWidget(fingerprintBox); - - // If key has more than primary uid, also show the other uids - /*gpgme_user_id_t addUserIds = key->uids->next; - if (addUserIds !=NULL) { - QVBoxLayout *vboxUID = new QVBoxLayout(); - while (addUserIds != NULL){ - addUserIdsVarLabel = new QLabel(addUserIds->name+ QString(" <")+addUserIds->email+">"); - addUserIdsVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - vboxUID->addWidget(addUserIdsVarLabel); - addUserIds=addUserIds->next; - } - additionalUidBox->setLayout(vboxUID); - mvbox->addWidget(additionalUidBox); - }*/ - - //if (key.secret()) { - if(mCtx->isSecretKey(key.id())) { - QGroupBox *privKeyBox = new QGroupBox(tr("Private Key")); - QVBoxLayout *vboxPK = new QVBoxLayout(); - - QPushButton *exportButton = new QPushButton(tr("Export Private Key")); - vboxPK->addWidget(exportButton); - connect(exportButton, SIGNAL(clicked()), this, SLOT(slotExportPrivateKey())); - - privKeyBox->setLayout(vboxPK); - mvbox->addWidget(privKeyBox); - } - - /*if((key->expired) || (key->revoked)) { - QHBoxLayout *expBox = new QHBoxLayout(); - QIcon icon = QIcon::fromTheme("dialog-warning"); - QPixmap pixmap = icon.pixmap(QSize(32,32),QIcon::Normal,QIcon::On); - - QLabel *expLabel = new QLabel(); - QLabel *iconLabel = new QLabel(); - if (key->expired) { - expLabel->setText(tr("Warning: Key expired")); - } - if (key->revoked) { - expLabel->setText(tr("Warning: Key revoked")); - } - - iconLabel->setPixmap(pixmap); - QFont font = expLabel->font(); - font.setBold(true); - expLabel->setFont(font); - expBox->addWidget(iconLabel); - expBox->addWidget(expLabel); - mvbox->addLayout(expBox); - }*/ - - mvbox->addWidget(buttonBox); - - this->setLayout(mvbox); - this->setWindowTitle(tr("Keydetails")); - this->setModal(true); - this->show(); - - exec(); -} - -void KeyDetailsDialog::slotExportPrivateKey() -{ - // Show a information box with explanation about private key - int ret = QMessageBox::information(this, tr("Exporting private Key"), - tr("You are about to export your private key.\n" - "This is NOT your public key, so don't give it away.\n" - "Make sure you keep it save." - "Do you really want to export your private key?"), - QMessageBox::Cancel | QMessageBox::Ok); - - // export key, if ok was clicked - if (ret == QMessageBox::Ok) { - /* QByteArray *keyArray = new QByteArray(); - mCtx->exportSecretKey(*keyid, keyArray); - KgpgCore::KgpgKey key = mCtx->getKeyDetails(*keyid); - QString fileString = key.name() + " " + key.email() + "(" + key.id()+ ")_pub_sec.asc"; - QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)"); - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox::critical(0,tr("Export error"),tr("Couldn't open %1 for writing").arg(fileName)); - return; - } - QTextStream stream(&file); - stream << *keyArray; - file.close(); - delete keyArray;*/ - KgpgCore::KgpgKey key = mCtx->getKeyDetails(*keyid); - QString fileString = key.name() + " " + key.email() + "(" + key.id()+ ")_pub_sec.asc"; - - QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)"); - - QStringList expopts; - expopts.append(QLatin1String( "--armor" )); - KGpgExport *exp = new KGpgExport(this, QStringList() << *keyid, fileName, expopts, true); - connect(exp, SIGNAL(done(int)), SLOT(slotExportPrivateKeyDone(int))); - exp->start(); - } -} - -void KeyDetailsDialog::slotExportPrivateKeyDone(int result) { - KGpgExport *exp = qobject_cast<KGpgExport *>(sender()); - Q_ASSERT(exp != NULL); - - if (result == KGpgTransaction::TS_OK) { - qDebug() << "export seems ok"; - } else { - qDebug() << "Your key could not be exported\nCheck the key."; - } - - exp->deleteLater(); -} - -QString KeyDetailsDialog::beautifyFingerprint(QString fingerprint) -{ - uint len = fingerprint.length(); - if ((len > 0) && (len % 4 == 0)) - for (uint n = 0; 4 *(n + 1) < len; ++n) - fingerprint.insert(5 * n + 4, ' '); - return fingerprint; -} - -void KeyDetailsDialog::slotCopyFingerprint() { - QString fpr = fingerPrintVarLabel->text().trimmed().replace(" ", ""); - QClipboard *cb = QApplication::clipboard(); - cb->setText(fpr); -} diff --git a/keydetailsdialog.h b/keydetailsdialog.h deleted file mode 100644 index 19d2fde..0000000 --- a/keydetailsdialog.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * keydetailsdialog.h - * - * Copyright 2008 gpg4usb-team <[email protected]> - * - * 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 <http://www.gnu.org/licenses/> - */ - -#ifndef __KEYDETAILSDIALOG_H__ -#define __KEYDETAILSDIALOG_H__ - -#include "gpgcontext.h" -#include "kgpg/core/kgpgkey.h" - -QT_BEGIN_NAMESPACE -class QDateTime; -class QVBoxLayout; -class QHBoxLayout; -class QDialogButtonBox; -class QDialog; -class QGroupBox; -class QLabel; -class QGridLayout; -class QPushButton; -QT_END_NAMESPACE - -class KeyDetailsDialog : public QDialog -{ - Q_OBJECT - -public: - KeyDetailsDialog(GpgME::GpgContext* ctx, KgpgCore::KgpgKey key, QWidget *parent = 0); - - /** - * @details Return QString with a space inserted at every fourth character - * - * @param fingerprint The fingerprint to be beautified - */ - static QString beautifyFingerprint(QString fingerprint); - -private slots: - /** - * @details Export the key to a file, which is choosen in a file dialog - */ - void slotExportPrivateKey(); - void slotExportPrivateKeyDone(int result); - - /** - * @details Copy the fingerprint to clipboard - */ - void slotCopyFingerprint(); - -private: - QString *keyid; /** The id of the key the details should be shown for */ - GpgME::GpgContext *mCtx; /** The current gpg-context */ - - QGroupBox *ownerBox; /** Groupbox containing owner information */ - QGroupBox *keyBox; /** Groupbox containing key information */ - QGroupBox *fingerprintBox; /** Groupbox containing fingerprint information */ - QGroupBox *additionalUidBox; /** Groupbox containing information about additional uids */ - QDialogButtonBox *buttonBox; /** Box containing the close button */ - - QLabel *nameVarLabel; /** Label containng the keys name */ - QLabel *emailVarLabel; /** Label containng the keys email */ - QLabel *commentVarLabel; /** Label containng the keys commment */ - QLabel *keySizeVarLabel; /** Label containng the keys keysize */ - QLabel *expireVarLabel; /** Label containng the keys expiration date */ - QLabel *createdVarLabel; /** Label containng the keys creation date */ - QLabel *algorithmVarLabel; /** Label containng the keys algorithm */ - QLabel *keyidVarLabel; /** Label containng the keys keyid */ - QLabel *fingerPrintVarLabel; /** Label containng the keys fingerprint */ - QLabel *addUserIdsVarLabel; /** Label containng info about keys additional uids */ -}; - -#endif // __KEYDETAILSDIALOG_H__ diff --git a/keymgmt.cpp b/keymgmt.cpp deleted file mode 100755 index b97340d..0000000 --- a/keymgmt.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* - * - * keymgmt.cpp - * - * Copyright 2008 gpg4usb-team <[email protected]> - * - * 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 <http://www.gnu.org/licenses/> - */ - -#include "keymgmt.h" - -KeyMgmt::KeyMgmt(GpgME::GpgContext *ctx, QWidget *parent ) : QMainWindow(parent) -{ - mCtx = ctx; - - /* the list of Keys available*/ - mKeyList = new KeyList(mCtx); - mKeyList->setColumnWidth(2, 250); - mKeyList->setColumnWidth(3, 250); - setCentralWidget(mKeyList); - - createActions(); - createMenus(); - createToolBars(); - connect(this,SIGNAL(statusBarChanged(QString)),this->parent(),SLOT(slotSetStatusBarText(QString))); - - /* Restore the iconstyle */ - QSettings settings; - settings.sync(); - QSize iconSize = settings.value("toolbar/iconsize", QSize(32, 32)).toSize(); - Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt()); - this->setIconSize(iconSize); - this->setToolButtonStyle(buttonStyle); - - // state sets pos & size of dock-widgets - this->restoreState(settings.value("keymgmt/windowState").toByteArray()); - - // Restore window size & location - if (settings.value("window/windowSave").toBool()) { - QPoint pos = settings.value("keymgmt/pos", QPoint(100, 100)).toPoint(); - QSize size = settings.value("keymgmt/size", QSize(800, 450)).toSize(); - this->resize(size); - this->move(pos); - } else { - this->resize(QSize(800, 400)); - } - - setWindowTitle(tr("Keymanagement")); - mKeyList->addMenuAction(deleteSelectedKeysAct); - mKeyList->addMenuAction(showKeyDetailsAct); -} - -void KeyMgmt::createActions() -{ - closeAct = new QAction(tr("&Close Key Management"), this); - closeAct->setShortcut(QKeySequence::Quit); - closeAct->setIcon(QIcon(":exit.png")); - closeAct->setToolTip(tr("Close Key Management")); - connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); - - importKeyFromFileAct = new QAction(tr("&File"), this); - importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png")); - importKeyFromFileAct->setToolTip(tr("Import New Key From File")); - connect(importKeyFromFileAct, SIGNAL(triggered()), this, SLOT(slotimportKeyFromFile())); - - importKeyFromClipboardAct = new QAction(tr("&Clipboard"), this); - importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png")); - importKeyFromClipboardAct->setToolTip(tr("Import New Key From Clipboard")); - connect(importKeyFromClipboardAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromClipboard())); - - importKeyFromKeyServerAct = new QAction(tr("&Keyserver"), this); - importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png")); - importKeyFromKeyServerAct->setToolTip(tr("Import New Key From Keyserver")); - connect(importKeyFromKeyServerAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromKeyServer())); - - exportKeyToClipboardAct = new QAction(tr("Export To &Clipboard"), this); - exportKeyToClipboardAct->setIcon(QIcon(":export_key_to_clipboard.png")); - exportKeyToClipboardAct->setToolTip(tr("Export Selected Key(s) To Clipboard")); - connect(exportKeyToClipboardAct, SIGNAL(triggered()), this, SLOT(slotExportKeyToClipboard())); - - exportKeyToFileAct = new QAction(tr("Export To &File"), this); - exportKeyToFileAct->setIcon(QIcon(":export_key_to_file.png")); - exportKeyToFileAct->setToolTip(tr("Export Selected Key(s) To File")); - connect(exportKeyToFileAct, SIGNAL(triggered()), this, SLOT(slotExportKeyToFile())); - - deleteSelectedKeysAct = new QAction(tr("Delete Selected Key(s)"), this); - deleteSelectedKeysAct->setToolTip(tr("Delete the Selected keys")); - connect(deleteSelectedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteSelectedKeys())); - - deleteCheckedKeysAct = new QAction(tr("Delete Checked Key(s)"), this); - deleteCheckedKeysAct->setToolTip(tr("Delete the Checked keys")); - deleteCheckedKeysAct->setIcon(QIcon(":button_cancel.png")); - connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteCheckedKeys())); - - generateKeyDialogAct = new QAction(tr("Generate Key"), this); - generateKeyDialogAct->setToolTip(tr("Generate New Key")); - generateKeyDialogAct->setIcon(QIcon(":key_generate.png")); - connect(generateKeyDialogAct, SIGNAL(triggered()), this, SLOT(slotGenerateKeyDialog())); - - showKeyDetailsAct = new QAction(tr("Show Keydetails"), this); - showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); - connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); -} - -void KeyMgmt::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(closeAct); - - keyMenu = menuBar()->addMenu(tr("&Key")); - importKeyMenu = keyMenu->addMenu(tr("&Import Key From...")); - importKeyMenu->addAction(importKeyFromFileAct); - importKeyMenu->addAction(importKeyFromClipboardAct); - importKeyMenu->addAction(importKeyFromKeyServerAct); - keyMenu->addAction(exportKeyToFileAct); - keyMenu->addAction(exportKeyToClipboardAct); - keyMenu->addSeparator(); - keyMenu->addAction(deleteCheckedKeysAct); - keyMenu->addAction(generateKeyDialogAct); -} - -void KeyMgmt::createToolBars() -{ - QToolBar *keyToolBar = addToolBar(tr("Key")); - keyToolBar->setObjectName("keytoolbar"); - - // add button with popup menu for import - QToolButton* toolButton = new QToolButton(this); - toolButton->setMenu(importKeyMenu); - toolButton->setPopupMode(QToolButton::InstantPopup); - toolButton->setIcon(QIcon(":key_import.png")); - toolButton->setToolTip(tr("Import key")); - toolButton->setText(tr("Import key from")); - toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - keyToolBar->addWidget(toolButton); - - keyToolBar->addSeparator(); - keyToolBar->addAction(deleteCheckedKeysAct); - keyToolBar->addSeparator(); - keyToolBar->addAction(exportKeyToFileAct); - keyToolBar->addAction(exportKeyToClipboardAct); - -} - - -// import for text based keys -void KeyMgmt::slotImportKeys(QString text) -{ - KGpgImport *imp = new KGpgImport(this, text); - connect(imp, SIGNAL(done(int)), SLOT(slotImportDone(int))); - imp->start(); -} - -void KeyMgmt::slotImportDone(int result) -{ - KGpgImport *import = qobject_cast<KGpgImport *>(sender()); - - Q_ASSERT(import != NULL); - const QStringList rawmsgs(import->getMessages()); - - if (result != 0) { - /*KMessageBox::detailedSorry(this, i18n("Key importing failed. Please see the detailed log for more information."), - rawmsgs.join( QLatin1String( "\n")) , i18n("Key Import" ));*/ - qDebug() << "Key importing failed. Please see the detailed log for more information." << rawmsgs.join( QLatin1String( "\n")); - } - - QStringList keys(import->getImportedIds(0x1f)); - const bool needsRefresh = !keys.isEmpty(); - keys << import->getImportedIds(0); -/* - if (!keys.isEmpty()) { - const QString msg(import->getImportMessage()); - const QStringList keynames(import->getImportedKeys()); - - new KgpgDetailedInfo(this, msg, rawmsgs.join( QLatin1String( "\n") ), keynames, i18n("Key Import" )); - if (needsRefresh) - imodel->refreshKeys(keys); - else - changeMessage(i18nc("Application ready for user input", "Ready")); - } else{ - changeMessage(i18nc("Application ready for user input", "Ready")); - } -*/ - //changeMessage(tr("Application ready for user input", "Ready")); - mCtx->emitKeyDBChanged(); - import->deleteLater(); -} - -void KeyMgmt::slotimportKeyFromFile() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Key"), "", tr("Key Files") + " (*.asc *.txt);;"+tr("Keyring files")+" (*.gpg);;All Files (*)"); - if (! fileName.isNull()) { - - QList<QUrl> urlList; - urlList << QUrl::fromLocalFile(fileName); - - KGpgImport *imp = new KGpgImport(this, urlList); - connect(imp, SIGNAL(done(int)), SLOT(slotImportDone(int))); - imp->start(); - } -} - -void KeyMgmt::slotImportKeyFromKeyServer() -{ - importDialog = new KeyServerImportDialog(mCtx, mKeyList, this); - importDialog->show(); -} - -void KeyMgmt::slotImportKeyFromClipboard() -{ - QClipboard *cb = QApplication::clipboard(); - slotImportKeys(cb->text(QClipboard::Clipboard).toAscii()); -} - -void KeyMgmt::slotDeleteSelectedKeys() -{ - deleteKeysWithWarning(mKeyList->getSelected()); -} - -void KeyMgmt::slotDeleteCheckedKeys() -{ - deleteKeysWithWarning(mKeyList->getChecked()); -} - -void KeyMgmt::deleteKeysWithWarning(QStringList *uidList) -{ - /** - * TODO: Different Messages for private/public key, check if - * more than one selected... compare to seahorse "delete-dialog" - */ - - if (uidList->isEmpty()) { - return; - } - QString keynames; - foreach (QString uid, *uidList) { - keynames.append(mCtx->getKeyDetails(uid).name()); - keynames.append("<i> <"); - keynames.append(mCtx->getKeyDetails(uid).email()); - keynames.append("> </i><br/>"); - } - - int ret = QMessageBox::warning(this, tr("Deleting Keys"), - "<b>"+tr("Are you sure that you want to delete the following keys?")+"</b><br/><br/>"+keynames+ - +"<br/>"+tr("The action can not be undone."), - QMessageBox::No | QMessageBox::Yes); - - if (ret == QMessageBox::Yes) { - //mCtx->deleteKeys(uidList); - KGpgDelKey *delkey = new KGpgDelKey(this, *uidList); - connect(delkey, SIGNAL(done(int)), SLOT(slotKeyDeleted(int))); - delkey->start(); - } -} - -void KeyMgmt::slotKeyDeleted(int retcode) -{ - KGpgDelKey *delkey = qobject_cast<KGpgDelKey *>(sender()); - - /*KGpgKeyNode *delkey = m_delkey->keys().first(); - if (retcode == 0) { - KMessageBox::information(this, i18n("Key <b>%1</b> deleted.", delkey->getBeautifiedFingerprint()), i18n("Delete key")); - imodel->delNode(delkey); - } else { - KMessageBox::error(this, i18n("Deleting key <b>%1</b> failed.", delkey->getBeautifiedFingerprint()), i18n("Delete key")); - }*/ - mCtx->emitKeyDBChanged(); - delkey->deleteLater(); -} - -void KeyMgmt::slotShowKeyDetails() -{ - if (mKeyList->getSelected()->isEmpty()) { - return; - } - - // TODO: first...? - KgpgCore::KgpgKey key = mCtx->getKeyDetails(mKeyList->getSelected()->first()); - - new KeyDetailsDialog(mCtx, key); -} - -void KeyMgmt::slotExportKeyToFile() -{ -// TODO -/* QByteArray *keyArray = new QByteArray(); - if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) { - return; - } - KgpgCore::KgpgKey key = mCtx->getKeyDetails(mKeyList->getChecked()->first()); - QString fileString = key.name() + " " + key.email() + "(" + key.id()+ ")_pub.asc"; - - QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)"); - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - QTextStream stream(&file); - stream << *keyArray; - file.close(); - delete keyArray; - emit statusBarChanged(QString(tr("key(s) exported"))); -*/ -} - -void KeyMgmt::slotExportKeyToClipboard() -{ -// TODO -/* QByteArray *keyArray = new QByteArray(); - QClipboard *cb = QApplication::clipboard(); - if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) { - return; - } - cb->setText(*keyArray); - delete keyArray; -*/ -} - -void KeyMgmt::slotGenerateKeyDialog() -{ - KeyGenDialog *keyGenDialog = new KeyGenDialog(mCtx,this); - keyGenDialog->show(); -} - -void KeyMgmt::closeEvent(QCloseEvent *event) -{ - QSettings settings; - //settings.setValue("geometry", saveGeometry()); - settings.setValue("keymgmt/windowState", saveState()); - settings.setValue("keymgmt/pos", pos()); - settings.setValue("keymgmt/size", size()); - - QMainWindow::closeEvent(event); -} diff --git a/keymgmt.h b/keymgmt.h deleted file mode 100755 index 3e3cf75..0000000 --- a/keymgmt.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * keymgmt.h - * - * Copyright 2008 gpg4usb-team <[email protected]> - * - * 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 <http://www.gnu.org/licenses/> - */ - -#ifndef __KEYMGMT_H__ -#define __KEYMGMT_H__ - -#include "keylist.h" -#include "keydetailsdialog.h" -#include "keyimportdetaildialog.h" -#include "keyserverimportdialog.h" -#include "keygendialog.h" -#include "kgpg/transactions/kgpgdelkey.h" -#include "kgpg/transactions/kgpgimport.h" -#include <QtGui> - -QT_BEGIN_NAMESPACE -class QMainWindow; -class iostream; -class QFileDialog; -class QIcon; -class QAction; -class QApplication; -QT_END_NAMESPACE - -class KeyMgmt : public QMainWindow -{ - Q_OBJECT - -public: - KeyMgmt(GpgME::GpgContext *ctx, QWidget *parent); - QAction *importKeyFromClipboardAct; - QAction *importKeyFromFileAct; - QAction *importKeyFromKeyServerAct; - -public slots: - void slotimportKeyFromFile(); - void slotImportKeyFromClipboard(); - void slotImportKeyFromKeyServer(); - void slotImportKeys(QString text); - void slotImportDone(int result); - void slotExportKeyToFile(); - void slotExportKeyToClipboard(); - void slotDeleteSelectedKeys(); - void slotDeleteCheckedKeys(); - void slotGenerateKeyDialog(); - void slotShowKeyDetails(); - void slotKeyDeleted(int retcode); - -signals: - void statusBarChanged(QString); - -private: - void createMenus(); - void createActions(); - void createToolBars(); - void deleteKeysWithWarning(QStringList *uidList); - - KeyList *mKeyList; - GpgME::GpgContext *mCtx; - QMenu *fileMenu; - QMenu *keyMenu; - QMenu *importKeyMenu; - QAction *exportKeyToFileAct; - QAction *exportKeyToClipboardAct; - QAction *deleteCheckedKeysAct; - QAction *deleteSelectedKeysAct; - QAction *generateKeyDialogAct; - QAction *closeAct; - QAction *showKeyDetailsAct; - QMessageBox msgbox; - KeyServerImportDialog *importDialog; - -protected: - void closeEvent(QCloseEvent *event); -}; - -#endif // __KEYMGMT_H__ diff --git a/qml/ImageButton.qml b/qml/ImageButton.qml new file mode 100644 index 0000000..7aaba27 --- /dev/null +++ b/qml/ImageButton.qml @@ -0,0 +1,71 @@ +// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 +import QtQuick 1.1 + + Rectangle { + id: container + + property string text: "Button" + property string image: "" + + signal clicked + + width: buttonLabel.width + 5 + height: buttonLabel.height + buttonImage.height + 5 + //width: 60 + //height: 60 + //border { width: 1; color: Qt.darker(activePalette.button) } + //smooth: true + radius: 8 + color: ffffff; + + /*gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + }*/ + + SystemPalette { id: activePalette } +// // color the button with a gradient +// gradient: Gradient { +// GradientStop { +// position: 0.0 +// color: { +// if (mouseArea.pressed) +// return activePalette.dark +// else +// return activePalette.light +// } +// } +// GradientStop { position: 1.0; color: activePalette.button } +// } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Image { + id: buttonImage + y: 5 + source: container.image + height: 30 + width: 30 + anchors.horizontalCenter: parent.horizontalCenter + //anchors.fill: parent + } + + Text { + id: buttonLabel + //anchors.centerIn: container + anchors { top: buttonImage.bottom; horizontalCenter: parent.horizontalCenter } + color: activePalette.buttonText + text: container.text + horizontalAlignment: Text.AlignLeft + } + } |