Redirecting project's purpose into password encryption. Need to separate declaration from implementation

This commit is contained in:
amazing-username
2017-07-27 12:04:10 -05:00
parent 41c53fe8e9
commit 4d5b19cabe
8 changed files with 89 additions and 80 deletions
+3 -3
View File
@@ -18,8 +18,8 @@ protected:
unique_ptr<QComboBox> selectionBox;
unique_ptr<QPushButton> actionButton;
unique_ptr<QHBoxLayout> mainLayout;
unique_ptr<VBoxLayout> subLayoutOne;
unique_ptr<VBoxLayout> subLayoutTwo;
int height, width;
unique_ptr<QVBoxLayout> subLayoutOne;
unique_ptr<QVBoxLayout> subLayoutTwo;
int windowHeight, windowWidth;
};
#endif
+13
View File
@@ -8,8 +8,10 @@ class Conversions
{
public:
Conversions() = default;
~Conversions()=default;
std::string cstringToString(char[], const int);
//char stringToChar(const string&);
private:
};
@@ -22,4 +24,15 @@ std::string Conversions::cstringToString(char tmp[], const int size)
cToS >> tmpString;
return tmpString;
}
/**
char Conversions::stringToChar(const string& tmp)
{
char tmpChar{};
stringstream sToC{};
for (auto index=0; index!=tmp.size(); ++index)
sToC << tmpChar;
sToC >> tmpChar;
return tmpChar;
}
*/
#endif
+38 -22
View File
@@ -1,4 +1,3 @@
#include<QtWidgets>
#include<QString>
#include<QWidget>
#include<string>
@@ -10,37 +9,54 @@
#include"Encryption.h"
#include"GenerateKeys.h"
#include"KeyRetrieval.h"
#include"Conversions.h"
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
{
comboBoxOfKeys = unique_ptr<QComboBox>{new QComboBox{}};
valueOfKey = unique_ptr<QLineEdit>{new QLineEdit{}};
generateNewDefaultKeys = unique_ptr<QPushButton>{new QPushButton(tr("Generate New Default Key"))};
closeButton = unique_ptr<QPushButton>{new QPushButton(tr("close"))};
windowWidth = 450;
windowHeight = 450;
elementView = unique_ptr<QTableView>{new QTableView};
selectionBox = unique_ptr<QComboBox>{new QComboBox{}};
generateNewKeys = unique_ptr<QPushButton>{new QPushButton(tr("Generate New Default Key"))};
closeButton = unique_ptr<QPushButton>{new QPushButton(tr("close"))};
actionButton = unique_ptr<QPushButton>{new QPushButton};
mainLayout = unique_ptr<QHBoxLayout>{new QHBoxLayout};
subLayoutOne = unique_ptr<QVBoxLayout>{new QVBoxLayout};
subLayoutTwo = unique_ptr<QVBoxLayout>{new QVBoxLayout};
subLayoutGoonOne = unique_ptr<QVBoxLayout>{new QVBoxLayout};
subLayoutGoonTwo = unique_ptr<QVBoxLayout>{new QVBoxLayout};
subLayoutOne.get()->addWidget(elementView.get());
subLayoutGoonOne.get()->addWidget(selectionBox.get());
subLayoutGoonOne.get()->addWidget(actionButton.get());
subLayoutGoonTwo.get()->addWidget(generateNewKeys.get());
subLayoutGoonTwo.get()->addWidget(closeButton.get());
subLayoutTwo.get()->addLayout(subLayoutGoonOne.get());
subLayoutTwo.get()->addLayout(subLayoutGoonTwo.get());
mainLayout.get()->addLayout(subLayoutOne.get());
mainLayout.get()->addLayout(subLayoutTwo.get());
vBox = unique_ptr<QVBoxLayout>{new QVBoxLayout};
hBox = unique_ptr<QHBoxLayout>{new QHBoxLayout};
hBox2 = unique_ptr<QHBoxLayout>{new QHBoxLayout};
setContentsOfComboBox();
hBox.get()->addWidget(comboBoxOfKeys.get());
hBox.get()->addWidget(valueOfKey.get());
hBox2.get()->addWidget(generateNewDefaultKeys.get());
hBox2.get()->addWidget(closeButton.get());
vBox.get()->addLayout(hBox.get());
vBox.get()->addLayout(hBox2.get());
setLayout(vBox.get());
setLayout(mainLayout.get());
setFixedWidth(windowWidth);
setFixedHeight(windowHeight);
setWindowTitle("Key Management Window");
QObject::connect(comboBoxOfKeys.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
QObject::connect(generateNewDefaultKeys.get(), SIGNAL(clicked()), this, SLOT(generation()));
QObject::connect(selectionBox.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
QObject::connect(generateNewKeys.get(), SIGNAL(clicked()), this, SLOT(generation()));
QObject::connect(closeButton.get(), SIGNAL(clicked()), this, SLOT(exitApplication()));
}
@@ -54,7 +70,7 @@ void KeyManagementWindow::setContentsOfComboBox()
{
std::string ch{static_cast<char>(c[index])};
QString bl = QString::fromStdString(ch);
comboBoxOfKeys.get()->addItem(bl);
selectionBox.get()->addItem(bl);
}
}
void KeyManagementWindow::test()
@@ -62,7 +78,7 @@ void KeyManagementWindow::test()
std::string emp{"d"};
Encryption ec{emp};
std::map<char, std::string> encrypted{ec.encryptedCharactersStructure()};
QString bo{comboBoxOfKeys.get()->currentText()};
QString bo{selectionBox.get()->currentText()};
std::string k{bo.toStdString()};
char f{};
@@ -72,7 +88,7 @@ void KeyManagementWindow::test()
std::string value{encrypted[f]};
QString v{QString::fromStdString(value)};
valueOfKey.get()->setText(v);
//valueOfKey.get()->setText(v);
}
void KeyManagementWindow::generation()
{
+3 -18
View File
@@ -8,16 +8,10 @@
#include<QLineEdit>
#include<QPushButton>
#include<memory>
#include"CommonWindow.h"
#include"ViewingWindow.h"
class QHBoxLayout;
class QVBoxLayout;
class QComboBox;
class QLineEdit;
class QPushButton;
using std::unique_ptr;
class KeyManagementWindow : public QDialog
class KeyManagementWindow : public QDialog, public CommonWindow, public ViewingWindow
{
Q_OBJECT
public:
@@ -30,15 +24,6 @@ private slots:
void generation();
void exitApplication();
private:
unique_ptr<QHBoxLayout> hBox;
unique_ptr<QHBoxLayout> hBox2;
unique_ptr<QVBoxLayout> vBox;
unique_ptr<QComboBox> comboBoxOfKeys;
unique_ptr<QLineEdit> valueOfKey;
unique_ptr<QPushButton> generateNewDefaultKeys;
unique_ptr<QPushButton> closeButton;
const int windowWidth{400};
const int windowHeight{400};
};
#endif
+2 -2
View File
@@ -1,11 +1,11 @@
#include<QApplication>
#include"MessagingControls.h"
#include"MainWindow.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MessagingControls stuff{};
MainWindow stuff{};
stuff.show();
+17 -22
View File
@@ -1,31 +1,30 @@
#include<QString>
#include<QIcon>
#include"MessagingControls.h"
#include"MainWindow.h"
#include"Encryption.h"
#include"Decryption.h"
#include"KeyRetrieval.h"
MessagingControls::MessagingControls()
MainWindow::MainWindow()
{
mainWindowWidth = 450;
mainWindowHeight = 450;
windowHeight = 450;
windowWidth = 450;
setupMainWindow();
}
void MessagingControls::setupMainWindow()
void MainWindow::setupMainWindow()
{
kh = unique_ptr<KeyManagementWindow>{new KeyManagementWindow};
textForCryption = unique_ptr<QTextEdit>{new QTextEdit{}};
cryptionButon = unique_ptr<QPushButton>{new QPushButton(tr("XO"))};
cryptionSwitch = unique_ptr<QPushButton>{new QPushButton(tr("encrypt chosen"))};
actionButton = unique_ptr<QPushButton>{new QPushButton(tr("encrypt"))};
selectionBox = unique_ptr<QComboBox>{new QComboBox{}};
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());
buttonLayout.get()->addWidget(selectionBox.get());
buttonLayout.get()->addWidget(actionButton.get());
buttonWidget.get()->setLayout(buttonLayout.get());
buttonDockWidget.get()->setWidget(buttonWidget.get());
buttonDockWidget.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
@@ -36,20 +35,16 @@ void MessagingControls::setupMainWindow()
cryptionArea.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
createMenus();
QObject::connect(closeApplication.get(), SIGNAL(triggered()), this, SLOT(exitApplication()));
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);
setFixedWidth(mainWindowWidth);
setFixedHeight(windowHeight);
setFixedWidth(windowWidth);
}
void MessagingControls::createMenus()
void MainWindow::createMenus()
{
fileMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
editMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
@@ -65,12 +60,12 @@ void MessagingControls::createMenus()
}
void MessagingControls::changeCryptionType()
void MainWindow::changeCryptionType()
{
(cryptionChoice) ? cryptionSwitch->setText("decrypt chosen") : cryptionSwitch->setText("encrypt chosen");
cryptionChoice = (cryptionChoice) ? false : true;
}
void MessagingControls::determineCryption()
void MainWindow::determineCryption()
{
if (cryptionChoice)
{
@@ -93,11 +88,11 @@ void MessagingControls::determineCryption()
cryptionChoice = true;
}
}
void MessagingControls::keyManagementWindow() { kh.get()->show(); }
void MessagingControls::exitApplication() { exit(0); }
void MainWindow::keyManagementWindow() { kh.get()->show(); }
void MainWindow::exitApplication() { exit(0); }
std::string MessagingControls::grabCryptionText()
std::string MainWindow::grabCryptionText()
{
auto placeHolder = textForCryption.get()->toPlainText();
+6 -13
View File
@@ -1,9 +1,8 @@
#ifndef MESSAGINGCONTROLS_H
#define MESSAGINGCONTROLS_H
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_
#include<QDialog>
#include<QPushButton>
#include<QLineEdit>
#include<QTextEdit>
#include<QLabel>
#include<QMenuBar>
@@ -15,16 +14,15 @@
#include<QWidget>
#include<memory>
#include"KeyManagementWindow.h"
#include"CommonWindow.h"
using std::unique_ptr;
class MessagingControls : public QMainWindow
class MainWindow : public QMainWindow, public CommonWindow
{
Q_OBJECT
public:
MessagingControls();
~MessagingControls() = default;
MainWindow();
~MainWindow() = default;
signals:
private slots:
@@ -44,10 +42,8 @@ private:
unique_ptr<QDockWidget> cryptionArea;
unique_ptr<QLabel> lblOfEncryptedBox;
unique_ptr<QLineEdit> encryptedBox;
unique_ptr<QTextEdit> textForCryption;
unique_ptr<QTextEdit> textToDecrypt;
unique_ptr<QPushButton> cryptionButon;
unique_ptr<QPushButton> cryptionSwitch;
@@ -61,9 +57,6 @@ private:
std::string grabCryptionText();
int mainWindowHeight;
int mainWindowWidth;
bool cryptionChoice;
};
#endif
+7
View File
@@ -1,6 +1,8 @@
#ifndef VIEWINGWINDOW_H_
#define VIEWINGWINDOW_H_
#include<QVBoxLayout>
#include<QTableView>
#include<QLineEdit>
#include<QPushButton>
#include<memory>
@@ -13,6 +15,11 @@ public:
ViewingWindow() = default;
~ViewingWindow() = default;
protected:
unique_ptr<QVBoxLayout> subLayoutGoonOne;
unique_ptr<QVBoxLayout> subLayoutGoonTwo;
unique_ptr<QLineEdit> crypticText;
unique_ptr<QTableView> elementView;
unique_ptr<QPushButton> closeButton;
unique_ptr<QPushButton> generateNewKeys;
};
#endif