#include "SysTray.h"
#include <QApplication>
#include <QThread>


extern QThread  workThread;
extern QThread refundThread;

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

    setIcon(QIcon(":takeaway.ico"));
}

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

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

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