mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:57:24 +00:00
TrayIcon: Simplify onTrayActivated()
This commit is contained in:
parent
ea94865f62
commit
fc51a44eb0
@ -196,44 +196,20 @@ WindowManager *TrayIcon::windowManager() const
|
||||
return ctrl()->windowManager();
|
||||
}
|
||||
|
||||
void TrayIcon::onMouseClicked(TrayIcon::ClickType clickType)
|
||||
{
|
||||
QAction *action = clickAction(clickType);
|
||||
if (action) {
|
||||
action->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
void TrayIcon::onTrayActivated(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
switch (reason) {
|
||||
case QSystemTrayIcon::Trigger: {
|
||||
if (clickAction(DoubleClick)) {
|
||||
m_trayTriggered = true;
|
||||
QTimer::singleShot(QApplication::doubleClickInterval(), this, [&] {
|
||||
if (m_trayTriggered) {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(SingleClick);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(SingleClick);
|
||||
}
|
||||
onTrayActivatedByTrigger();
|
||||
} break;
|
||||
case QSystemTrayIcon::DoubleClick: {
|
||||
if (m_trayTriggered) {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(DoubleClick);
|
||||
}
|
||||
onTrayActivatedByDoubleClick();
|
||||
} break;
|
||||
case QSystemTrayIcon::MiddleClick: {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(MiddleClick);
|
||||
onTrayActivatedByMiddleClick();
|
||||
} break;
|
||||
case QSystemTrayIcon::Context: {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(RightClick);
|
||||
onTrayActivatedByContext();
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
@ -626,3 +602,47 @@ QAction *TrayIcon::clickActionByType(ActionType actionType) const
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TrayIcon::onMouseClicked(TrayIcon::ClickType clickType)
|
||||
{
|
||||
QAction *action = clickAction(clickType);
|
||||
if (action) {
|
||||
action->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
void TrayIcon::onTrayActivatedByTrigger()
|
||||
{
|
||||
if (clickAction(DoubleClick)) {
|
||||
m_trayTriggered = true;
|
||||
QTimer::singleShot(QApplication::doubleClickInterval(), this, [&] {
|
||||
if (m_trayTriggered) {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(SingleClick);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(SingleClick);
|
||||
}
|
||||
}
|
||||
|
||||
void TrayIcon::onTrayActivatedByDoubleClick()
|
||||
{
|
||||
if (m_trayTriggered) {
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(DoubleClick);
|
||||
}
|
||||
}
|
||||
|
||||
void TrayIcon::onTrayActivatedByMiddleClick()
|
||||
{
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(MiddleClick);
|
||||
}
|
||||
|
||||
void TrayIcon::onTrayActivatedByContext()
|
||||
{
|
||||
m_trayTriggered = false;
|
||||
onMouseClicked(RightClick);
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ public slots:
|
||||
protected slots:
|
||||
void switchTrayMenu(bool checked);
|
||||
|
||||
void onMouseClicked(TrayIcon::ClickType clickType);
|
||||
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
|
||||
void saveTrayFlags();
|
||||
@ -97,6 +96,12 @@ private:
|
||||
QAction *clickActionFromIni(ClickType clickType) const;
|
||||
QAction *clickActionByType(ActionType actionType) const;
|
||||
|
||||
void onMouseClicked(TrayIcon::ClickType clickType);
|
||||
void onTrayActivatedByTrigger();
|
||||
void onTrayActivatedByDoubleClick();
|
||||
void onTrayActivatedByMiddleClick();
|
||||
void onTrayActivatedByContext();
|
||||
|
||||
private:
|
||||
bool m_trayTriggered : 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user