More fixes for "automatically lock database"

Removed some unneeded includes
Improved code formatting

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@187 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 17 years ago
parent 6850cae8dd
commit a30643a99d
  1. 2
      src/dialogs/AboutDlg.h
  2. 1
      src/dialogs/CollectEntropyDlg.cpp
  3. 2
      src/dialogs/CollectEntropyDlg.h
  4. 2
      src/dialogs/CustomizeDetailViewDlg.h
  5. 4
      src/dialogs/DatabaseSettingsDlg.h
  6. 2
      src/dialogs/EditEntryDlg.h
  7. 30
      src/dialogs/EditGroupDlg.h
  8. 2
      src/dialogs/ExpiredEntriesDlg.h
  9. 2
      src/dialogs/ManageBookmarksDlg.h
  10. 100
      src/dialogs/PasswordDlg.h
  11. 1
      src/dialogs/PasswordGenDlg.cpp
  12. 4
      src/dialogs/SearchDlg.h
  13. 51
      src/dialogs/SelectIconDlg.h
  14. 2
      src/dialogs/SettingsDlg.h
  15. 27
      src/dialogs/SimplePasswordDlg.h
  16. 3
      src/lib/EntryView.cpp
  17. 2
      src/lib/EntryView.h
  18. 2
      src/lib/GroupView.cpp
  19. 2
      src/lib/GroupView.h
  20. 29
      src/lib/UrlLabel.h
  21. 2
      src/lib/WaitAnimationWidget.h
  22. 17
      src/main.cpp
  23. 7
      src/main.h
  24. 16
      src/mainwindow.cpp
  25. 3
      src/mainwindow.h

