2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
2017-08-25 17:11:29 +02:00
|
|
|
* Falkon - Qt web browser
|
2017-01-20 11:14:50 +01:00
|
|
|
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#ifndef MAINAPPLICATION_H
|
|
|
|
#define MAINAPPLICATION_H
|
2012-01-11 21:58:25 +01:00
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
#define mApp MainApplication::instance()
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QList>
|
2015-10-13 04:42:13 +02:00
|
|
|
#include <QPointer>
|
2012-01-23 16:01:02 +01:00
|
|
|
|
2014-04-07 08:25:07 +02:00
|
|
|
#include "qtsingleapplication/qtsingleapplication.h"
|
2014-03-07 18:03:42 +01:00
|
|
|
#include "restoremanager.h"
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
|
2014-01-02 15:26:44 +01:00
|
|
|
class QMenu;
|
2015-05-24 17:29:41 +02:00
|
|
|
class QWebEngineProfile;
|
2015-01-27 11:01:52 +01:00
|
|
|
class QNetworkAccessManager;
|
2015-05-24 19:22:32 +02:00
|
|
|
class QWebEngineDownloadItem;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2012-04-30 16:33:14 +02:00
|
|
|
class History;
|
2014-03-10 00:47:07 +01:00
|
|
|
class AutoFill;
|
2014-09-25 14:09:26 +02:00
|
|
|
class MainMenu;
|
2014-03-10 00:47:07 +01:00
|
|
|
class Bookmarks;
|
2011-03-02 16:57:41 +01:00
|
|
|
class CookieJar;
|
2014-03-10 00:47:07 +01:00
|
|
|
class AutoSaver;
|
2011-03-02 16:57:41 +01:00
|
|
|
class PluginProxy;
|
2014-03-10 00:47:07 +01:00
|
|
|
class BrowserWindow;
|
2015-09-29 11:45:39 +02:00
|
|
|
class NetworkManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
class BrowsingLibrary;
|
2011-03-02 16:57:41 +01:00
|
|
|
class DownloadManager;
|
2012-08-16 23:15:31 +02:00
|
|
|
class UserAgentManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
class SearchEnginesManager;
|
2013-01-19 17:28:12 +01:00
|
|
|
class HTML5PermissionsManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
class RegisterQAppAssociation;
|
|
|
|
class DesktopNotificationsFactory;
|
2017-01-31 21:37:12 +01:00
|
|
|
class ProxyStyle;
|
2017-04-07 10:02:27 +02:00
|
|
|
class SessionManager;
|
2014-01-02 15:26:44 +01:00
|
|
|
|
2017-08-25 17:11:29 +02:00
|
|
|
class FALKON_EXPORT MainApplication : public QtSingleApplication
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-09-28 14:51:38 +02:00
|
|
|
enum AfterLaunch {
|
|
|
|
OpenBlankPage = 0,
|
|
|
|
OpenHomePage = 1,
|
|
|
|
OpenSpeedDial = 2,
|
2017-04-07 10:02:27 +02:00
|
|
|
RestoreSession = 3,
|
|
|
|
SelectSession = 4
|
2015-09-28 14:51:38 +02:00
|
|
|
};
|
|
|
|
|
2012-03-24 22:08:17 +01:00
|
|
|
explicit MainApplication(int &argc, char** argv);
|
2012-08-16 23:15:31 +02:00
|
|
|
~MainApplication();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2013-02-05 20:43:53 +01:00
|
|
|
bool isClosing() const;
|
2013-02-11 16:45:10 +01:00
|
|
|
bool isRestoring() const;
|
2014-03-10 00:47:07 +01:00
|
|
|
bool isPrivate() const;
|
2014-01-23 13:02:07 +01:00
|
|
|
bool isPortable() const;
|
2013-02-05 20:43:53 +01:00
|
|
|
bool isStartingAfterCrash() const;
|
2014-03-10 00:47:07 +01:00
|
|
|
|
2013-02-05 20:43:53 +01:00
|
|
|
int windowCount() const;
|
2014-03-10 00:47:07 +01:00
|
|
|
QList<BrowserWindow*> windows() const;
|
2013-02-05 15:41:10 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
BrowserWindow* getWindow() const;
|
|
|
|
BrowserWindow* createWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl());
|
|
|
|
|
2015-09-28 14:51:38 +02:00
|
|
|
AfterLaunch afterLaunch() const;
|
|
|
|
|
2017-03-26 11:27:04 +02:00
|
|
|
void openSession(BrowserWindow* window, RestoreData &restoreData);
|
2014-03-10 00:47:07 +01:00
|
|
|
bool restoreSession(BrowserWindow* window, RestoreData restoreData);
|
2012-08-21 20:28:38 +02:00
|
|
|
void destroyRestoreManager();
|
2014-03-10 00:47:07 +01:00
|
|
|
void reloadSettings();
|
2011-10-29 18:37:28 +02:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
// Name of current Qt style
|
|
|
|
QString styleName() const;
|
2017-01-31 21:37:12 +01:00
|
|
|
void setProxyStyle(ProxyStyle *style);
|
2014-03-10 00:47:07 +01:00
|
|
|
|
|
|
|
QString currentLanguageFile() const;
|
|
|
|
QString currentLanguage() const;
|
2012-09-03 13:24:29 +02:00
|
|
|
|
2012-04-30 16:33:14 +02:00
|
|
|
History* history();
|
2014-02-05 15:26:51 +01:00
|
|
|
Bookmarks* bookmarks();
|
2014-03-10 00:47:07 +01:00
|
|
|
|
2013-01-24 17:47:50 +01:00
|
|
|
AutoFill* autoFill();
|
2014-03-10 00:47:07 +01:00
|
|
|
CookieJar* cookieJar();
|
|
|
|
PluginProxy* plugins();
|
|
|
|
BrowsingLibrary* browsingLibrary();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2015-09-29 11:45:39 +02:00
|
|
|
NetworkManager* networkManager();
|
2014-03-10 00:47:07 +01:00
|
|
|
RestoreManager* restoreManager();
|
2017-04-07 10:02:27 +02:00
|
|
|
SessionManager* sessionManager();
|
2014-03-10 00:47:07 +01:00
|
|
|
DownloadManager* downloadManager();
|
|
|
|
UserAgentManager* userAgentManager();
|
|
|
|
SearchEnginesManager* searchEnginesManager();
|
|
|
|
HTML5PermissionsManager* html5PermissionsManager();
|
|
|
|
DesktopNotificationsFactory* desktopNotifications();
|
2015-05-24 19:22:32 +02:00
|
|
|
QWebEngineProfile* webProfile() const;
|
2012-01-12 20:10:51 +01:00
|
|
|
|
2017-04-07 10:02:27 +02:00
|
|
|
QByteArray saveState() const;
|
|
|
|
|
2014-03-07 18:03:42 +01:00
|
|
|
static MainApplication* instance();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
public slots:
|
2012-01-06 15:03:48 +01:00
|
|
|
void addNewTab(const QUrl &url = QUrl());
|
2014-02-22 15:20:54 +01:00
|
|
|
void startPrivateBrowsing(const QUrl &startUrl = QUrl());
|
2014-03-10 00:47:07 +01:00
|
|
|
|
2012-07-04 17:53:49 +02:00
|
|
|
void reloadUserStyleSheet();
|
2014-03-10 00:47:07 +01:00
|
|
|
void restoreOverrideCursor();
|
|
|
|
|
2016-02-26 10:43:34 +01:00
|
|
|
void changeOccurred();
|
2014-03-10 00:47:07 +01:00
|
|
|
void quitApplication();
|
2012-06-26 11:49:39 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
signals:
|
2014-03-10 00:47:07 +01:00
|
|
|
void settingsReloaded();
|
2017-03-20 09:07:33 +01:00
|
|
|
void activeWindowChanged(BrowserWindow* window);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-03-29 19:55:21 +02:00
|
|
|
private slots:
|
2011-12-30 16:54:37 +01:00
|
|
|
void postLaunch();
|
2011-03-29 19:55:21 +02:00
|
|
|
|
2012-01-12 20:10:51 +01:00
|
|
|
void saveSettings();
|
|
|
|
|
2014-05-01 14:08:06 +02:00
|
|
|
void messageReceived(const QString &message);
|
2014-03-10 00:47:07 +01:00
|
|
|
void windowDestroyed(QObject* window);
|
2014-12-02 19:35:17 +01:00
|
|
|
void onFocusChanged();
|
2016-12-24 11:32:48 +01:00
|
|
|
void runDeferredPostLaunchActions();
|
2014-03-10 00:47:07 +01:00
|
|
|
|
2015-05-24 19:22:32 +02:00
|
|
|
void downloadRequested(QWebEngineDownloadItem *download);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
2014-03-10 00:47:07 +01:00
|
|
|
enum PostLaunchAction {
|
|
|
|
OpenDownloadManager,
|
|
|
|
OpenNewTab,
|
|
|
|
ToggleFullScreen
|
|
|
|
};
|
2011-12-30 16:54:37 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
void loadSettings();
|
2013-06-07 12:59:22 +02:00
|
|
|
void loadTheme(const QString &name);
|
2014-03-10 00:47:07 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void translateApp();
|
|
|
|
|
2015-05-27 18:48:45 +02:00
|
|
|
void setUserStyleSheet(const QString &filePath);
|
2012-06-25 16:07:25 +02:00
|
|
|
|
2016-12-24 11:32:48 +01:00
|
|
|
void checkDefaultWebBrowser();
|
|
|
|
void checkOptimizeDatabase();
|
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
bool m_isPrivate;
|
|
|
|
bool m_isPortable;
|
|
|
|
bool m_isClosing;
|
|
|
|
bool m_isRestoring;
|
|
|
|
bool m_isStartingAfterCrash;
|
|
|
|
|
2014-03-06 16:12:36 +01:00
|
|
|
History* m_history;
|
2014-02-05 15:26:51 +01:00
|
|
|
Bookmarks* m_bookmarks;
|
2014-03-08 14:21:08 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
AutoFill* m_autoFill;
|
|
|
|
CookieJar* m_cookieJar;
|
|
|
|
PluginProxy* m_plugins;
|
|
|
|
BrowsingLibrary* m_browsingLibrary;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2015-09-29 11:45:39 +02:00
|
|
|
NetworkManager* m_networkManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
RestoreManager* m_restoreManager;
|
2017-04-07 10:02:27 +02:00
|
|
|
SessionManager* m_sessionManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
DownloadManager* m_downloadManager;
|
|
|
|
UserAgentManager* m_userAgentManager;
|
|
|
|
SearchEnginesManager* m_searchEnginesManager;
|
|
|
|
HTML5PermissionsManager* m_html5PermissionsManager;
|
|
|
|
DesktopNotificationsFactory* m_desktopNotifications;
|
2015-05-24 17:29:41 +02:00
|
|
|
QWebEngineProfile* m_webProfile;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
AutoSaver* m_autoSaver;
|
2017-01-31 21:37:12 +01:00
|
|
|
ProxyStyle *m_proxyStyle = nullptr;
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
QList<BrowserWindow*> m_windows;
|
2015-10-13 04:42:13 +02:00
|
|
|
QPointer<BrowserWindow> m_lastActiveWindow;
|
2014-12-02 19:35:17 +01:00
|
|
|
|
2011-12-30 16:54:37 +01:00
|
|
|
QList<PostLaunchAction> m_postLaunchActions;
|
2012-12-01 07:50:31 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
QString m_languageFile;
|
|
|
|
|
2017-01-20 11:14:50 +01:00
|
|
|
void createJumpList();
|
2017-03-18 17:19:57 +01:00
|
|
|
void initPulseSupport();
|
2017-01-20 11:14:50 +01:00
|
|
|
|
2014-01-02 15:26:44 +01:00
|
|
|
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
|
2014-03-10 00:47:07 +01:00
|
|
|
public:
|
|
|
|
RegisterQAppAssociation* associationManager();
|
|
|
|
|
|
|
|
private:
|
2012-12-01 07:50:31 +01:00
|
|
|
RegisterQAppAssociation* m_registerQAppAssociation;
|
2013-01-29 20:34:14 +01:00
|
|
|
#endif
|
2014-01-02 15:26:44 +01:00
|
|
|
|
2017-02-10 19:00:58 +01:00
|
|
|
#ifdef Q_OS_MACOS
|
2014-03-10 00:47:07 +01:00
|
|
|
public:
|
|
|
|
bool event(QEvent* e);
|
2013-02-09 01:17:58 +01:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINAPPLICATION_H
|