environmentalTest.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. #include "environmentalTest.h"
  2. #include "ui_environmentalTest.h"
  3. #include <QDesktopWidget>
  4. #include "CAppInfo.h"
  5. environmentalTest::environmentalTest(QWidget *parent) :
  6. QWidget(parent),
  7. ui(new Ui::environmentalTest)
  8. {
  9. ui->setupUi(this);
  10. setWindowFlags(Qt::FramelessWindowHint);
  11. setStyleSheet(g_appInfoPtr->m_sQssStr);
  12. m_curentStep = ENV_TEST_STEP::ett_network;
  13. initUI();
  14. }
  15. environmentalTest::~environmentalTest()
  16. {
  17. delete ui;
  18. }
  19. void environmentalTest::initUI()
  20. {
  21. QDesktopWidget *dekwiget = QApplication::desktop();
  22. setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  23. ui->widget_mask->setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  24. ui->widget_et_BG->setGeometry((width() - g_appInfoPtr->m_fRate*800)/2, (height() - g_appInfoPtr->m_fRate*377)/2,
  25. g_appInfoPtr->m_fRate*800, g_appInfoPtr->m_fRate*377);
  26. ui->label_et_title->adjustSize();
  27. ui->label_et_title->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*16,
  28. ui->label_et_title->width(), ui->label_et_title->height());
  29. ui->widget_et_steps->setGeometry(0, ui->label_et_title->y() + ui->label_et_title->height() + g_appInfoPtr->m_fRate*16,
  30. ui->widget_et_BG->width(), g_appInfoPtr->m_fRate*86);
  31. ui->label_et_networkIcon->setGeometry(g_appInfoPtr->m_fRate*55, g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*24, g_appInfoPtr->m_fRate*24);
  32. ui->label_et_network->adjustSize();
  33. ui->label_et_network->setGeometry(ui->label_et_networkIcon->x() + (ui->label_et_networkIcon->width() - ui->label_et_network->width())/2,
  34. ui->label_et_networkIcon->y() + ui->label_et_networkIcon->height() + g_appInfoPtr->m_fRate*6,
  35. ui->label_et_network->width(), ui->label_et_network->height());
  36. ui->label_et_HLine1->setGeometry(ui->label_et_networkIcon->x() + ui->label_et_networkIcon->width()/2, ui->label_et_networkIcon->y() + (ui->label_et_networkIcon->height() - g_appInfoPtr->m_fRate*1)/2,
  37. g_appInfoPtr->m_fRate*109 + ui->label_et_networkIcon->width(), g_appInfoPtr->m_fRate*1 < 1 ? 1 : g_appInfoPtr->m_fRate*1);
  38. ui->label_et_timeIcon->setGeometry(ui->label_et_networkIcon->x() + ui->label_et_HLine1->width(), ui->label_et_networkIcon->y(),
  39. ui->label_et_networkIcon->width(), ui->label_et_networkIcon->height());
  40. ui->label_et_time->adjustSize();
  41. ui->label_et_time->setGeometry(ui->label_et_timeIcon->x() + (ui->label_et_timeIcon->width() - ui->label_et_time->width())/2,
  42. ui->label_et_network->y(), ui->label_et_time->width(), ui->label_et_time->height());
  43. ui->label_et_HLine2->setGeometry(ui->label_et_HLine1->x() + ui->label_et_HLine1->width(), ui->label_et_HLine1->y(),
  44. ui->label_et_HLine1->width(), ui->label_et_HLine1->height());
  45. ui->label_et_cameraIcon->setGeometry(ui->label_et_timeIcon->x() + ui->label_et_HLine1->width(), ui->label_et_networkIcon->y(),
  46. ui->label_et_networkIcon->width(), ui->label_et_networkIcon->height());
  47. ui->label_et_camera->adjustSize();
  48. ui->label_et_camera->setGeometry(ui->label_et_cameraIcon->x() + (ui->label_et_cameraIcon->width() - ui->label_et_camera->width())/2,
  49. ui->label_et_network->y(), ui->label_et_camera->width(), ui->label_et_camera->height());
  50. ui->label_et_HLine3->setGeometry(ui->label_et_HLine2->x() + ui->label_et_HLine1->width(), ui->label_et_HLine1->y(),
  51. ui->label_et_HLine1->width(), ui->label_et_HLine1->height());
  52. ui->label_et_voiceIcon->setGeometry(ui->label_et_cameraIcon->x() + ui->label_et_HLine1->width(), ui->label_et_networkIcon->y(),
  53. ui->label_et_networkIcon->width(), ui->label_et_networkIcon->height());
  54. ui->label_et_voice->adjustSize();
  55. ui->label_et_voice->setGeometry(ui->label_et_voiceIcon->x() + (ui->label_et_voiceIcon->width() - ui->label_et_voice->width())/2,
  56. ui->label_et_network->y(), ui->label_et_voice->width(), ui->label_et_voice->height());
  57. ui->label_et_HLine4->setGeometry(ui->label_et_HLine3->x() + ui->label_et_HLine1->width(), ui->label_et_HLine1->y(),
  58. ui->label_et_HLine1->width(), ui->label_et_HLine1->height());
  59. ui->label_et_mobileIcon->setGeometry(ui->label_et_voiceIcon->x() + ui->label_et_HLine1->width(), ui->label_et_networkIcon->y(),
  60. ui->label_et_networkIcon->width(), ui->label_et_networkIcon->height());
  61. ui->label_et_mobile->adjustSize();
  62. ui->label_et_mobile->setGeometry(ui->label_et_mobileIcon->x() + (ui->label_et_mobileIcon->width() - ui->label_et_mobile->width())/2,
  63. ui->label_et_network->y(), ui->label_et_mobile->width(), ui->label_et_mobile->height());
  64. ui->label_et_HLine5->setGeometry(ui->label_et_HLine4->x() + ui->label_et_HLine1->width(), ui->label_et_HLine1->y(),
  65. ui->label_et_HLine1->width(), ui->label_et_HLine1->height());
  66. ui->label_et_resultIcon->setGeometry(ui->label_et_mobileIcon->x() + ui->label_et_HLine1->width(), ui->label_et_networkIcon->y(),
  67. ui->label_et_networkIcon->width(), ui->label_et_networkIcon->height());
  68. ui->label_et_result->adjustSize();
  69. ui->label_et_result->setGeometry(ui->label_et_resultIcon->x() + (ui->label_et_resultIcon->width() - ui->label_et_result->width())/2,
  70. ui->label_et_network->y(), ui->label_et_result->width(), ui->label_et_result->height());
  71. ui->btn_nextStep->setGeometry(ui->widget_et_BG->width() - g_appInfoPtr->m_fRate*(30 + 80), ui->widget_et_BG->height() - g_appInfoPtr->m_fRate*(30 + 30),
  72. g_appInfoPtr->m_fRate*80, g_appInfoPtr->m_fRate*30);
  73. ui->btn_previousStep->setGeometry(ui->btn_nextStep->x() - g_appInfoPtr->m_fRate*10 - ui->btn_nextStep->width(), ui->btn_nextStep->y(),
  74. ui->btn_nextStep->width(), ui->btn_nextStep->height());
  75. changeStepUI(m_curentStep);
  76. }
  77. void environmentalTest::changeStepUI(ENV_TEST_STEP step)
  78. {
  79. QString sHLineNormalStyle = QString(R"(QLabel
  80. {
  81. background:rgba(218,217,229,1);
  82. })");
  83. QString sHLineHoverStyle = QString(R"(QLabel
  84. {
  85. background:rgba(19,187,138,1);
  86. })");
  87. QString sNumNormalStyle = QString(R"(QLabel
  88. {
  89. border:1px solid rgba(105,105,105,1);
  90. border-radius:%1px;
  91. background:rgba(244,243,247,1);
  92. font-size:%2px;
  93. font-family:"Microsoft YaHei";
  94. font-weight:600;
  95. color:rgba(102, 102, 102,1);
  96. })").arg((int)(g_appInfoPtr->m_fRate*12)).arg((int)(g_appInfoPtr->m_fRate*12));
  97. QString sNumHoverStyle = QString(R"(QLabel
  98. {
  99. border:0px solid rgba(105,105,105,1);
  100. border-radius:%1px;
  101. background:rgba(19,187,138,1);
  102. font-size:%2px;
  103. font-family:"Microsoft YaHei";
  104. font-weight:600;
  105. color:rgba(255, 255, 255,1);
  106. })").arg((int)(g_appInfoPtr->m_fRate*12)).arg((int)(g_appInfoPtr->m_fRate*12));
  107. QString sTextNormalStyle = QString(R"(QLabel
  108. {
  109. font-size:%1px;
  110. font-family:"Microsoft YaHei";
  111. font-weight:600;
  112. color:rgba(102, 102, 102,1);
  113. })").arg((int)(g_appInfoPtr->m_fRate * 12));
  114. QString sTextHoverStyle = QString(R"(QLabel
  115. {
  116. font-size:%1px;
  117. font-family:"Microsoft YaHei";
  118. font-weight:600;
  119. color:rgba(19, 187, 138,1);
  120. })").arg((int)(g_appInfoPtr->m_fRate * 12));
  121. int nWidgetHeight = 0;
  122. int nHeight = 0;
  123. ui->btn_nextStep->setText(QString::fromLocal8Bit("下一步"));
  124. if(step == ENV_TEST_STEP::ett_network)
  125. {
  126. if(m_pTimeTest !=nullptr)
  127. {
  128. m_pTimeTest->hide();
  129. }
  130. if(m_pNetworkTest == nullptr)
  131. {
  132. m_pNetworkTest = std::make_shared<etNetworkTest>(ui->widget_et_BG);
  133. nHeight = m_pNetworkTest->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  134. }
  135. nHeight = m_pNetworkTest->widgetHeight();
  136. m_pNetworkTest->show();
  137. ui->label_et_HLine1->setStyleSheet(sHLineNormalStyle);
  138. ui->label_et_network->setStyleSheet(sTextHoverStyle);
  139. ui->label_et_networkIcon->setStyleSheet(sNumHoverStyle);
  140. ui->label_et_time->setStyleSheet(sTextNormalStyle);
  141. ui->label_et_timeIcon->setStyleSheet(sNumNormalStyle);
  142. }
  143. else if(step == ENV_TEST_STEP::ett_time)
  144. {
  145. if (m_pNetworkTest != nullptr)
  146. {
  147. m_pNetworkTest->hide();
  148. }
  149. if (m_pCameraTest != nullptr)
  150. {
  151. m_pCameraTest->hide();
  152. }
  153. if(m_pTimeTest == nullptr)
  154. {
  155. m_pTimeTest = std::make_shared<etTimeTest>(ui->widget_et_BG);
  156. nHeight = m_pTimeTest->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  157. }
  158. nHeight = m_pTimeTest->widgetHeight();
  159. m_pTimeTest->show();
  160. ui->label_et_HLine1->setStyleSheet(sHLineHoverStyle);
  161. ui->label_et_HLine2->setStyleSheet(sHLineNormalStyle);
  162. ui->label_et_network->setStyleSheet(sTextNormalStyle);
  163. ui->label_et_networkIcon->setStyleSheet(sNumNormalStyle);
  164. ui->label_et_camera->setStyleSheet(sTextNormalStyle);
  165. ui->label_et_cameraIcon->setStyleSheet(sNumNormalStyle);
  166. ui->label_et_time->setStyleSheet(sTextHoverStyle);
  167. ui->label_et_timeIcon->setStyleSheet(sNumHoverStyle);
  168. }
  169. else if(step == ENV_TEST_STEP::ett_camera)
  170. {
  171. if (m_pTimeTest != nullptr)
  172. {
  173. m_pTimeTest->hide();
  174. }
  175. if (m_pVoiceTest != nullptr)
  176. {
  177. m_pVoiceTest->hide();
  178. }
  179. if(m_pCameraTest == nullptr)
  180. {
  181. m_pCameraTest = std::make_shared<etCameraTest>(ui->widget_et_BG);
  182. nHeight = m_pCameraTest->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  183. }
  184. nHeight = m_pCameraTest->widgetHeight();
  185. m_pCameraTest->show();
  186. ui->label_et_HLine2->setStyleSheet(sHLineHoverStyle);
  187. ui->label_et_HLine3->setStyleSheet(sHLineNormalStyle);
  188. ui->label_et_camera->setStyleSheet(sTextHoverStyle);
  189. ui->label_et_cameraIcon->setStyleSheet(sNumHoverStyle);
  190. ui->label_et_time->setStyleSheet(sTextNormalStyle);
  191. ui->label_et_timeIcon->setStyleSheet(sNumNormalStyle);
  192. ui->label_et_voice->setStyleSheet(sTextNormalStyle);
  193. ui->label_et_voiceIcon->setStyleSheet(sNumNormalStyle);
  194. }
  195. else if(step == ENV_TEST_STEP::ett_voice)
  196. {
  197. if (m_pCameraTest != nullptr)
  198. {
  199. m_pCameraTest->hide();
  200. }
  201. if (m_pMobileTest != nullptr)
  202. {
  203. m_pMobileTest->hide();
  204. }
  205. if(m_pVoiceTest == nullptr)
  206. {
  207. m_pVoiceTest = std::make_shared<etVoiceTest>(ui->widget_et_BG);
  208. nHeight = m_pVoiceTest->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  209. }
  210. nHeight = m_pVoiceTest->widgetHeight();
  211. m_pVoiceTest->show();
  212. ui->label_et_HLine3->setStyleSheet(sHLineHoverStyle);
  213. ui->label_et_HLine4->setStyleSheet(sHLineNormalStyle);
  214. ui->label_et_camera->setStyleSheet(sTextNormalStyle);
  215. ui->label_et_cameraIcon->setStyleSheet(sNumNormalStyle);
  216. ui->label_et_voice->setStyleSheet(sTextHoverStyle);
  217. ui->label_et_voiceIcon->setStyleSheet(sNumHoverStyle);
  218. ui->label_et_mobile->setStyleSheet(sTextNormalStyle);
  219. ui->label_et_mobileIcon->setStyleSheet(sNumNormalStyle);
  220. }
  221. else if(step == ENV_TEST_STEP::ett_mobile)
  222. {
  223. if (m_pVoiceTest != nullptr)
  224. {
  225. m_pVoiceTest->hide();
  226. }
  227. if (m_pTestResult != nullptr)
  228. {
  229. m_pTestResult->hide();
  230. }
  231. if(m_pMobileTest == nullptr)
  232. {
  233. m_pMobileTest = std::make_shared<etMobileTest>(ui->widget_et_BG);
  234. nHeight = m_pMobileTest->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  235. }
  236. nHeight = m_pMobileTest->widgetHeight();
  237. m_pMobileTest->show();
  238. ui->label_et_HLine4->setStyleSheet(sHLineHoverStyle);
  239. ui->label_et_HLine5->setStyleSheet(sHLineNormalStyle);
  240. ui->label_et_voice->setStyleSheet(sTextNormalStyle);
  241. ui->label_et_voiceIcon->setStyleSheet(sNumNormalStyle);
  242. ui->label_et_mobile->setStyleSheet(sTextHoverStyle);
  243. ui->label_et_mobileIcon->setStyleSheet(sNumHoverStyle);
  244. ui->label_et_result->setStyleSheet(sTextNormalStyle);
  245. ui->label_et_resultIcon->setStyleSheet(sNumNormalStyle);
  246. }
  247. else if(step == ENV_TEST_STEP::ett_result)
  248. {
  249. if (m_pMobileTest != nullptr)
  250. {
  251. m_pMobileTest->hide();
  252. }
  253. if(m_pTestResult == nullptr)
  254. {
  255. m_pTestResult = std::make_shared<etTestResult>(ui->widget_et_BG);
  256. //nHeight = m_pTestResult->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  257. }
  258. //nHeight = m_pTestResult->widgetHeight();
  259. int nNetworkStatus = m_pNetworkTest->getCheckStatus();
  260. int nTimekStatus = m_pTimeTest->getCheckStatus();
  261. int nCameraStatus = m_pCameraTest->getCheckStatus();
  262. int nVoiceStatus = m_pVoiceTest->getCheckStatus();
  263. int nWXStatus = m_pMobileTest->getCheckStatus();
  264. m_pTestResult->setResult(nNetworkStatus, nTimekStatus, nCameraStatus,
  265. nVoiceStatus, nWXStatus);
  266. nHeight = m_pTestResult->setUI(0, ui->widget_et_steps->y() + ui->widget_et_steps->height(), ui->widget_et_BG->width());
  267. m_pTestResult->show();
  268. ui->label_et_HLine5->setStyleSheet(sHLineHoverStyle);
  269. ui->label_et_mobile->setStyleSheet(sTextNormalStyle);
  270. ui->label_et_mobileIcon->setStyleSheet(sNumNormalStyle);
  271. ui->label_et_result->setStyleSheet(sTextHoverStyle);
  272. ui->label_et_resultIcon->setStyleSheet(sNumHoverStyle);
  273. ui->btn_nextStep->setText(QString::fromLocal8Bit("进入考试"));
  274. }
  275. nWidgetHeight = ui->widget_et_steps->y() + ui->widget_et_steps->height() + nHeight + g_appInfoPtr->m_fRate*90;
  276. ui->widget_et_BG->setGeometry((width() - g_appInfoPtr->m_fRate*800)/2, (height() - nWidgetHeight)/2,
  277. g_appInfoPtr->m_fRate*800, nWidgetHeight);
  278. ui->btn_nextStep->setGeometry(ui->widget_et_BG->width() - g_appInfoPtr->m_fRate*(30 + 80), ui->widget_et_BG->height() - g_appInfoPtr->m_fRate*(30 + 30),
  279. g_appInfoPtr->m_fRate*80, g_appInfoPtr->m_fRate*30);
  280. ui->btn_previousStep->setGeometry(ui->btn_nextStep->x() - g_appInfoPtr->m_fRate*10 - ui->btn_nextStep->width(), ui->btn_nextStep->y(),
  281. ui->btn_nextStep->width(), ui->btn_nextStep->height());
  282. }
  283. void environmentalTest::on_btn_previousStep_clicked()
  284. {
  285. if(m_curentStep > ENV_TEST_STEP::ett_network)
  286. {
  287. m_curentStep = static_cast<ENV_TEST_STEP>(static_cast<int>(m_curentStep) - 1);
  288. changeStepUI(m_curentStep);
  289. }
  290. }
  291. void environmentalTest::on_btn_nextStep_clicked()
  292. {
  293. if(m_curentStep < ENV_TEST_STEP::ett_result)
  294. {
  295. m_curentStep = static_cast<ENV_TEST_STEP>(static_cast<int>(m_curentStep) + 1);
  296. changeStepUI(m_curentStep);
  297. }
  298. else
  299. {
  300. emit enterExam();
  301. }
  302. }