Falkon Develop
Cross-platform Qt-based web browser
browserwindow.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 BROWSERWINDOW_H
19#define BROWSERWINDOW_H
20
21#include <QMainWindow>
22#include <QPointer>
23#include <QUrl>
24
25#include "webtab.h"
26#include "qzcommon.h"
27
28class QLabel;
29class QVBoxLayout;
30class QSplitter;
31class QWebEngineFrame;
32class QTimer;
33
34class Menu;
35class MainMenu;
36class TabWidget;
37class TabbedWebView;
38class LineEdit;
39class HistoryMenu;
40class BookmarksMenu;
42class AutoFill;
43class MainApplication;
44class WebView;
45class WebPage;
46class SideBar;
47class SideBarManager;
48class ProgressBar;
49class StatusBar;
50class NavigationBar;
52class ClickableLabel;
53class LocationBar;
54class TabModel;
55class TabMruModel;
56
57class FALKON_EXPORT BrowserWindow : public QMainWindow
58{
59 Q_OBJECT
60
61public:
62 struct SavedWindow {
63 QByteArray windowState;
64 QByteArray windowGeometry;
65 QHash<QString, QVariant> windowUiState;
66 int virtualDesktop = -1;
67 int currentTab = -1;
68 QVector<WebTab::SavedTab> tabs;
69
72
73 bool isValid() const;
74 void clear();
75
76 friend FALKON_EXPORT QDataStream &operator<<(QDataStream &stream, const SavedWindow &window);
77 friend FALKON_EXPORT QDataStream &operator>>(QDataStream &stream, SavedWindow &window);
78 };
79
80 explicit BrowserWindow(Qz::BrowserWindowType type, const QUrl &url = QUrl());
81 ~BrowserWindow() override;
82
83 void setStartTab(WebTab* tab);
84 void setStartPage(WebPage* page);
85
86 void restoreWindow(const SavedWindow &window);
87
88 bool fullScreenNavigationVisible() const;
89 void showNavigationWithFullScreen();
90 void hideNavigationWithFullScreen();
91
92 void currentTabChanged();
93 void updateLoadingActions();
94
95 void addBookmark(const QUrl &url, const QString &title);
96 void addDeleteOnCloseWidget(QWidget* widget);
97
98 void createToolbarsMenu(QMenu* menu);
99 void createSidebarsMenu(QMenu* menu);
100 void createEncodingMenu(QMenu* menu);
101
102 void removeActions(const QList<QAction*> &actions);
103
104 SideBar* addSideBar();
105 void saveSideBarSettings();
106
107 int tabCount() const;
108 TabbedWebView* weView() const;
109 TabbedWebView* weView(int index) const;
110
111 Qz::BrowserWindowType windowType() const;
112 LocationBar* locationBar() const;
113 TabWidget* tabWidget() const;
114 BookmarksToolbar* bookmarksToolbar() const;
115 StatusBar* statusBar() const;
116 NavigationBar* navigationBar() const;
117 SideBarManager* sideBarManager() const;
118 QLabel* ipLabel() const;
119 QMenu* superMenu() const;
120
121 QUrl homepageUrl() const;
122
123 QAction* action(const QString &name) const;
124
125 TabModel *tabModel() const;
126 TabMruModel *tabMruModel() const;
127
128Q_SIGNALS:
131
132public Q_SLOTS:
133 void addTab();
134
135 void goHome();
136 void goHomeInNewTab();
137 void goBack();
138 void goForward();
139
140 void reload();
141 void reloadBypassCache();
142
143 void setWindowTitle(const QString &t);
144
145 void showWebInspector();
146 void toggleWebInspector();
147 void showHistoryManager();
148
149 void toggleShowMenubar();
150 void toggleShowStatusBar();
151 void toggleShowBookmarksToolbar();
152 void toggleShowNavigationToolbar();
153 void toggleTabsOnTop(bool enable);
154
155 void toggleFullScreen();
156 void requestHtmlFullScreen(TabbedWebView *view, bool enable);
157
158 void loadActionUrl(QObject* obj = nullptr);
159 void loadActionUrlInNewTab(QObject* obj = nullptr);
160
161 void bookmarkPage();
162 void bookmarkAllTabs();
163 void loadAddress(const QUrl &url);
164 void showSource(WebView *view = nullptr);
165
166private Q_SLOTS:
167 void openLocation();
168 void openFile();
169 void closeWindow();
170 void closeTab();
171 void loadSettings();
172 void postLaunch();
173
174 void webSearch();
175 void searchOnPage();
176 void changeEncoding();
177 void printPage();
178
179 void saveSettings();
180 void hideNavigationSlot();
181
182private:
183 bool event(QEvent* event) override;
184 void resizeEvent(QResizeEvent* event) override;
185 void keyPressEvent(QKeyEvent* event) override;
186 void keyReleaseEvent(QKeyEvent* event) override;
187 void closeEvent(QCloseEvent* event) override;
188
189 void setupUi();
190 void setupMenu();
191 void updateStartupFocus();
192
193 QAction *createEncodingAction(const QString &codecName, const QString &activeCodecName, QMenu *menu);
194 void createEncodingSubMenu(const QString &name, QStringList &codecNames, QMenu *menu);
195
196 QHash<QString, QVariant> saveUiState();
197 void restoreUiState(const QHash<QString, QVariant> &state);
198
199 QUrl m_startUrl;
200 QUrl m_homepage;
201 Qz::BrowserWindowType m_windowType;
202 WebTab* m_startTab;
203 WebPage* m_startPage;
204
205 QVBoxLayout* m_mainLayout;
206 QSplitter* m_mainSplitter;
207
208 TabWidget* m_tabWidget;
209 QPointer<SideBar> m_sideBar;
210 SideBarManager* m_sideBarManager;
211 StatusBar* m_statusBar;
212
213 NavigationContainer* m_navigationContainer;
214 NavigationBar* m_navigationToolbar;
215 BookmarksToolbar* m_bookmarksToolbar;
216
217 ProgressBar* m_progressBar;
218 QLabel* m_ipLabel;
219
220 QMenu* m_superMenu;
221 MainMenu* m_mainMenu;
222
223 TabModel *m_tabModel = nullptr;
224 TabMruModel *m_tabMruModel = nullptr;
225
226 int m_sideBarWidth;
227 int m_webViewWidth;
228
229 // Shortcuts
230 bool m_useTabNumberShortcuts;
231 bool m_useSpeedDialNumberShortcuts;
232 bool m_useSingleKeyShortcuts;
233
234 // Remember visibility of menubar and statusbar after entering Fullscreen
235 bool m_menuBarVisible;
236 bool m_statusBarVisible;
237 QPointer<TabbedWebView> m_htmlFullScreenView;
238 QTimer* m_hideNavigationTimer;
239
240 QList<QPointer<QWidget> > m_deleteOnCloseWidgets;
241
242#ifdef QZ_WS_X11
243private:
244 int getCurrentVirtualDesktop() const;
245 void moveToVirtualDesktop(int desktopId);
246#endif
247};
248
249#endif // BROWSERWINDOW_H
QDataStream & operator>>(QDataStream &stream, BrowserWindow::SavedWindow &window)
QDataStream & operator<<(QDataStream &stream, const BrowserWindow::SavedWindow &window)
void aboutToClose()
void startingCompleted()
Definition: webtab.h:40
BrowserWindowType
Definition: qzcommon.h:64
t
Definition: i18n.py:27
State state
#define FALKON_EXPORT
Definition: qzcommon.h:28
QVector< WebTab::SavedTab > tabs
Definition: browserwindow.h:68
QHash< QString, QVariant > windowUiState
Definition: browserwindow.h:65