summaryrefslogtreecommitdiff
path: root/Ladybird/Tab.h
blob: 3646a6d7649e9c4c4bb6a95b4d4591286ca62ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2022, Matthew Costa <ucosty@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "LocationEdit.h"
#include "WebContentView.h"
#include <Browser/History.h>
#include <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QToolBar>
#include <QToolButton>
#include <QWidget>

class BrowserWindow;

class Tab final : public QWidget {
    Q_OBJECT
public:
    Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling);

    WebContentView& view() { return *m_view; }

    enum class LoadType {
        Normal,
        HistoryNavigation,
    };
    void navigate(QString, LoadType = LoadType::Normal);

    void debug_request(DeprecatedString const& request, DeprecatedString const& argument);

    void update_reset_zoom_button();

public slots:
    void focus_location_editor();
    void location_edit_return_pressed();
    void page_title_changed(QString);
    void page_favicon_changed(QIcon);
    void back();
    void forward();
    void reload();

signals:
    void title_changed(int id, QString);
    void favicon_changed(int id, QIcon);

private:
    virtual void resizeEvent(QResizeEvent*) override;
    virtual bool event(QEvent*) override;

    void rerender_toolbar_icons();
    void update_hover_label();

    QBoxLayout* m_layout;
    QToolBar* m_toolbar { nullptr };
    QToolButton* m_reset_zoom_button { nullptr };
    QAction* m_reset_zoom_button_action { nullptr };
    LocationEdit* m_location_edit { nullptr };
    WebContentView* m_view { nullptr };
    BrowserWindow* m_window { nullptr };
    Browser::History m_history;
    QString m_title;
    QLabel* m_hover_label { nullptr };

    int tab_index();

    bool m_is_history_navigation { false };
};