#include "dialogmisscapture.h"
#include "ui_dialogmisscapture.h"

#include "mainwindow.h"

DialogMissCapture::DialogMissCapture(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogMissCapture)
{
    setAttribute(Qt::WA_TranslucentBackground);
    //setWindowFlags(Qt::CustomizeWindowHint);
    setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::Popup | Qt::WindowStaysOnTopHint);

    //setWindowFlags(Qt::FramelessWindowHint);


    ui->setupUi(this);
}

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

void DialogMissCapture::resizeEvent(QResizeEvent *event)
{
    int nDisplayType = MainWindow::GetCommonData()->GetDisplayType();
    if(nDisplayType==SDISPLAY_1280X1024)
    {
        ui->frame_info->setGeometry(100, 400, 1080, 200);
        ui->label->setGeometry(0, 30, 1080, 80);
        ui->pushButton->setGeometry(1080/2-250/2, 124, 250, 60);
    }
    else if(nDisplayType==SDISPLAY_1920X1080)
    {
        ui->frame_info->setGeometry(100, 400, 1720, 200);
        ui->label->setGeometry(0, 30, 1720, 80);
        ui->pushButton->setGeometry(728, 124, 271, 61);
    }
}

void DialogMissCapture::Show()
{
    show();
}

void DialogMissCapture::on_pushButton_clicked()
{
    CommonData* pCommonData = MainWindow::GetCommonData();
    //pCommonData->ClearCaptureImage();
    pCommonData->GetThreadCaptureImage()->ClearMissCapture();

    hide();
}


void DialogMissCapture::SetErrorType(int nType)
{
    QString strErrorMessage;

    if(nType==0)
    {
        strErrorMessage = "Check Patient Selection!!";
    }
    else if(nType==0x01)
    {
        strErrorMessage = "Error: Database Check!";
    }
    else if(nType==0x02)
    {
        strErrorMessage = "Error: Lock Check!";
    }
    else if(nType==0x04)
    {
        strErrorMessage = "Error: Image File Write!";
    }
    else if(nType==0x08)
    {
        strErrorMessage = "Error: Create Study!";
    }

    SetErrorString(strErrorMessage);
}

void DialogMissCapture::SetErrorString(const QString strErrorMessage)
{
    ui->label->setText(strErrorMessage);
    ui->pushButton->setEnabled(true);
}
