* along with Secret Notes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDir>
+#ifdef Q_WS_MAEMO_5
+#include <QAbstractKineticScroller>
+#endif /* Q_WS_MAEMO_5 */
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qmessagebox.h>
hasReadFile(false)
{
ui->setupUi(this);
+
+#ifdef Q_WS_MAEMO_5
+ QAbstractKineticScroller *scroller = ui->textEdit->property("kineticScroller")
+ .value<QAbstractKineticScroller *>();
+ if (scroller)
+ scroller->setEnabled(true);
+#endif /* Q_WS_MAEMO_5 */
+
+ 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()));
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());
MainWindow::~MainWindow()
{
plaintext.fill(0);
- undoText.fill(0);
delete ui;
if (password)
memset(password,0,passLength);
plaintext = decoded;
ui->textEdit->setPlainText(plaintext);
enableTextEdit(true);
+ enableChangePasswordAction(true);
}
decoded.fill(0);
}
if (QMessageBox::question(this, tr("Reset secret notes"),
tr("Do you want to reset Secret Notes?\n"
"This will destroy all contents!"),
- QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel) != QMessageBox::Yes) {
return;
}
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();
QString pass = dialog.getPassword();
setPassword(pass);
pass.fill(0);
+ enableChangePasswordAction(true);
return;
}
}
if (!ena) {
ui->textEdit->setPlainText(tr("Secret Notes disabled"));
}
+ enableResetAction(!ena);
}
-void MainWindow::enableUndoReset(bool ena)
+
+void MainWindow::undoEdit()
{
- undoResetAction->setVisible(ena);
+ ui->textEdit->undo();
}
-void MainWindow::undoReset()
+void MainWindow::on_textEdit_undoAvailable(bool b)
{
- plaintext.fill(0);
- plaintext = undoText;
- undoText.fill(0);
- undoText = "";
- ui->textEdit->setPlainText(plaintext);
- enableUndoReset(false);
- enableTextEdit(true);
+ undoEditAction->setVisible(b);
}
-void MainWindow::undoEdit()
+void MainWindow::enableResetAction(bool b)
{
- ui->textEdit->undo();
+ resetAction->setVisible(b);
}
-void MainWindow::on_textEdit_undoAvailable(bool b)
+void MainWindow::enableChangePasswordAction(bool b)
{
- undoEditAction->setVisible(b);
+ changePasswordAction->setVisible(b);
}