Нет описания

mainwindow.cpp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <string>
  4. #include <QDebug>
  5. #include <QString>
  6. #include "cypher.h"
  7. using namespace std;
  8. ///
  9. /// \brief MainWindow::MainWindow- Function which sets up the MainWindow
  10. ///
  11. MainWindow::MainWindow(QWidget *parent) :
  12. QMainWindow(parent),
  13. ui(new Ui::MainWindow)
  14. {
  15. ui->setupUi(this);
  16. setWindowTitle("Vigenere Cypher");
  17. }
  18. ///
  19. /// \brief MainWindow::~MainWindow- Default destructor
  20. ///
  21. MainWindow::~MainWindow()
  22. {
  23. delete ui;
  24. }
  25. ///
  26. /// \brief MainWindow::on_EncodeButton_clicked- Function that is called
  27. /// when the encode button is pressed. The message and the keyword
  28. /// that the user provides are placed into each variable accordingly then
  29. /// the cypher function is called using these variables.
  30. ///
  31. void MainWindow::on_EncodeButton_clicked()
  32. {
  33. string message = ui->PlainTextTextEdit->toPlainText().toStdString();
  34. string key = ui->keyText->toPlainText().simplified().toStdString() ;
  35. ui->CypherTextEdit->setText(QString::fromStdString(cypher(message, key)));
  36. }
  37. ///
  38. /// \brief MainWindow::on_DecodeButton_clicked- Function that is called
  39. /// when the decode button is pressed. The ciphertext and the keyword
  40. /// that the user provides are placed into each variable accordingly
  41. /// then the decypher function is called using these variables.
  42. ///
  43. void MainWindow::on_DecodeButton_clicked()
  44. {
  45. string message = ui->CypherTextEdit->toPlainText().toStdString();
  46. string key = ui->keyText->toPlainText().simplified().toStdString() ;
  47. ui->PlainTextTextEdit->setText(QString::fromStdString(decypher(message,key))) ;
  48. }