From 656e6d289a12275ea9ae539e8a4efdd365001976 Mon Sep 17 00:00:00 2001 From: clonejo Date: Tue, 11 Aug 2020 23:49:50 +0200 Subject: [PATCH] Don't ask when removing an empty URL There is no harm to deleting an empty URL from the browser integration URL list when the user never set a value. It's a bit annoying, actually. --- src/gui/entry/EditEntryWidget.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 53aa04ef..32482a9d 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -340,20 +340,25 @@ void EditEntryWidget::removeCurrentURL() QModelIndex index = m_browserUi->additionalURLsView->currentIndex(); if (index.isValid()) { - auto result = MessageBox::question(this, - tr("Confirm Removal"), - tr("Are you sure you want to remove this URL?"), - MessageBox::Remove | MessageBox::Cancel, - MessageBox::Cancel); + auto name = m_additionalURLsDataModel->keyByIndex(index); + auto url = m_entryAttributes->value(name); + if (url != tr("")) { + auto result = MessageBox::question(this, + tr("Confirm Removal"), + tr("Are you sure you want to remove this URL?"), + MessageBox::Remove | MessageBox::Cancel, + MessageBox::Cancel); - if (result == MessageBox::Remove) { - m_entryAttributes->remove(m_additionalURLsDataModel->keyByIndex(index)); - if (m_additionalURLsDataModel->rowCount() == 0) { - m_browserUi->editURLButton->setEnabled(false); - m_browserUi->removeURLButton->setEnabled(false); + if (result != MessageBox::Remove) { + return; } - setModified(true); } + m_entryAttributes->remove(m_additionalURLsDataModel->keyByIndex(index)); + if (m_additionalURLsDataModel->rowCount() == 0) { + m_browserUi->editURLButton->setEnabled(false); + m_browserUi->removeURLButton->setEnabled(false); + } + setModified(true); } }