void MainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::DoubleClick) showWindow(); else if (reason == QSystemTrayIcon::Trigger) toggleTrayMenuTimer(); else if (reason == QSystemTrayIcon::Context) showTrayMenu(QCursor::pos()); }
void MainWindow::timerEvent(QTimerEvent *event) { if (event->timerId() == trayClickTimer) { stopTrayMenuTimer(); showTrayMenu(trayClickPosition); } else if (event->timerId() == trayConnectingTimer) { QIcon nextConnectingIcon = StatusIcon::getNextConnectingIcon(); trayIcon->setIcon(nextConnectingIcon); if (contactList) contactList->setStatusButtonIcon(nextConnectingIcon); } QObject::timerEvent(event); }
bool Controller::init() { if (!m_audioControl.init()) { QMessageBox::warning(NULL, "Hint", QString::fromStdString(m_audioControl.errorMessage())); return false; } m_filterManager.init(); m_preferencesWidget.init(); QSettings::setDefaultFormat(QSettings::IniFormat); m_trayIcon.setIcon(m_icon); m_trayIcon.setContextMenu(&m_menu); m_trayIcon.show(); m_presetAction->setDisabled(true); m_noPresetAction->setCheckable(false); m_noPresetAction->setChecked(true); connect(&m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(showTrayMenu())); connect(m_preferencesAction, SIGNAL(triggered()), this, SLOT(showPreferences())); connect(m_quitAction, SIGNAL(triggered()), this, SLOT(deinit())); // Load presets from persistence load(); m_audioGraph.init(m_audioControl.loopbackInput().id, m_audioControl.defaultOutput().id); m_audioGraph.start(); return true; }