errorpopupdlg.cpp 1.11 KB
#include "errorpopupdlg.h"
#include "ui_errorpopupdlg.h"
#include <QDebug>

#include "soundplayer.h"
#include "udphandler.h"

ErrorPopupDlg::ErrorPopupDlg(QWidget *parent, const QString &MsgDesc, const QString &MsgTitle, bool sendClrCmd,int erridx) :
    QDialog(parent),
    ui(new Ui::ErrorPopupDlg)
{
    ui->setupUi(this);
    this->setAttribute( Qt::WA_TranslucentBackground);
    this->setAttribute( Qt::WA_DeleteOnClose);
    this->setWindowFlags(Qt::FramelessWindowHint);

    //ui->centralwidget->setWindowFlags(Qt::FramelessWindowHint);
    ui->ctrlWarnDescription->setText(MsgDesc);
    ui->ctrlWarnTitle->setText(MsgTitle);
    m_pParent = parent;

    foreach (QPushButton *button, findChildren<QPushButton *>())
        connect(button, &QPushButton::pressed, SoundPlayer::playClick);
    m_bClrCmd = sendClrCmd;
    m_nErrIdx = erridx;
}

ErrorPopupDlg::~ErrorPopupDlg()
{
    delete ui;
}

void ErrorPopupDlg::on_ctrlOkBtn_clicked()
{
    emit closedErrorPopup(m_nErrIdx);
    qApp->setActiveWindow(m_pParent);
    this->hide();
    if(m_bClrCmd) UdpHandler::getInstance()->set(TG_ERROR_CLEAR,0xCECE);
    close();
}