mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-09 15:02:39 -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
5 changed files with 32 additions and 2 deletions
|
@ -223,7 +223,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||||
if (dbName.right(1) == "*") {
|
if (dbName.right(1) == "*") {
|
||||||
dbName.chop(1);
|
dbName.chop(1);
|
||||||
}
|
}
|
||||||
if (dbStruct.dbWidget->isInEditMode() && db->hasKey()) {
|
if (dbStruct.dbWidget->isInEditMode() && db->hasKey() && dbStruct.dbWidget->isEditWidgetModified()) {
|
||||||
QMessageBox::StandardButton result =
|
QMessageBox::StandardButton result =
|
||||||
MessageBox::question(
|
MessageBox::question(
|
||||||
this, tr("Close?"),
|
this, tr("Close?"),
|
||||||
|
@ -654,7 +654,7 @@ void DatabaseTabWidget::lockDatabases()
|
||||||
// show the correct tab widget before we are asking questions about it
|
// show the correct tab widget before we are asking questions about it
|
||||||
setCurrentWidget(dbWidget);
|
setCurrentWidget(dbWidget);
|
||||||
|
|
||||||
if (mode == DatabaseWidget::EditMode) {
|
if (mode == DatabaseWidget::EditMode && dbWidget->isEditWidgetModified()) {
|
||||||
QMessageBox::StandardButton result =
|
QMessageBox::StandardButton result =
|
||||||
MessageBox::question(
|
MessageBox::question(
|
||||||
this, tr("Lock database"),
|
this, tr("Lock database"),
|
||||||
|
|
|
@ -194,6 +194,18 @@ bool DatabaseWidget::isInEditMode() const
|
||||||
return currentMode() == DatabaseWidget::EditMode;
|
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
|
QList<int> DatabaseWidget::splitterSizes() const
|
||||||
{
|
{
|
||||||
return m_splitter->sizes();
|
return m_splitter->sizes();
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
QStringList customEntryAttributes() const;
|
QStringList customEntryAttributes() const;
|
||||||
bool isGroupSelected() const;
|
bool isGroupSelected() const;
|
||||||
bool isInEditMode() const;
|
bool isInEditMode() const;
|
||||||
|
bool isEditWidgetModified() const;
|
||||||
QList<int> splitterSizes() const;
|
QList<int> splitterSizes() const;
|
||||||
void setSplitterSizes(const QList<int>& sizes);
|
void setSplitterSizes(const QList<int>& sizes);
|
||||||
QList<int> entryHeaderViewSizes() const;
|
QList<int> entryHeaderViewSizes() const;
|
||||||
|
|
|
@ -497,6 +497,22 @@ void EditEntryWidget::clear()
|
||||||
m_iconsWidget->reset();
|
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)
|
void EditEntryWidget::togglePasswordGeneratorButton(bool checked)
|
||||||
{
|
{
|
||||||
m_mainUi->passwordGenerator->setVisible(checked);
|
m_mainUi->passwordGenerator->setVisible(checked);
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
void createPresetsMenu(QMenu* expirePresetsMenu);
|
void createPresetsMenu(QMenu* expirePresetsMenu);
|
||||||
QString entryTitle() const;
|
QString entryTitle() const;
|
||||||
void clear();
|
void clear();
|
||||||
|
bool hasBeenModified() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue