diff --git a/src/gui/EditWidget.cpp b/src/gui/EditWidget.cpp index 72742b5a..fbd07a82 100644 --- a/src/gui/EditWidget.cpp +++ b/src/gui/EditWidget.cpp @@ -74,6 +74,18 @@ void EditWidget::addPage(const QString& labelText, const QIcon& icon, QWidget* w m_ui->categoryList->addCategory(labelText, icon); } +bool EditWidget::hasPage(QWidget* widget) +{ + for (int i = 0; i < m_ui->stackedWidget->count(); i++) { + auto* scrollArea = qobject_cast(m_ui->stackedWidget->widget(i)); + if (scrollArea && scrollArea->widget() == widget) { + return true; + } + } + + return false; +} + void EditWidget::setPageHidden(QWidget* widget, bool hidden) { int index = -1; diff --git a/src/gui/EditWidget.h b/src/gui/EditWidget.h index 361961f7..c4997aba 100644 --- a/src/gui/EditWidget.h +++ b/src/gui/EditWidget.h @@ -42,6 +42,7 @@ public: ~EditWidget(); void addPage(const QString& labelText, const QIcon& icon, QWidget* widget); + bool hasPage(QWidget* widget); void setPageHidden(QWidget* widget, bool hidden); void setCurrentPage(int index); void setHeadline(const QString& text); diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 123bb9d4..c4de8297 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -265,9 +265,8 @@ void EditEntryWidget::setupAutoType() #ifdef WITH_XC_BROWSER void EditEntryWidget::setupBrowser() { - m_browserUi->setupUi(m_browserWidget); - if (config()->get(Config::Browser_Enabled).toBool()) { + m_browserUi->setupUi(m_browserWidget); addPage(tr("Browser Integration"), Resources::instance()->icon("internet-web-browser"), m_browserWidget); m_additionalURLsDataModel->setEntryAttributes(m_entryAttributes); m_browserUi->additionalURLsView->setModel(m_additionalURLsDataModel); @@ -932,35 +931,44 @@ void EditEntryWidget::setForms(Entry* entry, bool restore) #endif #ifdef WITH_XC_BROWSER - 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); + if (config()->get(Config::Browser_Enabled).toBool()) { + if (!hasPage(m_browserWidget)) { + 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); + } + + 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); + } + + 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); + } + + m_browserUi->addURLButton->setEnabled(!m_history); + m_browserUi->removeURLButton->setEnabled(false); + m_browserUi->editURLButton->setEnabled(false); + m_browserUi->additionalURLsView->setEditTriggers(editTriggers); + + if (m_additionalURLsDataModel->rowCount() != 0) { + m_browserUi->additionalURLsView->setCurrentIndex(m_additionalURLsDataModel->index(0, 0)); + } } - 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); - } - - 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); - } - - m_browserUi->addURLButton->setEnabled(!m_history); - m_browserUi->removeURLButton->setEnabled(false); - m_browserUi->editURLButton->setEnabled(false); - m_browserUi->additionalURLsView->setEditTriggers(editTriggers); - - if (m_additionalURLsDataModel->rowCount() != 0) { - m_browserUi->additionalURLsView->setCurrentIndex(m_additionalURLsDataModel->index(0, 0)); - } + setPageHidden(m_browserWidget, !config()->get(Config::Browser_Enabled).toBool()); #endif m_editWidgetProperties->setFields(entry->timeInfo(), entry->uuid());