#include "SysTray.h"
#include <QApplication>
#include <QThread>
extern QThread tcpThread;
extern QThread  workThread;

SysTray::SysTray(QObject *parent) :
    QSystemTrayIcon(parent)
{
    _CreatMenu();

    setIcon(QIcon(":fm.png"));
}

void SysTray::_CreatMenu()
{
    m_menu = new QMenu();
    m_menu->setObjectName("trayMenu");
    QAction *acQuit = new QAction(QString::fromLocal8Bit("退出"), m_menu);
    connect(acQuit, &QAction::triggered, this, &SysTray::onActionQuitTriggered);

    m_menu->addAction(acQuit);
    setContextMenu(m_menu);
}

void SysTray::onActionQuitTriggered()
{
    tcpThread.terminate();
    workThread.terminate();
    qApp->exit(-1);
}
