copy to clipboard (qt4), tool buttons

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@26 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 77524c5b93
commit 8409e57be1
  1. BIN
      share/keepass/icons/nuvola/32x32/actions/identity.png
  2. BIN
      share/keepass/icons/nuvola/32x32/actions/kgpg_info.png
  3. BIN
      share/keepass/icons/nuvola/32x32/actions/klipper_dock.png
  4. 17
      src/main.cpp
  5. 5
      src/main.h
  6. 39
      src/mainwindow.cpp
  7. 9
      src/mainwindow.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -51,6 +51,10 @@ QIcon *Icon_FileSaveAs;
QIcon *Icon_Exit; QIcon *Icon_Exit;
QIcon *Icon_File_Export; QIcon *Icon_File_Export;
QIcon *Icon_EditDelete; QIcon *Icon_EditDelete;
QIcon *Icon_EditAdd;
QIcon *Icon_EditEdit;
QIcon *Icon_EditUsernameToCb;
QIcon *Icon_EditPasswordToCb;
QString DateTimeFormat("no-format-string"); QString DateTimeFormat("no-format-string");
@ -256,7 +260,18 @@ Icon_Exit=new QIcon(tmpImg);
//-------------------------- //--------------------------
loadImg(ThemeDir+"/actions/editdelete.png",tmpImg); loadImg(ThemeDir+"/actions/editdelete.png",tmpImg);
Icon_EditDelete=new QIcon(tmpImg); Icon_EditDelete=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/edit_add.png",tmpImg);
Icon_EditAdd=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/edit.png",tmpImg);
Icon_EditEdit=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/identity.png",tmpImg);
Icon_EditUsernameToCb=new QIcon(tmpImg);
//--------------------------
loadImg(ThemeDir+"/actions/klipper_dock.png",tmpImg);
Icon_EditPasswordToCb=new QIcon(tmpImg);
} }

@ -51,6 +51,11 @@ extern QIcon *Icon_FileSaveAs;
extern QIcon *Icon_Exit; extern QIcon *Icon_Exit;
extern QIcon *Icon_File_Export; extern QIcon *Icon_File_Export;
extern QIcon *Icon_EditDelete; extern QIcon *Icon_EditDelete;
extern QIcon *Icon_EditAdd;
extern QIcon *Icon_EditEdit;
extern QIcon *Icon_EditDelete;
extern QIcon *Icon_EditUsernameToCb;
extern QIcon *Icon_EditPasswordToCb;
extern QString DateTimeFormat; extern QString DateTimeFormat;

