void MainWindow::createActions() { refreshAction = new QAction(tr("&Refresh"), this); controlAction = new QAction(tr("&Control Monitor"), this); connect(controlAction, SIGNAL(triggered()), this, SLOT(showMonitor())); exitAction = new QAction(tr("&Exit"), this); exitAction->setShortcut(QKeySequence::Quit); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); }
void *NetmonitorPlugin::processEvent(Event *e) { if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdNetMonitor){ showMonitor(); return monitor; } } return NULL; }
NetmonitorPlugin::NetmonitorPlugin(unsigned base, const char *config) : Plugin(base) { load_data(monitorData, &data, config); if (getLogPackets()){ string packets = getLogPackets(); while (packets.length()){ string v = getToken(packets, ','); setLogType(atol(v.c_str()), true); } } monitor = NULL; CmdNetMonitor = registerType(); IconDef icon; icon.name = "network"; icon.xpm = network; icon.isSystem = false; Event eIcon(EventAddIcon, &icon); eIcon.process(); Command cmd; cmd->id = CmdNetMonitor; cmd->text = I18N_NOOP("Network monitor"); cmd->icon = "network"; cmd->bar_id = ToolBarMain; cmd->menu_id = MenuMain; cmd->menu_grp = 0x8000; cmd->flags = COMMAND_DEFAULT; Event eCmd(EventCommandCreate, cmd); eCmd.process(); string value; CmdParam p = { "-m", I18N_NOOP("Show network monitor"), &value }; Event e(EventArg, &p); if (e.process() || getShow()) showMonitor(); }