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
master
sniperbeamer 16 years ago
parent 07fb82c88b
commit 70bf7f5b5d
  1. 9
      src/Kdb3Database.cpp
  2. 4
      src/dialogs/AboutDlg.cpp
  3. 3
      src/forms/EditEntryDlg.ui
  4. 16
      src/forms/MainWindow.ui
  5. 51
      src/lib/EntryView.cpp
  6. 3
      src/lib/EntryView.h
  7. 13
      src/lib/random.cpp
  8. 2
      src/main_unix.cpp
  9. 12
      src/mainwindow.cpp
  10. 2
      src/res/default-detailview.html

@ -860,15 +860,18 @@ bool Kdb3Database::setFileKey(const QString& filename){
if(FileSize == 32){
if(file.read((char*)RawMasterKey,32) != 32){
error=decodeFileError(file.error());
return false;}
return false;
}
return true;
}
if(FileSize == 64){
char hex[64];
if(file.read(hex,64) != 64){
error=decodeFileError(file.error());
return false;}
if(convHexToBinaryKey(hex,(char*)RawMasterKey))return true;
return false;
}
if (convHexToBinaryKey(hex,(char*)RawMasterKey))
return true;
}
SHA256 sha;
unsigned char* buffer = new unsigned char[2048];

@ -45,11 +45,11 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent)
str+="<div style='margin-left:10px;'>";
str+="<u>Tarek Saidi</u><br>"+tr("Developer, Project Admin")+"<br>tarek_saidi@users.sf.net<br>";
str+="<br>";
str+="<u>Felix Geyer</u><br>"+tr("Developer, Project Admin")+"<br>sniperbeamer@users.sf.net<br>";
str+="<br>";
str+="<u>Eugen Gorschenin</u><br>"+tr("Web Designer")+"<br>geugen@users.sf.de<br>";
str+="<br>";
str+="<u>Juan J Gonz&aacute;lez C&aacute;rdenas [Jota Jota]</u><br>"+tr("Developer")+"<br>myxelf@users.sf.net<br>";
str+="<br>";
str+="<u>Felix Geyer</u><br>"+tr("Developer")+"<br>sniperbeamer@users.sf.net<br>";
str+="</div><br><div style='margin-left:0px;'>";
str+="<b>"+tr("Thanks To")+"</b><br>";
str+="</div><div style='margin-left:10px;'>";

@ -243,6 +243,9 @@
<property name="tabChangesFocus" >
<bool>true</bool>
</property>
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2" >

@ -17,6 +17,14 @@
<string>KeePassX</string>
</property>
<widget class="QWidget" name="centralWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>29</y>
<width>724</width>
<height>439</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QSplitter" name="VSplitter" >
@ -112,7 +120,7 @@
<x>0</x>
<y>0</y>
<width>724</width>
<height>30</height>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuHilfe" >
@ -170,6 +178,7 @@
<addaction name="EditUsernameToClipboardAction" />
<addaction name="EditPasswordToClipboardAction" />
<addaction name="EditOpenUrlAction" />
<addaction name="EditCopyUrlAction" />
<addaction name="EditSaveAttachmentAction" />
<addaction name="separator" />
<addaction name="EditNewEntryAction" />
@ -564,6 +573,11 @@
<string>Bookmark &amp;this Database...</string>
</property>
</action>
<action name="EditCopyUrlAction" >
<property name="text" >
<string>Copy URL to Clipboard</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

@ -21,6 +21,7 @@
#include <QHeaderView>
#include <QClipboard>
#include <QFileDialog>
#include <QProcess>
#include "lib/AutoType.h"
#include "lib/EntryView.h"
#include "dialogs/EditEntryDlg.h"
@ -244,13 +245,17 @@ void KeepassEntryView::OnNewEntry(){
void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
switch (columnListIndex(Column)){
case 0: editEntry((EntryViewItem*)item);
case 0:
editEntry((EntryViewItem*)item);
break;
case 1: OnUsernameToClipboard();
case 1:
OnUsernameToClipboard();
break;
case 2: OnEditOpenUrl();
case 2:
OnEditOpenUrl();
break;
case 3: OnPasswordToClipboard();
case 3:
OnPasswordToClipboard();
break;
}
@ -266,34 +271,62 @@ 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);
}
}
void KeepassEntryView::OnPasswordToClipboard(){
if (selectedItems().size() == 0) return;
SecString password;
password=((EntryViewItem*)selectedItems().first())->EntryHandle->password();
password.unlock();
if (password.string().isEmpty()) return;
Clipboard->setText(password.string(), QClipboard::Clipboard);
if(Clipboard->supportsSelection()){
Clipboard->setText(password.string(), QClipboard::Selection);
}
if (config->clipboardTimeOut()!=0) {
ClipboardTimer.setSingleShot(true);
ClipboardTimer.start(config->clipboardTimeOut()*1000);
}
}
void KeepassEntryView::OnClipboardTimeOut(){
Clipboard->clear(QClipboard::Clipboard);
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());

@ -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;
}

@ -70,5 +70,7 @@ void initAppPaths(int argc,char** argv) {
}
AppDir.truncate(AppDir.lastIndexOf("/"));
DataDir=AppDir+"/../share/keepassx";
if (!QFile::exists(DataDir) && QFile::exists(AppDir+"/share"))
DataDir=AppDir+"/share";
HomeDir = QDir::homePath()+"/.keepassx";
}

@ -157,6 +157,7 @@ void KeepassMainWindow::setupConnections(){
connect(EditUsernameToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnUsernameToClipboard()));
connect(EditPasswordToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnPasswordToClipboard()));
connect(EditOpenUrlAction, SIGNAL(triggered()), EntryView, SLOT(OnEditOpenUrl()));
connect(EditCopyUrlAction, SIGNAL(triggered()), EntryView, SLOT(OnEditCopyUrl()));
connect(EditSaveAttachmentAction, SIGNAL(triggered()),EntryView, SLOT(OnSaveAttachment()));
connect(EditSearchAction, SIGNAL(triggered()), this, SLOT(OnSearch()));
connect(EditGroupSearchAction, SIGNAL(triggered()), this, SLOT(OnGroupSearch()));
@ -282,6 +283,7 @@ void KeepassMainWindow::setupMenus(){
EntryView->ContextMenu->addAction(EditUsernameToClipboardAction);
EntryView->ContextMenu->addAction(EditPasswordToClipboardAction);
EntryView->ContextMenu->addAction(EditOpenUrlAction);
EntryView->ContextMenu->addAction(EditCopyUrlAction);
EntryView->ContextMenu->addAction(EditSaveAttachmentAction);
#ifdef AUTOTYPE
EntryView->ContextMenu->addAction(EditAutoTypeAction);
@ -578,6 +580,7 @@ void KeepassMainWindow::setStateFileOpen(bool IsOpen){
EditPasswordToClipboardAction->setEnabled(false);
EditUsernameToClipboardAction->setEnabled(false);
EditOpenUrlAction->setEnabled(false);
EditCopyUrlAction->setEnabled(false);
EditSaveAttachmentAction->setEnabled(false);
EditNewEntryAction->setEnabled(false);
EditEditEntryAction->setEnabled(false);
@ -722,6 +725,7 @@ void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EditPasswordToClipboardAction->setEnabled(false);
EditUsernameToClipboardAction->setEnabled(false);
EditOpenUrlAction->setEnabled(false);
EditCopyUrlAction->setEnabled(false);
EditSaveAttachmentAction->setEnabled(false);
EditEditEntryAction->setEnabled(false);
EditCloneEntryAction->setEnabled(false);
@ -736,6 +740,7 @@ void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EditPasswordToClipboardAction->setEnabled(true);
EditUsernameToClipboardAction->setEnabled(true);
EditOpenUrlAction->setEnabled(true);
EditCopyUrlAction->setEnabled(true);
EditSaveAttachmentAction->setEnabled(((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle->binarySize() > 0);
EditEditEntryAction->setEnabled(true);
EditCloneEntryAction->setEnabled(true);
@ -750,6 +755,7 @@ void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EditPasswordToClipboardAction->setEnabled(false);
EditUsernameToClipboardAction->setEnabled(false);
EditOpenUrlAction->setEnabled(false);
EditCopyUrlAction->setEnabled(false);
EditSaveAttachmentAction->setEnabled(false);
EditEditEntryAction->setEnabled(false);
EditCloneEntryAction->setEnabled(true);
@ -770,6 +776,7 @@ void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EditUsernameToClipboardAction->setEnabled(false);
EditPasswordToClipboardAction->setEnabled(false);
EditOpenUrlAction->setEnabled(false);
EditCopyUrlAction->setEnabled(false);
EditSaveAttachmentAction->setEnabled(false);
EditEditEntryAction->setEnabled(false);
EditCloneEntryAction->setEnabled(false);
@ -784,6 +791,7 @@ void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EditUsernameToClipboardAction->setEnabled(true);
EditPasswordToClipboardAction->setEnabled(true);
EditOpenUrlAction->setEnabled(true);
EditCopyUrlAction->setEnabled(true);
EditSaveAttachmentAction->setEnabled(((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle->binarySize() > 0);
EditEditEntryAction->setEnabled(true);
EditCloneEntryAction->setEnabled(false);
@ -798,6 +806,7 @@ void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EditUsernameToClipboardAction->setEnabled(false);
EditPasswordToClipboardAction->setEnabled(false);
EditOpenUrlAction->setEnabled(false);
EditCopyUrlAction->setEnabled(false);
EditSaveAttachmentAction->setEnabled(false);
EditEditEntryAction->setEnabled(false);
EditCloneEntryAction->setEnabled(false);
@ -833,7 +842,8 @@ bool KeepassMainWindow::OnFileSave(){
bool KeepassMainWindow::OnFileSaveAs(){
QString filename=KpxFileDialogs::saveFile(this,"MainWindow_FileSave",
tr("Save Database..."),QStringList()<<tr("KeePass Databases (*.kdb)")<< tr("All Files (*)"));
if(filename.isEmpty())return false;
if (filename.isEmpty() || filename.compare(".kdb", Qt::CaseInsensitive)==0)
return false;
if(!db->changeFile(filename)){
showErrMsg(QString("%1\n%2").arg(tr("File could not be saved.")).arg(db->getError()));
db->changeFile(QString());

@ -41,7 +41,7 @@
<td width="10%" class="fieldname">Password:</td>
<td width="40%" class="fieldvalue">%password%</td>
<td width="10%" class="fieldname">Modification:</td>
<td width="40%" class="fieldvalue">%creation%</td>
<td width="40%" class="fieldvalue">%lastmod%</td>
</tr>
<tr>
<td width="10%" class="fieldname">Attachment:</td>