Initial revision.
[secretnotes] / src / mainwindow.h
1 /*
2  *  This file is part of Secret Notes.
3  *  Copyright (C) 2010 Janusz Sobczak
4  *
5  *  Secret Notes is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  Secret Notes is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with Secret Notes.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef MAINWINDOW_H
19 #define MAINWINDOW_H
20
21 #include <QMainWindow>
22
23 namespace Ui {
24     class MainWindow;
25 }
26
27 class MainWindow : public QMainWindow {
28     Q_OBJECT
29 public:
30     MainWindow(QWidget *parent = 0);
31     ~MainWindow();
32
33 protected:
34     void changeEvent(QEvent *e);
35     void closeEvent(QCloseEvent *);
36
37 private:
38     Ui::MainWindow *ui;
39     void queryPassword(bool retry);
40     unsigned char* password;
41     int passLength;
42     bool hasPasswordChanged;
43     bool hasReadFile;
44     bool decode(QString& output, const QByteArray& input);
45     void encode(QByteArray& output, const QString& input);
46     void blowfish(unsigned char *output, const unsigned char *input,
47                               int length, int enc);
48     void setPassword(const QString& text);
49     void askNewPassword();
50     QString plaintext;
51     QString undoText;
52     void enableTextEdit(bool);
53     void enableUndoReset(bool);
54     QAction *undoResetAction;
55     QAction *undoEditAction;
56     QString filePath;
57
58 private slots:
59     void on_actionReset_secret_notes_triggered();
60     void on_actionChange_password_triggered();
61     void on_textEdit_undoAvailable(bool b);
62     void undoReset();
63     void undoEdit();
64     void readFile();
65 };
66
67 #endif // MAINWINDOW_H