mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
Ladybird/Qt: Adjust the Inspector context menu by the device pixel ratio
Otherwise, the context menu is very out of position on devices with a device pixel ratio other than 1.
This commit is contained in:
parent
b5e8f0ebfe
commit
3e1ffc03c4
2 changed files with 3 additions and 11 deletions
|
@ -97,14 +97,14 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
|
||||||
m_edit_node_action->setText("&Edit text");
|
m_edit_node_action->setText("&Edit text");
|
||||||
m_copy_node_action->setText("&Copy text");
|
m_copy_node_action->setText("&Copy text");
|
||||||
|
|
||||||
m_dom_node_text_context_menu->exec(to_widget_position(position));
|
m_dom_node_text_context_menu->exec(m_inspector_view->map_point_to_global_position(position));
|
||||||
};
|
};
|
||||||
|
|
||||||
m_inspector_client->on_requested_dom_node_tag_context_menu = [this](auto position, auto const& tag) {
|
m_inspector_client->on_requested_dom_node_tag_context_menu = [this](auto position, auto const& tag) {
|
||||||
m_edit_node_action->setText(qstring_from_ak_string(MUST(String::formatted("&Edit \"{}\"", tag))));
|
m_edit_node_action->setText(qstring_from_ak_string(MUST(String::formatted("&Edit \"{}\"", tag))));
|
||||||
m_copy_node_action->setText("&Copy HTML");
|
m_copy_node_action->setText("&Copy HTML");
|
||||||
|
|
||||||
m_dom_node_tag_context_menu->exec(to_widget_position(position));
|
m_dom_node_tag_context_menu->exec(m_inspector_view->map_point_to_global_position(position));
|
||||||
};
|
};
|
||||||
|
|
||||||
m_inspector_client->on_requested_dom_node_attribute_context_menu = [this](auto position, auto const&, WebView::Attribute const& attribute) {
|
m_inspector_client->on_requested_dom_node_attribute_context_menu = [this](auto position, auto const&, WebView::Attribute const& attribute) {
|
||||||
|
@ -117,7 +117,7 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
|
||||||
attribute.value, MAX_ATTRIBUTE_VALUE_LENGTH,
|
attribute.value, MAX_ATTRIBUTE_VALUE_LENGTH,
|
||||||
attribute.value.bytes_as_string_view().length() > MAX_ATTRIBUTE_VALUE_LENGTH ? "..."sv : ""sv))));
|
attribute.value.bytes_as_string_view().length() > MAX_ATTRIBUTE_VALUE_LENGTH ? "..."sv : ""sv))));
|
||||||
|
|
||||||
m_dom_node_attribute_context_menu->exec(to_widget_position(position));
|
m_dom_node_attribute_context_menu->exec(m_inspector_view->map_point_to_global_position(position));
|
||||||
};
|
};
|
||||||
|
|
||||||
setLayout(new QVBoxLayout);
|
setLayout(new QVBoxLayout);
|
||||||
|
@ -191,10 +191,4 @@ void InspectorWidget::closeEvent(QCloseEvent* event)
|
||||||
m_inspector_client->clear_selection();
|
m_inspector_client->clear_selection();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint InspectorWidget::to_widget_position(Gfx::IntPoint position) const
|
|
||||||
{
|
|
||||||
auto widget_position = m_inspector_view->mapTo(this, QPoint { position.x(), position.y() });
|
|
||||||
return mapToGlobal(widget_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ private:
|
||||||
bool event(QEvent*) override;
|
bool event(QEvent*) override;
|
||||||
void closeEvent(QCloseEvent*) override;
|
void closeEvent(QCloseEvent*) override;
|
||||||
|
|
||||||
QPoint to_widget_position(Gfx::IntPoint) const;
|
|
||||||
|
|
||||||
QScreen* m_current_screen;
|
QScreen* m_current_screen;
|
||||||
double m_device_pixel_ratio { 0 };
|
double m_device_pixel_ratio { 0 };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue