Modified Reset menu action behaviour.
[secretnotes] / src / mainwindow.cpp
index 835bde2..9d8a7c9 100644 (file)
@@ -37,10 +37,11 @@ MainWindow::MainWindow(QWidget *parent) :
     hasReadFile(false)
 {
     ui->setupUi(this);
+
+    resetAction = ui->menuOptions->addAction(tr("Reset secret notes"));
+    connect(resetAction, SIGNAL(triggered()), this, SLOT(on_actionReset_secret_notes_triggered()));
+
     enableTextEdit(false);
-    undoResetAction = ui->menuOptions->addAction(tr("Undo reset"));
-    connect(undoResetAction, SIGNAL(triggered()),this, SLOT(undoReset()));
-    enableUndoReset(false);
 
     undoEditAction = ui->menuOptions->addAction(tr("Undo edit"));
     connect(undoEditAction,SIGNAL(triggered()), this, SLOT(undoEdit()));
@@ -64,7 +65,6 @@ MainWindow::MainWindow(QWidget *parent) :
 MainWindow::~MainWindow()
 {
     plaintext.fill(0);
-    undoText.fill(0);
     delete ui;
     if (password)
         memset(password,0,passLength);
@@ -287,14 +287,8 @@ void MainWindow::on_actionReset_secret_notes_triggered()
     if (password)
         memset(password, 0, passLength);
     delete[] password;
-    password = NULL;    
-    if (plaintext.length() > 0) {
-        undoText.fill(0);
-        undoText = plaintext;
-    }
+    password = NULL;
 
-    if (undoText.length() > 0)
-        enableUndoReset(true);
     ui->textEdit->clear();
     enableTextEdit(true);
     askNewPassword();
@@ -338,23 +332,9 @@ void MainWindow::enableTextEdit(bool ena)
     if (!ena) {
         ui->textEdit->setPlainText(tr("Secret Notes disabled"));
     }
+    enableResetAction(!ena);
 }
 
-void MainWindow::enableUndoReset(bool ena)
-{
-    undoResetAction->setVisible(ena);
-}
-
-void MainWindow::undoReset()
-{
-    plaintext.fill(0);
-    plaintext = undoText;
-    undoText.fill(0);
-    undoText = "";
-    ui->textEdit->setPlainText(plaintext);
-    enableUndoReset(false);
-    enableTextEdit(true);
-}
 
 void MainWindow::undoEdit()
 {
@@ -365,3 +345,8 @@ void MainWindow::on_textEdit_undoAvailable(bool b)
 {
     undoEditAction->setVisible(b);
 }
+
+void MainWindow::enableResetAction(bool b)
+{
+    resetAction->setVisible(b);
+}