2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
|
|
|
* Copyright (C) 2010-2011 nowrep
|
|
|
|
*
|
|
|
|
* 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 <QToolBar>
|
|
|
|
#include <QWebSettings>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QPointer>
|
2011-03-23 22:36:03 +01:00
|
|
|
#include <QNetworkDiskCache>
|
2011-03-02 16:57:41 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "qtsingleapplication.h"
|
|
|
|
|
|
|
|
class QupZilla;
|
|
|
|
class BookmarksManager;
|
|
|
|
class CookieManager;
|
|
|
|
class HistoryManager;
|
|
|
|
class HistoryModel;
|
|
|
|
class NetworkManager;
|
|
|
|
class CookieJar;
|
|
|
|
class RSSManager;
|
|
|
|
class Updater;
|
|
|
|
class PluginProxy;
|
|
|
|
class BookmarksModel;
|
|
|
|
class DownloadManager;
|
|
|
|
class AutoFillModel;
|
|
|
|
|
|
|
|
class MainApplication : public QtSingleApplication
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
QString DATADIR;
|
|
|
|
explicit MainApplication(int &argc, char **argv);
|
|
|
|
|
2011-03-29 20:30:05 +02:00
|
|
|
enum MessageType{ SetAdBlockIconEnabled, CheckPrivateBrowsing };
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
void loadSettings();
|
|
|
|
bool restoreStateSlot(QupZilla* window);
|
|
|
|
void makeNewWindow(bool tryRestore, const QUrl &startUrl=QUrl());
|
|
|
|
void addNewTab(QUrl url);
|
|
|
|
void aboutToCloseWindow(QupZilla* window);
|
|
|
|
bool isChanged();
|
|
|
|
|
|
|
|
inline static MainApplication* getInstance() { return static_cast<MainApplication*>(QCoreApplication::instance()); }
|
|
|
|
inline QString getActiveProfil() { return m_activeProfil; }
|
|
|
|
inline QString getActiveLanguage() { return m_activeLanguage; }
|
|
|
|
inline bool isClosing() { return m_isClosing; }
|
|
|
|
inline bool isExited() { return m_isExited; }
|
2011-04-07 18:00:26 +02:00
|
|
|
bool checkSettingsDir();
|
|
|
|
void checkProfile(QString path);
|
2011-03-05 13:16:13 +01:00
|
|
|
inline int windowCount() { return m_mainWindows.count(); }
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
QupZilla* getWindow();
|
|
|
|
BookmarksManager* bookmarksManager();
|
|
|
|
CookieManager* cookieManager();
|
|
|
|
HistoryManager* historyManager();
|
|
|
|
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-03-23 22:36:03 +01:00
|
|
|
QNetworkDiskCache* networkCache() { return m_networkCache; }
|
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);
|
|
|
|
inline void setChanged() { m_isChanged = true; }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void message(MainApplication::MessageType mes, bool state);
|
|
|
|
|
2011-03-29 19:55:21 +02:00
|
|
|
private slots:
|
|
|
|
void restoreCursor() { QApplication::restoreOverrideCursor(); }
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
|
|
|
void connectDatabase();
|
|
|
|
void translateApp();
|
|
|
|
void restoreOtherWindows();
|
|
|
|
|
|
|
|
BookmarksManager* m_bookmarksmanager;
|
|
|
|
CookieManager* m_cookiemanager;
|
|
|
|
HistoryManager* m_historymanager;
|
|
|
|
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-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
QList<QPointer<QupZilla> > m_mainWindows;
|
|
|
|
|
|
|
|
QString m_activeProfil;
|
|
|
|
QString m_activeLanguage;
|
|
|
|
|
|
|
|
bool m_isClosing;
|
|
|
|
bool m_isChanged;
|
|
|
|
bool m_isExited;
|
2011-04-07 18:00:26 +02:00
|
|
|
bool m_isRestoring;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINAPPLICATION_H
|