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

219 lines
5.9 KiB
C
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
2014-01-11 16:11:42 +01:00
* Copyright (C) 2010-2014 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
2011-03-04 13:59:07 +01:00
#define mApp MainApplication::getInstance()
2011-03-02 16:57:41 +01:00
#include <QList>
2011-03-02 16:57:41 +01:00
#include <QUrl>
#include <QPointer>
#include "restoremanager.h"
2011-03-02 16:57:41 +01:00
#include "qtsingleapplication.h"
#include "qz_namespace.h"
2014-01-02 15:26:44 +01:00
class QMenu;
class QWebSettings;
class QNetworkDiskCache;
2011-03-02 16:57:41 +01:00
class QupZilla;
class CookieManager;
class BrowsingLibrary;
class History;
2011-03-02 16:57:41 +01:00
class NetworkManager;
class CookieJar;
class RSSManager;
class Updater;
class PluginProxy;
class BookmarksModel;
class DownloadManager;
class AutoFill;
class DesktopNotificationsFactory;
class IconProvider;
class SearchEnginesManager;
class DatabaseWriter;
class UserAgentManager;
class ProxyStyle;
2012-12-01 11:16:49 +01:00
class RegisterQAppAssociation;
class HTML5PermissionsManager;
class Speller;
2014-01-02 15:26:44 +01:00
#ifdef Q_OS_MAC
class MacMenuReceiver;
#endif
class QT_QUPZILLA_EXPORT MainApplication : public QtSingleApplication
2011-03-02 16:57:41 +01:00
{
Q_OBJECT
public:
QString DATADIR;
QString PROFILEDIR;
QString TRANSLATIONSDIR;
QString THEMESDIR;
explicit MainApplication(int &argc, char** argv);
~MainApplication();
2011-03-02 16:57:41 +01:00
void connectDatabase();
void reloadSettings();
bool restoreStateSlot(QupZilla* window, RestoreData recoveryData);
QupZilla* makeNewWindow(Qz::BrowserWindow type, const QUrl &startUrl = QUrl());
2011-03-02 16:57:41 +01:00
void aboutToCloseWindow(QupZilla* window);
bool isStateChanged();
2011-03-02 16:57:41 +01:00
QList<QupZilla*> mainWindows();
static MainApplication* getInstance() { return static_cast<MainApplication*>(QCoreApplication::instance()); }
bool isClosing() const;
bool isRestoring() const;
bool isPrivateSession() const;
bool isStartingAfterCrash() const;
int windowCount() const;
QString currentLanguageFile() const;
QString currentLanguage() const;
QString currentProfilePath() const;
bool checkSettingsDir();
void destroyRestoreManager();
void clearTempPath();
ProxyStyle* proxyStyle() const;
void setProxyStyle(ProxyStyle* style);
QString currentStyle() const;
QString tempPath() const;
2011-03-02 16:57:41 +01:00
QupZilla* getWindow();
CookieManager* cookieManager();
BrowsingLibrary* browsingLibrary();
History* history();
2011-03-02 16:57:41 +01:00
QWebSettings* webSettings();
NetworkManager* networkManager();
CookieJar* cookieJar();
RSSManager* rssManager();
PluginProxy* plugins();
BookmarksModel* bookmarksModel();
2011-03-02 16:57:41 +01:00
DownloadManager* downManager();
AutoFill* autoFill();
SearchEnginesManager* searchEnginesManager();
QNetworkDiskCache* networkCache();
DesktopNotificationsFactory* desktopNotifications();
HTML5PermissionsManager* html5permissions();
#ifdef USE_HUNSPELL
Speller* speller();
#endif
DatabaseWriter* dbWriter() { return m_dbWriter; }
UserAgentManager* uaManager() { return m_uaManager; }
RestoreManager* restoreManager() { return m_restoreManager; }
2014-01-02 15:26:44 +01:00
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
RegisterQAppAssociation* associationManager();
#endif
2011-03-02 16:57:41 +01:00
#ifdef Q_OS_MAC
MacMenuReceiver* macMenuReceiver();
QMenu* macDockMenu();
bool event(QEvent* e);
#endif
2011-03-02 16:57:41 +01:00
public slots:
bool saveStateSlot();
void quitApplication();
void sendMessages(Qz::AppMessageType mes, bool state);
2011-03-02 16:57:41 +01:00
void receiveAppMessage(QString message);
void setStateChanged();
void addNewTab(const QUrl &url = QUrl());
2011-03-02 16:57:41 +01:00
void startPrivateBrowsing();
void reloadUserStyleSheet();
bool checkDefaultWebBrowser();
2011-03-02 16:57:41 +01:00
signals:
void message(Qz::AppMessageType mes, bool state);
2011-03-02 16:57:41 +01:00
private slots:
void loadSettings();
void postLaunch();
void setupJumpList();
void restoreCursor();
void saveSettings();
2011-03-02 16:57:41 +01:00
private:
enum PostLaunchAction { OpenDownloadManager, OpenNewTab };
void loadTheme(const QString &name);
2011-03-02 16:57:41 +01:00
void translateApp();
void restoreOtherWindows();
void backupSavedSessions();
2011-03-02 16:57:41 +01:00
QUrl userStyleSheet(const QString &filePath) const;
2011-03-02 16:57:41 +01:00
CookieManager* m_cookiemanager;
BrowsingLibrary* m_browsingLibrary;
History* m_historymodel;
2011-03-02 16:57:41 +01:00
QWebSettings* m_websettings;
NetworkManager* m_networkmanager;
CookieJar* m_cookiejar;
RSSManager* m_rssmanager;
PluginProxy* m_plugins;
BookmarksModel* m_bookmarksModel;
DownloadManager* m_downloadManager;
AutoFill* m_autofill;
QNetworkDiskCache* m_networkCache;
DesktopNotificationsFactory* m_desktopNotifications;
SearchEnginesManager* m_searchEnginesManager;
RestoreManager* m_restoreManager;
ProxyStyle* m_proxyStyle;
HTML5PermissionsManager* m_html5permissions;
#ifdef USE_HUNSPELL
Speller* m_speller;
#endif
DatabaseWriter* m_dbWriter;
UserAgentManager* m_uaManager;
QList<QPointer<QupZilla> > m_mainWindows;
2011-03-02 16:57:41 +01:00
QString m_activeProfil;
QString m_activeLanguage;
QString m_activeThemePath;
2011-03-02 16:57:41 +01:00
bool m_isPrivateSession;
2011-03-02 16:57:41 +01:00
bool m_isClosing;
bool m_isStateChanged;
bool m_isRestoring;
bool m_startingAfterCrash;
bool m_databaseConnected;
QList<PostLaunchAction> m_postLaunchActions;
2014-01-02 15:26:44 +01:00
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
RegisterQAppAssociation* m_registerQAppAssociation;
#endif
2014-01-02 15:26:44 +01:00
#ifdef Q_OS_MAC
MacMenuReceiver* m_macMenuReceiver;
QMenu* m_macDockMenu;
#endif
2011-03-02 16:57:41 +01:00
};
#endif // MAINAPPLICATION_H