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"
|
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>
|
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>
|
|
|
|
|
2022-12-05 18:09:42 +00:00
|
|
|
namespace Browser {
|
|
|
|
class CookieJar;
|
|
|
|
}
|
|
|
|
|
2023-08-02 17:52:59 +00:00
|
|
|
namespace Ladybird {
|
|
|
|
|
|
|
|
class WebContentView;
|
|
|
|
|
2022-07-03 19:26:51 +00:00
|
|
|
class BrowserWindow : public QMainWindow {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-08-08 19:59:55 +00:00
|
|
|
explicit BrowserWindow(Optional<URL> const& initial_url, Browser::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
|
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
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
int tab_index(Tab*);
|
2022-07-05 17:42:45 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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:
|
2022-07-05 22:18:21 +00:00
|
|
|
void tab_title_changed(int index, QString const&);
|
|
|
|
void tab_favicon_changed(int index, QIcon icon);
|
2023-03-20 22:39:20 +00:00
|
|
|
Tab& new_tab(QString const&, Web::HTML::ActivateTab);
|
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);
|
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();
|
|
|
|
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:
|
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
|
|
|
|
2022-12-04 18:43:54 +00:00
|
|
|
void debug_request(DeprecatedString const& request, DeprecatedString 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
|
|
|
|
2022-07-05 22:18:21 +00:00
|
|
|
QTabWidget* m_tabs_container { nullptr };
|
2023-03-06 16:16:25 +00:00
|
|
|
Vector<NonnullOwnPtr<Tab>> m_tabs;
|
2022-07-05 22:18:21 +00:00
|
|
|
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
|
|
|
|
2023-05-13 12:07:12 +00:00
|
|
|
OwnPtr<QAction> m_go_back_action {};
|
|
|
|
OwnPtr<QAction> m_go_forward_action {};
|
|
|
|
OwnPtr<QAction> m_reload_action {};
|
2023-05-15 15:49:44 +00:00
|
|
|
OwnPtr<QAction> m_copy_selection_action {};
|
|
|
|
OwnPtr<QAction> m_select_all_action {};
|
|
|
|
OwnPtr<QAction> m_view_source_action {};
|
|
|
|
OwnPtr<QAction> m_inspect_dom_node_action {};
|
2023-05-13 12:07:12 +00:00
|
|
|
|
2022-12-05 18:09:42 +00:00
|
|
|
Browser::CookieJar& m_cookie_jar;
|
2022-11-14 16:08:44 +00:00
|
|
|
|
2022-12-15 14:18:52 +00:00
|
|
|
StringView m_webdriver_content_ipc_path;
|
2023-04-15 00:04:28 +00:00
|
|
|
WebView::EnableCallgrindProfiling m_enable_callgrind_profiling;
|
2023-08-01 20:39:19 +00:00
|
|
|
UseLagomNetworking m_use_lagom_networking;
|
2022-07-03 19:26:51 +00:00
|
|
|
};
|
2023-08-02 17:52:59 +00:00
|
|
|
|
|
|
|
}
|