Commit 653fd461 authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Don't ask to store credentials if all fields are empty and use...

Don't ask to store credentials if all fields are empty and use KActionCollection::setDefaultShortcut

If the user clicked the `submit` button in a form without having filled
any field in the form, if there was no cached data for that URL, he
would be asked whether to save credentials, which makes no sense since
he didn't enter any. This could also happen if a web page offers
alternative ways to login (for instance QR codes): using the alternative
method submits the form while leaving the fields empty, which triggered
the "save credentials" question.

To fix this issue, now we ignore forms which only have empty fields
(read-only fields aren't taken into account). This only happens for URLs
with no cached data associated with it.
parent 3fccec42
......@@ -1050,8 +1050,8 @@ void WebEnginePart::slotWalletSavedForms(const QUrl& url, bool success)
void WebEnginePart::createWalletActions()
QAction *a = new QAction(i18nc("Fill the Forms with Data from KWallet", "&Fill forms now"), this);
actionCollection()->addAction("walletFillFormsNow", a);
actionCollection()->setDefaultShortcut(a, QKeySequence("Ctrl+Shift+V"));
connect(a, &QAction::triggered, this, [this]{if(page() && m_wallet){m_wallet->detectAndFillPageForms(page());}});
a = new QAction(i18n("&Memorize Passwords in This Page Now"), this);
......@@ -96,6 +96,10 @@ bool WebEngineWallet::WebForm::hasAutoFillableFields() const
return std::any_of(fields.constBegin(), fields.constEnd(), [](const WebField &f){return !f.disabled && !f.readOnly && f.autocompleteAllowed;});
bool WebEngineWallet::WebForm::hasFieldsWithWrittenValues() const
return std::any_of(fields.constBegin(), fields.constEnd(), [](const WebField &f){return !f.readOnly && !f.value.isEmpty();});
WebEngineWallet::WebForm::WebFieldType WebEngineWallet::WebForm::fieldTypeFromTypeName(const QString& name)
......@@ -247,8 +251,10 @@ void WebEngineWallet::saveFormData(WebEnginePage *page, const WebFormList &allFo
} else {
if (std::any_of(formsToSave.constBegin(), formsToSave.constEnd(), [](const WebForm &f){return f.hasFieldsWithWrittenValues();})) {
emit saveFormDataRequested(key, url);
void WebEngineWallet::savePageDataNow(WebEnginePage* page)
......@@ -138,6 +138,13 @@ public:
bool hasAutoFillableFields() const;
* @brief Whether any of the writable fields in the form have non-empty values
* @return @b true if at least one of the #fields is not read-only and has a non-empty value
bool hasFieldsWithWrittenValues() const;
* @brief Creates a WebEngineSettings::WebFormInfo from this object
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment