mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-19 23:35:57 -04:00
Close database without asking when unmodified.
Don't ask for confirmation when closing/locking a database and - it's in edit entry mode - there haven't been any modifications Refs #511
This commit is contained in:
parent
cf8186312a
commit
8a50ee8b22
@ -223,7 +223,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
if (dbName.right(1) == "*") {
|
||||
dbName.chop(1);
|
||||
}
|
||||
if (dbStruct.dbWidget->isInEditMode() && db->hasKey()) {
|
||||
if (dbStruct.dbWidget->isInEditMode() && db->hasKey() && dbStruct.dbWidget->isEditWidgetModified()) {
|
||||
QMessageBox::StandardButton result =
|
||||
MessageBox::question(
|
||||
this, tr("Close?"),
|
||||
@ -654,7 +654,7 @@ void DatabaseTabWidget::lockDatabases()
|
||||
// show the correct tab widget before we are asking questions about it
|
||||
setCurrentWidget(dbWidget);
|
||||
|
||||
if (mode == DatabaseWidget::EditMode) {
|
||||
if (mode == DatabaseWidget::EditMode && dbWidget->isEditWidgetModified()) {
|
||||
QMessageBox::StandardButton result =
|
||||
MessageBox::question(
|
||||
this, tr("Lock database"),
|
||||
|
@ -194,6 +194,18 @@ bool DatabaseWidget::isInEditMode() const
|
||||
return currentMode() == DatabaseWidget::EditMode;
|
||||
}
|
||||
|
||||
bool DatabaseWidget::isEditWidgetModified() const
|
||||
{
|
||||
if (currentWidget() == m_editEntryWidget) {
|
||||
return m_editEntryWidget->hasBeenModified();
|
||||
}
|
||||
else {
|
||||
// other edit widget don't have a hasBeenModified() method yet
|
||||
// assume that they already have been modified
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QList<int> DatabaseWidget::splitterSizes() const
|
||||
{
|
||||
return m_splitter->sizes();
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
QStringList customEntryAttributes() const;
|
||||
bool isGroupSelected() const;
|
||||
bool isInEditMode() const;
|
||||
bool isEditWidgetModified() const;
|
||||
QList<int> splitterSizes() const;
|
||||
void setSplitterSizes(const QList<int>& sizes);
|
||||
QList<int> entryHeaderViewSizes() const;
|
||||
|
@ -497,6 +497,22 @@ void EditEntryWidget::clear()
|
||||
m_iconsWidget->reset();
|
||||
}
|
||||
|
||||
bool EditEntryWidget::hasBeenModified() const
|
||||
{
|
||||
// entry has been modified if a history item is to be deleted
|
||||
if (!m_historyModel->deletedEntries().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if updating the entry would modify it
|
||||
QScopedPointer<Entry> entry(new Entry());
|
||||
entry->copyDataFrom(m_entry);
|
||||
|
||||
entry->beginUpdate();
|
||||
updateEntryData(entry.data());
|
||||
return entry->endUpdate();
|
||||
}
|
||||
|
||||
void EditEntryWidget::togglePasswordGeneratorButton(bool checked)
|
||||
{
|
||||
m_mainUi->passwordGenerator->setVisible(checked);
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
void createPresetsMenu(QMenu* expirePresetsMenu);
|
||||
QString entryTitle() const;
|
||||
void clear();
|
||||
bool hasBeenModified() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void editFinished(bool accepted);
|
||||
|
Loading…
x
Reference in New Issue
Block a user