Release 0.4.3-3maemo with patches to disable menus/actions, add ScrollArea and fix...
[keepassx] / src / mainwindow.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2006 by Tarek Saidi                                *
3  *   tarek.saidi@arcor.de                                                  *
4  *                                                                         *
5  *   This program 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; version 2 of the License.               *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19
20
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
23
24 #include <QSessionManager>
25 #include <QSystemTrayIcon>
26 #include "lib/EntryView.h"
27 #include "lib/GroupView.h"
28 #include "export/Export.h"
29
30 #include "ui_MainWindow.h"
31 #include "ui_WorkspaceLockedWidget.h"
32
33 class KeepassMainWindow : public QMainWindow, private Ui_MainWindow{
34         Q_OBJECT
35         public:
36                 KeepassMainWindow (const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent=0, Qt::WFlags flags=0);
37                 IDatabase* db;
38                 inline bool isLocked() { return IsLocked; };
39                 inline bool isOpened() { return FileOpen; };
40         
41         public slots:
42                 void OnUnLockWorkspace();
43                 void openFile(const QString& filename);
44
45         signals:
46                 void entryChanged();
47
48         private slots:
49                 void OnFileNewKdb();
50                 //void OnFileNewKxdb(); // TODO Kxdb
51                 void OnFileOpen();
52                 void OnFileClose();
53                 bool OnFileSave();
54                 bool OnFileSaveAs();
55                 void OnFileSettings();
56                 void OnFileChangeKey();
57                 void OnFileExit();
58                 void OnBookmarkTriggered(QAction* action);
59                 void OnSearch();
60                 void OnGroupSearch();
61                 void OnViewShowToolbar(bool);
62                 void OnViewShowEntryDetails(bool);
63                 void OnViewToolbarIconSize16(bool);
64                 void OnViewToolbarIconSize22(bool);
65                 void OnViewToolbarIconSize28(bool);
66                 void OnGroupSelectionChanged(IGroupHandle*);
67                 void OnQuickSearch();
68                 void OnColumnVisibilityChanged();
69                 void OnUsernPasswVisibilityChanged();
70                 void OnFileModified();
71                 void OnExtrasSettings();
72                 void OnExtrasPasswordGen();
73                 void OnExtrasShowExpiredEntries();
74                 //void OnExtrasTrashCan(); //TODO TrashCan
75                 void OnHelpAbout();
76                 void OnHelpHandbook();
77                 //void OnItemExpanded(QTreeWidgetItem*);
78                 //void OnItemCollaped(QTreeWidgetItem*);
79                 void OnShowSearchResults();
80                 void OnEntryChanged(SelectionState);
81                 void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);
82                 void restoreWindow();
83                 void OnImport(QAction*);
84                 void OnExport(QAction*);
85                 void OnDetailViewUrlClicked(const QUrl& url);
86                 void OnLockClose();
87                 void OnInactivityTimer();
88                 void OnShutdown(QSessionManager& manager);
89                 void loadColumnVisibility();
90
91         private:
92                 void closeEvent(QCloseEvent* event);
93                 void hideEvent(QHideEvent* event);
94                 void showEvent(QShowEvent* event);
95                 void setLock();
96                 void resetLock();
97                 enum StatusBarMsg {
98                         StatusBarReady, StatusBarLoading, StatusBarLoadingFailed,
99                         StatusBarReadOnlyLock
100                 };
101                 void setStatusBarMsg(StatusBarMsg statusBarMsg);
102                 SelectionState GroupSelection, EntrySelection;
103                 bool FileOpen;
104                 bool ModFlag;
105                 bool IsLocked;
106                 QList<quint32> SearchResults;
107                 inline void setupToolbar();
108                 inline void setupIcons();
109                 inline void setupConnections();
110                 inline void setupMenus();
111                 void setStateFileOpen(bool);
112                 void setStateFileModified(bool);
113                 void setStateGroupSelected(SelectionState s);
114                 void setStateEntrySelected(SelectionState s);
115                 bool openDatabase(QString filename,bool IsAuto=false);
116                 void fakeOpenDatabase(const QString& filename);
117                 void setupDatabaseConnections(IDatabase* DB);
118                 bool closeDatabase(bool lock=false);
119                 void search(IGroupHandle* Group);
120                 //void removeFromSearchResults(int sID);
121                 void updateDetailView();
122                 void exportDatabase(IExport* exporter,QStringList filters);
123                 void saveLastFilename(const QString& filename);
124                 void createBookmarkActions();
125                 void updateWindowTitle();
126                 void updateTrayTooltip();
127                 void updateCurrentFile(const QString& filePath);
128                 QLineEdit* QuickSearchEdit;
129                 QLabel* StatusBarGeneral;
130                 //QLabel* StatusBarSelection;
131                 QToolBar* toolBar;
132                 QSystemTrayIcon* SysTray;
133                 QAction* ViewShowToolbarAction;
134                 QMenu* SysTrayMenu;
135                 //QAssistantClient* HelpBrowser; //TODO HelpBrowser
136                 QWidget* NormalCentralWidget;
137                 QWidget* LockedCentralWidget;
138                 Ui_WorkspaceLockedWidget WorkspaceLockedWidget;
139                 bool ShutingDown;
140                 bool InUnLock;
141                 QList<int> lockGroup;
142                 QDialog* unlockDlg;
143                 QString currentFilePath;
144                 QString currentFileName;
145                 int inactivityCounter;
146                 QTimer* inactivityTimer;
147                 StatusBarMsg statusbarState;
148                 bool dbReadOnly;
149 };
150
151 #endif