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);
81 void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);
83 void OnImport(QAction*);
84 void OnExport(QAction*);
85 void OnDetailViewUrlClicked(const QUrl& url);
87 void OnInactivityTimer();
88 void OnShutdown(QSessionManager& manager);
89 void loadColumnVisibility();
92 void closeEvent(QCloseEvent* event);
93 void hideEvent(QHideEvent* event);
94 void showEvent(QShowEvent* event);
98 StatusBarReady, StatusBarLoading, StatusBarLoadingFailed,
101 void setStatusBarMsg(StatusBarMsg statusBarMsg);
102 SelectionState GroupSelection, EntrySelection;
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;
132 QSystemTrayIcon* SysTray;
133 QAction* ViewShowToolbarAction;
135 //QAssistantClient* HelpBrowser; //TODO HelpBrowser
136 QWidget* NormalCentralWidget;
137 QWidget* LockedCentralWidget;
138 Ui_WorkspaceLockedWidget WorkspaceLockedWidget;
141 QList<int> lockGroup;
143 QString currentFilePath;
144 QString currentFileName;
145 int inactivityCounter;
146 QTimer* inactivityTimer;
147 StatusBarMsg statusbarState;