Falkon Develop
Cross-platform Qt-based web browser
mainapplication.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 MAINAPPLICATION_H
19#define MAINAPPLICATION_H
20
21#define mApp MainApplication::instance()
22
23#include <QList>
24#include <QPointer>
25
27#include "restoremanager.h"
28#include "qzcommon.h"
29
30class QMenu;
31class QWebEngineProfile;
32class QWebEngineSettings;
33class QNetworkAccessManager;
34class QWebEngineDownloadRequest;
35
36class History;
37class AutoFill;
38class MainMenu;
39class Bookmarks;
40class CookieJar;
41class AutoSaver;
42class PluginProxy;
43class BrowserWindow;
44class NetworkManager;
45class BrowsingLibrary;
46class DownloadManager;
52class ProxyStyle;
53class SessionManager;
57
59{
60 Q_OBJECT
61
62public:
64 OpenBlankPage = 0,
65 OpenHomePage = 1,
66 OpenSpeedDial = 2,
67 RestoreSession = 3,
68 SelectSession = 4
69 };
70
71 explicit MainApplication(int &argc, char** argv);
73
74 bool isClosing() const;
75 bool isPrivate() const;
76 bool isPortable() const;
77 bool isStartingAfterCrash() const;
78
79 int windowCount() const;
80 QList<BrowserWindow*> windows() const;
81
82 BrowserWindow* getWindow() const;
83 BrowserWindow* createWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl());
84
85 AfterLaunch afterLaunch() const;
86
87 void openSession(BrowserWindow* window, RestoreData &restoreData);
88 bool restoreSession(BrowserWindow* window, RestoreData restoreData);
89 void destroyRestoreManager();
90 void reloadSettings();
91
92 // Name of current Qt style
93 QString styleName() const;
94 void setProxyStyle(ProxyStyle *style);
95
96 QByteArray wmClass() const;
97
98 History* history();
99 Bookmarks* bookmarks();
100
101 AutoFill* autoFill();
102 CookieJar* cookieJar();
103 PluginProxy* plugins();
104 BrowsingLibrary* browsingLibrary();
105
106 NetworkManager* networkManager();
107 RestoreManager* restoreManager();
108 SessionManager* sessionManager();
109 DownloadManager* downloadManager();
110 UserAgentManager* userAgentManager();
111 SearchEnginesManager* searchEnginesManager();
112 ClosedWindowsManager* closedWindowsManager();
113 ProtocolHandlerManager *protocolHandlerManager();
114 HTML5PermissionsManager* html5PermissionsManager();
115 SiteSettingsManager* siteSettingsManager();
116 DesktopNotificationsFactory* desktopNotifications();
117 QWebEngineProfile* webProfile() const;
118 QWebEngineSettings *webSettings() const;
119
120 QByteArray saveState() const;
121
122 static MainApplication* instance();
123
124 static bool isTestModeEnabled();
125 static void setTestModeEnabled(bool enabled);
126
127public Q_SLOTS:
128 void addNewTab(const QUrl &url = QUrl());
129 void startPrivateBrowsing(const QUrl &startUrl = QUrl());
130
131 void reloadUserStyleSheet();
132 void restoreOverrideCursor();
133
134 void changeOccurred();
135 void quitApplication();
136
137Q_SIGNALS:
140
141private Q_SLOTS:
142 void postLaunch();
143
144 void saveSettings();
145
146 void messageReceived(const QString &message);
147 void windowDestroyed(QObject* window);
148 void onFocusChanged();
149 void runDeferredPostLaunchActions();
150
151 void downloadRequested(QWebEngineDownloadRequest *download);
152
153private:
154 enum PostLaunchAction {
155 OpenDownloadManager,
156 OpenNewTab,
157 ToggleFullScreen
158 };
159
160 void loadSettings();
161 void loadTheme(const QString &name);
162
163 void setupUserScripts();
164 void setUserStyleSheet(const QString &filePath);
165
166 void checkDefaultWebBrowser();
167 void checkOptimizeDatabase();
168
169 void registerAllowedSchemes();
170
171 bool m_isPrivate;
172 bool m_isPortable;
173 bool m_isClosing;
174 bool m_isStartingAfterCrash;
175
176 History* m_history;
177 Bookmarks* m_bookmarks;
178
179 AutoFill* m_autoFill;
180 CookieJar* m_cookieJar;
181 PluginProxy* m_plugins;
182 BrowsingLibrary* m_browsingLibrary;
183
184 NetworkManager* m_networkManager;
185 RestoreManager* m_restoreManager;
186 SessionManager* m_sessionManager;
187 DownloadManager* m_downloadManager;
188 UserAgentManager* m_userAgentManager;
189 SearchEnginesManager* m_searchEnginesManager;
190 ClosedWindowsManager* m_closedWindowsManager;
191 ProtocolHandlerManager *m_protocolHandlerManager;
192 HTML5PermissionsManager* m_html5PermissionsManager;
193 SiteSettingsManager* m_siteSettingsManager;
194 DesktopNotificationsFactory* m_desktopNotifications;
195 QWebEngineProfile* m_webProfile;
196
197 AutoSaver* m_autoSaver;
198 ProxyStyle *m_proxyStyle = nullptr;
199
200 QByteArray m_wmClass;
201
202 QList<BrowserWindow*> m_windows;
203 QPointer<BrowserWindow> m_lastActiveWindow;
204
205 QList<PostLaunchAction> m_postLaunchActions;
206
207 void createJumpList();
208 void initPulseSupport();
209
210#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
211public:
212 RegisterQAppAssociation* associationManager();
213
214private:
215 RegisterQAppAssociation* m_registerQAppAssociation;
216#endif
217
218#ifdef Q_OS_MACOS
219public:
220 bool event(QEvent* e);
221#endif
222};
223
224#endif // MAINAPPLICATION_H
void settingsReloaded()
void activeWindowChanged(BrowserWindow *window)
The QtSingleApplication class provides an API to detect and communicate with running instances of an ...
void messageReceived(const QString &message)
BrowserWindowType
Definition: qzcommon.h:64
#define FALKON_EXPORT
Definition: qzcommon.h:28