From b420767be6c6ba849f7f7d5c8e4df77aa64ce65a Mon Sep 17 00:00:00 2001 From: Janusz Sobczak Date: Thu, 20 May 2010 14:56:26 +0200 Subject: [PATCH] Modify Change Password menu action. Enable 'Change password' only when user has supplied a correct password. Signed-off-by: Janusz Sobczak --- src/mainwindow.cpp | 11 +++++++++++ src/mainwindow.h | 2 ++ src/mainwindow.ui | 1 - 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9d8a7c9..8566b73 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -47,6 +47,10 @@ MainWindow::MainWindow(QWidget *parent) : connect(undoEditAction,SIGNAL(triggered()), this, SLOT(undoEdit())); on_textEdit_undoAvailable(false); + changePasswordAction = ui->menuOptions->addAction(tr("Change password")); + connect(changePasswordAction, SIGNAL(triggered()), this, SLOT(on_actionChange_password_triggered())); + enableChangePasswordAction(false); + /* the secret notes file is stored in user home directory */ filePath = QDir::fromNativeSeparators(QDir::homePath()); @@ -172,6 +176,7 @@ void MainWindow::readFile() plaintext = decoded; ui->textEdit->setPlainText(plaintext); enableTextEdit(true); + enableChangePasswordAction(true); } decoded.fill(0); } @@ -321,6 +326,7 @@ void MainWindow::askNewPassword() QString pass = dialog.getPassword(); setPassword(pass); pass.fill(0); + enableChangePasswordAction(true); return; } } @@ -350,3 +356,8 @@ void MainWindow::enableResetAction(bool b) { resetAction->setVisible(b); } + +void MainWindow::enableChangePasswordAction(bool b) +{ + changePasswordAction->setVisible(b); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 9abe266..e8c73b2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -50,8 +50,10 @@ private: QString plaintext; void enableTextEdit(bool); void enableResetAction(bool); + void enableChangePasswordAction(bool); QAction *resetAction; QAction *undoEditAction; + QAction *changePasswordAction; QString filePath; private slots: diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 6a6d8cf..103f033 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -43,7 +43,6 @@ Options - -- 1.7.9.5