mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-26 10:29:09 -04:00
Close databases when they are locked.
Previously we've only hidden access to them. Closes #275
This commit is contained in:
parent
33650c4a04
commit
9e051e835b
@ -256,7 +256,7 @@ bool DatabaseTabWidget::closeAllDatabases()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::saveDatabase(Database* db)
|
bool DatabaseTabWidget::saveDatabase(Database* db)
|
||||||
{
|
{
|
||||||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||||
|
|
||||||
@ -272,18 +272,20 @@ void DatabaseTabWidget::saveDatabase(Database* db)
|
|||||||
if (result) {
|
if (result) {
|
||||||
dbStruct.modified = false;
|
dbStruct.modified = false;
|
||||||
updateTabName(db);
|
updateTabName(db);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
+ saveFile.errorString());
|
+ saveFile.errorString());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
saveDatabaseAs(db);
|
return saveDatabaseAs(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
||||||
{
|
{
|
||||||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||||
QString oldFileName;
|
QString oldFileName;
|
||||||
@ -311,12 +313,17 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||||||
dbStruct.dbWidget->updateFilename(dbStruct.filePath);
|
dbStruct.dbWidget->updateFilename(dbStruct.filePath);
|
||||||
updateTabName(db);
|
updateTabName(db);
|
||||||
updateLastDatabases(dbStruct.filePath);
|
updateLastDatabases(dbStruct.filePath);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
+ saveFile.errorString());
|
+ saveFile.errorString());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseTabWidget::closeDatabase(int index)
|
bool DatabaseTabWidget::closeDatabase(int index)
|
||||||
@ -340,21 +347,22 @@ void DatabaseTabWidget::closeDatabaseFromSender()
|
|||||||
closeDatabase(db);
|
closeDatabase(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::saveDatabase(int index)
|
bool DatabaseTabWidget::saveDatabase(int index)
|
||||||
{
|
{
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
index = currentIndex();
|
index = currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
saveDatabase(indexDatabase(index));
|
return saveDatabase(indexDatabase(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::saveDatabaseAs(int index)
|
bool DatabaseTabWidget::saveDatabaseAs(int index)
|
||||||
{
|
{
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
index = currentIndex();
|
index = currentIndex();
|
||||||
}
|
}
|
||||||
saveDatabaseAs(indexDatabase(index));
|
|
||||||
|
return saveDatabaseAs(indexDatabase(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::changeMasterKey()
|
void DatabaseTabWidget::changeMasterKey()
|
||||||
@ -525,16 +533,69 @@ bool DatabaseTabWidget::hasLockableDatabases() const
|
|||||||
|
|
||||||
void DatabaseTabWidget::lockDatabases()
|
void DatabaseTabWidget::lockDatabases()
|
||||||
{
|
{
|
||||||
QHashIterator<Database*, DatabaseManagerStruct> i(m_dbList);
|
for (int i = 0; i < count(); i++) {
|
||||||
while (i.hasNext()) {
|
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(widget(i));
|
||||||
i.next();
|
Database* db = databaseFromDatabaseWidget(dbWidget);
|
||||||
DatabaseWidget::Mode mode = i.value().dbWidget->currentMode();
|
|
||||||
|
|
||||||
if ((mode == DatabaseWidget::ViewMode || mode == DatabaseWidget::EditMode)
|
DatabaseWidget::Mode mode = dbWidget->currentMode();
|
||||||
&& i.value().dbWidget->dbHasKey()) {
|
|
||||||
i.value().dbWidget->lock();
|
if ((mode != DatabaseWidget::ViewMode && mode != DatabaseWidget::EditMode)
|
||||||
updateTabName(i.key());
|
|| !dbWidget->dbHasKey()) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show the correct tab widget before we are asking questions about it
|
||||||
|
setCurrentWidget(dbWidget);
|
||||||
|
|
||||||
|
if (mode == DatabaseWidget::EditMode) {
|
||||||
|
QMessageBox::StandardButton result =
|
||||||
|
MessageBox::question(
|
||||||
|
this, tr("Lock database"),
|
||||||
|
tr("Can't lock the database as you are currently editing it.\nPlease press cancel to finish your changes or discard them."),
|
||||||
|
QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
|
||||||
|
if (result == QMessageBox::Cancel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (m_dbList[db].modified && !m_dbList[db].saveToFilename) {
|
||||||
|
QMessageBox::StandardButton result =
|
||||||
|
MessageBox::question(
|
||||||
|
this, tr("Lock database"),
|
||||||
|
tr("This database has never been saved.\nYou can save the dabatase or stop locking it."),
|
||||||
|
QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Cancel);
|
||||||
|
if (result == QMessageBox::Save) {
|
||||||
|
if (!saveDatabase(db)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result == QMessageBox::Cancel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_dbList[db].modified) {
|
||||||
|
QMessageBox::StandardButton result =
|
||||||
|
MessageBox::question(
|
||||||
|
this, tr("Lock database"),
|
||||||
|
tr("This database has been modified.\nDo you want to save the database before locking it?\nOtherwise your changes are lost."),
|
||||||
|
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
|
||||||
|
if (result == QMessageBox::Save) {
|
||||||
|
if (!saveDatabase(db)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result == QMessageBox::Discard) {
|
||||||
|
m_dbList[db].modified = false;
|
||||||
|
}
|
||||||
|
else if (result == QMessageBox::Cancel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dbWidget->lock();
|
||||||
|
// database has changed so we can't use the db variable anymore
|
||||||
|
updateTabName(dbWidget->database());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ public Q_SLOTS:
|
|||||||
void newDatabase();
|
void newDatabase();
|
||||||
void openDatabase();
|
void openDatabase();
|
||||||
void importKeePass1Database();
|
void importKeePass1Database();
|
||||||
void saveDatabase(int index = -1);
|
bool saveDatabase(int index = -1);
|
||||||
void saveDatabaseAs(int index = -1);
|
bool saveDatabaseAs(int index = -1);
|
||||||
bool closeDatabase(int index = -1);
|
bool closeDatabase(int index = -1);
|
||||||
void closeDatabaseFromSender();
|
void closeDatabaseFromSender();
|
||||||
bool closeAllDatabases();
|
bool closeAllDatabases();
|
||||||
@ -88,8 +88,8 @@ private Q_SLOTS:
|
|||||||
void emitActivateDatabaseChanged();
|
void emitActivateDatabaseChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void saveDatabase(Database* db);
|
bool saveDatabase(Database* db);
|
||||||
void saveDatabaseAs(Database* db);
|
bool saveDatabaseAs(Database* db);
|
||||||
bool closeDatabase(Database* db);
|
bool closeDatabase(Database* db);
|
||||||
void deleteDatabase(Database* db);
|
void deleteDatabase(Database* db);
|
||||||
int databaseIndex(Database* db);
|
int databaseIndex(Database* db);
|
||||||
|
@ -188,14 +188,7 @@ DatabaseWidget::Mode DatabaseWidget::currentMode() const
|
|||||||
|
|
||||||
bool DatabaseWidget::isInEditMode() const
|
bool DatabaseWidget::isInEditMode() const
|
||||||
{
|
{
|
||||||
if (currentMode() == DatabaseWidget::LockedMode) {
|
return currentMode() == DatabaseWidget::EditMode;
|
||||||
return m_widgetBeforeLock != Q_NULLPTR
|
|
||||||
&& m_widgetBeforeLock != m_mainWidget
|
|
||||||
&& m_widgetBeforeLock != m_unlockDatabaseWidget;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return currentMode() == DatabaseWidget::EditMode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> DatabaseWidget::splitterSizes() const
|
QList<int> DatabaseWidget::splitterSizes() const
|
||||||
@ -231,6 +224,13 @@ void DatabaseWidget::setEntryViewHeaderSizes(const QList<int>& sizes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::clearAllWidgets()
|
||||||
|
{
|
||||||
|
m_editEntryWidget->clear();
|
||||||
|
m_historyEditEntryWidget->clear();
|
||||||
|
m_editGroupWidget->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWidget::emitCurrentModeChanged()
|
void DatabaseWidget::emitCurrentModeChanged()
|
||||||
{
|
{
|
||||||
Q_EMIT currentModeChanged(currentMode());
|
Q_EMIT currentModeChanged(currentMode());
|
||||||
@ -274,6 +274,15 @@ void DatabaseWidget::setIconFromParent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::replaceDatabase(Database* db)
|
||||||
|
{
|
||||||
|
Database* oldDb = m_db;
|
||||||
|
m_db = db;
|
||||||
|
m_groupView->changeDatabase(m_db);
|
||||||
|
Q_EMIT databaseChanged(m_db);
|
||||||
|
delete oldDb;
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWidget::cloneEntry()
|
void DatabaseWidget::cloneEntry()
|
||||||
{
|
{
|
||||||
Entry* currentEntry = m_entryView->currentEntry();
|
Entry* currentEntry = m_entryView->currentEntry();
|
||||||
@ -604,11 +613,7 @@ void DatabaseWidget::updateMasterKey(bool accepted)
|
|||||||
void DatabaseWidget::openDatabase(bool accepted)
|
void DatabaseWidget::openDatabase(bool accepted)
|
||||||
{
|
{
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
Database* oldDb = m_db;
|
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
|
||||||
m_db = static_cast<DatabaseOpenWidget*>(sender())->database();
|
|
||||||
m_groupView->changeDatabase(m_db);
|
|
||||||
Q_EMIT databaseChanged(m_db);
|
|
||||||
delete oldDb;
|
|
||||||
setCurrentWidget(m_mainWidget);
|
setCurrentWidget(m_mainWidget);
|
||||||
|
|
||||||
// We won't need those anymore and KeePass1OpenWidget closes
|
// We won't need those anymore and KeePass1OpenWidget closes
|
||||||
@ -628,11 +633,24 @@ void DatabaseWidget::openDatabase(bool accepted)
|
|||||||
|
|
||||||
void DatabaseWidget::unlockDatabase(bool accepted)
|
void DatabaseWidget::unlockDatabase(bool accepted)
|
||||||
{
|
{
|
||||||
// cancel button is disabled
|
if (!accepted) {
|
||||||
Q_ASSERT(accepted);
|
Q_EMIT closeRequest();
|
||||||
Q_UNUSED(accepted);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setCurrentWidget(m_widgetBeforeLock);
|
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
|
||||||
|
|
||||||
|
QList<Group*> groups = m_db->rootGroup()->groupsRecursive(true);
|
||||||
|
Q_FOREACH (Group* group, groups) {
|
||||||
|
if (group->uuid() == m_groupBeforeLock) {
|
||||||
|
m_groupView->setCurrentGroup(group);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_groupBeforeLock = Uuid();
|
||||||
|
setCurrentWidget(m_mainWidget);
|
||||||
|
m_unlockDatabaseWidget->clearForms();
|
||||||
Q_EMIT unlockedDatabase();
|
Q_EMIT unlockedDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,9 +873,13 @@ void DatabaseWidget::lock()
|
|||||||
{
|
{
|
||||||
Q_ASSERT(currentMode() != DatabaseWidget::LockedMode);
|
Q_ASSERT(currentMode() != DatabaseWidget::LockedMode);
|
||||||
|
|
||||||
m_widgetBeforeLock = currentWidget();
|
m_groupBeforeLock = m_groupView->currentGroup()->uuid();
|
||||||
m_unlockDatabaseWidget->load(m_filename, m_db);
|
clearAllWidgets();
|
||||||
|
m_unlockDatabaseWidget->load(m_filename);
|
||||||
setCurrentWidget(m_unlockDatabaseWidget);
|
setCurrentWidget(m_unlockDatabaseWidget);
|
||||||
|
Database* newDb = new Database();
|
||||||
|
newDb->metadata()->setName(m_db->metadata()->name());
|
||||||
|
replaceDatabase(newDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::updateFilename(const QString& fileName)
|
void DatabaseWidget::updateFilename(const QString& fileName)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
|
|
||||||
#include "core/Global.h"
|
#include "core/Global.h"
|
||||||
|
#include "core/Uuid.h"
|
||||||
|
|
||||||
#include "gui/entry/EntryModel.h"
|
#include "gui/entry/EntryModel.h"
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ public:
|
|||||||
void setSplitterSizes(const QList<int>& sizes);
|
void setSplitterSizes(const QList<int>& sizes);
|
||||||
QList<int> entryHeaderViewSizes() const;
|
QList<int> entryHeaderViewSizes() const;
|
||||||
void setEntryViewHeaderSizes(const QList<int>& sizes);
|
void setEntryViewHeaderSizes(const QList<int>& sizes);
|
||||||
|
void clearAllWidgets();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
@ -143,6 +145,7 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
void setClipboardTextAndMinimize(const QString& text);
|
void setClipboardTextAndMinimize(const QString& text);
|
||||||
void setIconFromParent();
|
void setIconFromParent();
|
||||||
|
void replaceDatabase(Database* db);
|
||||||
|
|
||||||
Database* m_db;
|
Database* m_db;
|
||||||
const QScopedPointer<Ui::SearchWidget> m_searchUi;
|
const QScopedPointer<Ui::SearchWidget> m_searchUi;
|
||||||
@ -164,8 +167,8 @@ private:
|
|||||||
Group* m_newParent;
|
Group* m_newParent;
|
||||||
Group* m_lastGroup;
|
Group* m_lastGroup;
|
||||||
QTimer* m_searchTimer;
|
QTimer* m_searchTimer;
|
||||||
QWidget* m_widgetBeforeLock;
|
|
||||||
QString m_filename;
|
QString m_filename;
|
||||||
|
Uuid m_groupBeforeLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_DATABASEWIDGET_H
|
#endif // KEEPASSX_DATABASEWIDGET_H
|
||||||
|
@ -25,33 +25,6 @@ UnlockDatabaseWidget::UnlockDatabaseWidget(QWidget* parent)
|
|||||||
: DatabaseOpenWidget(parent)
|
: DatabaseOpenWidget(parent)
|
||||||
{
|
{
|
||||||
m_ui->labelHeadline->setText(tr("Unlock database"));
|
m_ui->labelHeadline->setText(tr("Unlock database"));
|
||||||
|
|
||||||
m_ui->buttonBox->removeButton(m_ui->buttonBox->button(QDialogButtonBox::Cancel));
|
|
||||||
connect(this, SIGNAL(editFinished(bool)), SLOT(clearForms()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnlockDatabaseWidget::load(const QString& filename, Database* db)
|
|
||||||
{
|
|
||||||
Q_ASSERT(db);
|
|
||||||
|
|
||||||
DatabaseOpenWidget::load(filename);
|
|
||||||
m_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnlockDatabaseWidget::openDatabase()
|
|
||||||
{
|
|
||||||
CompositeKey masterKey = databaseKey();
|
|
||||||
if (masterKey.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_db->verifyKey(masterKey)) {
|
|
||||||
Q_EMIT editFinished(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::warning(this, tr("Error"), tr("Wrong key."));
|
|
||||||
m_ui->editPassword->clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnlockDatabaseWidget::clearForms()
|
void UnlockDatabaseWidget::clearForms()
|
||||||
@ -60,4 +33,5 @@ void UnlockDatabaseWidget::clearForms()
|
|||||||
m_ui->comboKeyFile->clear();
|
m_ui->comboKeyFile->clear();
|
||||||
m_ui->checkPassword->setChecked(false);
|
m_ui->checkPassword->setChecked(false);
|
||||||
m_ui->checkKeyFile->setChecked(false);
|
m_ui->checkKeyFile->setChecked(false);
|
||||||
|
m_db = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,6 @@ class UnlockDatabaseWidget : public DatabaseOpenWidget
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit UnlockDatabaseWidget(QWidget* parent = Q_NULLPTR);
|
explicit UnlockDatabaseWidget(QWidget* parent = Q_NULLPTR);
|
||||||
void load(const QString& filename, Database* db);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void openDatabase() Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void clearForms();
|
void clearForms();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -453,12 +453,7 @@ void EditEntryWidget::saveEntry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_entry = Q_NULLPTR;
|
clear();
|
||||||
m_database = Q_NULLPTR;
|
|
||||||
m_entryAttributes->clear();
|
|
||||||
m_entryAttachments->clear();
|
|
||||||
m_autoTypeAssoc->clear();
|
|
||||||
m_historyModel->clear();
|
|
||||||
|
|
||||||
Q_EMIT editFinished(true);
|
Q_EMIT editFinished(true);
|
||||||
}
|
}
|
||||||
@ -466,12 +461,8 @@ void EditEntryWidget::saveEntry()
|
|||||||
void EditEntryWidget::cancel()
|
void EditEntryWidget::cancel()
|
||||||
{
|
{
|
||||||
if (m_history) {
|
if (m_history) {
|
||||||
m_entry = Q_NULLPTR;
|
clear();
|
||||||
m_database = Q_NULLPTR;
|
|
||||||
m_entryAttributes->clear();
|
|
||||||
m_entryAttachments->clear();
|
|
||||||
Q_EMIT editFinished(false);
|
Q_EMIT editFinished(false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_entry->iconUuid().isNull() &&
|
if (!m_entry->iconUuid().isNull() &&
|
||||||
@ -479,14 +470,19 @@ void EditEntryWidget::cancel()
|
|||||||
m_entry->setIcon(Entry::DefaultIconNumber);
|
m_entry->setIcon(Entry::DefaultIconNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_entry = 0;
|
clear();
|
||||||
m_database = 0;
|
|
||||||
|
Q_EMIT editFinished(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditEntryWidget::clear()
|
||||||
|
{
|
||||||
|
m_entry = Q_NULLPTR;
|
||||||
|
m_database = Q_NULLPTR;
|
||||||
m_entryAttributes->clear();
|
m_entryAttributes->clear();
|
||||||
m_entryAttachments->clear();
|
m_entryAttachments->clear();
|
||||||
m_autoTypeAssoc->clear();
|
m_autoTypeAssoc->clear();
|
||||||
m_historyModel->clear();
|
m_historyModel->clear();
|
||||||
|
|
||||||
Q_EMIT editFinished(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEntryWidget::togglePasswordGeneratorButton(bool checked)
|
void EditEntryWidget::togglePasswordGeneratorButton(bool checked)
|
||||||
|
@ -60,6 +60,7 @@ public:
|
|||||||
|
|
||||||
void createPresetsMenu(QMenu* expirePresetsMenu);
|
void createPresetsMenu(QMenu* expirePresetsMenu);
|
||||||
QString entryTitle() const;
|
QString entryTitle() const;
|
||||||
|
void clear();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
|
@ -109,8 +109,7 @@ void EditGroupWidget::save()
|
|||||||
m_group->setIcon(iconStruct.uuid);
|
m_group->setIcon(iconStruct.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_group = Q_NULLPTR;
|
clear();
|
||||||
m_database = Q_NULLPTR;
|
|
||||||
Q_EMIT editFinished(true);
|
Q_EMIT editFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +120,14 @@ void EditGroupWidget::cancel()
|
|||||||
m_group->setIcon(Entry::DefaultIconNumber);
|
m_group->setIcon(Entry::DefaultIconNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear();
|
||||||
|
Q_EMIT editFinished(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditGroupWidget::clear()
|
||||||
|
{
|
||||||
m_group = Q_NULLPTR;
|
m_group = Q_NULLPTR;
|
||||||
m_database = Q_NULLPTR;
|
m_database = Q_NULLPTR;
|
||||||
Q_EMIT editFinished(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditGroupWidget::addTriStateItems(QComboBox* comboBox, bool inheritDefault)
|
void EditGroupWidget::addTriStateItems(QComboBox* comboBox, bool inheritDefault)
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
~EditGroupWidget();
|
~EditGroupWidget();
|
||||||
|
|
||||||
void loadGroup(Group* group, bool create, Database* database);
|
void loadGroup(Group* group, bool create, Database* database);
|
||||||
|
void clear();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
|
@ -421,10 +421,12 @@ void TestGui::testKeePass1Import()
|
|||||||
|
|
||||||
void TestGui::testDatabaseLocking()
|
void TestGui::testDatabaseLocking()
|
||||||
{
|
{
|
||||||
|
MessageBox::setNextAnswer(QMessageBox::Cancel);
|
||||||
|
|
||||||
triggerAction("actionLockDatabases");
|
triggerAction("actionLockDatabases");
|
||||||
|
|
||||||
QCOMPARE(m_tabWidget->tabText(0), QString("Save [locked]"));
|
QCOMPARE(m_tabWidget->tabText(0), QString("Save [locked]"));
|
||||||
QCOMPARE(m_tabWidget->tabText(1), QString("basic [New database] [locked]*"));
|
QCOMPARE(m_tabWidget->tabText(1), QString("basic [New database]*"));
|
||||||
|
|
||||||
QWidget* dbWidget = m_tabWidget->currentDatabaseWidget();
|
QWidget* dbWidget = m_tabWidget->currentDatabaseWidget();
|
||||||
QWidget* unlockDatabaseWidget = dbWidget->findChild<QWidget*>("unlockDatabaseWidget");
|
QWidget* unlockDatabaseWidget = dbWidget->findChild<QWidget*>("unlockDatabaseWidget");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user