diff --git a/Applications/Browser/CMakeLists.txt b/Applications/Browser/CMakeLists.txt index 0db53b2546..048ff35bac 100644 --- a/Applications/Browser/CMakeLists.txt +++ b/Applications/Browser/CMakeLists.txt @@ -1,4 +1,5 @@ compile_json_gui(BrowserWindow.json BrowserWindowUI.h browser_window_ui_json) +compile_json_gui(Tab.json TabUI.h tab_ui_json) set(SOURCES BookmarksBarWidget.cpp @@ -11,6 +12,7 @@ set(SOURCES Tab.cpp WindowActions.cpp BrowserWindowUI.h + TabUI.h ) serenity_bin(Browser) diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index 8f48c448fe..9c7dca6314 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -32,6 +32,7 @@ #include "InspectorWidget.h" #include "WindowActions.h" #include +#include #include #include #include @@ -76,16 +77,17 @@ URL url_from_user_input(const String& input) Tab::Tab(Type type) : m_type(type) { - auto& widget = *this; - set_layout(); + load_from_json(tab_ui_json); - m_toolbar_container = widget.add(); - auto& toolbar = m_toolbar_container->add(); + m_toolbar_container = static_cast(*find_descendant_by_name("toolbar_container")); + auto& toolbar = static_cast(*find_descendant_by_name("toolbar")); + + auto& webview_container = *find_descendant_by_name("webview_container"); if (m_type == Type::InProcessWebView) - m_page_view = widget.add(); + m_page_view = webview_container.add(); else - m_web_content_view = widget.add(); + m_web_content_view = webview_container.add(); m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { go_back(); }, this); m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { go_forward(); }, this); @@ -217,7 +219,7 @@ Tab::Tab(Type type) }, this); - m_statusbar = widget.add(); + m_statusbar = static_cast(*find_descendant_by_name("statusbar")); hooks().on_link_hover = [this](auto& url) { if (url.is_valid()) diff --git a/Applications/Browser/Tab.json b/Applications/Browser/Tab.json new file mode 100644 index 0000000000..2f1ef0a0ea --- /dev/null +++ b/Applications/Browser/Tab.json @@ -0,0 +1,29 @@ +{ + "layout": { + "class": "GUI::VerticalBoxLayout" + }, + + "children": [ + { + "class": "GUI::ToolBarContainer", + "name": "toolbar_container", + "children": [ + { + "class": "GUI::ToolBar", + "name": "toolbar" + } + ] + }, + { + "class": "GUI::Widget", + "name": "webview_container", + "layout": { + "class": "GUI::VerticalBoxLayout" + } + }, + { + "class": "GUI::StatusBar", + "name": "statusbar" + } + ] +}