diff options
| author | Martin Talarczyk <talarczyk.martin@fh-swf.de> | 2015-09-29 23:18:11 +0200 |
|---|---|---|
| committer | Martin Talarczyk <talarczyk.martin@fh-swf.de> | 2015-09-29 23:18:11 +0200 |
| commit | f3fce1732e286999132d05638c1ade32cb1f7185 (patch) | |
| tree | 2e9647793656f477bea9cdceaff944d6a567e842 /mainwindow.cpp | |
| parent | 5e3a2b3c451240415a6472fab05de0e4a2f232e1 (diff) | |
| download | src-f3fce1732e286999132d05638c1ade32cb1f7185.tar.gz src-f3fce1732e286999132d05638c1ade32cb1f7185.zip | |
Entferne Private Funksionen, Korigiere User Frührung
Eine Sinvollere leitung duch das Programm einfügen.
Private Funksionen für File Dialoge enfernen und ersetzen.
Diffstat (limited to 'mainwindow.cpp')
| -rw-r--r-- | mainwindow.cpp | 110 |
1 files changed, 41 insertions, 69 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index 7df9bbe..a4f45f0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -18,34 +18,38 @@ MainWindow::~MainWindow() void MainWindow::on_pushButtonDecrypt_clicked() { QString in = ui->lineEditFilePath->text(); - QString out = readFilename(tr("Speicher Ort für Entschlüsselte Datei")); + QString out; - if (in.isEmpty()) - { - QMessageBox::information(this, tr("Kein Datei ausgewählt"), - tr("Sie haben keine Datei eingegen die Entschlüsselt werden soll.")); - ui->lineEditFilePath->setFocus(); - } - else + if (hybridcrypt.isUserKeyInitialised()) { if (in.isEmpty()) { - QMessageBox::warning(this, tr("Keine Seicherort ausgefählt"), - tr("Sie haben keine Speicherort für die Entschlüsselte Datei eingegeben.")); + QMessageBox::information(this, tr("Kein Datei ausgewählt"), + tr("Sie haben keine Datei eingegen die Entschlüsselt werden soll.")); + ui->lineEditFilePath->setFocus(); + out = QFileDialog::getSaveFileName(this, + tr("Speicherort für Entschlüsseltedatei"), tr("Alle Datein")); } else { - try + if (out.isEmpty()) { - hybridcrypt.decrypt(in, out); + QMessageBox::warning(this, tr("Keine Seicherort ausgefählt"), + tr("Sie haben keine Speicherort für die Entschlüsselte Datei eingegeben.")); } - catch (CryptException e) + else { - QMessageBox::critical(this, tr("Fehler beim Entschlüsseln"), e.what()); + try + { + hybridcrypt.decrypt(in, out); + } + catch (CryptException e) + { + QMessageBox::critical(this, tr("Fehler beim Entschlüsseln"), e.what()); + } } } } - } void MainWindow::on_pushButtonEncrypt_clicked() @@ -82,7 +86,8 @@ void MainWindow::on_pushButtonEncrypt_clicked() void MainWindow::on_pushButtonOpenFile_clicked() { - QString fielname = readFilename("Datei öffnen"); + QString fielname = QFileDialog::getOpenFileName(this, tr("Datei Öffnen"), + tr("Alle Datein")); ui->lineEditFilePath->setText(fielname); } @@ -90,22 +95,22 @@ void MainWindow::on_pushButtonOpenFile_clicked() void MainWindow::on_actionImport_triggered() { - QString filename = readKeyFilename(tr("Importiren eines Schlüsselpaares")); + // nur für pem und der + QString filename = QFileDialog::getOpenFileName(this, + tr("Schlüssel Datei für Import."), tr("Schlüssel Datei (*.pem,*.der)")); if (!filename.isEmpty()) { - QString password = readPassword(); + PasswordDialog pwd; + pwd.exec(); - if (!password.isEmpty()) + try { - try - { - hybridcrypt.importUserKeypair(filename, password); - } - catch (CryptException e) - { - QMessageBox::critical(this, tr("Fehler beim Importieren"), e.what()); - } + hybridcrypt.importUserKeypair(filename, pwd.getPassword()); + } + catch (CryptException e) + { + QMessageBox::critical(this, tr("Fehler beim Importieren"), e.what()); } } else @@ -118,8 +123,6 @@ void MainWindow::on_actionImport_triggered() void MainWindow::on_actionExportMyKeypair_triggered() { - qDebug() << "on_actionExportMyKeypair_triggered"; - if (hybridcrypt.isUserKeyInitialised()) { QString expoKeyFileName = QFileDialog::getSaveFileName(this, @@ -129,17 +132,17 @@ void MainWindow::on_actionExportMyKeypair_triggered() if (!expoKeyFileName.isEmpty()) { - if (pwd.exec()) + pwd.exec(); + + try { - try - { - hybridcrypt.exportUserKeypair(expoKeyFileName, pwd.getPassword()); - } - catch (CryptException e) - { - QMessageBox::critical(this, tr("Fehler beim Exportieren"), e.what()); - } + hybridcrypt.exportUserKeypair(expoKeyFileName, pwd.getPassword()); + } + catch (CryptException e) + { + QMessageBox::critical(this, tr("Fehler beim Exportieren"), e.what()); } + } else { @@ -152,8 +155,6 @@ void MainWindow::on_actionExportMyKeypair_triggered() void MainWindow::on_actionExportMyPublicKey_triggered() { - qDebug() << "on_actionExportMyPublicKey_triggered"; - if (hybridcrypt.isUserKeyInitialised()) { QString expoKeyFileName = QFileDialog::getSaveFileName(this, @@ -201,32 +202,3 @@ void MainWindow::on_actionClose_triggered() { close(); } - -//Private Funksionen - -QString MainWindow::readKeyFilename(QString titel) -{ - return QFileDialog::getOpenFileName(this, titel, - QDir::homePath(), tr("Schlüssel Datein")); -} - -QString MainWindow::readFilename(QString titel) -{ - return QFileDialog::getOpenFileName(this, titel, - QDir::homePath(), tr("Alle Datein")); -} - -QString MainWindow::readPassword() -{ - PasswordDialog w; - - if (w.exec()) - { - return w.getPassword(); - } - - return ""; -} - - - |
