1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 11:02:19 +01:00
falkonOfficial/src/app/mainapplication.h

156 lines
4.8 KiB
C
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
* 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()
#define mStyle MainApplication::appStyle
2011-03-02 16:57:41 +01:00
#include <QToolBar>
#include <QWebSettings>
#include <QUrl>
#include <QWeakPointer>
#include <QNetworkDiskCache>
#include <QWebSecurityOrigin>
2011-03-02 16:57:41 +01:00
#include <iostream>
#include "qtsingleapplication.h"
#include "commandlineoptions.h"
2011-03-02 16:57:41 +01:00
class QupZilla;
class CookieManager;
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;
class DesktopNotificationsFactory;
class IconProvider;
class Style;
class SearchEnginesManager;
class DatabaseWriter;
2011-03-02 16:57:41 +01:00
class MainApplication : public QtSingleApplication
{
Q_OBJECT
public:
QString DATADIR;
QString PLUGINSDIR;
QString TRANSLATIONSDIR;
QString THEMESDIR;
explicit MainApplication(const QList<CommandLineOptions::ActionPair> &cmdActions, int &argc, char** argv);
2011-03-02 16:57:41 +01:00
enum MessageType { SetAdBlockIconEnabled, CheckPrivateBrowsing, ReloadSettings, HistoryStateChanged, BookmarksChanged };
2011-03-02 16:57:41 +01:00
void connectDatabase();
2011-03-02 16:57:41 +01:00
void loadSettings();
void reloadSettings() { loadSettings(); emit message(ReloadSettings, true); }
2011-03-02 16:57:41 +01:00
bool restoreStateSlot(QupZilla* window);
void makeNewWindow(bool tryRestore, const QUrl &startUrl = QUrl());
void addNewTab(const QUrl &url = QUrl());
2011-03-02 16:57:41 +01:00
void aboutToCloseWindow(QupZilla* window);
bool isStateChanged();
2011-03-02 16:57:41 +01:00
inline static MainApplication* getInstance() { return static_cast<MainApplication*>(QCoreApplication::instance()); }
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; }
inline int windowCount() { return m_mainWindows.count(); }
bool checkSettingsDir();
2011-03-02 16:57:41 +01:00
int defaultZoom() { return m_defaultZoom; }
2011-03-02 16:57:41 +01:00
QupZilla* getWindow();
CookieManager* cookieManager();
BrowsingLibrary* browsingLibrary();
2011-03-02 16:57:41 +01:00
HistoryModel* history();
QWebSettings* webSettings();
NetworkManager* networkManager();
CookieJar* cookieJar();
RSSManager* rssManager();
PluginProxy* plugins();
BookmarksModel* bookmarksModel();
2011-03-02 16:57:41 +01:00
DownloadManager* downManager();
AutoFillModel* autoFill();
SearchEnginesManager* searchEnginesManager();
QNetworkDiskCache* networkCache() { return m_networkCache; }
DesktopNotificationsFactory* desktopNotifications();
IconProvider* iconProvider() { return m_iconProvider; }
DatabaseWriter* dbWriter() { return m_dbWriter; }
2011-03-02 16:57:41 +01: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);
void setStateChanged();
2011-03-02 16:57:41 +01:00
signals:
void message(MainApplication::MessageType mes, bool state);
private slots:
void setupJumpList();
void restoreCursor();
2011-03-02 16:57:41 +01:00
private:
void translateApp();
void restoreOtherWindows();
CookieManager* m_cookiemanager;
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;
QNetworkDiskCache* m_networkCache;
DesktopNotificationsFactory* m_desktopNotifications;
IconProvider* m_iconProvider;
SearchEnginesManager* m_searchEnginesManager;
DatabaseWriter* m_dbWriter;
2011-03-02 16:57:41 +01:00
QList<QWeakPointer<QupZilla> > m_mainWindows;
2011-03-02 16:57:41 +01:00
QString m_activeProfil;
QString m_activeLanguage;
QString m_activeThemePath;
int m_defaultZoom;
2011-03-02 16:57:41 +01:00
bool m_isClosing;
bool m_isStateChanged;
2011-03-02 16:57:41 +01:00
bool m_isExited;
bool m_isRestoring;
bool m_databaseConnected;
2011-03-02 16:57:41 +01:00
};
#endif // MAINAPPLICATION_H