From d0d366731425ad6c5a221d5c12968632e7ba1478 Mon Sep 17 00:00:00 2001 From: Martin Talarczyk Date: Thu, 17 Sep 2015 10:58:30 +0200 Subject: MainWindow Funkson der Gui hergestelt. passworddialog ist Funksions Fähig und Kommentirt. das Treewidget bei PublicKeyImportDialog gegen listewiget ausgetrauscht und Teilweis Funksion hergestellt nicht Komentiert. Bei keinem Der Klassen ist eine verbindung mit der hybridcrypt gegebn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CryptLog.pro | 10 ++-- main.cpp | 3 ++ mainwindow.cpp | 76 ++++++++++++++++++++++++++ mainwindow.h | 26 +++++++++ mainwindow.ui | 18 +++---- passworddialog.cpp | 13 +++++ passworddialog.h | 30 +++++++++++ passworddialog.ui | 22 ++++---- publickeyimport.cpp | 14 ----- publickeyimport.h | 22 -------- publickeyimport.ui | 97 ---------------------------------- publickeyimportdialog.cpp | 68 ++++++++++++++++++++++++ publickeyimportdialog.h | 41 ++++++++++++++ publickeyimportdialog.ui | 132 ++++++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 414 insertions(+), 158 deletions(-) delete mode 100644 publickeyimport.cpp delete mode 100644 publickeyimport.h delete mode 100644 publickeyimport.ui create mode 100644 publickeyimportdialog.cpp create mode 100644 publickeyimportdialog.h create mode 100644 publickeyimportdialog.ui diff --git a/CryptLog.pro b/CryptLog.pro index 7eee1d7..06a704d 100644 --- a/CryptLog.pro +++ b/CryptLog.pro @@ -15,19 +15,19 @@ TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ passworddialog.cpp \ - publickeyimport.cpp \ crypt/hybridcrypt.cpp \ - crypt/cryptexception.cpp + crypt/cryptexception.cpp \ + publickeyimportdialog.cpp HEADERS += mainwindow.h \ passworddialog.h \ - publickeyimport.h \ crypt/hybridcrypt.h \ - crypt/cryptexception.h + crypt/cryptexception.h \ + publickeyimportdialog.h FORMS += mainwindow.ui \ passworddialog.ui \ - publickeyimport.ui + publickeyimportdialog.ui unix: CONFIG += link_pkgconfig unix: PKGCONFIG += openssl diff --git a/main.cpp b/main.cpp index b48f94e..ca36ba3 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,14 @@ #include "mainwindow.h" +#include "passworddialog.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; + //PublicKeyImport w; w.show(); + return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 49d64fc..2f5c9e7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,3 +12,79 @@ MainWindow::~MainWindow() { delete ui; } + + +void MainWindow::on_pushButtonDecrypt_clicked() +{ + +} + +void MainWindow::on_pushButtonEncrypt_clicked() +{ + PublicKeyImportDialog *temp = new PublicKeyImportDialog; + + if (temp->exec()&&!ui->lineEditFilePath->isEnabled()) + { + qDebug() << "Entschlüsseln möglich."; + // HybridCrypt::encrypt(); + } + delete temp; + +} + +void MainWindow::on_pushButtonOpenFile_clicked() +{ + QString fielname = QFileDialog::getOpenFileName(this, "Datei öffnen", + "/home", tr("Datei(*)")); + ui->lineEditFilePath->setText(fielname); + qDebug() << fielname; + +} + + +void MainWindow::on_actionImport_triggered() +{ + QString filename = readKeyFilename("Importiren eines Schlüsselpaares"); + + qDebug() << filename; + + if (!filename.isEmpty()) + { + QString password = readPassword(); + qDebug() << password; + } + +} + + + +void MainWindow::on_actionClose_triggered() +{ + close(); +} + +void MainWindow::on_actionExportMyPublicKey_triggered() +{ + +} + +QString MainWindow::readKeyFilename(QString titel) +{ + return QFileDialog::getOpenFileName(this, titel, + "/home", tr("key(*.net *.der *.pem *.asc)")); +} + +QString MainWindow::readPassword() +{ + PasswordDialog w; + + + if (w.exec()) + { + return w.getPassword(); + } + return ""; +} + + + diff --git a/mainwindow.h b/mainwindow.h index a3948a9..c505448 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -1,7 +1,13 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include #include +#include + +#include "crypt/hybridcrypt.h" +#include "passworddialog.h" +#include "publickeyimportdialog.h" namespace Ui { class MainWindow; @@ -15,8 +21,28 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); +private slots: + void on_pushButtonDecrypt_clicked(); + + void on_pushButtonEncrypt_clicked(); + + void on_pushButtonOpenFile_clicked(); + + void on_actionImport_triggered(); + + + + void on_actionClose_triggered(); + + void on_actionExportMyPublicKey_triggered(); + private: + + QString readKeyFilename(QString titel); + QString readPassword(); + Ui::MainWindow *ui; + }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 9e3455c..682319c 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -110,28 +110,28 @@ 0 0 590 - 29 + 30 Da&tei - + Eige&nen Schlüssel verwalten - + - - + + - + &Beenden @@ -141,17 +141,17 @@ &Importiere Schlüsselpaar - + Exportiere &öffentlichen Schlüssel - + Exportiere &Schlüsselpaar - + &Erzeuge Schlüsselpaar diff --git a/passworddialog.cpp b/passworddialog.cpp index a9c9590..e612edf 100644 --- a/passworddialog.cpp +++ b/passworddialog.cpp @@ -12,3 +12,16 @@ PasswordDialog::~PasswordDialog() { delete ui; } + +QString PasswordDialog::getPassword() +{ + return ui->lineEditPasswordField->text(); +} + +void PasswordDialog::on_buttonBox_clicked(QAbstractButton *button) +{ + if (ui->buttonBox->standardButton(button) == QDialogButtonBox::Reset) + { + ui->lineEditPasswordField->setText(""); + } +} diff --git a/passworddialog.h b/passworddialog.h index 3db9b1f..9d894ec 100644 --- a/passworddialog.h +++ b/passworddialog.h @@ -1,7 +1,10 @@ #ifndef PASSWORDDIALOG_H #define PASSWORDDIALOG_H +#include +#include #include +#include namespace Ui { class PasswordDialog; @@ -12,9 +15,36 @@ class PasswordDialog : public QDialog Q_OBJECT public: + /** + * @brief PasswordDialog + * Öffnent ein Neues Fenster zur Passwortapfrage. + * @param parent + * Zeiger auf das Aufrufende widget. + */ explicit PasswordDialog(QWidget *parent = 0); + + /** + * @brief PasswordDialog + * Löscht das User Interface. + */ ~PasswordDialog(); + /** + * @brief getPassword + * Gibt die Eingabe aus dem Passwortfeld zurück. + * @return Das eingebenes Passwort. + */ + QString getPassword(); + +private slots: + /** + * @brief on_buttonBox_clicked + * Setz das Passwortfeld Zurück wenn der Zurücksetzen Butten gefrückt wurde. + * @param button + * Der Gedrückt Button. + */ + void on_buttonBox_clicked(QAbstractButton *button); + private: Ui::PasswordDialog *ui; }; diff --git a/passworddialog.ui b/passworddialog.ui index c93ab86..68c91ff 100644 --- a/passworddialog.ui +++ b/passworddialog.ui @@ -55,7 +55,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset @@ -65,32 +65,32 @@ buttonBox - accepted() + rejected() PasswordDialog - accept() + reject() - 248 - 254 + 316 + 260 - 157 + 286 274 buttonBox - rejected() + accepted() PasswordDialog - reject() + accept() - 316 - 260 + 248 + 254 - 286 + 157 274 diff --git a/publickeyimport.cpp b/publickeyimport.cpp deleted file mode 100644 index 19b0438..0000000 --- a/publickeyimport.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "publickeyimport.h" -#include "ui_publickeyimport.h" - -PublicKeyImport::PublicKeyImport(QWidget *parent) : - QWidget(parent), - ui(new Ui::PublicKeyImport) -{ - ui->setupUi(this); -} - -PublicKeyImport::~PublicKeyImport() -{ - delete ui; -} diff --git a/publickeyimport.h b/publickeyimport.h deleted file mode 100644 index ecc64c1..0000000 --- a/publickeyimport.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef PUBLICKEYIMPORT_H -#define PUBLICKEYIMPORT_H - -#include - -namespace Ui { -class PublicKeyImport; -} - -class PublicKeyImport : public QWidget -{ - Q_OBJECT - -public: - explicit PublicKeyImport(QWidget *parent = 0); - ~PublicKeyImport(); - -private: - Ui::PublicKeyImport *ui; -}; - -#endif // PUBLICKEYIMPORT_H diff --git a/publickeyimport.ui b/publickeyimport.ui deleted file mode 100644 index 83bf6a8..0000000 --- a/publickeyimport.ui +++ /dev/null @@ -1,97 +0,0 @@ - - - PublicKeyImport - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - true - - - - ID - - - - - E-Mail - - - - - Name - - - - - - - - - - Hinzufügen - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Löschen - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Reset|QDialogButtonBox::Save - - - false - - - - - - - - diff --git a/publickeyimportdialog.cpp b/publickeyimportdialog.cpp new file mode 100644 index 0000000..a120f4e --- /dev/null +++ b/publickeyimportdialog.cpp @@ -0,0 +1,68 @@ +#include "publickeyimportdialog.h" +#include "ui_publickeyimportdialog.h" + +PublicKeyImportDialog::PublicKeyImportDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::PublicKeyImportDialog) +{ + ui->setupUi(this); + + oneKey = new QListWidgetItem("Eigener Privater Schlüssel", + ui->listWidgetPublicKeys); + + // QStringList listofuserdata; + // listofuserdata << "Eigener Öffentlicher Schlüssel"; + // addtreeitem(listofuserdata); + +} + +PublicKeyImportDialog::~PublicKeyImportDialog() +{ + delete ui; +} + +void PublicKeyImportDialog::on_buttonBox_clicked(QAbstractButton *button) +{ + + if (ui->buttonBox->standardButton(button) == QDialogButtonBox::Reset) + { + ui->listWidgetPublicKeys->clear(); + // ui->listWidgetPublicKeys->addItem(oneKey); + fielListPublicKey.clear(); + } +} + +void PublicKeyImportDialog::on_pushButtonDelete_clicked() +{ + + foreach(QListWidgetItem * item, ui->listWidgetPublicKeys->selectedItems()) + { + if (item != oneKey) + { + fielListPublicKey.removeOne(item->data(0).toString()); + delete item; + } + } +} + +void PublicKeyImportDialog::on_pushButtonAdd_clicked() +{ + + + QString temp = QFileDialog::getOpenFileName(this, + tr("Öffentlichen Schlüssel von Empfänger laden"), + "/home", tr("key(*.net *.der *.pem *.asc)")); + qDebug() << temp; + + fielListPublicKey.append(temp); + + new QListWidgetItem(temp, ui->listWidgetPublicKeys); + +} + + +void PublicKeyImportDialog::accept() +{ + qDebug() << "Speichern"; + QDialog::accept(); +} diff --git a/publickeyimportdialog.h b/publickeyimportdialog.h new file mode 100644 index 0000000..126d073 --- /dev/null +++ b/publickeyimportdialog.h @@ -0,0 +1,41 @@ +#ifndef PUBLICKEYIMPORTDIALOG_H +#define PUBLICKEYIMPORTDIALOG_H + +#include +#include +#include +#include +#include + +#include "crypt/hybridcrypt.h" + +namespace Ui { +class PublicKeyImportDialog; +} + +class PublicKeyImportDialog : public QDialog +{ + Q_OBJECT + +public: + explicit PublicKeyImportDialog(QWidget *parent = 0); + ~PublicKeyImportDialog(); + +private slots: + void on_buttonBox_clicked(QAbstractButton *button); + + void on_pushButtonDelete_clicked(); + + void on_pushButtonAdd_clicked(); + +private: + QVector fielListPublicKey; + Ui::PublicKeyImportDialog *ui; + QListWidgetItem *oneKey; + + // QDialog interface +public slots: + void accept(); +}; + +#endif // PUBLICKEYIMPORTDIALOG_H diff --git a/publickeyimportdialog.ui b/publickeyimportdialog.ui new file mode 100644 index 0000000..c87b983 --- /dev/null +++ b/publickeyimportdialog.ui @@ -0,0 +1,132 @@ + + + PublicKeyImportDialog + + + + 0 + 0 + 569 + 457 + + + + Dialog + + + + + + Datei URLs von Öffentliche Schlüssel + + + Qt::AlignCenter + + + + + + + + Neues Element + + + + + Neues Element + + + + + + + + + + Hinzufügen + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Löschen + + + + + + + + + Qt::Vertical + + + + 20 + 156 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Reset|QDialogButtonBox::Save + + + false + + + + + + + + + buttonBox + rejected() + PublicKeyImportDialog + reject() + + + 284 + 433 + + + 284 + 228 + + + + + buttonBox + accepted() + PublicKeyImportDialog + accept() + + + 284 + 433 + + + 284 + 228 + + + + + -- cgit v1.2.3-70-g09d2