1 /***************************************************************************
2 * Copyright (C) 2005-2006 by Tarek Saidi *
3 * tarek.saidi@arcor.de *
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. *
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. *
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 ***************************************************************************/
24 #include <QSessionManager>
25 #include <QSystemTrayIcon>
26 #include "lib/EntryView.h"
27 #include "lib/GroupView.h"
28 #include "export/Export.h"
30 #include "ui_MainWindow.h"
31 #include "ui_WorkspaceLockedWidget.h"
33 class KeepassMainWindow : public QMainWindow, private Ui_MainWindow{
36 KeepassMainWindow (const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent=0, Qt::WFlags flags=0);
38 inline bool isLocked() { return IsLocked; };
39 inline bool isOpened() { return FileOpen; };
42 void OnUnLockWorkspace();
43 void openFile(const QString& filename);
50 //void OnFileNewKxdb(); // TODO Kxdb
55 void OnFileSettings();
56 void OnFileChangeKey();
58 void OnBookmarkTriggered(QAction* action);
61 void OnViewShowToolbar(bool);
62 void OnViewShowEntryDetails(bool);
63 void OnViewToolbarIconSize16(bool);
64 void OnViewToolbarIconSize22(bool);
65 void OnViewToolbarIconSize28(bool);
66 void OnGroupSelectionChanged(IGroupHandle*);
68 void OnColumnVisibilityChanged();
69 void OnUsernPasswVisibilityChanged();
70 void OnFileModified();
71 void OnExtrasSettings();
72 void OnExtrasPasswordGen();
73 void OnExtrasShowExpiredEntries();
74 //void OnExtrasTrashCan(); //TODO TrashCan
76 void OnHelpHandbook();
77 //void OnItemExpanded(QTreeWidgetItem*);
78 //void OnItemCollaped(QTreeWidgetItem*);
79 void OnShowSearchResults();
80 void OnEntryChanged(SelectionState);
82 void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);
85 void OnImport(QAction*);
86 void OnExport(QAction*);
87 void OnDetailViewUrlClicked(const QUrl& url);
89 void OnInactivityTimer();
90 void OnShutdown(QSessionManager& manager);
91 void loadColumnVisibility();
94 void closeEvent(QCloseEvent* event);
95 void hideEvent(QHideEvent* event);
96 void showEvent(QShowEvent* event);
100 StatusBarReady, StatusBarLoading, StatusBarLoadingFailed,
101 StatusBarReadOnlyLock
103 void setStatusBarMsg(StatusBarMsg statusBarMsg);
104 SelectionState GroupSelection, EntrySelection;
108 QList<quint32> SearchResults;
109 inline void setupToolbar();
110 inline void setupIcons();
111 inline void setupConnections();
112 inline void setupMenus();
113 void setStateFileOpen(bool);
114 void setStateFileModified(bool);
115 void setStateGroupSelected(SelectionState s);
116 void setStateEntrySelected(SelectionState s);
117 bool openDatabase(QString filename,bool IsAuto=false);
118 void fakeOpenDatabase(const QString& filename);
119 void setupDatabaseConnections(IDatabase* DB);
120 bool closeDatabase(bool lock=false);
121 void search(IGroupHandle* Group);
122 //void removeFromSearchResults(int sID);
123 void updateDetailView();
124 void exportDatabase(IExport* exporter,QStringList filters);
125 void saveLastFilename(const QString& filename);
126 void createBookmarkActions();
127 void updateWindowTitle();
128 void updateTrayTooltip();
129 void updateCurrentFile(const QString& filePath);
130 QLineEdit* QuickSearchEdit;
131 QLabel* StatusBarGeneral;
132 //QLabel* StatusBarSelection;
134 QSystemTrayIcon* SysTray;
135 QAction* ViewShowToolbarAction;
137 //QAssistantClient* HelpBrowser; //TODO HelpBrowser
138 QWidget* NormalCentralWidget;
139 QWidget* LockedCentralWidget;
140 Ui_WorkspaceLockedWidget WorkspaceLockedWidget;
142 QList<int> lockGroup;
144 QString currentFilePath;
145 QString currentFileName;
146 int inactivityCounter;
147 QTimer* inactivityTimer;
148 StatusBarMsg statusbarState;