mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-18 17:12:54 +00:00
Inspector: Add context menu to copy property name/value
I added a context menu for the property tree view to copy the name/value of a property.
This commit is contained in:
parent
0af920b255
commit
fd43ee09e1
Notes:
sideshowbarker
2024-07-18 19:18:14 +09:00
Author: https://github.com/DragonAlex98
Commit: fd43ee09e1
Pull-request: https://github.com/SerenityOS/serenity/pull/6522
1 changed files with 20 additions and 0 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <LibDesktop/Launcher.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Menubar.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
|
@ -174,6 +175,25 @@ int main(int argc, char** argv)
|
|||
remote_process.set_inspected_object(remote_object->address);
|
||||
};
|
||||
|
||||
auto properties_tree_view_context_menu = GUI::Menu::construct("Properties Tree View");
|
||||
|
||||
auto copy_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png");
|
||||
auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) {
|
||||
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_string());
|
||||
});
|
||||
auto copy_property_value_action = GUI::Action::create("Copy Property Value", copy_bitmap, [&](auto&) {
|
||||
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().sibling_at_column(1).data().to_string());
|
||||
});
|
||||
|
||||
properties_tree_view_context_menu->add_action(copy_property_name_action);
|
||||
properties_tree_view_context_menu->add_action(copy_property_value_action);
|
||||
|
||||
properties_tree_view.on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||
if (index.is_valid()) {
|
||||
properties_tree_view_context_menu->popup(event.screen_position());
|
||||
}
|
||||
};
|
||||
|
||||
window->set_menubar(move(menubar));
|
||||
window->show();
|
||||
remote_process.update();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue