1 /* ============================================================ 2 * QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader 3 * Copyright (C) 2011-2020 QuiteRSS Team <quiterssteam@gmail.com> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * ============================================================ */ 18 #ifndef MAINAPPLICATION_H 19 #define MAINAPPLICATION_H 20 21 #define mainApp MainApplication::getInstance() 22 23 #ifdef HAVE_QT5 24 #include <QtWidgets> 25 #else 26 #include <QtGui> 27 #endif 28 #include <qtsingleapplication.h> 29 #include <QNetworkDiskCache> 30 #include <QLocale> 31 #include <QLibraryInfo> 32 #include <QNetworkProxy> 33 34 #include "cookiejar.h" 35 #include "downloadmanager.h" 36 #include "mainwindow.h" 37 #include "ganalytics.h" 38 39 class NetworkManager; 40 class SplashScreen; 41 class UpdateFeeds; 42 43 class MainApplication : public QtSingleApplication 44 { 45 Q_OBJECT 46 public: 47 explicit MainApplication(int &argc, char** argv); 48 ~MainApplication(); 49 50 static MainApplication *getInstance(); 51 52 bool isPortable() const; 53 bool isPortableAppsCom() const; 54 void setClosing(); 55 bool isClosing() const; 56 bool isNoDebugOutput() const; 57 void showClosingWidget(); 58 59 QString resourcesDir() const; 60 QString dataDir() const; 61 QString absolutePath(const QString &path) const; 62 QString dbFileName() const; 63 QString cacheDefaultDir() const; 64 QString soundNotifyDefaultFile() const; 65 QString styleSheetNewsDefaultFile() const; 66 QString styleSheetWebDarkFile() const; 67 68 bool storeDBMemory() const; dbFileExists()69 bool dbFileExists() const { return dbFileExists_; } 70 bool isSaveDataLastFeed() const; 71 void sqlQueryExec(const QString &query); 72 73 MainWindow *mainWindow(); 74 NetworkManager *networkManager(); 75 CookieJar *cookieJar(); 76 void setDiskCache(); 77 UpdateFeeds *updateFeeds(); 78 void runUserFilter(int feedId, int filterId); 79 DownloadManager *downloadManager(); 80 81 void c2fLoadSettings(); 82 void c2fSaveSettings(); 83 bool c2fIsEnabled() const; 84 void c2fSetEnabled(bool enabled); 85 QStringList c2fGetWhitelist(); 86 void c2fSetWhitelist(QStringList whitelist); 87 void c2fAddWhitelist(const QString &site); 88 89 void setTranslateApplication(); language()90 QString language() const { return langFileName_; } setLanguage(const QString & lang)91 void setLanguage(const QString &lang) { langFileName_ = lang; } 92 analytics()93 GAnalytics *analytics() const { return analytics_; } 94 networkProxy()95 QNetworkProxy networkProxy() const { return networkProxy_; } 96 void proxyLoadSettings(); 97 void proxySaveSettings(const QNetworkProxy &proxy); 98 99 public slots: 100 void receiveMessage(const QString &message); 101 void quitApplication(); 102 void reloadUserStyleBrowser(); 103 104 signals: 105 void signalRunUserFilter(int feedId, int filterId); 106 void signalSqlQueryExec(const QString &query); 107 108 private slots: 109 void commitData(QSessionManager &manager); 110 111 private: 112 void createSettings(); 113 void createGoogleAnalytics(); 114 void connectDatabase(); 115 void loadSettings(); 116 void setStyleApplication(); 117 void showSplashScreen(); 118 void closeSplashScreen(); 119 void setProgressSplashScreen(int value); 120 121 QUrl userStyleSheet(const QString &filePath) const; 122 123 void setProxy(); 124 125 bool isPortableAppsCom_; 126 bool isClosing_; 127 128 bool storeDBMemory_; 129 bool dbFileExists_; 130 bool isSaveDataLastFeed_; 131 QString styleApplication_; 132 bool showSplashScreen_; 133 bool updateFeedsStartUp_; 134 135 QTranslator *translator_; 136 QTranslator *qt_translator_; 137 QString langFileName_; 138 SplashScreen *splashScreen_; 139 MainWindow *mainWindow_; 140 NetworkManager *networkManager_; 141 CookieJar *cookieJar_; 142 QNetworkDiskCache *diskCache_; 143 UpdateFeeds *updateFeeds_; 144 DownloadManager *downloadManager_; 145 QWidget *closingWidget_; 146 147 QStringList c2fWhitelist_; 148 bool c2fEnabled_; 149 150 QNetworkProxy networkProxy_; 151 GAnalytics *analytics_; 152 153 }; 154 155 #endif // MAINAPPLICATION_H 156