Enable kinetic scrolling.
[secretnotes] / src / mainwindow.cpp
index 9d8a7c9..05e67a4 100644 (file)
@@ -16,6 +16,9 @@
  *  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>
@@ -38,6 +41,13 @@ MainWindow::MainWindow(QWidget *parent) :
 {
     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()));
 
@@ -47,6 +57,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 +186,7 @@ void MainWindow::readFile()
             plaintext = decoded;
             ui->textEdit->setPlainText(plaintext);
             enableTextEdit(true);
+            enableChangePasswordAction(true);
         }
         decoded.fill(0);
     }
@@ -281,7 +296,7 @@ void MainWindow::on_actionReset_secret_notes_triggered()
     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)
@@ -321,6 +336,7 @@ void MainWindow::askNewPassword()
             QString pass = dialog.getPassword();
             setPassword(pass);
             pass.fill(0);
+            enableChangePasswordAction(true);
             return;
         }
     }
@@ -350,3 +366,8 @@ void MainWindow::enableResetAction(bool b)
 {
     resetAction->setVisible(b);
 }
+
+void MainWindow::enableChangePasswordAction(bool b)
+{
+    changePasswordAction->setVisible(b);
+}