Skip to content

Truly independent web browser

UI/Qt: Share the site settings anchor between popovers

Luke Wilde1b15e3e1faa2
diff --git a/UI/Qt/Tab.cpp b/UI/Qt/Tab.cpp
index c6d451f9495..502c67ea958 100644
--- a/UI/Qt/Tab.cpp
+++ b/UI/Qt/Tab.cpp
@@ -547,15 +547,11 @@ void Tab::initialize(Optional<WebView::CanonicalTraversable&> traversable)
dialog->open();
};
- // A site's request for a permission hangs from the site settings button, or from the field when the page has no
- // such button.
m_permission_prompts.create_popover = [this](WebView::PermissionPromptRequest const& request) {
auto* popover = new PermissionPromptPopover(this, request);
popover->update_chrome_style(palette());
auto position = [this, popover] {
- auto& anchor = m_location_edit->site_settings_button();
- QWidget& anchor_or_field = anchor.isVisible() ? anchor : static_cast<QWidget&>(*m_location_edit);
- move_popover_below(*popover, anchor_or_field, PopoverAlignment::Leading);
+ move_popover_below(*popover, site_settings_anchor(), PopoverAlignment::Leading);
};
popover->adjustSize();
position();
@@ -1513,15 +1509,20 @@ void Tab::show_site_settings_popover()
.content_blocking = view().content_blocking_snapshot(),
.permissions = view().site_permission_rows(),
});
- // The site settings button is hidden for a page with no host, so the popover hangs from the field then.
- auto& anchor = m_location_edit->site_settings_button();
- QWidget& anchor_or_field = anchor.isVisible() ? anchor : static_cast<QWidget&>(*m_location_edit);
- move_popover_below(*m_site_settings_popover, anchor_or_field, PopoverAlignment::Leading);
+ move_popover_below(*m_site_settings_popover, site_settings_anchor(), PopoverAlignment::Leading);
m_site_settings_popover->show();
- move_popover_below(*m_site_settings_popover, anchor_or_field, PopoverAlignment::Leading);
+ move_popover_below(*m_site_settings_popover, site_settings_anchor(), PopoverAlignment::Leading);
m_site_settings_popover->raise();
}
+// What the popovers about a site hang from: the site settings button, or the field for a page with no host, which has no
+// such button.
+QWidget& Tab::site_settings_anchor() const
+{
+ auto& button = m_location_edit->site_settings_button();
+ return button.isVisible() ? button : static_cast<QWidget&>(*m_location_edit);
+}
+
// The rows are read again for the site the panel was opened for; a panel whose tab has moved on to another site closes
// instead, since its rows would be the new site's.
void Tab::refresh_site_settings_popover()
diff --git a/UI/Qt/Tab.h b/UI/Qt/Tab.h
index 3e0b4ba5c14..96e143d56de 100644
--- a/UI/Qt/Tab.h
+++ b/UI/Qt/Tab.h
@@ -213,6 +213,7 @@ private:
void update_tab_title();
void leave_report_review();
void position_private_session_popover();
+ QWidget& site_settings_anchor() const;
void hide_hover_label();
QImage render_hover_text(QString const&) const;
void set_loading(bool);