mirror of
https://github.com/tnodir/fort
synced 2024-11-15 12:26:26 +00:00
TrayIcon: Simplify actionTypeByName()
This commit is contained in:
parent
497e60c7a3
commit
ea94865f62
@ -21,21 +21,21 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char *const eventSingleClick = "singleClick";
|
const QString eventSingleClick = QStringLiteral("singleClick");
|
||||||
const char *const eventDoubleClick = "doubleClick";
|
const QString eventDoubleClick = QStringLiteral("doubleClick");
|
||||||
const char *const eventMiddleClick = "middleClick";
|
const QString eventMiddleClick = QStringLiteral("middleClick");
|
||||||
const char *const eventRightClick = "rightClick";
|
const QString eventRightClick = QStringLiteral("rightClick");
|
||||||
|
|
||||||
const char *const actionShowPrograms = "Programs";
|
const QString actionShowPrograms = QStringLiteral("Programs");
|
||||||
const char *const actionShowOptions = "Options";
|
const QString actionShowOptions = QStringLiteral("Options");
|
||||||
const char *const actionShowStatistics = "Statistics";
|
const QString actionShowStatistics = QStringLiteral("Statistics");
|
||||||
const char *const actionShowTrafficGraph = "TrafficGraph";
|
const QString actionShowTrafficGraph = QStringLiteral("TrafficGraph");
|
||||||
const char *const actionSwitchFilterEnabled = "FilterEnabled";
|
const QString actionSwitchFilterEnabled = QStringLiteral("FilterEnabled");
|
||||||
const char *const actionSwitchStopTraffic = "StopTraffic";
|
const QString actionSwitchStopTraffic = QStringLiteral("StopTraffic");
|
||||||
const char *const actionSwitchStopInetTraffic = "StopInetTraffic";
|
const QString actionSwitchStopInetTraffic = QStringLiteral("StopInetTraffic");
|
||||||
const char *const actionSwitchAutoAllowPrograms = "AutoAllowPrograms";
|
const QString actionSwitchAutoAllowPrograms = QStringLiteral("AutoAllowPrograms");
|
||||||
const char *const actionShowTrayMenu = "TrayMenu";
|
const QString actionShowTrayMenu = QStringLiteral("TrayMenu");
|
||||||
const char *const actionIgnore = "Ignore";
|
const QString actionIgnore = QStringLiteral("Ignore");
|
||||||
|
|
||||||
QString clickNameByType(TrayIcon::ClickType clickType)
|
QString clickNameByType(TrayIcon::ClickType clickType)
|
||||||
{
|
{
|
||||||
@ -83,40 +83,21 @@ QString actionNameByType(TrayIcon::ActionType actionType)
|
|||||||
|
|
||||||
TrayIcon::ActionType actionTypeByName(const QString &name)
|
TrayIcon::ActionType actionTypeByName(const QString &name)
|
||||||
{
|
{
|
||||||
if (name.isEmpty())
|
static const QHash<QString, TrayIcon::ActionType> actionTypeNamesMap = {
|
||||||
return TrayIcon::ActionNone;
|
{ actionShowPrograms, TrayIcon::ActionShowPrograms },
|
||||||
|
{ actionShowOptions, TrayIcon::ActionShowOptions },
|
||||||
|
{ actionShowStatistics, TrayIcon::ActionShowStatistics },
|
||||||
|
{ actionShowTrafficGraph, TrayIcon::ActionShowTrafficGraph },
|
||||||
|
{ actionSwitchFilterEnabled, TrayIcon::ActionSwitchFilterEnabled },
|
||||||
|
{ actionSwitchStopTraffic, TrayIcon::ActionSwitchStopTraffic },
|
||||||
|
{ actionSwitchStopInetTraffic, TrayIcon::ActionSwitchStopInetTraffic },
|
||||||
|
{ actionSwitchAutoAllowPrograms, TrayIcon::ActionSwitchAutoAllowPrograms },
|
||||||
|
{ actionShowTrayMenu, TrayIcon::ActionShowTrayMenu },
|
||||||
|
{ actionIgnore, TrayIcon::ActionIgnore }
|
||||||
|
};
|
||||||
|
|
||||||
if (name == actionShowPrograms)
|
return name.isEmpty() ? TrayIcon::ActionNone
|
||||||
return TrayIcon::ActionShowPrograms;
|
: actionTypeNamesMap.value(name, TrayIcon::ActionNone);
|
||||||
|
|
||||||
if (name == actionShowOptions)
|
|
||||||
return TrayIcon::ActionShowOptions;
|
|
||||||
|
|
||||||
if (name == actionShowStatistics)
|
|
||||||
return TrayIcon::ActionShowStatistics;
|
|
||||||
|
|
||||||
if (name == actionShowTrafficGraph)
|
|
||||||
return TrayIcon::ActionShowTrafficGraph;
|
|
||||||
|
|
||||||
if (name == actionSwitchFilterEnabled)
|
|
||||||
return TrayIcon::ActionSwitchFilterEnabled;
|
|
||||||
|
|
||||||
if (name == actionSwitchStopTraffic)
|
|
||||||
return TrayIcon::ActionSwitchStopTraffic;
|
|
||||||
|
|
||||||
if (name == actionSwitchStopInetTraffic)
|
|
||||||
return TrayIcon::ActionSwitchStopInetTraffic;
|
|
||||||
|
|
||||||
if (name == actionSwitchAutoAllowPrograms)
|
|
||||||
return TrayIcon::ActionSwitchAutoAllowPrograms;
|
|
||||||
|
|
||||||
if (name == actionShowTrayMenu)
|
|
||||||
return TrayIcon::ActionShowTrayMenu;
|
|
||||||
|
|
||||||
if (name == actionIgnore)
|
|
||||||
return TrayIcon::ActionIgnore;
|
|
||||||
|
|
||||||
return TrayIcon::ActionNone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrayIcon::ActionType defaultActionTypeByClick(TrayIcon::ClickType clickType)
|
TrayIcon::ActionType defaultActionTypeByClick(TrayIcon::ClickType clickType)
|
||||||
|
Loading…
Reference in New Issue
Block a user