Kernel::Kernel(const RuntimeConfiguration &config, QObject *parent) : QObject(parent) , m_runtimeConfiguration(config) , m_storage(new JsonStorage(this, this)) , m_qmlEngine(new QQmlEngine(0)) // leak the engine, no point in wasting shutdown time. Also we get a qmldebug server crash if it's parented to qApp, which Kernel is , m_settings(config.settings() ? config.settings() : new Settings(this)) , m_controller(new Controller(m_qmlEngine->rootContext(), this, m_storage, m_settings, this)) , m_pluginModel(new PluginModel(this)) #ifndef NO_WEBDAV , m_webDavSyncer(new WebDAVSyncer(this)) #endif #if defined(QT_WIDGETS_LIB) && !defined(QT_NO_SYSTRAY) , m_systrayIcon(0) , m_trayMenu(0) #endif { QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fontawesome-webfont.ttf")); QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/open-sans/OpenSans-Regular.ttf")); qApp->setFont(QFont(QStringLiteral("Open Sans"))); m_qmlEngine->rootContext()->setObjectName(QStringLiteral("QQmlContext")); // GammaRay convenience registerQmlTypes(); qmlContext()->setContextProperty(QStringLiteral("_controller"), m_controller); qmlContext()->setContextProperty(QStringLiteral("_storage"), m_storage); qmlContext()->setContextProperty(QStringLiteral("_pluginModel"), m_pluginModel); qmlContext()->setContextProperty(QStringLiteral("_loadManager"), m_controller->loadManager()); qmlContext()->setContextProperty(QStringLiteral("_settings"), m_settings); #ifndef NO_WEBDAV qmlContext()->setContextProperty("_webdavSync", m_webDavSyncer); #endif connect(m_controller, &Controller::currentTaskChanged, this, &Kernel::onTaskStatusChanged); connect(m_qmlEngine, &QQmlEngine::quit, qGuiApp, &QGuiApplication::quit); QMetaObject::invokeMethod(m_storage, "load", Qt::QueuedConnection); // Schedule a load. Don't do it directly, it will deadlock in instance() QMetaObject::invokeMethod(this, "maybeLoadPlugins", Qt::QueuedConnection); QMetaObject::invokeMethod(m_controller, "updateWebDavCredentials", Qt::QueuedConnection); if (m_runtimeConfiguration.useSystray() && m_settings->useSystray()) setupSystray(); const QDateTime currentDateTime = QDateTime::currentDateTime(); m_currentDate = currentDateTime.date(); connect(&m_dayChangedTimer, &QTimer::timeout, this, &Kernel::checkDayChanged); m_dayChangedTimer.start(5 * 60 * 1000); // every 5 minutes instead of daily in case of suspend // Startup counts as dayChanged, so handlers are run QMetaObject::invokeMethod(this, "dayChanged", Qt::QueuedConnection); }
void MainWin::init() { connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId))); connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId))); connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), SLOT(messagesInserted(const QModelIndex &, int, int))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString))); connect(Client::coreConnection(), SIGNAL(startCoreSetup(QVariantList)), SLOT(showCoreConfigWizard(QVariantList))); connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(handleCoreConnectionError(QString))); connect(Client::coreConnection(), SIGNAL(userAuthenticationRequired(CoreAccount *, bool *, QString)), SLOT(userAuthenticationRequired(CoreAccount *, bool *, QString))); connect(Client::coreConnection(), SIGNAL(handleNoSslInClient(bool*)), SLOT(handleNoSslInClient(bool *))); connect(Client::coreConnection(), SIGNAL(handleNoSslInCore(bool*)), SLOT(handleNoSslInCore(bool *))); #ifdef HAVE_SSL connect(Client::coreConnection(), SIGNAL(handleSslErrors(const QSslSocket *, bool *, bool *)), SLOT(handleSslErrors(const QSslSocket *, bool *, bool *))); #endif // Setup Dock Areas setDockNestingEnabled(true); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); // Order is sometimes important setupActions(); setupBufferWidget(); setupMenus(); setupTopicWidget(); setupNickWidget(); setupInputWidget(); setupChatMonitor(); setupStatusBar(); setupToolBars(); setupSystray(); setupTitleSetter(); setupHotList(); #ifndef HAVE_KDE # ifdef HAVE_PHONON QtUi::registerNotificationBackend(new PhononNotificationBackend(this)); # endif # ifndef QT_NO_SYSTEMTRAYICON QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); # endif QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); #else /* HAVE_KDE */ QtUi::registerNotificationBackend(new KNotificationBackend(this)); #endif /* HAVE_KDE */ #ifdef HAVE_INDICATEQT QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this)); #endif // we assume that at this point, all configurable actions are defined! QtUi::loadShortcuts(); connect(bufferWidget(), SIGNAL(currentChanged(BufferId)), SLOT(currentBufferChanged(BufferId))); setDisconnectedState(); // Disable menus and stuff #ifdef HAVE_KDE setAutoSaveSettings(); #endif // restore mainwin state QtUiSettings s; restoreStateFromSettings(s); // restore locked state of docks QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool()); CoreConnection *conn = Client::coreConnection(); if(!conn->connectToCore()) { // No autoconnect selected (or no accounts) showCoreConnectionDlg(); } }
void MainWin::init() { connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId))); connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId))); connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), SLOT(messagesInserted(const QModelIndex &, int, int))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId))); // Setup Dock Areas setDockNestingEnabled(true); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); // Order is sometimes important setupActions(); setupBufferWidget(); setupMenus(); setupTopicWidget(); setupChatMonitor(); setupNickWidget(); setupInputWidget(); setupStatusBar(); setupToolBars(); setupSystray(); setupTitleSetter(); setupHotList(); #ifndef HAVE_KDE QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); # ifdef HAVE_PHONON QtUi::registerNotificationBackend(new PhononNotificationBackend(this)); # endif # ifdef HAVE_DBUS QtUi::registerNotificationBackend(new DesktopNotificationBackend(this)); # endif #else /* HAVE_KDE */ QtUi::registerNotificationBackend(new KNotificationBackend(this)); #endif /* HAVE_KDE */ setDisconnectedState(); // Disable menus and stuff #ifdef HAVE_KDE setAutoSaveSettings(); #endif // restore mainwin state QtUiSettings s; restoreStateFromSettings(s); // restore locked state of docks QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool()); if(Quassel::runMode() != Quassel::Monolithic) { showCoreConnectionDlg(true); // autoconnect if appropriate } else { startInternalCore(); } }