diff options
| -rw-r--r-- | CryptLog.pro | 10 | ||||
| -rw-r--r-- | main.cpp | 3 | ||||
| -rw-r--r-- | mainwindow.cpp | 76 | ||||
| -rw-r--r-- | mainwindow.h | 26 | ||||
| -rw-r--r-- | mainwindow.ui | 18 | ||||
| -rw-r--r-- | passworddialog.cpp | 13 | ||||
| -rw-r--r-- | passworddialog.h | 30 | ||||
| -rw-r--r-- | passworddialog.ui | 22 | ||||
| -rw-r--r-- | publickeyimport.cpp | 14 | ||||
| -rw-r--r-- | publickeyimport.h | 22 | ||||
| -rw-r--r-- | publickeyimportdialog.cpp | 68 | ||||
| -rw-r--r-- | publickeyimportdialog.h | 41 | ||||
| -rw-r--r-- | publickeyimportdialog.ui (renamed from publickeyimport.ui) | 83 |
13 files changed, 341 insertions, 85 deletions
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 @@ -1,11 +1,14 @@ #include "mainwindow.h" +#include "passworddialog.h" #include <QApplication> 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 <QFileDialog> #include <QMainWindow> +#include <QDebug> + +#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 @@ <x>0</x> <y>0</y> <width>590</width> - <height>29</height> + <height>30</height> </rect> </property> <widget class="QMenu" name="menuDatei"> <property name="title"> <string>Da&tei</string> </property> - <addaction name="actionBeenden"/> + <addaction name="actionClose"/> </widget> <widget class="QMenu" name="menuSchl_ssel"> <property name="title"> <string>Eige&nen Schlüssel verwalten</string> </property> - <addaction name="actionErzeuge_Schl_sselpaar"/> + <addaction name="actionCreateKeypar"/> <addaction name="actionImport"/> - <addaction name="actionMein_privater_Schl_ssel"/> - <addaction name="actionMein_ffentlicher_Schl_ssel"/> + <addaction name="actionExportMyKeypar"/> + <addaction name="actionExportMyPublicKey"/> </widget> <addaction name="menuDatei"/> <addaction name="menuSchl_ssel"/> </widget> - <action name="actionBeenden"> + <action name="actionClose"> <property name="text"> <string>&Beenden</string> </property> @@ -141,17 +141,17 @@ <string>&Importiere Schlüsselpaar</string> </property> </action> - <action name="actionMein_ffentlicher_Schl_ssel"> + <action name="actionExportMyPublicKey"> <property name="text"> <string>Exportiere &öffentlichen Schlüssel</string> </property> </action> - <action name="actionMein_privater_Schl_ssel"> + <action name="actionExportMyKeypar"> <property name="text"> <string>Exportiere &Schlüsselpaar</string> </property> </action> - <action name="actionErzeuge_Schl_sselpaar"> + <action name="actionCreateKeypar"> <property name="text"> <string>&Erzeuge Schlüsselpaar</string> </property> 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 <QAbstractButton> +#include <QDebug> #include <QDialog> +#include <QString> 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 @@ <enum>Qt::Horizontal</enum> </property> <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set> </property> </widget> </item> @@ -65,32 +65,32 @@ <connections> <connection> <sender>buttonBox</sender> - <signal>accepted()</signal> + <signal>rejected()</signal> <receiver>PasswordDialog</receiver> - <slot>accept()</slot> + <slot>reject()</slot> <hints> <hint type="sourcelabel"> - <x>248</x> - <y>254</y> + <x>316</x> + <y>260</y> </hint> <hint type="destinationlabel"> - <x>157</x> + <x>286</x> <y>274</y> </hint> </hints> </connection> <connection> <sender>buttonBox</sender> - <signal>rejected()</signal> + <signal>accepted()</signal> <receiver>PasswordDialog</receiver> - <slot>reject()</slot> + <slot>accept()</slot> <hints> <hint type="sourcelabel"> - <x>316</x> - <y>260</y> + <x>248</x> + <y>254</y> </hint> <hint type="destinationlabel"> - <x>286</x> + <x>157</x> <y>274</y> </hint> </hints> 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 <QWidget> - -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/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 <QAbstractButton> +#include <QDebug> +#include <QDialog> +#include <QFileDialog> +#include <QListWidgetItem> + +#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<QString> fielListPublicKey; + Ui::PublicKeyImportDialog *ui; + QListWidgetItem *oneKey; + + // QDialog interface +public slots: + void accept(); +}; + +#endif // PUBLICKEYIMPORTDIALOG_H diff --git a/publickeyimport.ui b/publickeyimportdialog.ui index 83bf6a8..c87b983 100644 --- a/publickeyimport.ui +++ b/publickeyimportdialog.ui @@ -1,43 +1,45 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>PublicKeyImport</class> - <widget class="QWidget" name="PublicKeyImport"> + <class>PublicKeyImportDialog</class> + <widget class="QDialog" name="PublicKeyImportDialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>300</height> + <width>569</width> + <height>457</height> </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>Dialog</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QTreeWidget" name="treeWidgetPublicKeys"> - <attribute name="headerStretchLastSection"> - <bool>true</bool> - </attribute> - <column> - <property name="text"> - <string>ID</string> - </property> - </column> - <column> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Datei URLs von Öffentliche Schlüssel </string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidgetPublicKeys"> + <item> <property name="text"> - <string>E-Mail</string> + <string>Neues Element</string> </property> - </column> - <column> + </item> + <item> <property name="text"> - <string>Name</string> + <string>Neues Element</string> </property> - </column> + </item> </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QPushButton" name="pushButtonAdd"> <property name="text"> @@ -46,7 +48,7 @@ </widget> </item> <item> - <spacer name="horizontalSpacer_3"> + <spacer name="horizontalSpacer_4"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -75,7 +77,7 @@ <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>156</height> </size> </property> </spacer> @@ -93,5 +95,38 @@ </layout> </widget> <resources/> - <connections/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PublicKeyImportDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>284</x> + <y>433</y> + </hint> + <hint type="destinationlabel"> + <x>284</x> + <y>228</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PublicKeyImportDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>284</x> + <y>433</y> + </hint> + <hint type="destinationlabel"> + <x>284</x> + <y>228</y> + </hint> + </hints> + </connection> + </connections> </ui> |
