QMenu *MainWindow::serverMenu(DVRServer *server) { QMenu *m = static_cast<QMenu*>(server->property("uiMenu").value<QObject*>()); if (m) return m; ServerMenu *menu = new ServerMenu(server, server->configuration().displayName()); connect(menu, SIGNAL(openServerConfig()), SLOT(openServerConfig())); connect(menu, SIGNAL(openServerSettings()), SLOT(openServerSettings())); connect(menu, SIGNAL(showEventsWindow()), SLOT(showEventsWindow())); server->setProperty("uiMenu", QVariant::fromValue<QObject*>(menu)); return menu; }
void ServerMenu::createActions() { m_connectAction = addAction(tr("Connect"), m_server, SLOT(toggleOnline())); addSeparator(); m_browseEventsAction = addAction(tr("Browse &events"), this, SIGNAL(showEventsWindow())); m_browseEventsAction->setEnabled(m_server->isOnline()); connect(m_server, SIGNAL(onlineChanged(bool)), m_browseEventsAction, SLOT(setEnabled(bool))); m_configureServerAction = addAction(tr("&Configure server"), this, SIGNAL(openServerConfig())); m_configureServerAction->setEnabled(m_server->isOnline()); connect(m_server, SIGNAL(onlineChanged(bool)), m_configureServerAction, SLOT(setEnabled(bool))); addSeparator(); m_configureServerAction = addAction(tr("Refresh devices"), m_server, SLOT(updateCameras())); m_configureServerAction->setEnabled(m_server->isOnline()); connect(m_server, SIGNAL(onlineChanged(bool)), m_configureServerAction, SLOT(setEnabled(bool))); m_configureServerAction = addAction(tr("Settings"), this, SIGNAL(openServerSettings())); updateMenuForServer(); }