awBackground.cpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #include "awBackground.h"
  2. #include "ui_awBackground.h"
  3. #include "CAppInfo.h"
  4. #include "awMsgBox.h"
  5. #include <QDesktopWidget>
  6. awBackground::awBackground(AW_WIDGET_TYPE wt, QWidget *parent) :
  7. QWidget(parent),
  8. ui(new Ui::awBackground), m_wt(wt)
  9. {
  10. ui->setupUi(this);
  11. setStyleSheet(g_appInfoPtr->m_sQssStr);
  12. initUI();
  13. g_appInfoPtr->m_pAnsBgWidget = this;
  14. qRegisterMetaType<CGetCourseInfo>("CGetCourseInfo");
  15. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetCourseInfo, this, &awBackground::onGetCourseInfo);
  16. }
  17. awBackground::~awBackground()
  18. {
  19. g_appInfoPtr->m_pAnsBgWidget = nullptr;
  20. delete ui;
  21. }
  22. void awBackground::initUI()
  23. {
  24. //ui->label_awbg_exam->setText(QString::fromLocal8Bit("%1(%2)").arg().arg());
  25. ui->label_awbg_student->setText(QString::fromLocal8Bit("%1 | %2 | %3 | %4")
  26. .arg(g_appInfoPtr->m_sStudentName).arg(g_appInfoPtr->m_sStudentCode)
  27. .arg(g_appInfoPtr->m_nVersionId).arg(g_appInfoPtr->m_sOrgName));
  28. QDesktopWidget *dekwiget = QApplication::desktop();
  29. setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  30. ui->widget_awbg_BG->setGeometry(0, 0, width(), height());
  31. ui->widget_awbg_top->setGeometry(0, 0, ui->widget_awbg_BG->width(), g_appInfoPtr->m_fRate*112);
  32. ui->label_awbg_examIcon->setGeometry(g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*20,
  33. g_appInfoPtr->m_fRate*16, g_appInfoPtr->m_fRate*16);
  34. ui->label_awbg_exam->adjustSize();
  35. ui->label_awbg_exam->setGeometry(ui->label_awbg_examIcon->x() + ui->label_awbg_examIcon->width() + g_appInfoPtr->m_fRate*10,
  36. ui->label_awbg_examIcon->y() + (ui->label_awbg_examIcon->height() - ui->label_awbg_exam->height())/2,
  37. ui->label_awbg_exam->width(), ui->label_awbg_exam->height());
  38. ui->label_awbg_student->adjustSize();
  39. ui->label_awbg_student->setGeometry(ui->widget_awbg_top->width() - g_appInfoPtr->m_fRate*30 - ui->label_awbg_student->width(),
  40. ui->label_awbg_exam->y(), ui->label_awbg_student->width(), ui->label_awbg_student->height());
  41. ui->label_awbg_studentIcon->setGeometry(ui->label_awbg_student->x() - g_appInfoPtr->m_fRate*(10 + 16),
  42. ui->label_awbg_examIcon->y(), ui->label_awbg_examIcon->width(), ui->label_awbg_examIcon->height());
  43. ui->label_cl_company->adjustSize();
  44. ui->label_cl_company->setGeometry(g_appInfoPtr->m_fRate*30, ui->widget_awbg_BG->height() - g_appInfoPtr->m_fRate*10 - ui->label_cl_company->height(),
  45. ui->label_cl_company->width(), ui->label_cl_company->height());
  46. ui->label_cl_version->adjustSize();
  47. ui->label_cl_version->setGeometry(ui->widget_awbg_BG->width() - g_appInfoPtr->m_fRate*30 - ui->label_cl_version->width(),
  48. ui->label_cl_company->y(), ui->label_cl_version->width(), ui->label_cl_version->height());
  49. ui->label_serverTime->adjustSize();
  50. ui->label_serverTime->setGeometry(ui->label_cl_version->x() - g_appInfoPtr->m_fRate*20 - ui->label_serverTime->width(),
  51. ui->label_cl_company->y(), ui->label_serverTime->width(), ui->label_serverTime->height());
  52. if (m_wt == AW_WIDGET_TYPE::awwt_waitExam)
  53. {
  54. if(m_pWaitExam == nullptr)
  55. {
  56. m_pWaitExam = std::make_shared<awWaitExam>(this);
  57. connect(m_pWaitExam.get(), &awWaitExam::enterExam, this, [&](){
  58. m_pWaitExam.reset();
  59. CHttpRequestPackage hrp;
  60. hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/getCourseInfo/%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId);
  61. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
  62. hrp.nRequestType = RequestType::rtGetCourseInfo;
  63. hrp.eParamType = HttpParamType::hptUrl;
  64. g_httpBllPtr->post(hrp);
  65. m_wt = AW_WIDGET_TYPE::awwt_answerWidget;
  66. if (m_pAnswerWidget == nullptr)
  67. {
  68. m_pAnswerWidget = std::make_shared<answerWidget>(this);
  69. connect(m_pAnswerWidget.get(), &answerWidget::showPracticeInfo, this, [&](){
  70. m_pAnswerWidget.reset();
  71. emit showPracticeInfo();
  72. });
  73. connect(m_pAnswerWidget.get(), &answerWidget::gobackCourseList, this, [&](){
  74. m_pAnswerWidget.reset();
  75. emit closeWidget();
  76. });
  77. connect(m_pAnswerWidget.get(), &answerWidget::showExamScore, this, [&](){
  78. m_pAnswerWidget.reset();
  79. m_wt = AW_WIDGET_TYPE::awwt_examScore;
  80. if(m_pExamScore == nullptr)
  81. {
  82. m_pExamScore = std::make_shared<awExamScore>(this);
  83. connect(m_pExamScore.get(), &awExamScore::goHomePage, this, [&](){
  84. emit closeWidget();
  85. });
  86. }
  87. m_pExamScore->setUI(g_appInfoPtr->m_fRate * 20, g_appInfoPtr->m_fRate * 56, width() - g_appInfoPtr->m_fRate * 20 * 2,
  88. height() - g_appInfoPtr->m_fRate*(56 + 38));
  89. m_pExamScore->show();
  90. });
  91. }
  92. m_pAnswerWidget->setUI(g_appInfoPtr->m_fRate * 20, g_appInfoPtr->m_fRate * 56, width() - g_appInfoPtr->m_fRate * 20 * 2,
  93. height() - g_appInfoPtr->m_fRate*(56 + 38));
  94. m_pAnswerWidget->show();
  95. });
  96. }
  97. m_pWaitExam->setUI(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*56, width() - g_appInfoPtr->m_fRate*20*2,
  98. height() - g_appInfoPtr->m_fRate*(56 + 38));
  99. m_pWaitExam->show();
  100. }
  101. else if (m_wt == AW_WIDGET_TYPE::awwt_answerWidget)
  102. {
  103. CHttpRequestPackage hrp;
  104. hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/getCourseInfo/%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId);
  105. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
  106. hrp.nRequestType = RequestType::rtGetCourseInfo;
  107. hrp.eParamType = HttpParamType::hptUrl;
  108. g_httpBllPtr->post(hrp);
  109. if(m_pAnswerWidget == nullptr)
  110. {
  111. m_pAnswerWidget = std::make_shared<answerWidget>(this);
  112. connect(m_pAnswerWidget.get(), &answerWidget::showPracticeInfo, this, [&](){
  113. m_pAnswerWidget.reset();
  114. emit showPracticeInfo();
  115. });
  116. connect(m_pAnswerWidget.get(), &answerWidget::gobackCourseList, this, [&](){
  117. m_pAnswerWidget.reset();
  118. emit closeWidget();
  119. });
  120. connect(m_pAnswerWidget.get(), &answerWidget::showExamScore, this, [&](){
  121. m_pAnswerWidget.reset();
  122. m_wt = AW_WIDGET_TYPE::awwt_examScore;
  123. if(m_pExamScore == nullptr)
  124. {
  125. m_pExamScore = std::make_shared<awExamScore>(this);
  126. connect(m_pExamScore.get(), &awExamScore::goHomePage, this, [&](){
  127. emit closeWidget();
  128. });
  129. }
  130. m_pExamScore->setUI(g_appInfoPtr->m_fRate * 20, g_appInfoPtr->m_fRate * 56, width() - g_appInfoPtr->m_fRate * 20 * 2,
  131. height() - g_appInfoPtr->m_fRate*(56 + 38));
  132. m_pExamScore->show();
  133. });
  134. }
  135. m_pAnswerWidget->setUI(g_appInfoPtr->m_fRate * 20, g_appInfoPtr->m_fRate * 56, width() - g_appInfoPtr->m_fRate * 20 * 2,
  136. height() - g_appInfoPtr->m_fRate*(56 + 38));
  137. m_pAnswerWidget->show();
  138. }
  139. else if (m_wt == AW_WIDGET_TYPE::awwt_examScore)
  140. {
  141. if(m_pExamScore == nullptr)
  142. {
  143. m_pExamScore = std::make_shared<awExamScore>(this);
  144. }
  145. m_pExamScore->setUI(g_appInfoPtr->m_fRate * 20, g_appInfoPtr->m_fRate * 56, width() - g_appInfoPtr->m_fRate * 20 * 2,
  146. height() - g_appInfoPtr->m_fRate*(56 + 38));
  147. m_pExamScore->show();
  148. }
  149. }
  150. void awBackground::onGetCourseInfo(CGetCourseInfo getCourseInfo)
  151. {
  152. if (getCourseInfo.nCode == 200)
  153. {
  154. ui->label_awbg_exam->setText(QString::fromLocal8Bit("%1(%2)").arg(getCourseInfo.sCourseName).arg(getCourseInfo.sCourseCode));
  155. g_appInfoPtr->m_oExamInfo.sCourseCode = getCourseInfo.sCourseCode;
  156. g_appInfoPtr->m_oExamInfo.sCourseName = getCourseInfo.sCourseName;
  157. }
  158. else
  159. {
  160. if(getCourseInfo.sMessage.isEmpty())
  161. {
  162. ShowMsg(QString::fromLocal8Bit("获取科目信息失败"), g_appInfoPtr->m_pAnsBgWidget);
  163. }
  164. else
  165. {
  166. ShowMsg(getCourseInfo.sMessage, g_appInfoPtr->m_pAnsBgWidget);
  167. }
  168. }
  169. }