Falkon Develop
Cross-platform Qt-based web browser
webtab.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef WEBTAB_H
19#define WEBTAB_H
20
21#include <QWidget>
22#include <QIcon>
23#include <QUrl>
24
25#include "qzcommon.h"
26
27class QVBoxLayout;
28class QWebEngineHistory;
29class QSplitter;
30
31class BrowserWindow;
32class TabbedWebView;
33class WebInspector;
34class LocationBar;
35class TabIcon;
36class TabBar;
37class LoadRequest;
38
39class FALKON_EXPORT WebTab : public QWidget
40{
41 Q_OBJECT
42public:
44 QString title;
45 QUrl url;
46 QIcon icon;
47 QByteArray history;
51 QVector<int> childTabs;
52 QHash<QString, QVariant> sessionData;
53
54 SavedTab();
55 SavedTab(WebTab* webTab);
56
57 bool isValid() const;
58 void clear();
59
60 friend FALKON_EXPORT QDataStream &operator<<(QDataStream &stream, const SavedTab &tab);
61 friend FALKON_EXPORT QDataStream &operator>>(QDataStream &stream, SavedTab &tab);
62 };
63
65 AppendChild = 0,
66 PrependChild
67 };
68
69 explicit WebTab(QWidget *parent = nullptr);
70
71 BrowserWindow *browserWindow() const;
72 TabbedWebView* webView() const;
73 LocationBar* locationBar() const;
74 TabIcon* tabIcon() const;
75
76 WebTab *parentTab() const;
77 void setParentTab(WebTab *tab);
78 void addChildTab(WebTab *tab, int index = -1);
79 QVector<WebTab*> childTabs() const;
80
81 QHash<QString, QVariant> sessionData() const;
82 void setSessionData(const QString &key, const QVariant &value);
83
84 QUrl url() const;
85 QString title(bool allowEmpty = false) const;
86 QIcon icon(bool allowNull = false) const;
87 QWebEngineHistory* history() const;
88 int zoomLevel() const;
89 void setZoomLevel(int level);
90
91 void detach();
92 void attach(BrowserWindow* window);
93
94 QByteArray historyData() const;
95
96 void stop();
97 void reload();
98 void load(const LoadRequest &request);
99 void unload();
100 bool isLoading() const;
101
102 bool isPinned() const;
103 void setPinned(bool state);
104 void togglePinned();
105
106 bool isMuted() const;
107 bool isPlaying() const;
108 void setMuted(bool muted);
109 void toggleMuted();
110
111 bool backgroundActivity() const;
112
113 int tabIndex() const;
114
115 bool isCurrentTab() const;
116 void makeCurrentTab();
117 void closeTab();
118 void moveTab(int to);
119
120 bool haveInspector() const;
121 void showWebInspector(bool inspectElement = false);
122 void toggleWebInspector();
123
124 void showSearchToolBar(const QString &searchText = QString());
125
126 bool isRestored() const;
127 void restoreTab(const SavedTab &tab);
128 void p_restoreTab(const SavedTab &tab);
129 void p_restoreTab(const QUrl &url, const QByteArray &history, int zoomLevel);
130
131 void tabActivated();
132
133 static AddChildBehavior addChildBehavior();
134 static void setAddChildBehavior(AddChildBehavior behavior);
135
136private Q_SLOTS:
137 void showNotification(QWidget* notif);
138 void loadFinished();
139
140Q_SIGNALS:
141 void titleChanged(const QString &title);
142 void iconChanged(const QIcon &icon);
143 void pinnedChanged(bool pinned);
144 void restoredChanged(bool restored);
145 void currentTabChanged(bool current);
146 void loadingChanged(bool loading);
147 void mutedChanged(bool muted);
148 void playingChanged(bool playing);
149 void backgroundActivityChanged(bool activity);
151 void childTabAdded(WebTab *tab, int index);
152 void childTabRemoved(WebTab *tab, int index);
153
154private:
155 void titleWasChanged(const QString &title);
156 void resizeEvent(QResizeEvent *event) override;
157 void removeFromTabTree();
158
159 QVBoxLayout* m_layout;
160 QSplitter* m_splitter;
161
162 TabbedWebView* m_webView;
163 WebInspector* m_inspector;
164 LocationBar* m_locationBar;
165 TabIcon* m_tabIcon;
166 QWidget *m_notificationWidget;
167 BrowserWindow* m_window = nullptr;
168 TabBar* m_tabBar = nullptr;
169
170 WebTab *m_parentTab = nullptr;
171 QVector<WebTab*> m_childTabs;
172 QHash<QString, QVariant> m_sessionData;
173
174 SavedTab m_savedTab;
175 bool m_isPinned = false;
176 bool m_isCurrentTab = false;
177};
178
179#endif // WEBTAB_H
QDataStream & operator>>(QDataStream &stream, BrowserWindow::SavedWindow &window)
QDataStream & operator<<(QDataStream &stream, const BrowserWindow::SavedWindow &window)
Definition: tabbar.h:31
Definition: webtab.h:40
void mutedChanged(bool muted)
void titleChanged(const QString &title)
void currentTabChanged(bool current)
void restoredChanged(bool restored)
void iconChanged(const QIcon &icon)
void parentTabChanged(WebTab *tab)
void pinnedChanged(bool pinned)
void childTabRemoved(WebTab *tab, int index)
AddChildBehavior
Definition: webtab.h:64
void childTabAdded(WebTab *tab, int index)
void backgroundActivityChanged(bool activity)
void loadingChanged(bool loading)
void playingChanged(bool playing)
int value(const QColor &c)
Definition: colors.cpp:238
State state
#define FALKON_EXPORT
Definition: qzcommon.h:28
QVector< int > childTabs
Definition: webtab.h:51
QString title
Definition: webtab.h:44
QIcon icon
Definition: webtab.h:46
QHash< QString, QVariant > sessionData
Definition: webtab.h:52
QByteArray history
Definition: webtab.h:47
bool isPinned
Definition: webtab.h:48