2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2013-01-24 17:47:50 +01:00
|
|
|
* Copyright (C) 2010-2013 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
|
|
|
|
2011-03-04 13:59:07 +01:00
|
|
|
#define mApp MainApplication::getInstance()
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QList>
|
2011-03-02 16:57:41 +01:00
|
|
|
#include <QUrl>
|
2012-12-20 14:45:35 +01:00
|
|
|
#include <QPointer>
|
2012-01-23 16:01:02 +01:00
|
|
|
|
2012-08-21 20:28:38 +02:00
|
|
|
#include "restoremanager.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "qtsingleapplication.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "qz_namespace.h"
|
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
class QWebSettings;
|
|
|
|
class QNetworkDiskCache;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
class QupZilla;
|
|
|
|
class CookieManager;
|
2011-07-29 15:39:43 +02:00
|
|
|
class BrowsingLibrary;
|
2012-04-30 16:33:14 +02:00
|
|
|
class History;
|
2011-03-02 16:57:41 +01:00
|
|
|
class NetworkManager;
|
|
|
|
class CookieJar;
|
|
|
|
class RSSManager;
|
|
|
|
class Updater;
|
|
|
|
class PluginProxy;
|
|
|
|
class BookmarksModel;
|
|
|
|
class DownloadManager;
|
2013-01-24 17:47:50 +01:00
|
|
|
class AutoFill;
|
2011-04-24 22:40:35 +02:00
|
|
|
class DesktopNotificationsFactory;
|
2011-04-25 20:56:45 +02:00
|
|
|
class IconProvider;
|
2011-10-21 23:26:34 +02:00
|
|
|
class SearchEnginesManager;
|
2011-12-08 19:12:43 +01:00
|
|
|
class DatabaseWriter;
|
2012-08-16 23:15:31 +02:00
|
|
|
class UserAgentManager;
|
2012-09-03 13:24:29 +02:00
|
|
|
class ProxyStyle;
|
2012-12-01 11:16:49 +01:00
|
|
|
class RegisterQAppAssociation;
|
2013-01-19 17:28:12 +01:00
|
|
|
class HTML5PermissionsManager;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QT_QUPZILLA_EXPORT MainApplication : public QtSingleApplication
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
QString DATADIR;
|
2011-12-28 14:55:54 +01:00
|
|
|
QString PROFILEDIR;
|
2011-09-11 19:15:06 +02:00
|
|
|
QString TRANSLATIONSDIR;
|
|
|
|
QString THEMESDIR;
|
2011-12-28 14:55:54 +01: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
|
|
|
|
2011-10-23 14:44:18 +02:00
|
|
|
void connectDatabase();
|
2011-03-02 16:57:41 +01:00
|
|
|
void loadSettings();
|
2012-01-12 21:32:27 +01:00
|
|
|
void reloadSettings();
|
2012-08-24 19:24:48 +02:00
|
|
|
bool restoreStateSlot(QupZilla* window, RestoreData recoveryData);
|
2012-01-21 23:19:38 +01:00
|
|
|
QupZilla* makeNewWindow(Qz::BrowserWindow type, const QUrl &startUrl = QUrl());
|
2011-03-02 16:57:41 +01:00
|
|
|
void aboutToCloseWindow(QupZilla* window);
|
2011-07-28 12:12:00 +02:00
|
|
|
bool isStateChanged();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-04-01 16:36:38 +02:00
|
|
|
QList<QupZilla*> mainWindows();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
inline static MainApplication* getInstance() { return static_cast<MainApplication*>(QCoreApplication::instance()); }
|
2012-04-04 18:48:54 +02:00
|
|
|
inline QString currentProfilePath() { return m_activeProfil; }
|
|
|
|
inline QString currentLanguage() { return m_activeLanguage; }
|
2012-06-26 11:49:39 +02:00
|
|
|
inline bool isPrivateSession() { return m_isPrivateSession; }
|
2011-03-02 16:57:41 +01:00
|
|
|
inline bool isClosing() { return m_isClosing; }
|
2012-03-14 14:04:20 +01:00
|
|
|
inline bool isStartingAfterCrash() { return m_startingAfterCrash; }
|
2011-05-10 21:25:31 +02:00
|
|
|
inline int windowCount() { return m_mainWindows.count(); }
|
|
|
|
|
2011-04-07 18:00:26 +02:00
|
|
|
bool checkSettingsDir();
|
2012-08-21 20:28:38 +02:00
|
|
|
void destroyRestoreManager();
|
2012-11-27 19:14:03 +01:00
|
|
|
void clearTempPath();
|
2011-10-29 18:37:28 +02:00
|
|
|
|
2012-09-03 13:24:29 +02:00
|
|
|
void setProxyStyle(ProxyStyle* style);
|
|
|
|
QString currentStyle() const;
|
2012-11-27 19:14:03 +01:00
|
|
|
QString tempPath() const;
|
2012-09-03 13:24:29 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QupZilla* getWindow();
|
|
|
|
CookieManager* cookieManager();
|
2011-07-29 15:39:43 +02:00
|
|
|
BrowsingLibrary* browsingLibrary();
|
2012-04-30 16:33:14 +02:00
|
|
|
History* history();
|
2011-03-02 16:57:41 +01:00
|
|
|
QWebSettings* webSettings();
|
|
|
|
NetworkManager* networkManager();
|
|
|
|
CookieJar* cookieJar();
|
|
|
|
RSSManager* rssManager();
|
|
|
|
PluginProxy* plugins();
|
2011-04-15 20:45:22 +02:00
|
|
|
BookmarksModel* bookmarksModel();
|
2011-03-02 16:57:41 +01:00
|
|
|
DownloadManager* downManager();
|
2013-01-24 17:47:50 +01:00
|
|
|
AutoFill* autoFill();
|
2011-10-21 23:26:34 +02:00
|
|
|
SearchEnginesManager* searchEnginesManager();
|
2012-06-15 17:43:19 +02:00
|
|
|
QNetworkDiskCache* networkCache();
|
2011-04-24 22:40:35 +02:00
|
|
|
DesktopNotificationsFactory* desktopNotifications();
|
2013-01-19 17:28:12 +01:00
|
|
|
HTML5PermissionsManager* html5permissions();
|
2012-08-16 23:15:31 +02:00
|
|
|
|
2011-12-08 19:12:43 +01:00
|
|
|
DatabaseWriter* dbWriter() { return m_dbWriter; }
|
2012-08-16 23:15:31 +02:00
|
|
|
UserAgentManager* uaManager() { return m_uaManager; }
|
2012-08-21 20:28:38 +02:00
|
|
|
RestoreManager* restoreManager() { return m_restoreManager; }
|
2013-01-29 20:34:14 +01:00
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
2012-12-01 07:50:31 +01:00
|
|
|
RegisterQAppAssociation* associationManager();
|
2013-01-29 20:34:14 +01:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_MAC
|
2012-01-12 20:10:51 +01:00
|
|
|
bool event(QEvent* e);
|
|
|
|
#endif
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
public slots:
|
|
|
|
bool saveStateSlot();
|
|
|
|
void quitApplication();
|
2012-01-21 23:19:38 +01:00
|
|
|
void sendMessages(Qz::AppMessageType mes, bool state);
|
2011-03-02 16:57:41 +01:00
|
|
|
void receiveAppMessage(QString message);
|
2011-07-28 12:12:00 +02:00
|
|
|
void setStateChanged();
|
2012-01-06 15:03:48 +01:00
|
|
|
void addNewTab(const QUrl &url = QUrl());
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-06-26 11:49:39 +02:00
|
|
|
void startPrivateBrowsing();
|
2012-07-04 17:53:49 +02:00
|
|
|
void reloadUserStyleSheet();
|
2012-12-01 07:50:31 +01:00
|
|
|
bool checkDefaultWebBrowser();
|
2012-06-26 11:49:39 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
signals:
|
2012-01-21 23:19:38 +01:00
|
|
|
void message(Qz::AppMessageType mes, bool state);
|
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-05-06 20:05:49 +02:00
|
|
|
void setupJumpList();
|
2011-10-22 22:29:33 +02:00
|
|
|
void restoreCursor();
|
2011-03-29 19:55:21 +02:00
|
|
|
|
2012-01-12 20:10:51 +01:00
|
|
|
void saveSettings();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
2012-07-10 00:36:05 +02:00
|
|
|
enum PostLaunchAction { OpenDownloadManager, OpenNewTab };
|
2011-12-30 16:54:37 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void translateApp();
|
|
|
|
void restoreOtherWindows();
|
|
|
|
|
2013-01-31 11:53:48 +01:00
|
|
|
QUrl userStyleSheet(const QString &filePath) const;
|
2012-06-25 16:07:25 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
CookieManager* m_cookiemanager;
|
2011-07-29 15:39:43 +02:00
|
|
|
BrowsingLibrary* m_browsingLibrary;
|
2012-04-30 16:33:14 +02:00
|
|
|
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;
|
2013-01-24 17:47:50 +01:00
|
|
|
AutoFill* m_autofill;
|
2011-03-23 22:36:03 +01:00
|
|
|
QNetworkDiskCache* m_networkCache;
|
2011-04-24 22:40:35 +02:00
|
|
|
DesktopNotificationsFactory* m_desktopNotifications;
|
2011-10-21 23:26:34 +02:00
|
|
|
SearchEnginesManager* m_searchEnginesManager;
|
2012-08-21 20:28:38 +02:00
|
|
|
RestoreManager* m_restoreManager;
|
2012-09-03 13:24:29 +02:00
|
|
|
ProxyStyle* m_proxyStyle;
|
2013-01-19 17:28:12 +01:00
|
|
|
HTML5PermissionsManager* m_html5permissions;
|
2011-12-08 19:12:43 +01:00
|
|
|
DatabaseWriter* m_dbWriter;
|
2012-08-16 23:15:31 +02:00
|
|
|
UserAgentManager* m_uaManager;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-12-20 14:45:35 +01:00
|
|
|
QList<QPointer<QupZilla> > m_mainWindows;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
QString m_activeProfil;
|
|
|
|
QString m_activeLanguage;
|
2011-09-11 19:15:06 +02:00
|
|
|
QString m_activeThemePath;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-06-26 11:49:39 +02:00
|
|
|
bool m_isPrivateSession;
|
2011-03-02 16:57:41 +01:00
|
|
|
bool m_isClosing;
|
2011-07-28 12:12:00 +02:00
|
|
|
bool m_isStateChanged;
|
2011-04-07 18:00:26 +02:00
|
|
|
bool m_isRestoring;
|
2012-03-14 14:04:20 +01:00
|
|
|
bool m_startingAfterCrash;
|
2011-10-24 17:46:45 +02:00
|
|
|
|
|
|
|
bool m_databaseConnected;
|
2011-12-30 16:54:37 +01:00
|
|
|
QList<PostLaunchAction> m_postLaunchActions;
|
2012-12-01 07:50:31 +01:00
|
|
|
|
2013-01-29 20:34:14 +01:00
|
|
|
#ifdef Q_OS_WIN
|
2012-12-01 07:50:31 +01:00
|
|
|
RegisterQAppAssociation* m_registerQAppAssociation;
|
2013-01-29 20:34:14 +01:00
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINAPPLICATION_H
|