2022-07-05 22:18:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2023-01-12 14:39:53 +00:00
|
|
|
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
2022-07-05 22:18:21 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-12-05 18:09:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
#include "Tab.h"
|
2023-12-01 17:18:40 +00:00
|
|
|
#include <Ladybird/Types.h>
|
2022-07-05 17:42:45 +00:00
|
|
|
#include <LibCore/Forward.h>
|
2023-03-20 22:39:20 +00:00
|
|
|
#include <LibWeb/HTML/ActivateTab.h>
|
2024-03-28 15:16:10 +00:00
|
|
|
#include <LibWeb/HTML/AudioPlayState.h>
|
2023-08-31 11:07:07 +00:00
|
|
|
#include <LibWebView/Forward.h>
|
2022-07-05 04:53:11 +00:00
|
|
|
#include <QIcon>
|
2022-07-03 19:26:51 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMainWindow>
|
2022-07-05 22:18:21 +00:00
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QTabWidget>
|
2022-07-03 19:26:51 +00:00
|
|
|
#include <QToolBar>
|
|
|
|
|
2023-08-02 17:52:59 +00:00
|
|
|
namespace Ladybird {
|
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
class SettingsDialog;
|
2023-08-02 17:52:59 +00:00
|
|
|
class WebContentView;
|
2024-03-26 17:38:12 +00:00
|
|
|
class TaskManagerWindow;
|
2023-08-02 17:52:59 +00:00
|
|
|
|
2022-07-03 19:26:51 +00:00
|
|
|
class BrowserWindow : public QMainWindow {
|
|
|
|
Q_OBJECT
|
2023-12-01 17:18:40 +00:00
|
|
|
|
2022-07-03 19:26:51 +00:00
|
|
|
public:
|
2024-03-18 03:22:27 +00:00
|
|
|
BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path);
|
2022-07-03 19:26:51 +00:00
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
WebContentView& view() const { return m_current_tab->view(); }
|
2022-07-03 19:26:51 +00:00
|
|
|
|
2024-04-28 14:07:23 +00:00
|
|
|
int tab_count() { return m_tabs_container->count(); }
|
2022-07-05 22:18:21 +00:00
|
|
|
int tab_index(Tab*);
|
2024-04-26 21:23:20 +00:00
|
|
|
Tab& create_new_tab(Web::HTML::ActivateTab activate_tab);
|
2022-07-05 17:42:45 +00:00
|
|
|
|
2024-05-05 15:11:51 +00:00
|
|
|
QMenu& hamburger_menu()
|
|
|
|
{
|
|
|
|
return *m_hamburger_menu;
|
|
|
|
}
|
|
|
|
|
2023-05-13 12:07:12 +00:00
|
|
|
QAction& go_back_action()
|
|
|
|
{
|
|
|
|
return *m_go_back_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction& go_forward_action()
|
|
|
|
{
|
|
|
|
return *m_go_forward_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction& reload_action()
|
|
|
|
{
|
|
|
|
return *m_reload_action;
|
|
|
|
}
|
|
|
|
|
2024-04-05 11:21:48 +00:00
|
|
|
QAction& new_tab_action()
|
|
|
|
{
|
|
|
|
return *m_new_tab_action;
|
|
|
|
}
|
|
|
|
|
2024-04-27 00:53:55 +00:00
|
|
|
QAction& new_window_action()
|
|
|
|
{
|
|
|
|
return *m_new_window_action;
|
|
|
|
}
|
|
|
|
|
2023-05-15 15:49:44 +00:00
|
|
|
QAction& copy_selection_action()
|
|
|
|
{
|
|
|
|
return *m_copy_selection_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction& select_all_action()
|
|
|
|
{
|
|
|
|
return *m_select_all_action;
|
|
|
|
}
|
|
|
|
|
2024-03-22 10:56:49 +00:00
|
|
|
QAction& paste_action()
|
|
|
|
{
|
|
|
|
return *m_paste_action;
|
|
|
|
}
|
|
|
|
|
2023-05-15 15:49:44 +00:00
|
|
|
QAction& view_source_action()
|
|
|
|
{
|
|
|
|
return *m_view_source_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction& inspect_dom_node_action()
|
|
|
|
{
|
|
|
|
return *m_inspect_dom_node_action;
|
|
|
|
}
|
|
|
|
|
2022-07-05 19:10:50 +00:00
|
|
|
public slots:
|
2023-12-13 18:10:05 +00:00
|
|
|
void device_pixel_ratio_changed(qreal dpi);
|
2022-07-05 22:18:21 +00:00
|
|
|
void tab_title_changed(int index, QString const&);
|
2023-05-29 09:05:40 +00:00
|
|
|
void tab_favicon_changed(int index, QIcon const& icon);
|
2024-03-28 15:16:10 +00:00
|
|
|
void tab_audio_play_state_changed(int index, Web::HTML::AudioPlayState);
|
2024-04-13 22:05:47 +00:00
|
|
|
void tab_navigation_buttons_state_changed(int index);
|
2024-03-18 03:22:27 +00:00
|
|
|
Tab& new_tab_from_url(URL::URL const&, Web::HTML::ActivateTab);
|
2024-01-31 01:52:59 +00:00
|
|
|
Tab& new_tab_from_content(StringView html, Web::HTML::ActivateTab);
|
2024-01-31 03:05:00 +00:00
|
|
|
Tab& new_child_tab(Web::HTML::ActivateTab, Tab& parent, Web::HTML::WebViewHints, Optional<u64> page_index);
|
2023-03-20 23:52:00 +00:00
|
|
|
void activate_tab(int index);
|
2022-07-06 13:36:49 +00:00
|
|
|
void close_tab(int index);
|
2024-04-28 14:07:23 +00:00
|
|
|
void move_tab(int old_index, int new_index);
|
2022-07-19 10:16:46 +00:00
|
|
|
void close_current_tab();
|
2022-09-12 07:22:43 +00:00
|
|
|
void open_next_tab();
|
|
|
|
void open_previous_tab();
|
2023-05-25 21:47:12 +00:00
|
|
|
void open_file();
|
2022-09-19 08:48:02 +00:00
|
|
|
void enable_auto_color_scheme();
|
|
|
|
void enable_light_color_scheme();
|
|
|
|
void enable_dark_color_scheme();
|
2023-01-12 14:39:53 +00:00
|
|
|
void zoom_in();
|
|
|
|
void zoom_out();
|
|
|
|
void reset_zoom();
|
2023-08-04 11:37:52 +00:00
|
|
|
void update_zoom_menu();
|
2023-01-11 19:09:52 +00:00
|
|
|
void select_all();
|
2024-03-22 10:56:49 +00:00
|
|
|
void paste();
|
2023-01-11 19:09:52 +00:00
|
|
|
void copy_selected_text();
|
2022-07-05 19:10:50 +00:00
|
|
|
|
2023-02-05 02:26:20 +00:00
|
|
|
protected:
|
2023-03-08 20:57:24 +00:00
|
|
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
2023-02-05 02:26:20 +00:00
|
|
|
|
2022-07-03 19:26:51 +00:00
|
|
|
private:
|
2024-01-27 04:14:41 +00:00
|
|
|
virtual bool event(QEvent*) override;
|
2023-03-08 20:57:24 +00:00
|
|
|
virtual void resizeEvent(QResizeEvent*) override;
|
|
|
|
virtual void moveEvent(QMoveEvent*) override;
|
2023-06-30 22:33:04 +00:00
|
|
|
virtual void wheelEvent(QWheelEvent*) override;
|
2023-08-09 10:23:32 +00:00
|
|
|
virtual void closeEvent(QCloseEvent*) override;
|
2023-03-08 20:57:24 +00:00
|
|
|
|
2024-01-31 03:05:00 +00:00
|
|
|
Tab& create_new_tab(Web::HTML::ActivateTab, Tab& parent, Web::HTML::WebViewHints, Optional<u64> page_index);
|
|
|
|
void initialize_tab(Tab*);
|
2023-08-28 20:14:34 +00:00
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
void debug_request(ByteString const& request, ByteString const& argument = "");
|
2022-07-08 12:14:40 +00:00
|
|
|
|
2023-03-26 17:56:17 +00:00
|
|
|
void set_current_tab(Tab* tab);
|
2023-03-28 23:25:42 +00:00
|
|
|
void update_displayed_zoom_level();
|
2023-03-26 17:56:17 +00:00
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
template<typename Callback>
|
|
|
|
void for_each_tab(Callback&& callback)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_tabs_container->count(); ++i) {
|
|
|
|
auto& tab = verify_cast<Tab>(*m_tabs_container->widget(i));
|
|
|
|
callback(tab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-03 01:35:52 +00:00
|
|
|
void create_close_button_for_tab(Tab*);
|
|
|
|
|
2024-03-30 22:36:26 +00:00
|
|
|
QIcon icon_for_page_mute_state(Tab&) const;
|
|
|
|
QString tool_tip_for_page_mute_state(Tab&) const;
|
2024-03-30 22:47:50 +00:00
|
|
|
QTabBar::ButtonPosition audio_button_position_for_tab(int tab_index) const;
|
2024-03-30 13:48:33 +00:00
|
|
|
|
2023-12-13 18:10:05 +00:00
|
|
|
QScreen* m_current_screen;
|
|
|
|
double m_device_pixel_ratio { 0 };
|
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
QTabWidget* m_tabs_container { nullptr };
|
|
|
|
Tab* m_current_tab { nullptr };
|
2023-03-26 17:56:17 +00:00
|
|
|
QMenu* m_zoom_menu { nullptr };
|
2022-10-11 08:53:28 +00:00
|
|
|
|
2024-05-05 15:11:51 +00:00
|
|
|
QMenu* m_hamburger_menu { nullptr };
|
|
|
|
|
2023-12-04 14:39:22 +00:00
|
|
|
QAction* m_go_back_action { nullptr };
|
|
|
|
QAction* m_go_forward_action { nullptr };
|
|
|
|
QAction* m_reload_action { nullptr };
|
2024-04-05 11:21:48 +00:00
|
|
|
QAction* m_new_tab_action { nullptr };
|
2024-04-27 00:53:55 +00:00
|
|
|
QAction* m_new_window_action { nullptr };
|
2023-12-04 14:39:22 +00:00
|
|
|
QAction* m_copy_selection_action { nullptr };
|
2024-03-22 10:56:49 +00:00
|
|
|
QAction* m_paste_action { nullptr };
|
2023-12-04 14:39:22 +00:00
|
|
|
QAction* m_select_all_action { nullptr };
|
|
|
|
QAction* m_view_source_action { nullptr };
|
|
|
|
QAction* m_inspect_dom_node_action { nullptr };
|
|
|
|
|
|
|
|
SettingsDialog* m_settings_dialog { nullptr };
|
2023-05-13 12:07:12 +00:00
|
|
|
|
2023-08-31 11:07:07 +00:00
|
|
|
WebView::CookieJar& m_cookie_jar;
|
2022-11-14 16:08:44 +00:00
|
|
|
|
2023-12-01 17:18:40 +00:00
|
|
|
WebContentOptions m_web_content_options;
|
2022-12-15 14:18:52 +00:00
|
|
|
StringView m_webdriver_content_ipc_path;
|
2022-07-03 19:26:51 +00:00
|
|
|
};
|
2023-08-02 17:52:59 +00:00
|
|
|
|
|
|
|
}
|