From 2074f26c4eef7c0f6df12836476a48ac4b96ebdd Mon Sep 17 00:00:00 2001 From: amazing-username Date: Sat, 29 Jul 2017 16:18:50 -0500 Subject: [PATCH] Added vacant Password Management Window --- Conversions.h | 31 +++++++++++++++--------------- EncryptedMessaging.pro | 20 ------------------- KeyManagementWindow.cpp | 37 +++++++++++++++++++++--------------- KeyManagementWindow.h | 11 +++-------- MainWindow.cpp | 21 ++++++++++++++------ MainWindow.h | 5 +++++ PasswordManagementWindow.cpp | 35 ++++++++++++++++++++++++++++++++++ PasswordManagementWindow.h | 15 +++++++++++++++ 8 files changed, 111 insertions(+), 64 deletions(-) delete mode 100644 EncryptedMessaging.pro diff --git a/Conversions.h b/Conversions.h index f3b50b5..ff6c38f 100644 --- a/Conversions.h +++ b/Conversions.h @@ -10,29 +10,30 @@ public: Conversions() = default; ~Conversions()=default; - std::string cstringToString(char[], const int); - //char stringToChar(const string&); + template + S cstringToString(const C[], const int); + template + C stringToChar(const S&); private: }; - -std::string Conversions::cstringToString(char tmp[], const int size) +template +S Conversions::cstringToString(const C tmp[], const int size) { - std::string tmpString{}; std::stringstream cToS{}; - for (auto index =0; index!=size; ++ index) - cToS << tmp[index]; - cToS >> tmpString; + for (auto index=0; index!=size; ++index) + cToS<>tmpString; return tmpString; } -/** -char Conversions::stringToChar(const string& tmp) +template +C Conversions::stringToChar(const S& tmp) { + std::stringstream sToC{}; + for (auto tmpElements:tmp) + sToC<> tmpChar; + sToC>>tmpChar; return tmpChar; } -*/ #endif diff --git a/EncryptedMessaging.pro b/EncryptedMessaging.pro deleted file mode 100644 index 2a60b9b..0000000 --- a/EncryptedMessaging.pro +++ /dev/null @@ -1,20 +0,0 @@ -###################################################################### -# Automatically generated by qmake (3.1) Fri Mar 24 12:16:30 2017 -###################################################################### - -TEMPLATE = app -TARGET = EncryptedMessaging -QT += core gui -QT += widgets -INCLUDEPATH += . - -# Input -HEADERS += Decryption.h Encryption.h GenerateKeys.h MessagingControls.h Cryption.h KeyManagementWindow.h KeyRetrieval.h Conversions.h CommonWindow.h ViewingWindow.h -SOURCES += Decryption.cpp \ - Encryption.cpp \ - Cryption.cpp \ - KeyManagementWindow.cpp \ - KeyRetrieval.cpp \ - GenerateKeys.cpp \ - Main.cpp \ - MessagingControls.cpp diff --git a/KeyManagementWindow.cpp b/KeyManagementWindow.cpp index 678f726..cbfd923 100644 --- a/KeyManagementWindow.cpp +++ b/KeyManagementWindow.cpp @@ -12,6 +12,25 @@ #include"Conversions.h" KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent) +{ + setupWindow(); + connections(); +} + + +void KeyManagementWindow::setContentsOfComboBox() +{ + KeyRetrieval kr{}; + std::vector c{kr.codeCharacterStructure()}; + + for (auto index = 0u; index!=c.size(); ++index) + { + std::string ch{static_cast(c[index])}; + QString bl = QString::fromStdString(ch); + selectionBox.get()->addItem(bl); + } +} +void KeyManagementWindow::setupWindow() { windowWidth = 450; windowHeight = 450; @@ -54,25 +73,13 @@ KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent) setFixedHeight(windowHeight); setWindowTitle("Key Management Window"); - +} +void KeyManagementWindow::connections() +{ 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())); } - - -void KeyManagementWindow::setContentsOfComboBox() -{ - KeyRetrieval kr{}; - std::vector c{kr.codeCharacterStructure()}; - - for (auto index = 0u; index!=c.size(); ++index) - { - std::string ch{static_cast(c[index])}; - QString bl = QString::fromStdString(ch); - selectionBox.get()->addItem(bl); - } -} void KeyManagementWindow::test() { std::string emp{"d"}; diff --git a/KeyManagementWindow.h b/KeyManagementWindow.h index 749253e..cf8c639 100644 --- a/KeyManagementWindow.h +++ b/KeyManagementWindow.h @@ -2,11 +2,6 @@ #define KEYMANAGEMENTWINDOW_H #include -#include -#include -#include -#include -#include #include #include"CommonWindow.h" #include"ViewingWindow.h" @@ -17,13 +12,13 @@ class KeyManagementWindow : public QDialog, public CommonWindow, public ViewingW public: KeyManagementWindow(QWidget* parent = 0); ~KeyManagementWindow() = default; - - void setContentsOfComboBox(); private slots: void test(); void generation(); void exitApplication(); private: + void setContentsOfComboBox(); + void setupWindow(); + void connections(); }; - #endif diff --git a/MainWindow.cpp b/MainWindow.cpp index c178a8a..e55970a 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -6,15 +6,16 @@ MainWindow::MainWindow() { - windowHeight = 450; - windowWidth = 450; + kh = unique_ptr{new KeyManagementWindow}; + ph = unique_ptr{new PasswordManagementWindow}; setupMainWindow(); } void MainWindow::setupMainWindow() { - kh = unique_ptr{new KeyManagementWindow}; + windowHeight = 450; + windowWidth = 450; textForCryption = unique_ptr{new QTextEdit{}}; actionButton = unique_ptr{new QPushButton(tr("encrypt"))}; selectionBox = unique_ptr{new QComboBox{}}; @@ -37,12 +38,10 @@ void MainWindow::setupMainWindow() createMenus(); - QObject::connect(closeApplication.get(), SIGNAL(triggered()), this, SLOT(exitApplication())); - QObject::connect(keyEdit.get(), SIGNAL(triggered()), this, SLOT(keyManagementWindow())); - setWindowTitle("Encryption Decryption Messaging"); setFixedHeight(windowHeight); setFixedWidth(windowWidth); + connections(); } void MainWindow::createMenus() { @@ -54,9 +53,18 @@ void MainWindow::createMenus() keyEdit = unique_ptr{new QAction(new QObject(nullptr))}; keyEdit.get()->setText("Key Management"); + passwordManage = unique_ptr{new QAction{new QObject{nullptr}}}; + passwordManage.get()->setText("PasswordManagement"); fileMenu.get()->addAction(closeApplication.get()); editMenu.get()->addAction(keyEdit.get()); + editMenu.get()->addAction(passwordManage.get()); +} +void MainWindow::connections() +{ + QObject::connect(closeApplication.get(), SIGNAL(triggered()), this, SLOT(exitApplication())); + QObject::connect(keyEdit.get(), SIGNAL(triggered()), this, SLOT(keyManagementWindow())); + QObject::connect(passwordManage.get(), SIGNAL(triggered()), this, SLOT(passwordManageWindow())); } @@ -89,6 +97,7 @@ void MainWindow::determineCryption() } } void MainWindow::keyManagementWindow() { kh.get()->show(); } +void MainWindow::passwordManageWindow() { ph.get()->show(); } void MainWindow::exitApplication() { exit(0); } diff --git a/MainWindow.h b/MainWindow.h index e7e99ba..41d2f3b 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -14,6 +14,7 @@ #include #include #include"KeyManagementWindow.h" +#include"PasswordManagementWindow.h" #include"CommonWindow.h" @@ -29,10 +30,12 @@ private slots: void changeCryptionType(); void determineCryption(); void keyManagementWindow(); + void passwordManageWindow(); void exitApplication(); private: void setupMainWindow(); void createMenus(); + void connections(); unique_ptr buttonLayout; @@ -52,8 +55,10 @@ private: unique_ptr editMenu; unique_ptr closeApplication; unique_ptr keyEdit; + unique_ptr passwordManage; unique_ptr kh; + unique_ptr ph; std::string grabCryptionText(); diff --git a/PasswordManagementWindow.cpp b/PasswordManagementWindow.cpp index f00cf56..4224ff8 100644 --- a/PasswordManagementWindow.cpp +++ b/PasswordManagementWindow.cpp @@ -1,6 +1,41 @@ #include"PasswordManagementWindow.h" PasswordManagementWindow::PasswordManagementWindow(QWidget* parent) : QDialog(parent) +{ + setupWindow(); +} + +void PasswordManagementWindow::setupWindow() +{ + windowWidth=450; + windowHeight=450; + + elementView=unique_ptr{new QTableView}; + + selectionBox=unique_ptr{new QComboBox}; + actionButton=unique_ptr{new QPushButton{"i3"}}; + crypticText=unique_ptr{new QLineEdit}; + + mainLayout=unique_ptr{new QHBoxLayout}; + subLayoutOne=unique_ptr{new QVBoxLayout}; + subLayoutTwo=unique_ptr{new QVBoxLayout}; + + subLayoutOne.get()->addWidget(elementView.get()); + subLayoutTwo.get()->addWidget(selectionBox.get()); + subLayoutTwo.get()->addWidget(actionButton.get()); + subLayoutTwo.get()->addWidget(crypticText.get()); + + mainLayout.get()->addLayout(subLayoutOne.get()); + mainLayout.get()->addLayout(subLayoutTwo.get()); + + setLayout(mainLayout.get()); + + setFixedWidth(windowWidth); + setFixedHeight(windowHeight); + + connections(); +} +void PasswordManagementWindow::connections() { } diff --git a/PasswordManagementWindow.h b/PasswordManagementWindow.h index 7a57e8b..c54d593 100644 --- a/PasswordManagementWindow.h +++ b/PasswordManagementWindow.h @@ -1,7 +1,22 @@ #ifndef PASSWORDMANAGEMENTWINDOW_H_ #define PASSWORDMANAGEMENTWINDOW_H_ +#include +#include"CommonWindow.h" +#include"ViewingWindow.h" + class PasswordManagementWindow : public QDialog, public CommonWindow, public ViewingWindow { + Q_OBJECT +public: + PasswordManagementWindow(QWidget* parent=0); + ~PasswordManagementWindow()=default; +private: + void setupWindow(); + void connections(); + + unique_ptr passwordField; +private slots: }; +#endif