summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CryptLog.pro9
-rw-r--r--decryptdatadialog.cpp56
-rw-r--r--decryptdatadialog.h68
-rw-r--r--decryptdatadialog.ui116
-rw-r--r--mainwindow.cpp43
-rw-r--r--mainwindow.h1
6 files changed, 261 insertions, 32 deletions
diff --git a/CryptLog.pro b/CryptLog.pro
index 52e5193..6a9c2ec 100644
--- a/CryptLog.pro
+++ b/CryptLog.pro
@@ -17,17 +17,20 @@ SOURCES += main.cpp\
passworddialog.cpp \
publickeyimportdialog.cpp \
crypt/hybridcrypt.cpp \
- crypt/cryptexception.cpp
+ crypt/cryptexception.cpp \
+ decryptdatadialog.cpp
HEADERS += mainwindow.h \
passworddialog.h \
publickeyimportdialog.h \
crypt/hybridcrypt.h \
- crypt/cryptexception.h
+ crypt/cryptexception.h \
+ decryptdatadialog.h
FORMS += mainwindow.ui \
passworddialog.ui \
- publickeyimportdialog.ui
+ publickeyimportdialog.ui \
+ decryptdatadialog.ui
RESOURCES += \
ressources.qrc
diff --git a/decryptdatadialog.cpp b/decryptdatadialog.cpp
new file mode 100644
index 0000000..b7d3e2a
--- /dev/null
+++ b/decryptdatadialog.cpp
@@ -0,0 +1,56 @@
+#include "decryptdatadialog.h"
+#include "ui_decryptdatadialog.h"
+
+DecryptDataDialog::DecryptDataDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::DecryptDataDialog)
+{
+ ui->setupUi(this);
+}
+
+DecryptDataDialog::~DecryptDataDialog()
+{
+ delete ui;
+}
+
+void DecryptDataDialog::accept()
+{
+ if (!ui->lineEditFilePath->text().isEmpty())
+ {
+ m_outFile = QFileDialog::getSaveFileName(this, tr("Datei Speichern"),
+ QDir::homePath(), tr("Alle Dateien"));
+
+ if (!m_outFile.isEmpty())
+ {
+ QDialog::accept();
+ }
+ }
+ else
+ {
+ QMessageBox::information(this, tr("Keine verschlüsselte Datei"),
+ tr("Bitte wählen Sie eine verschlüsselte Datei aus,\nbevor Sie entschlüsseln."));
+ }
+
+}
+
+void DecryptDataDialog::on_pushButtonOpenFile_clicked()
+{
+ QString filename = QFileDialog::getOpenFileName(this, tr("Datei Öffnen"),
+ QDir::homePath(),
+ tr("Alle Dateien"));
+
+ if (!filename.isEmpty())
+ {
+ ui->lineEditFilePath->setText(filename);
+ }
+}
+
+QString DecryptDataDialog::getInFilename() const
+{
+ return ui->lineEditFilePath->text();
+}
+
+QString DecryptDataDialog::getOutFileName() const
+{
+ return m_outFile;
+}
diff --git a/decryptdatadialog.h b/decryptdatadialog.h
new file mode 100644
index 0000000..8faf514
--- /dev/null
+++ b/decryptdatadialog.h
@@ -0,0 +1,68 @@
+#ifndef DECRYPTDATADIALOG_H
+#define DECRYPTDATADIALOG_H
+
+#include <QDialog>
+#include <QDir>
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QString>
+
+namespace Ui {
+class DecryptDataDialog;
+}
+
+/**
+ * @brief Ein Wizard, der durch das Entschlüsseln führt.
+ */
+class DecryptDataDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @brief Erzeugt ein neuen DecryptDataDialog, mit dem angegeben Elternfenster.
+ * @param parent Das Elternfenster, welches überschattet wird.
+ */
+ explicit DecryptDataDialog(QWidget *parent = 0);
+ ~DecryptDataDialog();
+
+ /**
+ * @brief Gibt den Pfad der zu speichernden Datei an.
+ * @return Der Dateipfad.
+ */
+ QString getOutFileName() const;
+
+ /**
+ * @brief Gibt den Pfad der zu entschlüsselnden Datei an.
+ * @return Der Dateipfad.
+ */
+ QString getCipherFilename() const;
+
+public slots:
+ /**
+ * @brief Fängt Fehler nach dem Okay ab.
+ */
+ virtual void accept();
+
+private slots:
+ /**
+ * @brief Öffnet einen Dateidialog
+ * für die verschlüsselte Datei.
+ * Schreibt Dateipfad in lineEditFilePath(ChangeEvent).
+ */
+ void on_pushButtonOpenFile_clicked();
+
+private:
+ /**
+ * @brief Liefert Zugriff auf die UI.
+ */
+ Ui::DecryptDataDialog *ui;
+
+ /**
+ * @brief Der Pfad, der zu speichernden Datei.
+ */
+ QString m_outFile;
+
+};
+
+#endif // DECRYPTDATADIALOG_H
diff --git a/decryptdatadialog.ui b/decryptdatadialog.ui
new file mode 100644
index 0000000..35fa56a
--- /dev/null
+++ b/decryptdatadialog.ui
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DecryptDataDialog</class>
+ <widget class="QDialog" name="DecryptDataDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Verschlüsselte Datei auswählen</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="lineEditFilePath">
+ <property name="echoMode">
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonOpenFile">
+ <property name="text">
+ <string>Datei auswählen</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>DecryptDataDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>DecryptDataDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8b888aa..efec3ad 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -17,43 +17,28 @@ void MainWindow::on_pushButtonDecrypt_clicked()
{
if (hybridcrypt.isUserKeyInitialised())
{
- QString inFilename = QFileDialog::getOpenFileName(this,
- tr("Verschlüsselte Datei laden"), QDir::homePath(), tr("Alle Dateien"));
+ DecryptDataDialog decryptDialog;
- if (!inFilename.isEmpty())
+ if (decryptDialog.exec())
{
-
- QString outFilename = QFileDialog::getSaveFileName(this,
- tr("Entschlüsselte Datei speichern"), QDir::homePath(), tr("Alle Dateien"));
-
- if (!outFilename.isEmpty())
+ try
{
- try
- {
- statusBar()->showMessage(tr("Entschlüsselung hat begonnen."), messageTimeout);
- hybridcrypt.decrypt(inFilename, outFilename);
- statusBar()->showMessage(tr("Entschlüsselung war erfolgreich."),
- messageTimeout);
+ QString inFilename = decryptDialog.getInFilename();
+ QString outFilename = decryptDialog.getOutFileName();
- // Zeige entschlüsselte Datei
- ui->lineEditFilePath->setText(outFilename);
- }
- catch (CryptException e)
- {
- QMessageBox::critical(this, tr("Fehler beim Entschlüsseln"), e.what());
- }
+ statusBar()->showMessage(tr("Entschlüsselung hat begonnen."), messageTimeout);
+ hybridcrypt.decrypt(inFilename, outFilename);
+ statusBar()->showMessage(tr("Entschlüsselung war erfolgreich."),
+ messageTimeout);
+
+ // Zeige entschlüsselte Datei
+ ui->lineEditFilePath->setText(outFilename);
}
- else
+ catch (CryptException e)
{
- QMessageBox::warning(this, tr("Keinen Seicherort ausgewählt"),
- tr("Sie haben keine Speicherort für die entschlüsselte Datei eingegeben."));
+ QMessageBox::critical(this, tr("Fehler beim Entschlüsseln"), e.what());
}
}
- else
- {
- QMessageBox::information(this, tr("Kein Datei ausgewählt"),
- tr("Sie haben keine Datei eingeben die entschlüsselt werden soll."));
- }
}
else
{
diff --git a/mainwindow.h b/mainwindow.h
index 4ae6bb9..f7ddaae 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -13,6 +13,7 @@
#include "crypt/hybridcrypt.h"
#include "passworddialog.h"
#include "publickeyimportdialog.h"
+#include "decryptdatadialog.h"
namespace Ui {
class MainWindow;