2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2011-12-15 18:34:48 +01:00
|
|
|
* Copyright (C) 2010-2011 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-05-04 18:22:54 +02:00
|
|
|
#define mStyle MainApplication::appStyle
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QWebSettings>
|
|
|
|
#include <QUrl>
|
2011-12-09 21:56:01 +01:00
|
|
|
#include <QWeakPointer>
|
2011-03-23 22:36:03 +01:00
|
|
|
#include <QNetworkDiskCache>
|
2011-12-02 23:25:27 +01:00
|
|
|
#include <QWebSecurityOrigin>
|
2011-03-02 16:57:41 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "qtsingleapplication.h"
|
2011-05-18 22:58:49 +02:00
|
|
|
#include "commandlineoptions.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
class QupZilla;
|
|
|
|
class CookieManager;
|
2011-07-29 15:39:43 +02:00
|
|
|
class BrowsingLibrary;
|
2011-03-02 16:57:41 +01:00
|
|
|
class HistoryModel;
|
|
|
|
class NetworkManager;
|
|
|
|
class CookieJar;
|
|
|
|
class RSSManager;
|
|
|
|
class Updater;
|
|
|
|
class PluginProxy;
|
|
|
|
class BookmarksModel;
|
|
|
|
class DownloadManager;
|
|
|
|
class AutoFillModel;
|
2011-04-24 22:40:35 +02:00
|
|
|
class DesktopNotificationsFactory;
|
2011-04-25 20:56:45 +02:00
|
|
|
class IconProvider;
|
2011-05-04 18:22:54 +02:00
|
|
|
class Style;
|
2011-10-21 23:26:34 +02:00
|
|
|
class SearchEnginesManager;
|
2011-12-08 19:12:43 +01:00
|
|
|
class DatabaseWriter;
|
2011-03-02 16:57:41 +01:00
|
|
|
class MainApplication : public QtSingleApplication
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
QString DATADIR;
|
2011-12-28 14:55:54 +01:00
|
|
|
QString PROFILEDIR;
|
2011-09-11 19:15:06 +02:00
|
|
|
QString PLUGINSDIR;
|
|
|
|
QString TRANSLATIONSDIR;
|
|
|
|
QString THEMESDIR;
|
2011-12-28 14:55:54 +01:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
explicit MainApplication(const QList<CommandLineOptions::ActionPair> &cmdActions, int &argc, char** argv);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-12-26 20:23:54 +01:00
|
|
|
enum MessageType { SetAdBlockIconEnabled, CheckPrivateBrowsing, ReloadSettings,
|
2011-12-27 19:10:53 +01:00
|
|
|
HistoryStateChanged, BookmarksChanged, StartPrivateBrowsing
|
|
|
|
};
|
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();
|
2011-07-11 21:08:41 +02:00
|
|
|
void reloadSettings() { loadSettings(); emit message(ReloadSettings, true); }
|
2011-03-02 16:57:41 +01:00
|
|
|
bool restoreStateSlot(QupZilla* window);
|
2011-12-27 12:27:39 +01:00
|
|
|
QupZilla* makeNewWindow(bool tryRestore, const QUrl &startUrl = QUrl());
|
2011-05-18 22:58:49 +02:00
|
|
|
void addNewTab(const QUrl &url = 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
|
|
|
|
|
|
|
inline static MainApplication* getInstance() { return static_cast<MainApplication*>(QCoreApplication::instance()); }
|
2011-09-11 19:15:06 +02:00
|
|
|
inline QString getActiveProfilPath() { return m_activeProfil; }
|
2011-03-02 16:57:41 +01:00
|
|
|
inline QString getActiveLanguage() { return m_activeLanguage; }
|
|
|
|
inline bool isClosing() { return m_isClosing; }
|
|
|
|
inline bool isExited() { return m_isExited; }
|
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();
|
2011-10-29 18:37:28 +02:00
|
|
|
int defaultZoom() { return m_defaultZoom; }
|
|
|
|
|
2011-12-30 16:54:37 +01:00
|
|
|
void togglePrivateBrowsingMode(bool state);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QupZilla* getWindow();
|
|
|
|
CookieManager* cookieManager();
|
2011-07-29 15:39:43 +02:00
|
|
|
BrowsingLibrary* browsingLibrary();
|
2011-03-02 16:57:41 +01:00
|
|
|
HistoryModel* history();
|
|
|
|
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();
|
|
|
|
AutoFillModel* autoFill();
|
2011-10-21 23:26:34 +02:00
|
|
|
SearchEnginesManager* searchEnginesManager();
|
2011-03-23 22:36:03 +01:00
|
|
|
QNetworkDiskCache* networkCache() { return m_networkCache; }
|
2011-04-24 22:40:35 +02:00
|
|
|
DesktopNotificationsFactory* desktopNotifications();
|
2011-04-25 20:56:45 +02:00
|
|
|
IconProvider* iconProvider() { return m_iconProvider; }
|
2011-12-08 19:12:43 +01:00
|
|
|
DatabaseWriter* dbWriter() { return m_dbWriter; }
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-05-04 18:22:54 +02:00
|
|
|
static Style* appStyle;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
public slots:
|
|
|
|
bool saveStateSlot();
|
|
|
|
void quitApplication();
|
|
|
|
void sendMessages(MainApplication::MessageType mes, bool state);
|
|
|
|
void receiveAppMessage(QString message);
|
2011-07-28 12:12:00 +02:00
|
|
|
void setStateChanged();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void message(MainApplication::MessageType mes, bool state);
|
|
|
|
|
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
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
2011-12-30 16:54:37 +01:00
|
|
|
enum PostLaunchAction { PrivateBrowsing, OpenDownloadManager, OpenNewTab };
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void translateApp();
|
|
|
|
void restoreOtherWindows();
|
|
|
|
|
|
|
|
CookieManager* m_cookiemanager;
|
2011-07-29 15:39:43 +02:00
|
|
|
BrowsingLibrary* m_browsingLibrary;
|
2011-03-02 16:57:41 +01:00
|
|
|
HistoryModel* m_historymodel;
|
|
|
|
QWebSettings* m_websettings;
|
|
|
|
NetworkManager* m_networkmanager;
|
|
|
|
CookieJar* m_cookiejar;
|
|
|
|
RSSManager* m_rssmanager;
|
|
|
|
Updater* m_updater;
|
|
|
|
PluginProxy* m_plugins;
|
|
|
|
BookmarksModel* m_bookmarksModel;
|
|
|
|
DownloadManager* m_downloadManager;
|
|
|
|
AutoFillModel* 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-04-25 20:56:45 +02:00
|
|
|
IconProvider* m_iconProvider;
|
2011-10-21 23:26:34 +02:00
|
|
|
SearchEnginesManager* m_searchEnginesManager;
|
2011-12-08 19:12:43 +01:00
|
|
|
DatabaseWriter* m_dbWriter;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-12-09 21:56:01 +01:00
|
|
|
QList<QWeakPointer<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-10-29 18:37:28 +02:00
|
|
|
int m_defaultZoom;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
bool m_isClosing;
|
2011-07-28 12:12:00 +02:00
|
|
|
bool m_isStateChanged;
|
2011-03-02 16:57:41 +01:00
|
|
|
bool m_isExited;
|
2011-04-07 18:00:26 +02:00
|
|
|
bool m_isRestoring;
|
2011-10-24 17:46:45 +02:00
|
|
|
|
|
|
|
bool m_databaseConnected;
|
2011-12-30 16:54:37 +01:00
|
|
|
QList<PostLaunchAction> m_postLaunchActions;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINAPPLICATION_H
|