blob: 9352e0f24e319bfb6515300428f1c88ede78715a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPlainTextEdit>
#include <QMenu>
#include <QActionGroup>
#include <QMessageBox>
#include <QFile>
#include "tabwidgetselectalgorithm.h"
#include "crypt/cryptengine.h"
#include "dialogload.h"
#include "dialogsave.h"
namespace Ui {
class MainWindow;
}
/**
* \class MainWindow
* \brief Class for the Application's MainWindow.
*
* This Class encapsulates the GUI-functionality (Menu, Buttons, Edits and their connections).
* The Attribute m_cryptEngine provides an interface to all crypt-related functionality.
* [m_cryptEngine is a QObject and thus can be connected via Signals and Slots]
* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
* \version 1.0.1
* \date 13.05.2013
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public: //Methods
/**
* \brief Class Constructor.
*
* Class Constructor. Initializes Graphical Elements of the Widget and sets the Window's Title.
* A new cryptEngine is created (m_cryptEngine).
* Menu actions for the four kinds of Ciphers are grouped in the actionGroup m_actionGroupAlgorithm to enable
* exclusive selection.
* The TabWidgetSelectAlgorithm's Signal "currentTabChanged(QString)" is connected to the Slot "oncurrentTabChanged_triggered(QString)",
* so that the currently active Tab corresponds to what action is selected in the menu.
* \param QWidget* parent The QWidget the used instance of this class is subordinated to (0, since this is the MainWindow).
*/
MainWindow(QWidget *parent = 0);
/**
* \brief Class Destructor.
*
* Class Destructor. Deletes CryptEngine and the ui-Object containing the graphical Elements.
*/
~MainWindow();
private: //Attributes
/**
* \brief Pointer to GUI-Object.
*/
Ui::MainWindow* ui;
/**
* \brief Pointer to the instance of the Crypt-Interface-Class.
*/
CryptEngine* m_cryptEngine;
/**
* \brief Actiongroup used to group the menu-actions for the four kinds of Ciphers.
*/
QActionGroup* m_actionGroupAlgorithm;
private: //Methods
/**
* \brief Method to put Text from a File into a QPlainTextEdit.
*
* \param QPlainTextEdit* destination Text will be inserted here.
*/
void setDataToPlainTextEditUnencrypted( QString text );
/**
* \brief Method to put Text from a File into a QPlainTextEdit.
*
* \param QPlainTextEdit* destination Text will be inserted here.
*/
void setDataToPlainTextEditEncrypted( QString text );
/**
* \brief Method to put Text from a File into a QPlainTextEdit.
*
* Reads all Text from File and puts it into the given QPlainTextEdit.
* \param QPlainTextEdit* destination Text will be inserted here.
* \param QFile* source Text will be read from here.
*/
void setPlainTextFromFile( QPlainTextEdit* destination, QFile* source );
/**
* \brief Method to put Binary Data from a File into a Subclass of QPlainTextEdit.
*
* Reads all data from File and puts it into the given QPlainTextEdit.
* \param QPlainTextEdit* destination Data will be inserted here.
* \param QFile* source Data will be read from here.
* \attention THIS METHOD IS NOT IMPLEMENTED YET
*/
void setBinaryDataFromFile( QPlainTextEdit* destination, QFile* source );
/**
* \brief Method to write Text from a QPlainTextEdit into a File.
*
* Writes all Text from QPlainTextEdit and puts it into the given File.
* \param QPlainTextEdit* source Text will be read from here.
* \param QFile* destination Text will be read from here.
*/
void writePlainTextToFile( QPlainTextEdit* source, QFile* destination );
/**
* \brief Method to write Binary Data into a File.
*
* Writes all data into File.
* \param QPlainTextEdit* source Text will be inserted here.
* \param QFile* destination Text will be read from here.
* \attention THIS METHOD IS NOT IMPLEMENTED YET
*/
void writeBinaryDataToFile( QPlainTextEdit* source, QFile* destination );
private slots:
//actions
/**
* \brief Slot for the Load Action.
*
* Opens a Dialog for selection of the file to open.
*/
void on_actionLoad_triggered();
/**
* \brief Slot for the Save Action.
*
* Opens a Dialog for selection of the file to save.
*/
void on_actionSave_triggered();
/**
* \brief Slot for the Exit Action.
*
* Closes the application.
*/
void on_actionExit_triggered();
/**
* \brief Slot for the About Action.
*
* Opens a Message Box displaying basic Information about the application.
*/
void on_actionAbout_triggered();
//crypt actions
/**
* \brief Slot for the NullCipher Action.
*
* Sets the active kind of algorithm to NullCipher. The instance of the TabWidgetSelectAlgorithm's Tab for NullCipher
* will be set active as well.
*/
void on_actionNullCipher_triggered();
/**
* \brief Slot for the Symmetric Action.
*
* Sets the active kind of algorithm to Symmetric Ciphers. The instance of the TabWidgetSelectAlgorithm's Tab for Symmetric Ciphers
* will be set active as well.
*/
void on_actionSymmetric_triggered();
/**
* \brief Slot for the Asymmetric Action.
*
* Sets the active kind of algorithm to Asymmetric Ciphers. The instance of the TabWidgetSelectAlgorithm's Tab for Asymmetric Ciphers
* will be set active as well.
*/
void on_actionAsymmetric_triggered();
/**
* \brief Slot for the Hybrid Action.
*
* Sets the active kind of algorithm to Hybrid Ciphers. The instance of the TabWidgetSelectAlgorithm's Tab for Hybrid Ciphers
* will be set active as well.
*/
void on_actionHybrid_triggered();
void on_actionUnencrypted_as_Text_triggered(bool checked);
void on_actionUnencrypted_as_Binary_triggered(bool checked);
void on_actionEncrypted_as_Text_triggered(bool checked);
void on_actionEncrypted_as_Binary_triggered(bool checked);
//rest gui
/**
* \brief Slot for the Button which tells the CryptEngine to generate a new Password.
*
* Calls the generatePassword Method of class CryptEngine.
* \attention This Method may do nothing depending on the Algorithm in use.
* \see CryptEngine::generatePassword
*/
void on_pushButtonGeneratePassword_clicked();
/**
* \brief Slot for the Clear Button for QPlainTextEdit for Unencrpted Data.
*
* Calls the clear-method of the QPlainTextEdit for Unencrypted Data.
*/
void on_pushButtonClearUnencrypted_clicked();
/**
* \brief Slot for the Clear Button for QPlainTextEdit for Encrpted Data.
*
* Calls the clear-method of the QPlainTextEdit for Encrypted Data.
*/
void on_pushButtonClearEncrypted_clicked();
/**
* \brief Slot for the Encrypt Button.
*
* Calls the encrypt-method of m_CryptEngine, encrypting CryptText using the currently selected algorithm and key.
*/
void on_pushButtonEncrypt_clicked();
/**
* \brief Slot for the Decrypt Button.
*
* Calls the decrypt-method of m_CryptEngine, decrypting CryptText using the currently selected algorithm and key.
*/
void on_pushButtonDecrypt_clicked();
/**
* \brief Slot for the Load Button.
*
* Opens a Dialog for selection of the file to open by calling on_actionLoad_triggered().
*/
void on_pushButtonLoad_clicked();
/**
* \brief Slot for the Save Button.
*
* Opens a Dialog for selection of the file to save by calling on_actionSave_triggered().
*/
void on_pushButtonSave_clicked();
//rest/ other
/**
* \brief Slot called when the instance of TabWidgetSelectAlgorithm changes the active Tab.
*
* Changes the currently selected Menu-Action (what kind of encryption) according to the newly active Tab.
*/
void oncurrentTabChanged_triggered( QString currentTabName );
/**
* \brief Slot called to change PlainTextEdits from Binary to PlainText when a new algorithm is selected.
*
* Sets both PlainttextEdits to whatever the newly selected algorithm needs.
*/
void ondataIsBinary_triggered( bool dataIsBinary );
};
#endif // MAINWINDOW_H
|