UI: TrayIcon: Simplify clickActionByType()

This commit is contained in:
Nodir Temirkhodjaev 2023-01-13 19:56:44 +03:00
parent da7c7e64b3
commit c3220c557b

View File

@ -605,28 +605,23 @@ QAction *TrayIcon::clickActionFromIni(ClickType clickType) const
QAction *TrayIcon::clickActionByType(ActionType actionType) const QAction *TrayIcon::clickActionByType(ActionType actionType) const
{ {
switch (actionType) { QAction *actions[] = {
case TrayIcon::ActionShowPrograms: m_programsAction,
return m_programsAction; m_optionsAction,
case TrayIcon::ActionShowOptions: m_statisticsAction,
return m_optionsAction; m_graphAction,
case TrayIcon::ActionShowStatistics: m_filterEnabledAction,
return m_statisticsAction; m_stopTrafficAction,
case TrayIcon::ActionShowTrafficGraph: m_stopInetTrafficAction,
return m_graphAction; m_autoAllowProgsAction,
case TrayIcon::ActionSwitchFilterEnabled: m_trayMenuAction,
return m_filterEnabledAction; };
case TrayIcon::ActionSwitchStopTraffic:
return m_stopTrafficAction; if (actionType > TrayIcon::ActionNone && actionType < TrayIcon::ActionIgnore) {
case TrayIcon::ActionSwitchStopInetTraffic: return actions[actionType];
return m_stopInetTrafficAction;
case TrayIcon::ActionSwitchAutoAllowPrograms:
return m_autoAllowProgsAction;
case TrayIcon::ActionShowTrayMenu:
return m_trayMenuAction;
default:
return nullptr;
} }
return nullptr;
} }
void TrayIcon::onMouseClicked(TrayIcon::ClickType clickType) void TrayIcon::onMouseClicked(TrayIcon::ClickType clickType)