#ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include #include #include #include #include #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