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
|
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>
|
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;
|
2012-02-29 18:33:50 +01:00
|
|
|
class QNetworkDiskCache;
|
2015-01-27 11:01:52 +01:00
|
|
|
class QNetworkAccessManager;
|
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 RSSManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
class ProxyStyle;
|
2011-03-02 16:57:41 +01:00
|
|
|
class PluginProxy;
|
2014-03-10 00:47:07 +01:00
|
|
|
class BrowserWindow;
|
|
|
|
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;
|
2014-01-02 15:26:44 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT MainApplication : public QtSingleApplication
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
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());
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-03-03 20:18:34 +01:00
|
|
|
ProxyStyle* proxyStyle() const;
|
2012-09-03 13:24:29 +02:00
|
|
|
void setProxyStyle(ProxyStyle* style);
|
2013-03-03 20:18:34 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
// Name of current Qt style
|
|
|
|
QString styleName() const;
|
|
|
|
|
|
|
|
// TODO: Move translating into own class (LocaleManager ?)
|
|
|
|
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();
|
2012-06-15 17:43:19 +02:00
|
|
|
QNetworkDiskCache* networkCache();
|
2014-03-10 00:47:07 +01:00
|
|
|
BrowsingLibrary* browsingLibrary();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
RSSManager* rssManager();
|
2015-01-27 11:01:52 +01:00
|
|
|
QNetworkAccessManager* networkManager();
|
2014-03-10 00:47:07 +01:00
|
|
|
RestoreManager* restoreManager();
|
|
|
|
DownloadManager* downloadManager();
|
|
|
|
UserAgentManager* userAgentManager();
|
|
|
|
SearchEnginesManager* searchEnginesManager();
|
|
|
|
HTML5PermissionsManager* html5PermissionsManager();
|
|
|
|
DesktopNotificationsFactory* desktopNotifications();
|
2012-01-12 20:10:51 +01:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
void changeOcurred();
|
|
|
|
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();
|
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
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
void saveSession();
|
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();
|
2014-03-10 00:47:07 +01:00
|
|
|
|
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();
|
2013-12-06 21:26:07 +01:00
|
|
|
void backupSavedSessions();
|
2014-03-10 00:47:07 +01:00
|
|
|
void checkDefaultWebBrowser();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2013-01-31 11:53:48 +01:00
|
|
|
QUrl userStyleSheet(const QString &filePath) const;
|
2012-06-25 16:07:25 +02:00
|
|
|
|
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;
|
|
|
|
QNetworkDiskCache* m_networkCache;
|
|
|
|
BrowsingLibrary* m_browsingLibrary;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
RSSManager* m_rssManager;
|
2015-01-27 11:01:52 +01:00
|
|
|
QNetworkAccessManager* m_networkManager;
|
2014-03-10 00:47:07 +01:00
|
|
|
RestoreManager* m_restoreManager;
|
|
|
|
DownloadManager* m_downloadManager;
|
|
|
|
UserAgentManager* m_userAgentManager;
|
|
|
|
SearchEnginesManager* m_searchEnginesManager;
|
|
|
|
HTML5PermissionsManager* m_html5PermissionsManager;
|
|
|
|
DesktopNotificationsFactory* m_desktopNotifications;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
AutoSaver* m_autoSaver;
|
|
|
|
ProxyStyle* m_proxyStyle;
|
2011-10-24 17:46:45 +02:00
|
|
|
|
2014-03-10 00:47:07 +01:00
|
|
|
QList<BrowserWindow*> m_windows;
|
2014-12-02 19:35:17 +01:00
|
|
|
BrowserWindow* m_lastActiveWindow;
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
2013-02-09 01:17:58 +01:00
|
|
|
#ifdef Q_OS_MAC
|
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
|