void SessionMgr::initMenu(QMenu *menu) { m_menus.insert(menu); if(m_sessions.empty()) { QAction *empty = menu->addAction(tr("No saved sessions")); empty->setEnabled(false); } else { for(int i = 0; i < m_sessions.size(); ++i) { QAction *act = menu->addAction(m_sessions[i].remove(".cldta")); m_sig_map->setMapping(act, act->text()); connect(act, SIGNAL(triggered()), m_sig_map, SLOT(map())); } } menu->addSeparator(); QAction *saveAct = menu->addAction(tr("Save this session...")); QAction *managerAct = menu->addAction(tr("Session manager...")); connect(saveAct, SIGNAL(triggered()), SLOT(saveSessionAct())); connect(managerAct, SIGNAL(triggered()), SLOT(openManager())); connect(menu, SIGNAL(destroyed(QObject*)), SLOT(removeMenu(QObject*))); }
void MainWidget::createTrayIcon() { trayIcon = createTrayObject(this); trayIcon->init(); #ifndef Q_OS_WIN32 trayIcon->setIcon("qcma_off"); #else trayIcon->setIcon("tray/qcma_off_16"); #endif trayIcon->show(); connect(trayIcon, SIGNAL(openConfig()), this, SLOT(openConfig())); connect(trayIcon, SIGNAL(openManager()), this, SLOT(openManager())); connect(trayIcon, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase())); connect(trayIcon, SIGNAL(showAboutDialog()), this, SLOT(showAboutDialog())); connect(trayIcon, SIGNAL(showAboutQt()), this, SLOT(showAboutQt())); connect(trayIcon, SIGNAL(stopServer()), this, SLOT(stopServer())); connect(managerForm, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnect(QString))); connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect())); connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString))); }
void KDENotifierTray::init() { options = new QAction(tr("Settings"), this); reload = new QAction(tr("Refresh database"), this); backup = new QAction(tr("Backup Manager"), this); about = new QAction(tr("About QCMA"), this); about_qt = new QAction(tr("About Qt"), this); quit = new QAction(tr("Quit"), this); connect(options, SIGNAL(triggered()), this, SIGNAL(openConfig())); connect(backup, SIGNAL(triggered()), this, SIGNAL(openManager())); connect(reload, SIGNAL(triggered()), this, SIGNAL(refreshDatabase())); connect(about, SIGNAL(triggered()), this, SIGNAL(showAboutDialog())); connect(about_qt, SIGNAL(triggered()), this, SIGNAL(showAboutQt())); connect(quit, SIGNAL(triggered()), this, SIGNAL(stopServer())); #if QT_VERSION < 0x050000 KMenu *tray_icon_menu = new KMenu(this); #else QMenu *tray_icon_menu = new QMenu(this); #endif tray_icon_menu->addAction(options); tray_icon_menu->addAction(reload); tray_icon_menu->addAction(backup); tray_icon_menu->addSeparator(); tray_icon_menu->addAction(about); tray_icon_menu->addAction(about_qt); tray_icon_menu->addSeparator(); tray_icon_menu->addAction(quit); m_notifier_item = new KDENotifier("QcmaNotifier", this); m_notifier_item->setContextMenu(tray_icon_menu); m_notifier_item->setTitle("Qcma"); m_notifier_item->setCategory(KStatusNotifierItem::ApplicationStatus); m_notifier_item->setIconByPixmap(QIcon(":/main/resources/images/qcma_off.png")); m_notifier_item->setStatus(KStatusNotifierItem::Active); m_notifier_item->setToolTipTitle(tr("Qcma status")); m_notifier_item->setToolTipIconByPixmap(QIcon(":/main/resources/images/qcma.png")); m_notifier_item->setToolTipSubTitle(tr("Disconnected")); m_notifier_item->setStandardActionsEnabled(false); }