Show browser integration tab dynamically

This commit is contained in:
varjolintu 2020-12-20 23:03:44 -05:00 committed by Jonathan White
parent 7078086b50
commit bbc71b3144
3 changed files with 50 additions and 29 deletions

View File

@ -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<QScrollArea*>(m_ui->stackedWidget->widget(i));
if (scrollArea && scrollArea->widget() == widget) {
return true;
}
}
return false;
}
void EditWidget::setPageHidden(QWidget* widget, bool hidden)
{
int index = -1;

View File

@ -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);

View File

@ -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,6 +931,11 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
#endif
#ifdef WITH_XC_BROWSER
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);
@ -941,7 +945,8 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
}
if (m_customData->contains(BrowserService::OPTION_HIDE_ENTRY)) {
m_browserUi->hideEntryCheckbox->setChecked(m_customData->value(BrowserService::OPTION_HIDE_ENTRY) == TRUE_STR);
m_browserUi->hideEntryCheckbox->setChecked(m_customData->value(BrowserService::OPTION_HIDE_ENTRY)
== TRUE_STR);
} else {
m_browserUi->hideEntryCheckbox->setChecked(false);
}
@ -961,6 +966,9 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
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());