Refractoring code and adding memory management
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
#include"Cryption.h"
|
||||
|
||||
Cryption::Cryption()
|
||||
{ }
|
||||
|
||||
Cryption::~Cryption()
|
||||
{ }
|
||||
|
||||
Cryption::Cryption(const std::string& message)
|
||||
{ this->message = message; }
|
||||
|
||||
|
||||
+3
-5
@@ -1,22 +1,20 @@
|
||||
#ifndef CRYPTION_H
|
||||
#define CRYPTION_H
|
||||
|
||||
#include<fstream>
|
||||
#include<string>
|
||||
|
||||
class Cryption
|
||||
{
|
||||
public:
|
||||
Cryption();
|
||||
~Cryption();
|
||||
Cryption() = default;
|
||||
~Cryption() = default;
|
||||
Cryption(const std::string&);
|
||||
|
||||
std::string getMessage() const;
|
||||
protected:
|
||||
void setMessage(const std::string&);
|
||||
|
||||
std::string message{};
|
||||
std::fstream ioEvent{};
|
||||
std::string message;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+6
-10
@@ -1,4 +1,5 @@
|
||||
#include<iostream>
|
||||
#include<fstream>
|
||||
#include<sstream>
|
||||
#include<ios>
|
||||
#include<string>
|
||||
@@ -6,14 +7,11 @@
|
||||
#include"Decryption.h"
|
||||
#include"GenerateKeys.h"
|
||||
|
||||
Decryption::Decryption()
|
||||
{ }
|
||||
|
||||
Decryption::~Decryption()
|
||||
{ }
|
||||
|
||||
Decryption::Decryption(const std::string& message)
|
||||
{ this->message = message; }
|
||||
{
|
||||
this->message = message;
|
||||
decryptMessage();
|
||||
}
|
||||
|
||||
|
||||
void Decryption::setDecryptedMessage(const std::string& message)
|
||||
@@ -22,7 +20,7 @@ void Decryption::setDecryptedMessage(const std::string& message)
|
||||
void Decryption::decryptMessage()
|
||||
{
|
||||
GenerateKeys gk{};
|
||||
|
||||
std::fstream ioEvent{};
|
||||
ioEvent.open("encryptedFile.txt", std::ios::in);
|
||||
|
||||
std::string messageToBeDecrypted{}, decryptedMessage{};
|
||||
@@ -35,10 +33,8 @@ void Decryption::decryptMessage()
|
||||
{
|
||||
char cryptedKey[5]{};
|
||||
for (auto index = 0; index!=5; ++index)
|
||||
{
|
||||
cryptedKey[index] = (messageToBeDecrypted.at(indexOfChar + index));
|
||||
|
||||
}
|
||||
decryptedMessage += gk.decryptedCharacters[cstringToString(cryptedKey, 5)];
|
||||
}
|
||||
setDecryptedMessage(decryptedMessage);
|
||||
|
||||
+3
-4
@@ -9,9 +9,8 @@
|
||||
class Decryption : public Cryption
|
||||
{
|
||||
public:
|
||||
|
||||
Decryption();
|
||||
~Decryption();
|
||||
Decryption() = default;
|
||||
~Decryption() = default;
|
||||
Decryption(const std::string&);
|
||||
|
||||
void setDecryptedMessage(const std::string&);
|
||||
@@ -21,7 +20,7 @@ public:
|
||||
|
||||
private:
|
||||
std::string cstringToString(char[], const int&);
|
||||
std::string decryptedMessage{};
|
||||
std::string decryptedMessage;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+8
-16
@@ -1,40 +1,32 @@
|
||||
#include<ios>
|
||||
#include<iostream>
|
||||
#include<fstream>
|
||||
#include<string>
|
||||
|
||||
#include"Encryption.h"
|
||||
#include"GenerateKeys.h"
|
||||
|
||||
Encryption::Encryption()
|
||||
{ }
|
||||
|
||||
Encryption::~Encryption()
|
||||
{ }
|
||||
|
||||
Encryption::Encryption(const std::string& message)
|
||||
{ this->message = message; }
|
||||
{
|
||||
this->message = message;
|
||||
encryptMessage();
|
||||
}
|
||||
|
||||
|
||||
void Encryption::setEncryptedMessage(const std::string& encryptedMessage)
|
||||
{ this->encryptedMessage = encryptedMessage; }
|
||||
void Encryption::encryptMessage()
|
||||
{
|
||||
auto numberOfNewLines = 0;
|
||||
GenerateKeys gk{};
|
||||
std::fstream ioEvent{};
|
||||
ioEvent.open("encryptedFile.txt", std::ios::out);
|
||||
|
||||
for (auto index = 0; index != message.size(); ++index)
|
||||
{
|
||||
char stringIndex = message.at(index);
|
||||
if (stringIndex == '\n')
|
||||
++numberOfNewLines;
|
||||
}
|
||||
for (auto indexOfString = 0; indexOfString!=message.size(); ++indexOfString)
|
||||
for (auto indexOfString = 0u; indexOfString!=message.size(); ++indexOfString)
|
||||
{
|
||||
ioEvent << gk.encryptedCharacters[message.at(indexOfString)];
|
||||
encryptedMessage += (gk.encryptedCharacters[message.at(indexOfString)]);
|
||||
}
|
||||
setEncryptedMessage(encryptedMessage);
|
||||
this->encryptedMessage = encryptedMessage;
|
||||
ioEvent.close();
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -9,17 +9,16 @@
|
||||
class Encryption : public Cryption
|
||||
{
|
||||
public:
|
||||
Encryption();
|
||||
~Encryption();
|
||||
Encryption() = default;
|
||||
~Encryption() = default;
|
||||
Encryption(const std::string&);
|
||||
|
||||
void setEncryptedMessage(const std::string&);
|
||||
void encryptMessage();
|
||||
|
||||
std::string getEncryptedMessage() const;
|
||||
|
||||
private:
|
||||
std::string encryptedMessage{};
|
||||
std::string encryptedMessage;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+11
-15
@@ -11,18 +11,13 @@ GenerateKeys::GenerateKeys()
|
||||
populateNumbers();
|
||||
populateLetters();
|
||||
|
||||
for (auto index = 0u; index!=symbols.size(); ++index)
|
||||
allCharacters.push_back(symbols[index]);
|
||||
for (auto index = 0u; index!=numbers.size(); ++index)
|
||||
allCharacters.push_back(numbers[index]);
|
||||
for (auto index = 0u; index!=letters.size(); ++index)
|
||||
allCharacters.push_back(letters[index]);
|
||||
addToCentralContainer(symbols);
|
||||
addToCentralContainer(numbers);
|
||||
addToCentralContainer(letters);
|
||||
|
||||
populateDecryptedValues();
|
||||
populateEncryptedValues();
|
||||
}
|
||||
GenerateKeys::~GenerateKeys()
|
||||
{ }
|
||||
|
||||
void GenerateKeys::populateDecryptedValues()
|
||||
{
|
||||
@@ -33,7 +28,7 @@ void GenerateKeys::populateDecryptedValues()
|
||||
{
|
||||
readKeys >> tmpKey;
|
||||
decryptedCharacters[tmpKey] = static_cast<char>(allCharacters[index]);
|
||||
tmpKey = "";
|
||||
tmpKey.assign("");
|
||||
}
|
||||
readKeys.close();
|
||||
decryptedCharacters["#2a9u"] = (char) 32;
|
||||
@@ -48,7 +43,7 @@ void GenerateKeys::populateEncryptedValues()
|
||||
{
|
||||
readKeys >> tmpKey;
|
||||
encryptedCharacters[decryptedCharacters[tmpKey]] = tmpKey;
|
||||
tmpKey = "";
|
||||
tmpKey.assign("");
|
||||
}
|
||||
readKeys.close();
|
||||
encryptedCharacters[(char) 32] = "#2a9u";
|
||||
@@ -70,16 +65,19 @@ void GenerateKeys::populateNumbers()
|
||||
}
|
||||
void GenerateKeys::populateLetters()
|
||||
{
|
||||
addRange(letters, 65, 90);
|
||||
addRange(letters, 97, 122);
|
||||
}
|
||||
void GenerateKeys::addRange(std::vector<int>& ch, int from, const int to)
|
||||
{
|
||||
auto range = to - from;
|
||||
for (auto index = 0; index<=range; ++index)
|
||||
{
|
||||
for (auto index = 0; index<=range; ++index, ++from)
|
||||
ch.push_back(from);
|
||||
++from;
|
||||
}
|
||||
void GenerateKeys::addToCentralContainer(std::vector<int>& con)
|
||||
{
|
||||
for (auto index = 0u; index!=con.size(); ++index)
|
||||
allCharacters.push_back(con[index]);
|
||||
}
|
||||
void GenerateKeys::generateKey(std::string& key, const int& SIZE)
|
||||
{
|
||||
@@ -127,10 +125,8 @@ bool GenerateKeys::isThereRepetition()
|
||||
std::string chosenOne{keys[index]};
|
||||
auto repetition{0};
|
||||
for (auto innerIndex = 0; innerIndex!=totalCharacters; ++innerIndex)
|
||||
{
|
||||
if (chosenOne == keys[innerIndex])
|
||||
++repetition;
|
||||
}
|
||||
if (repetition > 1)
|
||||
{
|
||||
std::cout << "Too much repetitive stuff" << std::endl;
|
||||
|
||||
+2
-1
@@ -9,7 +9,7 @@ class GenerateKeys
|
||||
{
|
||||
public:
|
||||
GenerateKeys();
|
||||
~GenerateKeys();
|
||||
~GenerateKeys() = default;
|
||||
|
||||
void populateDecryptedValues();
|
||||
void populateEncryptedValues();
|
||||
@@ -26,6 +26,7 @@ private:
|
||||
void populateNumbers();
|
||||
void populateLetters();
|
||||
void addRange(std::vector<int>&, int, const int);
|
||||
void addToCentralContainer(std::vector<int>&);
|
||||
|
||||
void generateKey(std::string&, const int&);
|
||||
bool isThereRepetition();
|
||||
|
||||
+19
-27
@@ -15,40 +15,32 @@ KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
GenerateKeys gk{};
|
||||
|
||||
comboBoxOfKeys = new QComboBox{};
|
||||
valueOfKey = new QLineEdit{};
|
||||
generateNewDefaultKeys = new QPushButton(tr("Generate New Default Key"));
|
||||
comboBoxOfKeys = unique_ptr<QComboBox>{new QComboBox{}};
|
||||
valueOfKey = unique_ptr<QLineEdit>{new QLineEdit{}};
|
||||
generateNewDefaultKeys = unique_ptr<QPushButton>{new QPushButton(tr("Generate New Default Key"))};
|
||||
|
||||
vBox = new QVBoxLayout;
|
||||
hBox = new QHBoxLayout;
|
||||
QHBoxLayout* hBox2 = new QHBoxLayout;
|
||||
vBox = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
hBox = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||
hBox2 = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||
|
||||
setContentsOfComboBox();
|
||||
hBox->addWidget(comboBoxOfKeys);
|
||||
hBox->addWidget(valueOfKey);
|
||||
hBox.get()->addWidget(comboBoxOfKeys.get());
|
||||
hBox.get()->addWidget(valueOfKey.get());
|
||||
|
||||
hBox2->addWidget(generateNewDefaultKeys);
|
||||
hBox2.get()->addWidget(generateNewDefaultKeys.get());
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
vBox->addLayout(hBox2);
|
||||
vBox.get()->addLayout(hBox.get());
|
||||
vBox.get()->addLayout(hBox2.get());
|
||||
|
||||
setLayout(vBox);
|
||||
setLayout(vBox.get());
|
||||
|
||||
setFixedWidth(400);
|
||||
setFixedHeight(400);
|
||||
setFixedWidth(windowWidth);
|
||||
setFixedHeight(windowHeight);
|
||||
|
||||
setWindowTitle("Key Management Window");
|
||||
|
||||
QObject::connect(comboBoxOfKeys, SIGNAL(currentIndexChanged(int)), SLOT(test()));
|
||||
QObject::connect(generateNewDefaultKeys, SIGNAL(clicked()), this, SLOT(generation()));
|
||||
}
|
||||
KeyManagementWindow::~KeyManagementWindow()
|
||||
{
|
||||
delete comboBoxOfKeys;
|
||||
delete valueOfKey;
|
||||
delete generateNewDefaultKeys;
|
||||
delete hBox;
|
||||
delete vBox;
|
||||
QObject::connect(comboBoxOfKeys.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
|
||||
QObject::connect(generateNewDefaultKeys.get(), SIGNAL(clicked()), this, SLOT(generation()));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,13 +52,13 @@ void KeyManagementWindow::setContentsOfComboBox()
|
||||
{
|
||||
std::string ch{static_cast<char>(gk.allCharacters[index])};
|
||||
QString bl = QString::fromStdString(ch);
|
||||
comboBoxOfKeys->addItem(bl);
|
||||
comboBoxOfKeys.get()->addItem(bl);
|
||||
}
|
||||
}
|
||||
void KeyManagementWindow::test()
|
||||
{
|
||||
GenerateKeys gk{};
|
||||
QString bo{comboBoxOfKeys->currentText()};
|
||||
QString bo{comboBoxOfKeys.get()->currentText()};
|
||||
std::string k{bo.toStdString()};
|
||||
char f{};
|
||||
|
||||
@@ -76,7 +68,7 @@ void KeyManagementWindow::test()
|
||||
|
||||
std::string value{gk.encryptedCharacters[f]};
|
||||
QString v{QString::fromStdString(value)};
|
||||
valueOfKey->setText(v);
|
||||
valueOfKey.get()->setText(v);
|
||||
}
|
||||
void KeyManagementWindow::generation()
|
||||
{
|
||||
|
||||
+13
-6
@@ -6,6 +6,8 @@
|
||||
#include<QHBoxLayout>
|
||||
#include<QComboBox>
|
||||
#include<QLineEdit>
|
||||
#include<QPushButton>
|
||||
#include<memory>
|
||||
|
||||
class QHBoxLayout;
|
||||
class QVBoxLayout;
|
||||
@@ -13,23 +15,28 @@ class QComboBox;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
class KeyManagementWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KeyManagementWindow(QWidget* parent = 0);
|
||||
~KeyManagementWindow();
|
||||
~KeyManagementWindow() = default;
|
||||
|
||||
void setContentsOfComboBox();
|
||||
private slots:
|
||||
void test();
|
||||
void generation();
|
||||
private:
|
||||
QHBoxLayout* hBox{};
|
||||
QVBoxLayout* vBox{};
|
||||
QComboBox* comboBoxOfKeys{};
|
||||
QLineEdit* valueOfKey{};
|
||||
QPushButton* generateNewDefaultKeys;
|
||||
unique_ptr<QHBoxLayout> hBox;
|
||||
unique_ptr<QHBoxLayout> hBox2;
|
||||
unique_ptr<QVBoxLayout> vBox;
|
||||
unique_ptr<QComboBox> comboBoxOfKeys;
|
||||
unique_ptr<QLineEdit> valueOfKey;
|
||||
unique_ptr<QPushButton> generateNewDefaultKeys;
|
||||
int windowWidth{400};
|
||||
int windowHeight{400};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+44
-63
@@ -2,7 +2,7 @@
|
||||
#include<QString>
|
||||
#include<QIcon>
|
||||
#include<iostream>
|
||||
|
||||
#include<memory>
|
||||
#include"MessagingControls.h"
|
||||
#include"KeyManagementWindow.h"
|
||||
#include"Encryption.h"
|
||||
@@ -10,47 +10,40 @@
|
||||
|
||||
MessagingControls::MessagingControls()
|
||||
{
|
||||
textForCryption = new QTextEdit;
|
||||
cryptionChoice = true;
|
||||
|
||||
setupMainWindow();
|
||||
}
|
||||
MessagingControls::~MessagingControls()
|
||||
{
|
||||
delete lblOfEncryptedBox;
|
||||
delete cryptionButon;
|
||||
delete textForCryption;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MessagingControls::setupMainWindow()
|
||||
{
|
||||
cryptionButon = new QPushButton(tr("XO"));
|
||||
cryptionSwitch = new QPushButton(tr("encrypt chosen"));
|
||||
textForCryption = unique_ptr<QTextEdit>{new QTextEdit{}};
|
||||
cryptionButon = unique_ptr<QPushButton>{new QPushButton(tr("XO"))};
|
||||
cryptionSwitch = unique_ptr<QPushButton>{new QPushButton(tr("encrypt chosen"))};
|
||||
|
||||
buttonLayout = new QVBoxLayout;
|
||||
buttonWidget = new QWidget;
|
||||
buttonDockWidget = new QDockWidget;
|
||||
buttonDockWidget->setWindowTitle(tr("Cryption Controls"));
|
||||
buttonLayout->addWidget(cryptionButon);
|
||||
buttonLayout->addWidget(cryptionSwitch);
|
||||
buttonWidget->setLayout(buttonLayout);
|
||||
buttonDockWidget->setWidget(buttonWidget);
|
||||
buttonDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
setCentralWidget(buttonDockWidget);
|
||||
buttonLayout = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
buttonWidget = unique_ptr<QWidget>{new QWidget};
|
||||
buttonDockWidget = unique_ptr<QDockWidget>{new QDockWidget};
|
||||
buttonDockWidget.get()->setWindowTitle(tr("Cryption Controls"));
|
||||
buttonLayout.get()->addWidget(cryptionButon.get());
|
||||
buttonLayout.get()->addWidget(cryptionSwitch.get());
|
||||
buttonWidget.get()->setLayout(buttonLayout.get());
|
||||
buttonDockWidget.get()->setWidget(buttonWidget.get());
|
||||
buttonDockWidget.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
setCentralWidget(buttonDockWidget.get());
|
||||
|
||||
QDockWidget* cryptionArea = new QDockWidget(tr("Cryption"));
|
||||
cryptionArea->setWidget(textForCryption);
|
||||
cryptionArea->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea);
|
||||
cryptionArea = unique_ptr<QDockWidget>{new QDockWidget(tr("Cryption"))};
|
||||
cryptionArea.get()->setWidget(textForCryption.get());
|
||||
cryptionArea.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
|
||||
|
||||
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
|
||||
|
||||
createMenus();
|
||||
|
||||
QObject::connect(closeApplication, SIGNAL(triggered()), this, SLOT(close()));
|
||||
QObject::connect(cryptionSwitch, SIGNAL(clicked()), this, SLOT(changeCryptionType()));
|
||||
QObject::connect(cryptionButon, SIGNAL(clicked()), this, SLOT(determineCryption()));
|
||||
QObject::connect(keyEdit, SIGNAL(triggered()), this, SLOT(keyManagementWindow()));
|
||||
QObject::connect(closeApplication.get(), SIGNAL(triggered()), this, SLOT(close()));
|
||||
QObject::connect(cryptionSwitch.get(), SIGNAL(clicked()), this, SLOT(changeCryptionType()));
|
||||
QObject::connect(cryptionButon.get(), SIGNAL(clicked()), this, SLOT(determineCryption()));
|
||||
QObject::connect(keyEdit.get(), SIGNAL(triggered()), this, SLOT(keyManagementWindow()));
|
||||
|
||||
setWindowTitle("Encryption Decryption Messaging");
|
||||
setFixedHeight(mainWindowHeight);
|
||||
@@ -58,70 +51,58 @@ void MessagingControls::setupMainWindow()
|
||||
}
|
||||
void MessagingControls::createMenus()
|
||||
{
|
||||
fileMenu = menuBar()->addMenu(tr("File"));
|
||||
editMenu = menuBar()->addMenu(tr("Edit"));
|
||||
fileMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
||||
editMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
||||
|
||||
closeApplication = new QAction(new QObject(nullptr));
|
||||
closeApplication->setText("Exit Application");
|
||||
closeApplication = unique_ptr<QAction>{new QAction(new QObject(nullptr))};
|
||||
closeApplication.get()->setText("Exit Application");
|
||||
|
||||
keyEdit = new QAction(new QObject(nullptr));
|
||||
keyEdit->setText("Key Management");
|
||||
keyEdit = unique_ptr<QAction>{new QAction(new QObject(nullptr))};
|
||||
keyEdit.get()->setText("Key Management");
|
||||
|
||||
fileMenu->addAction(closeApplication);
|
||||
|
||||
editMenu->addAction(keyEdit);
|
||||
fileMenu.get()->addAction(closeApplication.get());
|
||||
editMenu.get()->addAction(keyEdit.get());
|
||||
}
|
||||
|
||||
|
||||
void MessagingControls::changeCryptionType()
|
||||
{
|
||||
if (cryptionChoice)
|
||||
{
|
||||
cryptionSwitch->setText("decrypt chosen");
|
||||
cryptionChoice = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
cryptionSwitch->setText("encrypt chosen");
|
||||
cryptionChoice = true;
|
||||
}
|
||||
(cryptionChoice) ? cryptionSwitch->setText("decrypt chosen") : cryptionSwitch->setText("encrypt chosen");
|
||||
cryptionChoice = (cryptionChoice) ? false : true;
|
||||
}
|
||||
void MessagingControls::determineCryption()
|
||||
{
|
||||
if (cryptionChoice)
|
||||
{
|
||||
Encryption ec{grabCryptionText()};
|
||||
ec.encryptMessage();
|
||||
|
||||
textForCryption->clear();
|
||||
textForCryption->setText(QString::fromStdString(ec.getEncryptedMessage()));
|
||||
textForCryption.get()->clear();
|
||||
textForCryption.get()->setText(QString::fromStdString(ec.getEncryptedMessage()));
|
||||
|
||||
cryptionSwitch->setText("decrypt chosen");
|
||||
cryptionSwitch.get()->setText("decrypt chosen");
|
||||
cryptionChoice = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Decryption dc{grabCryptionText()};
|
||||
dc.decryptMessage();
|
||||
|
||||
textForCryption->clear();
|
||||
textForCryption->setText(QString::fromStdString(dc.getDecryptedMessage()));
|
||||
textForCryption.get()->clear();
|
||||
textForCryption.get()->setText(QString::fromStdString(dc.getDecryptedMessage()));
|
||||
|
||||
cryptionSwitch->setText("encrypt chosen");
|
||||
cryptionSwitch.get()->setText("encrypt chosen");
|
||||
cryptionChoice = true;
|
||||
}
|
||||
}
|
||||
void MessagingControls::keyManagementWindow()
|
||||
{
|
||||
KeyManagementWindow* kh = new KeyManagementWindow;
|
||||
kh->show();
|
||||
kh = unique_ptr<KeyManagementWindow>{new KeyManagementWindow};
|
||||
kh.get()->show();
|
||||
}
|
||||
|
||||
|
||||
std::string MessagingControls::grabCryptionText()
|
||||
{
|
||||
QString placeHolder = textForCryption->toPlainText();
|
||||
std::string message = placeHolder.toStdString();
|
||||
auto placeHolder = textForCryption.get()->toPlainText();
|
||||
|
||||
return message;
|
||||
return placeHolder.toStdString();
|
||||
}
|
||||
|
||||
+22
-20
@@ -14,6 +14,8 @@
|
||||
#include<QDockWidget>
|
||||
#include<QWidget>
|
||||
#include<QString>
|
||||
#include<memory>
|
||||
#include"KeyManagementWindow.h"
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
@@ -25,52 +27,52 @@ class QMenu;
|
||||
class QAction;
|
||||
class QString;
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
class MessagingControls : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MessagingControls();
|
||||
~MessagingControls();
|
||||
|
||||
~MessagingControls() = default;
|
||||
signals:
|
||||
|
||||
|
||||
private slots:
|
||||
void changeCryptionType();
|
||||
void determineCryption();
|
||||
void keyManagementWindow();
|
||||
|
||||
private:
|
||||
void setupMainWindow();
|
||||
void createMenus();
|
||||
QVBoxLayout* buttonLayout;
|
||||
|
||||
QWidget* buttonWidget;
|
||||
unique_ptr<QVBoxLayout> buttonLayout;
|
||||
|
||||
QDockWidget* buttonDockWidget;
|
||||
QDockWidget* cryptionArea;
|
||||
unique_ptr<QWidget> buttonWidget;
|
||||
|
||||
QLabel* lblOfEncryptedBox;
|
||||
QLineEdit* encryptedBox;
|
||||
unique_ptr<QDockWidget> buttonDockWidget;
|
||||
unique_ptr<QDockWidget> cryptionArea;
|
||||
|
||||
QTextEdit* textForCryption;
|
||||
QTextEdit* textToDecrypt;
|
||||
unique_ptr<QLabel> lblOfEncryptedBox;
|
||||
unique_ptr<QLineEdit> encryptedBox;
|
||||
|
||||
QPushButton* cryptionButon;
|
||||
QPushButton* cryptionSwitch;
|
||||
unique_ptr<QTextEdit> textForCryption;
|
||||
unique_ptr<QTextEdit> textToDecrypt;
|
||||
|
||||
QMenu* fileMenu;
|
||||
QMenu* editMenu;
|
||||
QAction* closeApplication;
|
||||
QAction* keyEdit;
|
||||
unique_ptr<QPushButton> cryptionButon;
|
||||
unique_ptr<QPushButton> cryptionSwitch;
|
||||
|
||||
unique_ptr<QMenu> fileMenu;
|
||||
unique_ptr<QMenu> editMenu;
|
||||
unique_ptr<QAction> closeApplication;
|
||||
unique_ptr<QAction> keyEdit;
|
||||
|
||||
unique_ptr<KeyManagementWindow> kh;
|
||||
|
||||
std::string grabCryptionText();
|
||||
|
||||
int mainWindowHeight{450};
|
||||
int mainWindowWidth{550};
|
||||
|
||||
bool cryptionChoice{};
|
||||
bool cryptionChoice{true};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user