#include "awHandinPaper.h"
#include "ui_awHandinPaper.h"

#include "CAppInfo.h"

#include <QDesktopWidget>

awHandinPaper::awHandinPaper(int nAnswered, int nUnanswered, int nMarked, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::awHandinPaper)
{
    ui->setupUi(this);

    setStyleSheet(g_appInfoPtr->m_sQssStr);

    ui->label_awhp_answered->setText(QString::fromLocal8Bit("已答题目：%1").arg(nAnswered));
    ui->label_awhp_unanswered->setText(QString::fromLocal8Bit("未答题目：%1").arg(nUnanswered));
    ui->label_awhp_marked->setText(QString::fromLocal8Bit("标记题目：%1").arg(nMarked));

    initUI();
}

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

void awHandinPaper::initUI()
{
    QDesktopWidget *dekwiget = QApplication::desktop();
    setGeometry(0, 0, dekwiget->width(), dekwiget->height());
    ui->widget_mask->setGeometry(0, 0, dekwiget->width(), dekwiget->height());
    ui->widget_awhp_BG->setGeometry((width() - g_appInfoPtr->m_fRate*480)/2, (height() - g_appInfoPtr->m_fRate*227)/2,
                                   g_appInfoPtr->m_fRate*480, g_appInfoPtr->m_fRate*227);
    ui->label_awhp_icon->setGeometry(g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*30,
                                    g_appInfoPtr->m_fRate*40, g_appInfoPtr->m_fRate*40);
    ui->label_awhp_title->adjustSize();
    ui->label_awhp_title->setGeometry(ui->label_awhp_icon->x() + ui->label_awhp_icon->width() + g_appInfoPtr->m_fRate*20,
                                      ui->label_awhp_icon->y(), ui->label_awhp_title->width(), ui->label_awhp_title->height());
    ui->label_awhp_answered->adjustSize();
    ui->label_awhp_answered->setGeometry(ui->label_awhp_title->x(), ui->label_awhp_title->y() + ui->label_awhp_title->height() + g_appInfoPtr->m_fRate*20,
                                         ui->label_awhp_answered->width(), ui->label_awhp_answered->height());
    ui->label_awhp_unanswered->adjustSize();
    ui->label_awhp_unanswered->setGeometry(ui->label_awhp_answered->x(), ui->label_awhp_answered->y() + ui->label_awhp_answered->height() + g_appInfoPtr->m_fRate*5,
                                           ui->label_awhp_unanswered->width(), ui->label_awhp_unanswered->height());
    ui->label_awhp_marked->adjustSize();
    ui->label_awhp_marked->setGeometry(ui->label_awhp_unanswered->x(), ui->label_awhp_unanswered->y() + ui->label_awhp_unanswered->height() + g_appInfoPtr->m_fRate*5,
                                       ui->label_awhp_marked->width(), ui->label_awhp_marked->height());
    ui->label_multipleChoiceTips->adjustSize();
    ui->label_multipleChoiceTips->setGeometry(ui->label_awhp_unanswered->x(), ui->label_awhp_marked->y() + ui->label_awhp_marked->height() + g_appInfoPtr->m_fRate*15,
                                       ui->label_multipleChoiceTips->width(), ui->label_multipleChoiceTips->height());
    ui->label_multipleChoiceTips->setVisible(false);
    ui->btn_awhp_comfirm->setGeometry(ui->widget_awhp_BG->width() - g_appInfoPtr->m_fRate*(20 + 80),
                                      ui->widget_awhp_BG->height() - g_appInfoPtr->m_fRate*(20 + 30),
                                      g_appInfoPtr->m_fRate*80, g_appInfoPtr->m_fRate*30);
    ui->btn_awhp_cancel->setGeometry(ui->btn_awhp_comfirm->x() - g_appInfoPtr->m_fRate*10 - ui->btn_awhp_comfirm->width(), ui->btn_awhp_comfirm->y(),
                                     ui->btn_awhp_comfirm->width(), ui->btn_awhp_comfirm->height());
}

void awHandinPaper::showMutipleChoiceTip()
{
    ui->label_multipleChoiceTips->setVisible(true);
}

void awHandinPaper::on_btn_awhp_cancel_clicked()
{
    emit cancelHandinPaper();
}

void awHandinPaper::on_btn_awhp_comfirm_clicked()
{
    emit handinPaper();
}
