#include "menubar.h"
#include <QWidget>
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QDebug>

MenuBar::MenuBar(QWidget* parent)
{
    ApplicationMenu    = new QMenu(QObject::tr("文件(F)"),parent);
    newAction    = new QAction(QObject::tr("New"),parent);
    openAction    = new QAction(QObject::tr("Open"),parent);
    closeAction    = new QAction(QObject::tr("Close"),parent);
    ApplicationMenu->addAction(newAction);
    ApplicationMenu->addAction(openAction);
    ApplicationMenu->addAction(closeAction);

    testMenu    = new QMenu(QObject::tr("测试(T)"),parent);
    arrayAction    = new QAction(QObject::tr("Array"),parent);
    rtAction    = new QAction(QObject::tr("Realtime"),parent);
    voltAction    = new QAction(QObject::tr("Volt"),parent);
    testMenu->addAction(arrayAction);
    testMenu->addAction(rtAction);
    testMenu->addAction(voltAction);

    viewMenu    = new QMenu(QObject::tr("视图(V)"),parent);
    realwinAction    = new QAction(QObject::tr("实时曲线"),parent);
    realdataAction    = new QAction(QObject::tr("实时数据"),parent);
    imageAction    = new QAction(QObject::tr("Image"),parent);
    viewMenu->addAction(realwinAction);
    viewMenu->addAction(realdataAction);
    viewMenu->addAction(imageAction);

    plotMenu    = new QMenu(QObject::tr("分析(A)"),parent);
    dynamicAction    = new QAction(QObject::tr("Dynamic"),parent);
    staticAction    = new QAction(QObject::tr("Static"),parent);
    renderAction    = new QAction(QObject::tr("Render"),parent);
    plotMenu->addAction(dynamicAction);
    plotMenu->addAction(staticAction);
    plotMenu->addAction(renderAction);

    markerMenu    = new QMenu(QObject::tr("处理(D)"),parent);
    thermalAction    = new QAction(QObject::tr("热焓校正..."),parent);
    mark1Action    = new QAction(QObject::tr("Mark1"),parent);
    mark2Action    = new QAction(QObject::tr("Mark2"),parent);
    markerMenu->addAction(thermalAction);
    markerMenu->addAction(mark1Action);
    markerMenu->addAction(mark2Action);

    showMenu    = new QMenu(QObject::tr("设置(S)"),parent);
    doubAction    = new QAction(QObject::tr("Double"),parent);
    quadAction    = new QAction(QObject::tr("Triple"),parent);
    halfAction    = new QAction(QObject::tr("Half"),parent);
    showMenu->addAction(doubAction);
    showMenu->addAction(quadAction);
    showMenu->addAction(halfAction);

    helpMenu    = new QMenu(QObject::tr("帮助(H)"),parent);
    aboutAction    = new QAction(QObject::tr("About"),parent);
    aboutEMGAction    = new QAction(QObject::tr("About YT_ANA"),parent);
    helpMenu->addAction(aboutAction);
    helpMenu->addAction(aboutEMGAction);

    connect(realwinAction,SIGNAL(triggered()),this,SLOT(emit_show_real_window_signal()));
    connect(thermalAction,SIGNAL(triggered()),this,SLOT(emit_show_thermal_calib_signal()));
}


MenuBar::~MenuBar()
{
    delete    newAction;
    delete    openAction;
    delete    closeAction;

    delete    arrayAction;
    delete    rtAction;
    delete    voltAction;

    delete    realwinAction;
    delete    realdataAction;
    delete    imageAction;

    delete    dynamicAction;
    delete    staticAction;
    delete    renderAction;

    delete    thermalAction;
    delete    mark1Action;
    delete    mark2Action;

    delete    doubAction;
    delete    quadAction;
    delete    halfAction;

    delete    aboutAction;
    delete    aboutEMGAction;


    newAction    = 0;
    openAction    = 0;
    closeAction    = 0;

    arrayAction    = 0;
    rtAction    = 0;
    voltAction    = 0;

    realwinAction    = 0;
    realdataAction    = 0;
    imageAction    = 0;

    dynamicAction    = 0;
    staticAction    = 0;
    renderAction    = 0;

    thermalAction    = 0;
    mark1Action    = 0;
    mark2Action    = 0;

    doubAction    = 0;
    quadAction    = 0;
    halfAction    = 0;

    aboutAction    = 0;
    aboutEMGAction    = 0;
}

void MenuBar::emit_show_real_window_signal()
{
    emit show_real_window();
    qDebug()<<"emit_show_real_window_signal"<<Qt::endl;
}

void MenuBar::emit_show_thermal_calib_signal()
{
    emit show_thermal_window();
    qDebug()<<"emit_show_thermal_calib_signal"<<Qt::endl;
}