@ -22,7 +22,7 @@
#include "ui_AboutDlg.h" #include "ui_AboutDlg.h"
class AboutDialog : public QDialog, public Ui_AboutDlg class AboutDialog : public QDialog, private Ui_AboutDlg
{ {
Q_OBJECT Q_OBJECT

@ -19,7 +19,6 @@
***************************************************************************/ ***************************************************************************/
#include "crypto/yarrow.h"
#include "CollectEntropyDlg.h" #include "CollectEntropyDlg.h"

@ -23,7 +23,7 @@
#include "ui_CollectEntropyDlg.h" #include "ui_CollectEntropyDlg.h"
class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{ class CollectEntropyDlg: public QDialog, private Ui_CollectEntropyDlg{
Q_OBJECT Q_OBJECT
public: public:
CollectEntropyDlg(QWidget* parent); CollectEntropyDlg(QWidget* parent);

@ -22,7 +22,7 @@
#include "ui_CustomizeDetailViewDlg.h" #include "ui_CustomizeDetailViewDlg.h"
class CustomizeDetailViewDialog : public QDialog, public Ui_CustomizeDetailViewDialog{ class CustomizeDetailViewDialog : public QDialog, private Ui_CustomizeDetailViewDialog{
Q_OBJECT Q_OBJECT
public: public:
CustomizeDetailViewDialog(QWidget* parent); CustomizeDetailViewDialog(QWidget* parent);

@ -23,7 +23,7 @@
#include "ui_DatabaseSettingsDlg.h" #include "ui_DatabaseSettingsDlg.h"
class CDbSettingsDlg : public QDialog, public Ui_DatabaseSettingsDlg class CDbSettingsDlg : public QDialog, private Ui_DatabaseSettingsDlg
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -31,7 +31,7 @@ class CDbSettingsDlg : public QDialog, public Ui_DatabaseSettingsDlg
~CDbSettingsDlg(); ~CDbSettingsDlg();
virtual void paintEvent(QPaintEvent *); virtual void paintEvent(QPaintEvent *);
public slots: private slots:
virtual void OnCancel(); virtual void OnCancel();
virtual void OnOK(); virtual void OnOK();

@ -24,7 +24,7 @@
#include "ui_EditEntryDlg.h" #include "ui_EditEntryDlg.h"
#include "Kdb3Database.h" #include "Kdb3Database.h"
class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog class CEditEntryDlg : public QDialog, private Ui_EditEntryDialog
{ {
Q_OBJECT Q_OBJECT
public: public:

@ -23,23 +23,23 @@
#include "ui_EditGroupDlg.h" #include "ui_EditGroupDlg.h"
class CEditGroupDialog : public QDialog, public Ui_EditGroupDialog class CEditGroupDialog : public QDialog, private Ui_EditGroupDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CEditGroupDialog(IDatabase*,IGroupHandle*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); CEditGroupDialog(IDatabase*,IGroupHandle*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
CEditGroupDialog(IDatabase*,CGroup*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); CEditGroupDialog(IDatabase*,CGroup*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
~CEditGroupDialog(); ~CEditGroupDialog();
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event);
private: private:
IDatabase* db; IDatabase* db;
IGroupHandle* handle; IGroupHandle* handle;
CGroup* group; CGroup* group;
public slots: private slots:
virtual void OnOK(); virtual void OnOK();
virtual void OnCancel(); virtual void OnCancel();
virtual void OnIconDlg(); virtual void OnIconDlg();
}; };
#endif #endif

@ -24,7 +24,7 @@
#include "ui_ExpiredEntriesDlg.h" #include "ui_ExpiredEntriesDlg.h"
class ExpiredEntriesDialog:public QDialog, public Ui_ExpiredEntriesDialog{ class ExpiredEntriesDialog:public QDialog, private Ui_ExpiredEntriesDialog{
Q_OBJECT Q_OBJECT
public: public:
ExpiredEntriesDialog(QWidget* parent,IDatabase* database,const QList<IEntryHandle*>& Entries); ExpiredEntriesDialog(QWidget* parent,IDatabase* database,const QList<IEntryHandle*>& Entries);

@ -22,8 +22,6 @@
#include "ui_ManageBookmarksDlg.h" #include "ui_ManageBookmarksDlg.h"
#include "main.h"
class ManageBookmarksDlg : public QDialog, private Ui::ManageBookmarksDlg class ManageBookmarksDlg : public QDialog, private Ui::ManageBookmarksDlg
{ {
Q_OBJECT Q_OBJECT

@ -20,65 +20,61 @@
#ifndef PASSWORDDIALOG_H #ifndef PASSWORDDIALOG_H
#define PASSWORDDIALOG_H #define PASSWORDDIALOG_H
#include <QPixmap>
#include <QPaintEvent> #include <QPaintEvent>
#include "ui_PasswordDlg.h" #include "ui_PasswordDlg.h"
#include "main.h"
#include "lib/UrlLabel.h"
#include "Database.h"
class PasswordDialog : public QDialog, public Ui_PasswordDlg { class PasswordDialog : public QDialog, private Ui_PasswordDlg {
Q_OBJECT Q_OBJECT
public: public:
enum DlgMode { enum DlgMode {
Mode_Ask, // Normal password entry when opening a database Mode_Ask, // Normal password entry when opening a database
Mode_Set, // Setting password for the first time after creating a new database Mode_Set, // Setting password for the first time after creating a new database
Mode_Change // Changing the password of a database Mode_Change // Changing the password of a database
}; };
enum DlgFlags {
Flag_None = 0x00,
Flag_Auto = 0x01 // Dialog was automatically opened on start-up
};
enum DlgExit {
Exit_Ok=QDialog::Accepted,
Exit_Cancel=QDialog::Rejected,
Exit_Quit=3
};
typedef bool (KeyFileGenProc)(const QString& filename,QString* error);
PasswordDialog(QWidget* parent,DlgMode mode,DlgFlags flags,const QString& filename=QString()); enum DlgFlags {
Flag_None = 0x00,
// result functions Flag_Auto = 0x01 // Dialog was automatically opened on start-up
QString selectedBookmark(); };
QString keyFile();
QString password(); enum DlgExit {
Exit_Ok=QDialog::Accepted,
Exit_Cancel=QDialog::Rejected,
Exit_Quit=3
};
typedef bool (KeyFileGenProc)(const QString& filename,QString* error);
PasswordDialog(QWidget* parent,DlgMode mode,DlgFlags flags,const QString& filename=QString());
// result functions
QString selectedBookmark();
QString keyFile();
QString password();
public slots: private slots:
void OnOK(); void OnOK();
void OnCancel(); void OnCancel();
void OnButtonBrowse(); void OnButtonBrowse();
void OnButtonQuit(); void OnButtonQuit();
void OnGenKeyFile(); void OnGenKeyFile();
void OnButtonBack(); void OnButtonBack();
void ChangeEchoModeDatabaseKey(); void ChangeEchoModeDatabaseKey();
void OnBookmarkTriggered(QAction* action); void OnBookmarkTriggered(QAction* action);
void OnCheckBoxesChanged(int state); void OnCheckBoxesChanged(int state);
private: private:
DlgMode Mode; DlgMode Mode;
QPixmap BannerPixmap; QPixmap BannerPixmap;
QString BookmarkFilename; QString BookmarkFilename;
QString Filename; QString Filename;
QString Password; QString Password;
QString KeyFile; QString KeyFile;
void setStatePasswordOnly(); void setStatePasswordOnly();
void setStateKeyFileOnly(); void setStateKeyFileOnly();
void setStateBoth(); void setStateBoth();
virtual void paintEvent(QPaintEvent*); virtual void paintEvent(QPaintEvent*);
}; };
#endif #endif

@ -21,7 +21,6 @@
#include "dialogs/PasswordGenDlg.h" #include "dialogs/PasswordGenDlg.h"
#include "dialogs/CollectEntropyDlg.h" #include "dialogs/CollectEntropyDlg.h"
#include "crypto/yarrow.h"
bool CGenPwDialog::EntropyCollected=false; bool CGenPwDialog::EntropyCollected=false;

@ -22,7 +22,7 @@
#include "ui_SearchDlg.h" #include "ui_SearchDlg.h"
class SearchDialog : public QDialog, public Ui_Search_Dlg class SearchDialog : public QDialog, private Ui_Search_Dlg
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -30,7 +30,7 @@ class SearchDialog : public QDialog, public Ui_Search_Dlg
~SearchDialog(); ~SearchDialog();
QList<IEntryHandle*> Result; QList<IEntryHandle*> Result;
public slots: private slots:
virtual void OnClose(); virtual void OnClose();
virtual void OnSearch(); virtual void OnSearch();

@ -23,31 +23,32 @@
#include "ui_SelectIconDlg.h" #include "ui_SelectIconDlg.h"
class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{ class CSelectIconDlg:public QDialog, private Ui_SelectIconDlg{
Q_OBJECT Q_OBJECT
public:
CSelectIconDlg(IDatabase* db,int ImageID,QWidget* parent = 0, bool modal = false, Qt::WFlags fl = 0); public:
CSelectIconDlg(IDatabase* db,int ImageID,QWidget* parent = 0, bool modal = false, Qt::WFlags fl = 0);
public slots:
void OnAddIcon(); private slots:
void OnPickIcon(); void OnAddIcon();
void OnCancel(); void OnPickIcon();
void OnDelete(); void OnCancel();
void OnReplace(); void OnDelete();
void OnSelectionChanged(QListWidgetItem*); void OnReplace();
void OnSelectionChanged(QListWidgetItem*);
private:
int Id; private:
IDatabase* db; int Id;
void updateView(); IDatabase* db;
QMenu* CtxMenu; void updateView();
QAction* DeleteAction; QMenu* CtxMenu;
QAction* ReplaceAction; QAction* DeleteAction;
QPushButton* Button_PickIcon; QAction* ReplaceAction;
QPushButton* Button_PickIcon;
protected:
virtual void contextMenuEvent(QContextMenuEvent *event); protected:
virtual void showEvent(QShowEvent* event); virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void showEvent(QShowEvent* event);
}; };

@ -24,7 +24,7 @@
#include "ui_SettingsDlg.h" #include "ui_SettingsDlg.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
class CSettingsDlg : public QDialog, public Ui_SettingsDialog class CSettingsDlg : public QDialog, private Ui_SettingsDialog
{ {
Q_OBJECT Q_OBJECT
public: public:

@ -23,21 +23,20 @@
#include "ui_SimplePasswordDlg.h" #include "ui_SimplePasswordDlg.h"
class SimplePasswordDialog : public QDialog, public Ui_SimplePasswordDialog class SimplePasswordDialog : public QDialog, private Ui_SimplePasswordDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SimplePasswordDialog(QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); SimplePasswordDialog(QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
~SimplePasswordDialog(); ~SimplePasswordDialog();
QString password;
public: QString password;
private slots:
public slots: virtual void OnCancel();
virtual void OnCancel(); virtual void OnOK();
virtual void OnOK(); virtual void OnHidePasswordToggled(bool state);
virtual void OnHidePasswordToggled(bool state); virtual void OnTextChanged(const QString&);
virtual void OnTextChanged(const QString&);
}; };
#endif #endif

@ -563,8 +563,9 @@ void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
mimeData->setData("text/plain;charset=UTF-8",DragItems.first()->text(0).toUtf8()); mimeData->setData("text/plain;charset=UTF-8",DragItems.first()->text(0).toUtf8());
mimeData->setData("application/x-keepassx-entry",QByteArray((char*)&pDragItems,sizeof(void*))); mimeData->setData("application/x-keepassx-entry",QByteArray((char*)&pDragItems,sizeof(void*)));
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
EventOccurredBlock = true;
drag->exec(Qt::MoveAction); drag->exec(Qt::MoveAction);
EventOccurredBlock = false;
} }
void KeepassEntryView::removeDragItems(){ void KeepassEntryView::removeDragItems(){

@ -69,7 +69,7 @@ class KeepassEntryView:public QTreeWidget{
virtual void resizeEvent(QResizeEvent* event); virtual void resizeEvent(QResizeEvent* event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
public slots: private slots:
void OnColumnResized(int index,int OldSize, int NewSize); void OnColumnResized(int index,int OldSize, int NewSize);
void OnHeaderSectionClicked(int index); void OnHeaderSectionClicked(int index);
void OnGroupChanged(IGroupHandle* group); void OnGroupChanged(IGroupHandle* group);

@ -467,7 +467,9 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
mimeData->setData("application/x-keepassx-group",QByteArray()); mimeData->setData("application/x-keepassx-group",QByteArray());
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
EventOccurredBlock = true;
drag->exec(Qt::MoveAction); drag->exec(Qt::MoveAction);
EventOccurredBlock = false;
} }
void KeepassGroupView::OnItemExpanded(QTreeWidgetItem* item){ void KeepassGroupView::OnItemExpanded(QTreeWidgetItem* item){

@ -58,7 +58,7 @@ class KeepassGroupView:public QTreeWidget{
GroupViewDragType DragType; GroupViewDragType DragType;
QList<QTreeWidgetItem*>* EntryDragItems; QList<QTreeWidgetItem*>* EntryDragItems;
public slots: private slots:
void OnCurrentGroupChanged(QTreeWidgetItem*); void OnCurrentGroupChanged(QTreeWidgetItem*);
void OnDeleteGroup(); void OnDeleteGroup();
void OnNewGroup(); void OnNewGroup();

@ -22,24 +22,25 @@
#define _LINKLABEL_H_ #define _LINKLABEL_H_
class LinkLabel : public QLabel{ class LinkLabel : public QLabel{
Q_OBJECT Q_OBJECT
public:
LinkLabel(QWidget *parent,const QString& text=QString::null, int x=0, int y=0,Qt::WFlags f=0); public:
~LinkLabel(); LinkLabel(QWidget *parent,const QString& text=QString::null, int x=0, int y=0,Qt::WFlags f=0);
void setPos(int x,int y); ~LinkLabel();
QString url(); void setPos(int x,int y);
QString url();
public slots: public slots:
virtual void setText(const QString&); virtual void setText(const QString&);
signals: signals:
void clicked(); void clicked();
protected: protected:
virtual void mouseReleaseEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event);
private: private:
QString URL; QString URL;
}; };

@ -28,7 +28,7 @@ class WaitAnimationWidget:public QWidget{
void setRefreshRate(int fps); void setRefreshRate(int fps);
void start(); void start();
void stop(); void stop();
public slots: private slots:
void refreshAnimation(); void refreshAnimation();
private: private:
virtual void paintEvent(QPaintEvent* event); virtual void paintEvent(QPaintEvent* event);

@ -22,7 +22,6 @@
#include "plugins/interfaces/IFileDialog.h" #include "plugins/interfaces/IFileDialog.h"
#include "plugins/interfaces/IKdeInit.h" #include "plugins/interfaces/IKdeInit.h"
#include "plugins/interfaces/IGnomeInit.h" #include "plugins/interfaces/IGnomeInit.h"
#include "plugins/interfaces/IIconTheme.h"
#include <QTranslator> #include <QTranslator>
@ -30,7 +29,6 @@
#include <QPluginLoader> #include <QPluginLoader>
#include "mainwindow.h" #include "mainwindow.h"
#include "main.h" #include "main.h"
#include "crypto/yarrow.h"
#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE) #if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE)
#include "Application_X11.h" #include "Application_X11.h"
#endif #endif
@ -46,6 +44,7 @@ bool TrActive;
QString DetailViewTemplate; QString DetailViewTemplate;
bool EventOccurred; bool EventOccurred;
bool EventOccurredBlock = false; bool EventOccurredBlock = false;
EventListener* eventListener;
QPixmap* EntryIcons; QPixmap* EntryIcons;
IIconTheme* IconLoader=NULL; IIconTheme* IconLoader=NULL;
@ -181,10 +180,14 @@ int main(int argc, char **argv)
initYarrow(); //init random number generator initYarrow(); //init random number generator
SecString::generateSessionKey(); SecString::generateSessionKey();
eventListener = new EventListener();
app->installEventFilter(eventListener);
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
KeepassMainWindow *mainWin = new KeepassMainWindow(args.file(), args.startMinimized(), args.startLocked()); KeepassMainWindow *mainWin = new KeepassMainWindow(args.file(), args.startMinimized(), args.startLocked());
int r=app->exec(); int r=app->exec();
delete mainWin; delete mainWin;
delete eventListener;
fileDlgHistory.save(); fileDlgHistory.save();
delete app; delete app;
@ -312,4 +315,12 @@ QString findPlugin(const QString& filename){
} }
bool EventListener::eventFilter(QObject*, QEvent* event){
if (!EventOccurred){
int t = event->type();
if ( t>=QEvent::MouseButtonPress&&t<=QEvent::KeyRelease || t>=QEvent::HoverEnter&&t<=QEvent::HoverMove )
EventOccurred = true;
}
return false;
}

@ -48,4 +48,11 @@ private:
bool Help; bool Help;
}; };
class EventListener : public QObject {
Q_OBJECT
protected:
bool eventFilter(QObject*, QEvent* event);
};
#endif #endif

@ -21,7 +21,6 @@
#include <QStatusBar> #include <QStatusBar>
#include "mainwindow.h" #include "mainwindow.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
#include "lib/FileDialogs.h"
#include "import/Import_PwManager.h" #include "import/Import_PwManager.h"
#include "import/Import_KWalletXml.h" #include "import/Import_KWalletXml.h"
#include "import/Import_KeePassX_Xml.h" #include "import/Import_KeePassX_Xml.h"
@ -1009,15 +1008,6 @@ void KeepassMainWindow::showEvent(QShowEvent* event){
QMainWindow::showEvent(event); QMainWindow::showEvent(event);
} }
bool KeepassMainWindow::event(QEvent* event){
if (!EventOccurred){
int t = event->type();
if ( t>=QEvent::MouseButtonPress&&t<=QEvent::KeyRelease || t>=QEvent::HoverEnter&&t<=QEvent::HoverMove )
EventOccurred = true;
}
return QMainWindow::event(event);
}
void KeepassMainWindow::OnExtrasSettings(){ void KeepassMainWindow::OnExtrasSettings(){
CSettingsDlg dlg(this); CSettingsDlg dlg(this);
dlg.exec(); dlg.exec();
@ -1256,8 +1246,12 @@ void KeepassMainWindow::OnInactivityTimer(){
} }
else{ else{
inactivityCounter++; inactivityCounter++;
if (inactivityCounter*(inactivityTimer->interval()) >= config->lockAfterSec()*1000) if (inactivityCounter*(inactivityTimer->interval()) >= config->lockAfterSec()*1000){
QWidget* popUpWidget = QApplication::activePopupWidget();
if (popUpWidget!=NULL)
popUpWidget->hide();
OnUnLockWorkspace(); OnUnLockWorkspace();
}
} }
} }

@ -29,7 +29,7 @@
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
#include "ui_WorkspaceLockedWidget.h" #include "ui_WorkspaceLockedWidget.h"
class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{ class KeepassMainWindow : public QMainWindow, private Ui_MainWindow{
Q_OBJECT Q_OBJECT
public: public:
KeepassMainWindow (const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent=0, Qt::WFlags flags=0); KeepassMainWindow (const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent=0, Qt::WFlags flags=0);
@ -84,7 +84,6 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);
void hideEvent(QHideEvent* event); void hideEvent(QHideEvent* event);
void showEvent(QShowEvent* event); void showEvent(QShowEvent* event);
bool event(QEvent* event);
void setLock(); void setLock();
void resetLock(); void resetLock();
SelectionState GroupSelection, EntrySelection; SelectionState GroupSelection, EntrySelection;