Merge branch 'develop' into feature/yubikey

This commit is contained in:
Janek Bevendorff 2017-03-06 13:49:48 +01:00
commit 3c1271b1c4
No known key found for this signature in database
GPG key ID: CFEC2F6850BFFA53
13 changed files with 280 additions and 33 deletions

71
src/gui/CloneDialog.cpp Normal file
View file

@ -0,0 +1,71 @@
/*
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CloneDialog.h"
#include "ui_CloneDialog.h"
#include "config-keepassx.h"
#include "version.h"
#include "core/Database.h"
#include "core/Entry.h"
#include "core/FilePath.h"
#include "crypto/Crypto.h"
#include "gui/DatabaseWidget.h"
CloneDialog::CloneDialog(DatabaseWidget* parent, Database* db, Entry* entry)
: QDialog(parent)
, m_ui(new Ui::CloneDialog())
{
m_db = db;
m_entry = entry;
m_parent = parent;
m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(cloneEntry()));
}
void CloneDialog::cloneEntry()
{
Entry::CloneFlags flags = Entry::CloneNewUuid | Entry::CloneResetTimeInfo;
if (m_ui->titleClone->isChecked()) {
flags |= Entry::CloneRenameTitle;
}
if (m_ui->referencesClone->isChecked()) {
flags |= Entry::CloneUserAsRef;
flags |= Entry::ClonePassAsRef;
}
if (m_ui->historyClone->isChecked()) {
flags |= Entry::CloneIncludeHistory;
}
Entry* entry = m_entry->clone(flags);
entry->setGroup(m_entry->group());
emit m_parent->refreshSearch();
close();
}
CloneDialog::~CloneDialog()
{
}

51
src/gui/CloneDialog.h Normal file
View file

@ -0,0 +1,51 @@
/*
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_CLONEDIALOG_H
#define KEEPASSX_CLONEDIALOG_H
#include <QDialog>
#include <QScopedPointer>
#include "core/Entry.h"
#include "core/Database.h"
#include "gui/DatabaseWidget.h"
namespace Ui {
class CloneDialog;
}
class CloneDialog : public QDialog
{
Q_OBJECT
public:
explicit CloneDialog(DatabaseWidget* parent = nullptr, Database* db = nullptr, Entry* entry = nullptr);
~CloneDialog();
private:
QScopedPointer<Ui::CloneDialog> m_ui;
private Q_SLOTS:
void cloneEntry();
protected:
Database* m_db;
Entry* m_entry;
DatabaseWidget* m_parent;
};
#endif // KEEPASSX_CLONEDIALOG_H

77
src/gui/CloneDialog.ui Normal file
View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CloneDialog</class>
<widget class="QDialog" name="CloneDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>338</width>
<height>120</height>
</rect>
</property>
<property name="windowTitle">
<string>Clone Options</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>12</x>
<y>12</y>
<width>323</width>
<height>62</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="titleClone">
<property name="maximumSize">
<size>
<width>170</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Append ' - Copy' to title</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="referencesClone">
<property name="text">
<string>Replace username and password with references</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="historyClone">
<property name="text">
<string>Copy history</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>160</x>
<y>90</y>
<width>164</width>
<height>32</height>
</rect>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -41,6 +41,7 @@
#include "format/KeePass2Reader.h"
#include "gui/ChangeMasterKeyWidget.h"
#include "gui/Clipboard.h"
#include "gui/CloneDialog.h"
#include "gui/DatabaseOpenWidget.h"
#include "gui/DatabaseSettingsWidget.h"
#include "gui/KeePass1OpenWidget.h"
@ -320,12 +321,9 @@ void DatabaseWidget::cloneEntry()
return;
}
Entry* entry = currentEntry->clone(Entry::CloneNewUuid | Entry::CloneResetTimeInfo | Entry::CloneRenameTitle);
entry->setGroup(currentEntry->group());
if (isInSearchMode())
search(m_lastSearchText);
m_entryView->setFocus();
m_entryView->setCurrentEntry(entry);
CloneDialog* cloneDialog = new CloneDialog(this, m_db, currentEntry);
cloneDialog->show();
return;
}
void DatabaseWidget::deleteEntries()
@ -366,6 +364,7 @@ void DatabaseWidget::deleteEntries()
for (Entry* entry : asConst(selectedEntries)) {
delete entry;
}
refreshSearch();
}
}
else {
@ -408,7 +407,7 @@ void DatabaseWidget::copyTitle()
return;
}
setClipboardTextAndMinimize(currentEntry->title());
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->title()));
}
void DatabaseWidget::copyUsername()
@ -419,7 +418,7 @@ void DatabaseWidget::copyUsername()
return;
}
setClipboardTextAndMinimize(currentEntry->username());
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->username()));
}
void DatabaseWidget::copyPassword()
@ -430,7 +429,7 @@ void DatabaseWidget::copyPassword()
return;
}
setClipboardTextAndMinimize(currentEntry->password());
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->password()));
}
void DatabaseWidget::copyURL()
@ -441,7 +440,7 @@ void DatabaseWidget::copyURL()
return;
}
setClipboardTextAndMinimize(currentEntry->url());
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->url()));
}
void DatabaseWidget::copyNotes()
@ -452,7 +451,7 @@ void DatabaseWidget::copyNotes()
return;
}
setClipboardTextAndMinimize(currentEntry->notes());
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->notes()));
}
void DatabaseWidget::copyAttribute(QAction* action)
@ -875,6 +874,12 @@ void DatabaseWidget::databaseSaved()
m_databaseModified = false;
}
void DatabaseWidget::refreshSearch() {
if (isInSearchMode()) {
search(m_lastSearchText);
}
}
void DatabaseWidget::search(const QString& searchtext)
{
if (searchtext.isEmpty())
@ -908,9 +913,7 @@ void DatabaseWidget::search(const QString& searchtext)
void DatabaseWidget::setSearchCaseSensitive(bool state)
{
m_searchCaseSensitive = state;
if (isInSearchMode())
search(m_lastSearchText);
refreshSearch();
}
void DatabaseWidget::onGroupChanged(Group* group)
@ -1173,7 +1176,7 @@ bool DatabaseWidget::currentEntryHasUsername()
Q_ASSERT(false);
return false;
}
return !currentEntry->username().isEmpty();
return !currentEntry->resolvePlaceholder(currentEntry->username()).isEmpty();
}
bool DatabaseWidget::currentEntryHasPassword()
@ -1183,7 +1186,7 @@ bool DatabaseWidget::currentEntryHasPassword()
Q_ASSERT(false);
return false;
}
return !currentEntry->password().isEmpty();
return !currentEntry->resolvePlaceholder(currentEntry->password()).isEmpty();
}
bool DatabaseWidget::currentEntryHasUrl()
@ -1193,7 +1196,7 @@ bool DatabaseWidget::currentEntryHasUrl()
Q_ASSERT(false);
return false;
}
return !currentEntry->url().isEmpty();
return !currentEntry->resolvePlaceholder(currentEntry->url()).isEmpty();
}
bool DatabaseWidget::currentEntryHasNotes()
@ -1203,7 +1206,7 @@ bool DatabaseWidget::currentEntryHasNotes()
Q_ASSERT(false);
return false;
}
return !currentEntry->notes().isEmpty();
return !currentEntry->resolvePlaceholder(currentEntry->notes()).isEmpty();
}
GroupView* DatabaseWidget::groupView() {

View file

@ -99,6 +99,7 @@ public:
void showUnlockDialog();
void closeUnlockDialog();
void blockAutoReload(bool block = true);
void refreshSearch();
signals:
void closeRequest();
@ -147,10 +148,12 @@ public slots:
void switchToImportKeepass1(const QString& fileName);
void databaseModified();
void databaseSaved();
// Search related slots
void search(const QString& searchtext);
void setSearchCaseSensitive(bool state);
void endSearch();
void showMessage(const QString& text, MessageWidget::MessageType type);
void hideMessage();