#include "etWhetherEnvTest.h"
#include "ui_etWhetherEnvTest.h"

#include <QDesktopWidget>

#include "CAppInfo.h"

etWhetherEnvTest::etWhetherEnvTest(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::etWhetherEnvTest)
{
    ui->setupUi(this);

    setWindowFlags(Qt::FramelessWindowHint);

    setStyleSheet(g_appInfoPtr->m_sQssStr);

    initUI();
}

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

void etWhetherEnvTest::initUI()
{
    QDesktopWidget *dekwiget = QApplication::desktop();
    setGeometry(0, 0, dekwiget->width(), dekwiget->height());
    ui->widget_mask->setGeometry(0, 0, dekwiget->width(), dekwiget->height());
    ui->widget_wcw_BG->setGeometry((width() - g_appInfoPtr->m_fRate*420)/2, (height() - g_appInfoPtr->m_fRate*212)/2,
                                   g_appInfoPtr->m_fRate*420, g_appInfoPtr->m_fRate*212);
    ui->label_wcw_icon->setGeometry(g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*30,
                                    g_appInfoPtr->m_fRate*40, g_appInfoPtr->m_fRate*40);
    ui->label_wec_tips->adjustSize();
    ui->label_wec_tips->setGeometry(ui->label_wcw_icon->x() + ui->label_wcw_icon->width() + g_appInfoPtr->m_fRate*20,
                                    ui->label_wcw_icon->y(), ui->label_wec_tips->width(), ui->label_wec_tips->height());
    ui->label_wec_content->setLineWidth(ui->widget_wcw_BG->width() - g_appInfoPtr->m_fRate*(30 + 20) - ui->label_wcw_icon->x() - ui->label_wcw_icon->width());
    ui->label_wec_content->adjustSize();
    ui->label_wec_content->setGeometry(ui->label_wec_tips->x(), ui->label_wec_tips->y() + ui->label_wec_tips->height() + g_appInfoPtr->m_fRate*8,
                                           ui->label_wec_content->width(), ui->label_wec_content->height());

    ui->btn_startEnvTest->setGeometry(ui->widget_wcw_BG->width() - g_appInfoPtr->m_fRate*(20 + 80), ui->widget_wcw_BG->height() - g_appInfoPtr->m_fRate*(20 + 30),
                                     g_appInfoPtr->m_fRate*80, g_appInfoPtr->m_fRate*30);
    ui->btn_skipEnvTest->setGeometry(ui->btn_startEnvTest->x() - ui->btn_startEnvTest->width() - g_appInfoPtr->m_fRate*10,
                                      ui->btn_startEnvTest->y(), ui->btn_startEnvTest->width(), ui->btn_startEnvTest->height());
}

void etWhetherEnvTest::on_btn_skipEnvTest_clicked()
{
    emit skipEnvTest();
}

void etWhetherEnvTest::on_btn_startEnvTest_clicked()
{
    emit envTest();
}
