1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #include "core/feedsmodel.h" 4 #include "definitions/definitions.h" 5 #include "gui/dialogs/formmain.h" 6 #include "gui/feedmessageviewer.h" 7 #include "gui/feedsview.h" 8 #include "miscellaneous/application.h" 9 #include "services/abstract/label.h" 10 11 #if defined(Q_OS_WIN) 12 #include <QtPlatformHeaders/QWindowsWindowFunctions> 13 #endif 14 15 #if defined(Q_OS_MACOS) 16 extern void disableWindowTabbing(); 17 18 #endif 19 main(int argc,char * argv[])20int main(int argc, char* argv[]) { 21 qSetMessagePattern(QSL("time=\"%{time process}\" type=\"%{type}\" -> %{message}")); 22 23 #if QT_VERSION_MAJOR <= 5 24 QApplication::setAttribute(Qt::ApplicationAttribute::AA_UseHighDpiPixmaps); 25 QApplication::setAttribute(Qt::ApplicationAttribute::AA_EnableHighDpiScaling); 26 #endif 27 28 #if defined(Q_OS_UNIX) 29 QApplication::setDesktopFileName(APP_DESKTOP_ENTRY_FILE); 30 #endif 31 32 // Ensure that ini format is used as application settings storage on Mac OS. 33 QSettings::setDefaultFormat(QSettings::IniFormat); 34 35 #if defined(Q_OS_MACOS) 36 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); 37 disableWindowTabbing(); 38 #endif 39 40 // Instantiate base application object. 41 Application application(QSL(APP_LOW_NAME), argc, argv); 42 43 qDebugNN << LOGSEC_CORE << "Starting" << NONQUOTE_W_SPACE_DOT(APP_LONG_NAME); 44 qDebugNN << LOGSEC_CORE << "Instantiated class " << QUOTE_W_SPACE_DOT(application.metaObject()->className()); 45 46 // Check if another instance is running. 47 if (application.isAlreadyRunning()) { 48 qWarningNN << LOGSEC_CORE << "Another instance of the application is already running. Notifying it."; 49 return EXIT_FAILURE; 50 } 51 52 // Load localization and setup locale before any widget is constructed. 53 qApp->localization()->loadActiveLanguage(); 54 qApp->setFeedReader(new FeedReader(&application)); 55 56 // Register needed metatypes. 57 qRegisterMetaType<QList<Message>>("QList<Message>"); 58 qRegisterMetaType<QList<RootItem*>>("QList<RootItem*>"); 59 qRegisterMetaType<QList<Label*>>("QList<Label*>"); 60 qRegisterMetaType<Label*>("Label*"); 61 62 // Add an extra path for non-system icon themes and set current icon theme 63 // and skin. 64 qApp->icons()->setupSearchPaths(); 65 qApp->icons()->loadCurrentIconTheme(); 66 qApp->skins()->loadCurrentSkin(); 67 68 // These settings needs to be set before any QSettings object. 69 Application::setApplicationName(QSL(APP_NAME)); 70 Application::setApplicationVersion(QSL(APP_VERSION)); 71 Application::setOrganizationDomain(QSL(APP_URL)); 72 Application::setWindowIcon(qApp->desktopAwareIcon()); 73 74 qApp->reactOnForeignNotifications(); 75 76 #ifdef Q_OS_WIN 77 QWindowsWindowFunctions::setWindowActivationBehavior(QWindowsWindowFunctions::AlwaysActivateWindow); 78 #endif 79 80 FormMain main_window; 81 82 qApp->loadDynamicShortcuts(); 83 qApp->hideOrShowMainForm(); 84 qApp->feedReader()->loadSavedMessageFilters(); 85 qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts(); 86 qApp->showTrayIcon(); 87 qApp->offerChanges(); 88 qApp->showPolls(); 89 qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates(); 90 qApp->parseCmdArgumentsFromOtherInstance(qApp->cmdParser()->positionalArguments().join(QSL(ARGUMENTS_LIST_SEPARATOR))); 91 92 return Application::exec(); 93 } 94