diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index 2f5148561..71529937c 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -2513,6 +2513,10 @@ Would you like to correct it? Would you like to correct it? + + Some Browser Integration settings are overridden by group settings. + + EditEntryWidgetAdvanced @@ -2968,8 +2972,55 @@ Would you like to correct it? Inherit from parent group (%1) - Entry has unsaved changes - Entry has unsaved changes + Browser Integration + Browser Integration + + + Group has unsaved changes + + + + + EditGroupWidgetBrowser + + Edit Group + + + + These settings affect to the group's behaviour with the browser extension. + + + + Hide entries from browser extension: + + + + Hide entries from browser extension toggle for this and sub groups + + + + Skip Auto-Submit for entries: + + + + Skip Auto-Submit toggle for this and sub groups + + + + Use entries only with HTTP Basic Auth: + + + + Only HTTP Auth toggle for this and sub groups + + + + Do not use entries with HTTP Basic Auth: + + + + Do not use HTTP Auth toggle for this and sub groups + diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 8581544b9..b6ffdb55c 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -390,18 +390,19 @@ QJsonArray BrowserService::findMatchingEntries(const QString& dbid, QList pwEntriesToConfirm; QList pwEntries; for (auto* entry : searchEntries(siteUrlStr, formUrlStr, keyList)) { - if (entry->customData()->contains(BrowserService::OPTION_HIDE_ENTRY) - && entry->customData()->value(BrowserService::OPTION_HIDE_ENTRY) == TRUE_STR) { + auto entryCustomData = entry->customData(); + + if (!httpAuth + && ((entryCustomData->contains(BrowserService::OPTION_ONLY_HTTP_AUTH) + && entryCustomData->value(BrowserService::OPTION_ONLY_HTTP_AUTH) == TRUE_STR) + || entry->group()->resolveCustomDataTriState(BrowserService::OPTION_ONLY_HTTP_AUTH) == Group::Enable)) { continue; } - if (!httpAuth && entry->customData()->contains(BrowserService::OPTION_ONLY_HTTP_AUTH) - && entry->customData()->value(BrowserService::OPTION_ONLY_HTTP_AUTH) == TRUE_STR) { - continue; - } - - if (httpAuth && entry->customData()->contains(BrowserService::OPTION_NOT_HTTP_AUTH) - && entry->customData()->value(BrowserService::OPTION_NOT_HTTP_AUTH) == TRUE_STR) { + if (httpAuth + && ((entryCustomData->contains(BrowserService::OPTION_NOT_HTTP_AUTH) + && entryCustomData->value(BrowserService::OPTION_NOT_HTTP_AUTH) == TRUE_STR) + || entry->group()->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH) == Group::Enable)) { continue; } @@ -614,12 +615,15 @@ BrowserService::searchEntries(const QSharedPointer& db, const QString& } for (const auto& group : rootGroup->groupsRecursive(true)) { - if (group->isRecycled() || !group->resolveSearchingEnabled()) { + if (group->isRecycled() + || group->resolveCustomDataTriState(BrowserService::OPTION_HIDE_ENTRY) == Group::Enable) { continue; } for (auto* entry : group->entries()) { - if (entry->isRecycled()) { + if (entry->isRecycled() + || (entry->customData()->contains(BrowserService::OPTION_HIDE_ENTRY) + && entry->customData()->value(BrowserService::OPTION_HIDE_ENTRY) == TRUE_STR)) { continue; } @@ -870,8 +874,13 @@ QJsonObject BrowserService::prepareEntry(const Entry* entry) res["expired"] = TRUE_STR; } - if (entry->customData()->contains(BrowserService::OPTION_SKIP_AUTO_SUBMIT)) { - res["skipAutoSubmit"] = entry->customData()->value(BrowserService::OPTION_SKIP_AUTO_SUBMIT); + auto skipAutoSubmitGroup = entry->group()->resolveCustomDataTriState(BrowserService::OPTION_SKIP_AUTO_SUBMIT); + if (skipAutoSubmitGroup == Group::Inherit) { + if (entry->customData()->contains(BrowserService::OPTION_SKIP_AUTO_SUBMIT)) { + res["skipAutoSubmit"] = entry->customData()->value(BrowserService::OPTION_SKIP_AUTO_SUBMIT); + } + } else { + res["skipAutoSubmit"] = skipAutoSubmitGroup == Group::Enable ? TRUE_STR : FALSE_STR; } if (browserSettings()->supportKphFields()) { diff --git a/src/core/CustomData.cpp b/src/core/CustomData.cpp index fc4401ef0..fb959e186 100644 --- a/src/core/CustomData.cpp +++ b/src/core/CustomData.cpp @@ -80,11 +80,13 @@ void CustomData::remove(const QString& key) { emit aboutToBeRemoved(key); - m_data.remove(key); + if (m_data.contains(key)) { + m_data.remove(key); + updateLastModified(); + emitModified(); + } - updateLastModified(); emit removed(key); - emitModified(); } void CustomData::rename(const QString& oldKey, const QString& newKey) @@ -180,7 +182,7 @@ int CustomData::dataSize() const void CustomData::updateLastModified() { - if (m_data.size() == 1 && m_data.contains(LastModified)) { + if (m_data.isEmpty() || (m_data.size() == 1 && m_data.contains(LastModified))) { m_data.remove(LastModified); return; } diff --git a/src/core/Group.cpp b/src/core/Group.cpp index c82209039..196f230c1 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Felix Geyer - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2021 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -276,6 +276,35 @@ const CustomData* Group::customData() const return m_customData; } +Group::TriState Group::resolveCustomDataTriState(const QString& key, bool checkParent) const +{ + // If not defined, check our parent up to the root group + if (!m_customData->contains(key)) { + if (!m_parent || !checkParent) { + return Inherit; + } else { + return m_parent->resolveCustomDataTriState(key); + } + } + + return m_customData->value(key) == TRUE_STR ? Enable : Disable; +} + +void Group::setCustomDataTriState(const QString& key, const Group::TriState& value) +{ + switch (value) { + case Enable: + m_customData->set(key, TRUE_STR); + break; + case Disable: + m_customData->set(key, FALSE_STR); + break; + case Inherit: + m_customData->remove(key); + break; + } +} + bool Group::equals(const Group* other, CompareItemOptions options) const { if (!other) { diff --git a/src/core/Group.h b/src/core/Group.h index f259cd8b8..c564d1609 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Felix Geyer - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2021 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -101,6 +101,8 @@ public: bool isEmpty() const; CustomData* customData(); const CustomData* customData() const; + Group::TriState resolveCustomDataTriState(const QString& key, bool checkParent = true) const; + void setCustomDataTriState(const QString& key, const Group::TriState& value); bool equals(const Group* other, CompareItemOptions options) const; diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 9a70b2118..e736efaad 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Felix Geyer - * Copyright (C) 2020 KeePassXC Team + * Copyright (C) 2021 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ #include "core/Database.h" #include "core/Entry.h" #include "core/EntryAttributes.h" +#include "core/Group.h" #include "core/Metadata.h" #include "core/TimeDelta.h" #ifdef WITH_XC_SSHAGENT @@ -263,6 +264,11 @@ void EditEntryWidget::setupBrowser() m_additionalURLsDataModel->setEntryAttributes(m_entryAttributes); m_browserUi->additionalURLsView->setModel(m_additionalURLsDataModel); + m_browserUi->messageWidget->setCloseButtonVisible(false); + m_browserUi->messageWidget->setAutoHideTimeout(-1); + m_browserUi->messageWidget->setAnimate(false); + m_browserUi->messageWidget->setVisible(false); + // Use a custom item delegate to align the icon to the right side auto iconDelegate = new URLModelIconDelegate(m_browserUi->additionalURLsView); m_browserUi->additionalURLsView->setItemDelegate(iconDelegate); @@ -296,14 +302,26 @@ void EditEntryWidget::updateBrowser() return; } - auto skip = m_browserUi->skipAutoSubmitCheckbox->isChecked(); - auto hide = m_browserUi->hideEntryCheckbox->isChecked(); - auto onlyHttpAuth = m_browserUi->onlyHttpAuthCheckbox->isChecked(); - auto notHttpAuth = m_browserUi->notHttpAuthCheckbox->isChecked(); - m_customData->set(BrowserService::OPTION_SKIP_AUTO_SUBMIT, (skip ? TRUE_STR : FALSE_STR)); - m_customData->set(BrowserService::OPTION_HIDE_ENTRY, (hide ? TRUE_STR : FALSE_STR)); - m_customData->set(BrowserService::OPTION_ONLY_HTTP_AUTH, (onlyHttpAuth ? TRUE_STR : FALSE_STR)); - m_customData->set(BrowserService::OPTION_NOT_HTTP_AUTH, (notHttpAuth ? TRUE_STR : FALSE_STR)); + // Only update the custom data if no group level settings are used (checkbox is enabled) + if (m_browserUi->hideEntryCheckbox->isEnabled()) { + auto hide = m_browserUi->hideEntryCheckbox->isChecked(); + m_customData->set(BrowserService::OPTION_HIDE_ENTRY, (hide ? TRUE_STR : FALSE_STR)); + } + + if (m_browserUi->skipAutoSubmitCheckbox->isEnabled()) { + auto skip = m_browserUi->skipAutoSubmitCheckbox->isChecked(); + m_customData->set(BrowserService::OPTION_SKIP_AUTO_SUBMIT, (skip ? TRUE_STR : FALSE_STR)); + } + + if (m_browserUi->onlyHttpAuthCheckbox->isEnabled()) { + auto onlyHttpAuth = m_browserUi->onlyHttpAuthCheckbox->isChecked(); + m_customData->set(BrowserService::OPTION_ONLY_HTTP_AUTH, (onlyHttpAuth ? TRUE_STR : FALSE_STR)); + } + + if (m_browserUi->notHttpAuthCheckbox->isEnabled()) { + auto notHttpAuth = m_browserUi->notHttpAuthCheckbox->isChecked(); + m_customData->set(BrowserService::OPTION_NOT_HTTP_AUTH, (notHttpAuth ? TRUE_STR : FALSE_STR)); + } } void EditEntryWidget::insertURL() @@ -941,34 +959,55 @@ void EditEntryWidget::setForms(Entry* entry, bool restore) setupBrowser(); } - if (m_customData->contains(BrowserService::OPTION_SKIP_AUTO_SUBMIT)) { - // clang-format off - m_browserUi->skipAutoSubmitCheckbox->setChecked(m_customData->value(BrowserService::OPTION_SKIP_AUTO_SUBMIT) == TRUE_STR); - // clang-format on - } else { - m_browserUi->skipAutoSubmitCheckbox->setChecked(false); + auto hideEntriesCheckBoxEnabled = true; + auto skipAutoSubmitCheckBoxEnabled = true; + auto onlyHttpAuthCheckBoxEnabled = true; + auto notHttpAuthCheckBoxEnabled = true; + auto hideEntries = false; + auto skipAutoSubmit = false; + auto onlyHttpAuth = false; + auto notHttpAuth = false; + + const auto group = m_entry->group(); + if (group) { + hideEntries = group->resolveCustomDataTriState(BrowserService::OPTION_HIDE_ENTRY) == Group::Enable; + skipAutoSubmit = group->resolveCustomDataTriState(BrowserService::OPTION_SKIP_AUTO_SUBMIT) == Group::Enable; + onlyHttpAuth = group->resolveCustomDataTriState(BrowserService::OPTION_ONLY_HTTP_AUTH) == Group::Enable; + notHttpAuth = group->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH) == Group::Enable; + + hideEntriesCheckBoxEnabled = + group->resolveCustomDataTriState(BrowserService::OPTION_HIDE_ENTRY) == Group::Inherit; + skipAutoSubmitCheckBoxEnabled = + group->resolveCustomDataTriState(BrowserService::OPTION_SKIP_AUTO_SUBMIT) == Group::Inherit; + onlyHttpAuthCheckBoxEnabled = + group->resolveCustomDataTriState(BrowserService::OPTION_ONLY_HTTP_AUTH) == Group::Inherit; + notHttpAuthCheckBoxEnabled = + group->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH) == Group::Inherit; } - if (m_customData->contains(BrowserService::OPTION_HIDE_ENTRY)) { - m_browserUi->hideEntryCheckbox->setChecked(m_customData->value(BrowserService::OPTION_HIDE_ENTRY) - == TRUE_STR); - } else { - m_browserUi->hideEntryCheckbox->setChecked(false); + // Show information about group level settings + if (!hideEntriesCheckBoxEnabled || !skipAutoSubmitCheckBoxEnabled || !onlyHttpAuthCheckBoxEnabled + || !notHttpAuthCheckBoxEnabled) { + m_browserUi->messageWidget->showMessage( + tr("Some Browser Integration settings are overridden by group settings."), MessageWidget::Information); + m_browserUi->messageWidget->setVisible(true); } - if (m_customData->contains(BrowserService::OPTION_ONLY_HTTP_AUTH)) { - m_browserUi->onlyHttpAuthCheckbox->setChecked(m_customData->value(BrowserService::OPTION_ONLY_HTTP_AUTH) - == TRUE_STR); - } else { - m_browserUi->onlyHttpAuthCheckbox->setChecked(false); - } - - if (m_customData->contains(BrowserService::OPTION_NOT_HTTP_AUTH)) { - m_browserUi->notHttpAuthCheckbox->setChecked(m_customData->value(BrowserService::OPTION_NOT_HTTP_AUTH) - == TRUE_STR); - } else { - m_browserUi->notHttpAuthCheckbox->setChecked(false); - } + // Disable checkboxes based on group level settings + updateBrowserIntegrationCheckbox( + m_browserUi->hideEntryCheckbox, hideEntriesCheckBoxEnabled, hideEntries, BrowserService::OPTION_HIDE_ENTRY); + updateBrowserIntegrationCheckbox(m_browserUi->skipAutoSubmitCheckbox, + skipAutoSubmitCheckBoxEnabled, + skipAutoSubmit, + BrowserService::OPTION_SKIP_AUTO_SUBMIT); + updateBrowserIntegrationCheckbox(m_browserUi->onlyHttpAuthCheckbox, + onlyHttpAuthCheckBoxEnabled, + onlyHttpAuth, + BrowserService::OPTION_ONLY_HTTP_AUTH); + updateBrowserIntegrationCheckbox(m_browserUi->notHttpAuthCheckbox, + notHttpAuthCheckBoxEnabled, + notHttpAuth, + BrowserService::OPTION_NOT_HTTP_AUTH); m_browserUi->addURLButton->setEnabled(!m_history); m_browserUi->removeURLButton->setEnabled(false); @@ -1163,6 +1202,28 @@ void EditEntryWidget::updateEntryData(Entry* entry) const #endif } +void EditEntryWidget::updateBrowserIntegrationCheckbox(QCheckBox* checkBox, + bool enabled, + bool value, + const QString& option) +{ + auto block = checkBox->signalsBlocked(); + checkBox->blockSignals(true); + + if (enabled) { + if (m_customData->contains(option)) { + checkBox->setChecked(m_customData->value(option) == TRUE_STR); + } else { + checkBox->setChecked(false); + } + } else { + checkBox->setChecked(value); + } + checkBox->setEnabled(enabled); + + checkBox->blockSignals(block); +} + void EditEntryWidget::cancel() { if (m_history) { diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h index 4616e1af5..89422c0d4 100644 --- a/src/gui/entry/EditEntryWidget.h +++ b/src/gui/entry/EditEntryWidget.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Felix Geyer - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2021 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #define KEEPASSX_EDITENTRYWIDGET_H #include +#include #include #include #include @@ -152,6 +153,7 @@ private: void setForms(Entry* entry, bool restore = false); QMenu* createPresetsMenu(); void updateEntryData(Entry* entry) const; + void updateBrowserIntegrationCheckbox(QCheckBox* checkBox, bool enabled, bool value, const QString& option); #ifdef WITH_XC_SSHAGENT bool getOpenSSHKey(OpenSSHKey& key, bool decrypt = false); #endif diff --git a/src/gui/entry/EditEntryWidgetBrowser.ui b/src/gui/entry/EditEntryWidgetBrowser.ui index 5f117e987..093d141e8 100644 --- a/src/gui/entry/EditEntryWidgetBrowser.ui +++ b/src/gui/entry/EditEntryWidgetBrowser.ui @@ -30,6 +30,16 @@ + + + + + 0 + 0 + + + + @@ -37,16 +47,16 @@ - + - Skip Auto-Submit for this entry + Hide this entry from the browser extension - + - Hide this entry from the browser extension + Skip Auto-Submit for this entry @@ -69,16 +79,16 @@ Do not use this entry with HTTP Basic Auth - + - - Additional URL's - - + + Additional URL's + + @@ -147,9 +157,15 @@ + + + MessageWidget + QWidget +
gui/MessageWidget.h
+
+
skipAutoSubmitCheckbox - hideEntryCheckbox onlyHttpAuthCheckbox additionalURLsView addURLButton diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp index 15d8fd4a5..687dd056d 100644 --- a/src/gui/group/EditGroupWidget.cpp +++ b/src/gui/group/EditGroupWidget.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Felix Geyer + * Copyright (C) 2021 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +18,10 @@ #include "EditGroupWidget.h" #include "ui_EditGroupWidgetMain.h" +#if defined(WITH_XC_BROWSER) +#include "browser/BrowserService.h" +#include "ui_EditGroupWidgetBrowser.h" +#endif #include "core/Config.h" #include "core/Metadata.h" @@ -65,12 +70,23 @@ EditGroupWidget::EditGroupWidget(QWidget* parent) , m_editGroupWidgetMain(new QScrollArea()) , m_editGroupWidgetIcons(new EditWidgetIcons()) , m_editWidgetProperties(new EditWidgetProperties()) +#if defined(WITH_XC_BROWSER) + , m_browserSettingsChanged(false) + , m_browserUi(new Ui::EditGroupWidgetBrowser()) + , m_browserWidget(new QScrollArea()) +#endif , m_group(nullptr) { m_mainUi->setupUi(m_editGroupWidgetMain); addPage(tr("Group"), icons()->icon("document-edit"), m_editGroupWidgetMain); addPage(tr("Icon"), icons()->icon("preferences-desktop-icons"), m_editGroupWidgetIcons); +#if defined(WITH_XC_BROWSER) + if (config()->get(Config::Browser_Enabled).toBool()) { + addPage(tr("Browser Integration"), icons()->icon("internet-web-browser"), m_browserWidget); + m_browserUi->setupUi(m_browserWidget); + } +#endif #if defined(WITH_XC_KEESHARE) addEditPage(new EditGroupPageKeeShare(this)); #endif @@ -116,6 +132,33 @@ void EditGroupWidget::setupModifiedTracking() // Icon tab connect(m_editGroupWidgetIcons, SIGNAL(widgetUpdated()), SLOT(setModified())); + +#if defined(WITH_XC_BROWSER) + if (config()->get(Config::Browser_Enabled).toBool()) { + // Browser integration tab + connect( + m_browserUi->browserIntegrationHideEntriesComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified())); + connect(m_browserUi->browserIntegrationSkipAutoSubmitComboBox, + SIGNAL(currentIndexChanged(int)), + SLOT(setModified())); + connect( + m_browserUi->browserIntegrationOnlyHttpAuthComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified())); + connect( + m_browserUi->browserIntegrationNotHttpAuthComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified())); + connect(m_browserUi->browserIntegrationHideEntriesComboBox, + SIGNAL(currentIndexChanged(int)), + SLOT(updateBrowserModified())); + connect(m_browserUi->browserIntegrationSkipAutoSubmitComboBox, + SIGNAL(currentIndexChanged(int)), + SLOT(updateBrowserModified())); + connect(m_browserUi->browserIntegrationOnlyHttpAuthComboBox, + SIGNAL(currentIndexChanged(int)), + SLOT(updateBrowserModified())); + connect(m_browserUi->browserIntegrationNotHttpAuthComboBox, + SIGNAL(currentIndexChanged(int)), + SLOT(updateBrowserModified())); + } +#endif } void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer& database) @@ -170,6 +213,37 @@ void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer< page.set(m_temporaryGroup.data(), m_db); } +#ifdef WITH_XC_BROWSER + if (config()->get(Config::Browser_Enabled).toBool()) { + auto inheritHideEntries = false; + auto inheritSkipSubmit = false; + auto inheritOnlyHttp = false; + auto inheritNoHttp = false; + + auto parent = group->parentGroup(); + if (parent) { + inheritHideEntries = parent->resolveCustomDataTriState(BrowserService::OPTION_HIDE_ENTRY); + inheritSkipSubmit = parent->resolveCustomDataTriState(BrowserService::OPTION_SKIP_AUTO_SUBMIT); + inheritOnlyHttp = parent->resolveCustomDataTriState(BrowserService::OPTION_ONLY_HTTP_AUTH); + inheritNoHttp = parent->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH); + } + + addTriStateItems(m_browserUi->browserIntegrationHideEntriesComboBox, inheritHideEntries); + addTriStateItems(m_browserUi->browserIntegrationSkipAutoSubmitComboBox, inheritSkipSubmit); + addTriStateItems(m_browserUi->browserIntegrationOnlyHttpAuthComboBox, inheritOnlyHttp); + addTriStateItems(m_browserUi->browserIntegrationNotHttpAuthComboBox, inheritNoHttp); + + m_browserUi->browserIntegrationHideEntriesComboBox->setCurrentIndex( + indexFromTriState(group->resolveCustomDataTriState(BrowserService::OPTION_HIDE_ENTRY, false))); + m_browserUi->browserIntegrationSkipAutoSubmitComboBox->setCurrentIndex( + indexFromTriState(group->resolveCustomDataTriState(BrowserService::OPTION_SKIP_AUTO_SUBMIT, false))); + m_browserUi->browserIntegrationOnlyHttpAuthComboBox->setCurrentIndex( + indexFromTriState(group->resolveCustomDataTriState(BrowserService::OPTION_ONLY_HTTP_AUTH, false))); + m_browserUi->browserIntegrationNotHttpAuthComboBox->setCurrentIndex( + indexFromTriState(group->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH, false))); + } +#endif + setCurrentPage(0); m_mainUi->editName->setFocus(); @@ -217,6 +291,27 @@ void EditGroupWidget::apply() page.assign(); } +#ifdef WITH_XC_BROWSER + if (config()->get(Config::Browser_Enabled).toBool()) { + if (!m_browserSettingsChanged) { + return; + } + + m_temporaryGroup->setCustomDataTriState( + BrowserService::OPTION_HIDE_ENTRY, + triStateFromIndex(m_browserUi->browserIntegrationHideEntriesComboBox->currentIndex())); + m_temporaryGroup->setCustomDataTriState( + BrowserService::OPTION_SKIP_AUTO_SUBMIT, + triStateFromIndex(m_browserUi->browserIntegrationSkipAutoSubmitComboBox->currentIndex())); + m_temporaryGroup->setCustomDataTriState( + BrowserService::OPTION_ONLY_HTTP_AUTH, + triStateFromIndex(m_browserUi->browserIntegrationOnlyHttpAuthComboBox->currentIndex())); + m_temporaryGroup->setCustomDataTriState( + BrowserService::OPTION_NOT_HTTP_AUTH, + triStateFromIndex(m_browserUi->browserIntegrationNotHttpAuthComboBox->currentIndex())); + } +#endif + // Icons add/remove are applied globally outside the transaction! m_group->copyDataFrom(m_temporaryGroup.data()); @@ -243,7 +338,7 @@ void EditGroupWidget::cancel() if (isModified()) { auto result = MessageBox::question(this, QString(), - tr("Entry has unsaved changes"), + tr("Group has unsaved changes"), MessageBox::Cancel | MessageBox::Save | MessageBox::Discard, MessageBox::Cancel); if (result == MessageBox::Cancel) { @@ -259,6 +354,13 @@ void EditGroupWidget::cancel() emit editFinished(false); } +#ifdef WITH_XC_BROWSER +void EditGroupWidget::updateBrowserModified() +{ + m_browserSettingsChanged = true; +} +#endif + void EditGroupWidget::clear() { m_group = nullptr; diff --git a/src/gui/group/EditGroupWidget.h b/src/gui/group/EditGroupWidget.h index 03e93d2c3..e61e38c54 100644 --- a/src/gui/group/EditGroupWidget.h +++ b/src/gui/group/EditGroupWidget.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Felix Geyer + * Copyright (C) 2021 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +32,7 @@ class EditWidgetProperties; namespace Ui { class EditGroupWidgetMain; + class EditGroupWidgetBrowser; class EditWidget; } // namespace Ui @@ -69,6 +71,9 @@ private slots: void apply(); void save(); void cancel(); +#ifdef WITH_XC_BROWSER + void updateBrowserModified(); +#endif private: void addTriStateItems(QComboBox* comboBox, bool inheritValue); @@ -81,6 +86,11 @@ private: QPointer m_editGroupWidgetMain; QPointer m_editGroupWidgetIcons; QPointer m_editWidgetProperties; +#ifdef WITH_XC_BROWSER + bool m_browserSettingsChanged; + const QScopedPointer m_browserUi; + QPointer m_browserWidget; +#endif QScopedPointer m_temporaryGroup; QPointer m_group; diff --git a/src/gui/group/EditGroupWidgetBrowser.ui b/src/gui/group/EditGroupWidgetBrowser.ui new file mode 100644 index 000000000..f043438d0 --- /dev/null +++ b/src/gui/group/EditGroupWidgetBrowser.ui @@ -0,0 +1,174 @@ + + + EditGroupWidgetBrowser + + + + 0 + 0 + 539 + 523 + + + + Edit Group + + + QFrame::NoFrame + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + 0 + 0 + 539 + 523 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + These settings affect to the group's behaviour with the browser extension. + + + + + +    +   0 +   +   +   10 +   +   +   0 +   +   +   0 +    +    +   10 +    +    +   8 +    +    +    +    +   Hide entries from browser extension: +    +    +   Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter +    +    +    +    +    +    +   Hide entries from browser extension toggle for this and sub groups +    +    +    +    +    +    +   Skip Auto-Submit for entries: +    +    +   Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter +    +    +    +    +    +    +   Skip Auto-Submit toggle for this and sub groups +    +    +    +    +    +    +   Use entries only with HTTP Basic Auth: +    +    +   Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter +    +    +    +    +    +    +   Only HTTP Auth toggle for this and sub groups +    +    +    +    +   +    +    Do not use entries with HTTP Basic Auth: +    +    +    Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter +    +    +    +    +    +    +    Do not use HTTP Auth toggle for this and sub groups +    +    +    +    +    +    +    Qt::Vertical +    +    +    +    20 +    40 +    +    +    +    +    +   + + + + + browserIntegrationHideEntriesComboBox + browserIntegrationSkipAutoSubmitComboBox + browserIntegrationOnlyHttpAuthComboBox + browserIntegrationNotHttpAuthComboBox + + + +