Added action "Copy URL to Clipboard" (closes #1944021)
Fixed: Unnamed Database saved as ".kdb" (closes #2109972, #2118340) Fixed: Date of Modification isn't updated (closes #2108658, #2121768) Fixed and improved the initialization of the fallback random number source (closes #2091784) Don't clear clipboard if "Clear clipboard after" is set to 0 Try to clear Klipper history when clearing clipboard git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@220 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <QHeaderView>
|
||||
#include <QClipboard>
|
||||
#include <QFileDialog>
|
||||
#include <QProcess>
|
||||
#include "lib/AutoType.h"
|
||||
#include "lib/EntryView.h"
|
||||
#include "dialogs/EditEntryDlg.h"
|
||||
@@ -243,15 +244,19 @@ void KeepassEntryView::OnNewEntry(){
|
||||
}
|
||||
|
||||
void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
|
||||
switch(columnListIndex(Column)){
|
||||
case 0: editEntry((EntryViewItem*)item);
|
||||
break;
|
||||
case 1: OnUsernameToClipboard();
|
||||
break;
|
||||
case 2: OnEditOpenUrl();
|
||||
break;
|
||||
case 3: OnPasswordToClipboard();
|
||||
break;
|
||||
switch (columnListIndex(Column)){
|
||||
case 0:
|
||||
editEntry((EntryViewItem*)item);
|
||||
break;
|
||||
case 1:
|
||||
OnUsernameToClipboard();
|
||||
break;
|
||||
case 2:
|
||||
OnEditOpenUrl();
|
||||
break;
|
||||
case 3:
|
||||
OnPasswordToClipboard();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -266,14 +271,31 @@ void KeepassEntryView::OnEditOpenUrl(){
|
||||
openBrowser( ((EntryViewItem*)selectedItems().first())->EntryHandle );
|
||||
}
|
||||
|
||||
void KeepassEntryView::OnEditCopyUrl(){
|
||||
if (selectedItems().size() == 0) return;
|
||||
QString url = ((EntryViewItem*)selectedItems().first())->EntryHandle->url();
|
||||
if (url.startsWith("cmd://") && url.length()>6)
|
||||
url = url.right(url.length()-6);
|
||||
|
||||
Clipboard->setText(url, QClipboard::Clipboard);
|
||||
if(Clipboard->supportsSelection()){
|
||||
Clipboard->setText(url, QClipboard::Selection);
|
||||
}
|
||||
}
|
||||
|
||||
void KeepassEntryView::OnUsernameToClipboard(){
|
||||
if (selectedItems().size() == 0) return;
|
||||
Clipboard->setText(((EntryViewItem*)selectedItems().first())->EntryHandle->username(), QClipboard::Clipboard);
|
||||
QString username = ((EntryViewItem*)selectedItems().first())->EntryHandle->username();
|
||||
if (username.trimmed().isEmpty()) return;
|
||||
Clipboard->setText(username, QClipboard::Clipboard);
|
||||
if(Clipboard->supportsSelection()){
|
||||
Clipboard->setText(((EntryViewItem*)selectedItems().first())->EntryHandle->username(),QClipboard::Selection);
|
||||
Clipboard->setText(username, QClipboard::Selection);
|
||||
}
|
||||
|
||||
if (config->clipboardTimeOut()!=0) {
|
||||
ClipboardTimer.setSingleShot(true);
|
||||
ClipboardTimer.start(config->clipboardTimeOut()*1000);
|
||||
}
|
||||
ClipboardTimer.setSingleShot(true);
|
||||
ClipboardTimer.start(config->clipboardTimeOut()*1000);
|
||||
}
|
||||
|
||||
void KeepassEntryView::OnPasswordToClipboard(){
|
||||
@@ -281,12 +303,16 @@ void KeepassEntryView::OnPasswordToClipboard(){
|
||||
SecString password;
|
||||
password=((EntryViewItem*)selectedItems().first())->EntryHandle->password();
|
||||
password.unlock();
|
||||
Clipboard->setText(password.string(),QClipboard::Clipboard);
|
||||
if (password.string().isEmpty()) return;
|
||||
Clipboard->setText(password.string(), QClipboard::Clipboard);
|
||||
if(Clipboard->supportsSelection()){
|
||||
Clipboard->setText(password.string(),QClipboard::Selection);
|
||||
Clipboard->setText(password.string(), QClipboard::Selection);
|
||||
}
|
||||
|
||||
if (config->clipboardTimeOut()!=0) {
|
||||
ClipboardTimer.setSingleShot(true);
|
||||
ClipboardTimer.start(config->clipboardTimeOut()*1000);
|
||||
}
|
||||
ClipboardTimer.setSingleShot(true);
|
||||
ClipboardTimer.start(config->clipboardTimeOut()*1000);
|
||||
}
|
||||
|
||||
void KeepassEntryView::OnClipboardTimeOut(){
|
||||
@@ -294,6 +320,13 @@ void KeepassEntryView::OnClipboardTimeOut(){
|
||||
if(Clipboard->supportsSelection()){
|
||||
Clipboard->clear(QClipboard::Selection);
|
||||
}
|
||||
#ifdef Q_WS_X11
|
||||
static bool clearKlipper = true;
|
||||
if (clearKlipper){
|
||||
if (QProcess::execute("dcop klipper klipper clearClipboardHistory")!=0)
|
||||
clearKlipper = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -312,9 +345,9 @@ void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{while(selectedItems().size()){
|
||||
setItemSelected(selectedItems().first(),false);}
|
||||
else{
|
||||
while (selectedItems().size())
|
||||
setItemSelected(selectedItems().first(),false);
|
||||
}
|
||||
e->accept();
|
||||
ContextMenu->popup(e->globalPos());
|
||||
@@ -621,7 +654,7 @@ bool EntryViewItem::operator<(const QTreeWidgetItem& other)const{
|
||||
KpxDateTime DateThis;
|
||||
KpxDateTime DateOther;
|
||||
|
||||
switch(ListIndex){
|
||||
switch (ListIndex){
|
||||
case 5: DateThis=EntryHandle->expire();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->expire();
|
||||
break;
|
||||
|
||||
@@ -69,6 +69,7 @@ class KeepassEntryView:public QTreeWidget{
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
void OnColumnResized(int index,int OldSize, int NewSize);
|
||||
void OnHeaderSectionClicked(int index);
|
||||
@@ -91,6 +92,8 @@ class KeepassEntryView:public QTreeWidget{
|
||||
void removeDragItems();
|
||||
void OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex);
|
||||
void OnEditOpenUrl();
|
||||
void OnEditCopyUrl();
|
||||
|
||||
signals:
|
||||
void fileModified();
|
||||
void selectionChanged(SelectionState);
|
||||
|
||||
@@ -88,9 +88,18 @@ extern void initStdRand(){
|
||||
stream << QCursor::pos();
|
||||
stream << QDateTime::currentDateTime().toTime_t();
|
||||
stream << QTime::currentTime().msec();
|
||||
#ifdef Q_WS_WIN
|
||||
stream << GetCurrentProcessId();
|
||||
#else
|
||||
stream << getpid();
|
||||
#endif
|
||||
/* On a modern OS code, stack and heap base are randomized */
|
||||
quint64 code_value = (quint64)initStdRand;
|
||||
stream << code_value;
|
||||
stream << (quint64)&code_value;
|
||||
|
||||
QByteArray hash = QCryptographicHash::hash(buffer, QCryptographicHash::Md4);
|
||||
QByteArray hash = QCryptographicHash::hash(buffer, QCryptographicHash::Sha1);
|
||||
|
||||
qsrand( (uint) hash.constData() );
|
||||
qsrand( *((uint*) hash.data()) );
|
||||
initalized = true;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ QString getImageFile(const QString& name){
|
||||
|
||||
|
||||
const QIcon& getIcon(const QString& name){
|
||||
static QHash<QString,QIcon*>IconCache;
|
||||
static QHash<QString,QIcon*>IconCache;
|
||||
QIcon* CachedIcon=IconCache.value(name);
|
||||
if(CachedIcon)
|
||||
return *CachedIcon;
|
||||
|
||||
Reference in New Issue
Block a user