@ -65,6 +65,7 @@ KeepassMainWindow::KeepassMainWindow(QWidget *parent, Qt::WFlags flags):QMainWin
setupToolbar(); setupToolbar();
setStateFileOpen(false); setStateFileOpen(false);
FileOpen=false; FileOpen=false;
Clipboard=QApplication::clipboard();
} }
void KeepassMainWindow::setupConnections(){ void KeepassMainWindow::setupConnections(){
@ -86,7 +87,10 @@ void KeepassMainWindow::setupConnections(){
connect(EditEditEntryAction, SIGNAL(triggered()), this, SLOT(OnEditEditEntry())); connect(EditEditEntryAction, SIGNAL(triggered()), this, SLOT(OnEditEditEntry()));
connect(EditCloneEntryAction, SIGNAL(triggered()), this, SLOT(OnEditCloneEntry())); connect(EditCloneEntryAction, SIGNAL(triggered()), this, SLOT(OnEditCloneEntry()));
connect(EditDeleteEntryAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteEntry())); connect(EditDeleteEntryAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteEntry()));
connect(EditUsernameToClipboardAction, SIGNAL(triggered()), this, SLOT(OnEditUsernameToClipboard()));
connect(EditPasswordToClipboardAction, SIGNAL(triggered()), this, SLOT(OnEditPasswordToClipboard()));
connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut()));
connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this, connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*))); SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this, connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,
@ -100,7 +104,12 @@ toolBar->addAction(FileNewAction);
toolBar->addAction(FileOpenAction); toolBar->addAction(FileOpenAction);
toolBar->addAction(FileSaveAction); toolBar->addAction(FileSaveAction);
toolBar->addSeparator(); toolBar->addSeparator();
toolBar->addAction(EditNewEntryAction);
toolBar->addAction(EditEditEntryAction);
toolBar->addAction(EditDeleteEntryAction);
toolBar->addSeparator();
toolBar->addAction(EditPasswordToClipboardAction);
toolBar->addAction(EditUsernameToClipboardAction);
} }
void KeepassMainWindow::setupIcons(){ void KeepassMainWindow::setupIcons(){
@ -110,6 +119,11 @@ FileSaveAction->setIcon(*Icon_FileSave);
FileSaveAsAction->setIcon(*Icon_FileSaveAs); FileSaveAsAction->setIcon(*Icon_FileSaveAs);
FileCloseAction->setIcon(*Icon_FileClose); FileCloseAction->setIcon(*Icon_FileClose);
FileExitAction->setIcon(*Icon_Exit); FileExitAction->setIcon(*Icon_Exit);
EditNewEntryAction->setIcon(*Icon_EditAdd);
EditEditEntryAction->setIcon(*Icon_EditEdit);
EditDeleteEntryAction->setIcon(*Icon_EditDelete);
EditPasswordToClipboardAction->setIcon(*Icon_EditPasswordToCb);
EditUsernameToClipboardAction->setIcon(*Icon_EditUsernameToCb);
} }
@ -456,7 +470,30 @@ setStateFileModified(true);
EntryView->updateItems(); EntryView->updateItems();
} }
void KeepassMainWindow::OnEditUsernameToClipboard(){
Clipboard->setText(currentEntry()->UserName, QClipboard::Clipboard);
ClipboardTimer.start(config.ClipboardTimeOut*1000,true);
}
void KeepassMainWindow::OnEditPasswordToClipboard(){
Clipboard->setText(currentEntry()->Password.getString(),QClipboard::Clipboard);
ClipboardTimer.start(config.ClipboardTimeOut*1000,true);
currentEntry()->Password.delRef();
}
void KeepassMainWindow::OnClipboardTimeOut(){
Clipboard->clear(QClipboard::Clipboard);
qDebug("Clipper cleared.");
}
CGroup* KeepassMainWindow::currentGroup(){ CGroup* KeepassMainWindow::currentGroup(){
Q_ASSERT(GroupView->selectedItems().size()); Q_ASSERT(GroupView->selectedItems().size());
return static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup; return static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup;
} }
CEntry* KeepassMainWindow::currentEntry(){
Q_ASSERT(EntryView->selectedItems().size()==1);
return static_cast<EntryViewItem*>(EntryView->selectedItems()[0])->pEntry;
}

@ -34,7 +34,8 @@
#include <QDropEvent> #include <QDropEvent>
#include <QListWidget> #include <QListWidget>
#include <QTreeWidget> #include <QTreeWidget>
#include <QClipboard>
#include <QTimer>
#include "PwManager.h" #include "PwManager.h"
#include "PwmConfig.h" #include "PwmConfig.h"
@ -68,16 +69,21 @@ private slots:
void OnEditEditEntry(); void OnEditEditEntry();
void OnEditCloneEntry(); void OnEditCloneEntry();
void OnEditDeleteEntry(); void OnEditDeleteEntry();
void OnEditUsernameToClipboard();
void OnEditPasswordToClipboard();
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*); void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column); void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
void OnEntrySelectionChanged(); void OnEntrySelectionChanged();
void OnGroupSelectionChanged(); void OnGroupSelectionChanged();
void OnClipboardTimeOut();
private: private:
enum SelectionState{NONE,SINGLE,MULTIPLE}; enum SelectionState{NONE,SINGLE,MULTIPLE};
SelectionState GroupSelection, EntrySelection; SelectionState GroupSelection, EntrySelection;
bool FileOpen; bool FileOpen;
bool ModFlag; bool ModFlag;
QClipboard* Clipboard;
QTimer ClipboardTimer;
inline void setupToolbar(); inline void setupToolbar();
inline void setupIcons(); inline void setupIcons();
inline void setupConnections(); inline void setupConnections();
@ -89,6 +95,7 @@ private:
bool closeDatabase(); bool closeDatabase();
void editEntry(CEntry* pEntry); void editEntry(CEntry* pEntry);
inline CGroup* currentGroup(); inline CGroup* currentGroup();
inline CEntry* currentEntry();