1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-15 03:22:11 +01:00
falkonOfficial/src/lib/app/mainapplication.h

217 lines
5.6 KiB
C
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
2017-08-25 17:11:29 +02:00
* Falkon - Qt web browser
* Copyright (C) 2010-2018 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
#define mApp MainApplication::instance()
2011-03-02 16:57:41 +01:00
#include <QList>
2015-10-13 04:42:13 +02:00
#include <QPointer>
#include "qtsingleapplication/qtsingleapplication.h"
#include "restoremanager.h"
#include "qzcommon.h"
2014-01-02 15:26:44 +01:00
class QMenu;
class QWebEngineProfile;
class QWebEngineSettings;
class QNetworkAccessManager;
class QWebEngineDownloadItem;
class History;
class AutoFill;
class MainMenu;
class Bookmarks;
2011-03-02 16:57:41 +01:00
class CookieJar;
class AutoSaver;
2011-03-02 16:57:41 +01:00
class PluginProxy;
class BrowserWindow;
2015-09-29 11:45:39 +02:00
class NetworkManager;
class BrowsingLibrary;
2011-03-02 16:57:41 +01:00
class DownloadManager;
class UserAgentManager;
class SearchEnginesManager;
class HTML5PermissionsManager;
class RegisterQAppAssociation;
class DesktopNotificationsFactory;
2017-01-31 21:37:12 +01:00
class ProxyStyle;
2017-04-07 10:02:27 +02:00
class SessionManager;
class ClosedWindowsManager;
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
};
explicit MainApplication(int &argc, char** argv);
~MainApplication();
2011-03-02 16:57:41 +01:00
bool isClosing() const;
bool isPrivate() const;
bool isPortable() const;
bool isStartingAfterCrash() const;
int windowCount() const;
QList<BrowserWindow*> windows() const;
BrowserWindow* getWindow() const;
BrowserWindow* createWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl());
2015-09-28 14:51:38 +02:00
AfterLaunch afterLaunch() const;
void openSession(BrowserWindow* window, RestoreData &restoreData);
bool restoreSession(BrowserWindow* window, RestoreData restoreData);
void destroyRestoreManager();
void reloadSettings();
// Name of current Qt style
QString styleName() const;
2017-01-31 21:37:12 +01:00
void setProxyStyle(ProxyStyle *style);
QString currentLanguageFile() const;
QString currentLanguage() const;
History* history();
Bookmarks* bookmarks();
AutoFill* autoFill();
CookieJar* cookieJar();
PluginProxy* plugins();
BrowsingLibrary* browsingLibrary();
2011-03-02 16:57:41 +01:00
2015-09-29 11:45:39 +02:00
NetworkManager* networkManager();
RestoreManager* restoreManager();
2017-04-07 10:02:27 +02:00
SessionManager* sessionManager();
DownloadManager* downloadManager();
UserAgentManager* userAgentManager();
SearchEnginesManager* searchEnginesManager();
ClosedWindowsManager* closedWindowsManager();
HTML5PermissionsManager* html5PermissionsManager();
DesktopNotificationsFactory* desktopNotifications();
QWebEngineProfile* webProfile() const;
QWebEngineSettings *webSettings() const;
2017-04-07 10:02:27 +02:00
QByteArray saveState() const;
static MainApplication* instance();
2011-03-02 16:57:41 +01:00
public slots:
void addNewTab(const QUrl &url = QUrl());
void startPrivateBrowsing(const QUrl &startUrl = QUrl());
void reloadUserStyleSheet();
void restoreOverrideCursor();
void changeOccurred();
void quitApplication();
2011-03-02 16:57:41 +01:00
signals:
void settingsReloaded();
void activeWindowChanged(BrowserWindow* window);
2011-03-02 16:57:41 +01:00
private slots:
void postLaunch();
void saveSettings();
void messageReceived(const QString &message);
void windowDestroyed(QObject* window);
void onFocusChanged();
void runDeferredPostLaunchActions();
void downloadRequested(QWebEngineDownloadItem *download);
2011-03-02 16:57:41 +01:00
private:
enum PostLaunchAction {
OpenDownloadManager,
OpenNewTab,
ToggleFullScreen
};
void loadSettings();
void loadTheme(const QString &name);
2011-03-02 16:57:41 +01:00
void translateApp();
void setupUserScripts();
void setUserStyleSheet(const QString &filePath);
void checkDefaultWebBrowser();
void checkOptimizeDatabase();
bool m_isPrivate;
bool m_isPortable;
bool m_isClosing;
bool m_isStartingAfterCrash;
History* m_history;
Bookmarks* m_bookmarks;
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;
RestoreManager* m_restoreManager;
2017-04-07 10:02:27 +02:00
SessionManager* m_sessionManager;
DownloadManager* m_downloadManager;
UserAgentManager* m_userAgentManager;
SearchEnginesManager* m_searchEnginesManager;
ClosedWindowsManager* m_closedWindowsManager;
HTML5PermissionsManager* m_html5PermissionsManager;
DesktopNotificationsFactory* m_desktopNotifications;
QWebEngineProfile* m_webProfile;
2011-03-02 16:57:41 +01:00
AutoSaver* m_autoSaver;
2017-01-31 21:37:12 +01:00
ProxyStyle *m_proxyStyle = nullptr;
QList<BrowserWindow*> m_windows;
2015-10-13 04:42:13 +02:00
QPointer<BrowserWindow> m_lastActiveWindow;
QList<PostLaunchAction> m_postLaunchActions;
QString m_languageFile;
void createJumpList();
void initPulseSupport();
2014-01-02 15:26:44 +01:00
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
public:
RegisterQAppAssociation* associationManager();
private:
RegisterQAppAssociation* m_registerQAppAssociation;
#endif
2014-01-02 15:26:44 +01:00
2017-02-10 19:00:58 +01:00
#ifdef Q_OS_MACOS
public:
bool event(QEvent* e);
#endif
2011-03-02 16:57:41 +01:00
};
#endif // MAINAPPLICATION_H