etTestResult.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. #include "etTestResult.h"
  2. #include "ui_etTestResult.h"
  3. #include "CAppInfo.h"
  4. #include <QScrollBar>
  5. #include <QHBoxLayout>
  6. #include <QLabel>
  7. etTestResult::etTestResult(QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::etTestResult)
  10. {
  11. ui->setupUi(this);
  12. setStyleSheet(g_appInfoPtr->m_sQssStr);
  13. ui->tablewt_envTest->setEditTriggers(QAbstractItemView::NoEditTriggers);
  14. //整行选中的方式
  15. ui->tablewt_envTest->setSelectionBehavior(QAbstractItemView::SelectRows);
  16. //设置为只能选中一行
  17. ui->tablewt_envTest->setSelectionMode(QAbstractItemView::SingleSelection);
  18. //隐藏列表头
  19. ui->tablewt_envTest->verticalHeader()->setVisible(false);
  20. //隐藏边框
  21. ui->tablewt_envTest->setShowGrid(false);
  22. //表头不高亮显示
  23. ui->tablewt_envTest->horizontalHeader()->setVisible(false);// ->setHighlightSections(false);
  24. //设置行数
  25. ui->tablewt_envTest->setRowCount(6);
  26. //设置列数
  27. ui->tablewt_envTest->setColumnCount(2);
  28. ui->tablewt_envTest->setHorizontalScrollMode(QTableWidget::ScrollPerPixel);
  29. ui->tablewt_envTest->horizontalScrollBar()->setSingleStep(g_appInfoPtr->m_fRate * 5);
  30. QStringList sHeadStr;
  31. sHeadStr << QString::fromLocal8Bit("检测项") <<
  32. QString::fromLocal8Bit("结果");
  33. ui->tablewt_envTest->setHorizontalHeaderLabels(sHeadStr);
  34. ui->tablewt_envTest->horizontalHeader()->setDefaultAlignment(Qt::AlignJustify | Qt::AlignVCenter);
  35. ui->tablewt_envTest->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
  36. ui->tablewt_envTest->verticalHeader()->setDefaultSectionSize(g_appInfoPtr->m_fRate * 48);
  37. ui->tablewt_envTest->setColumnWidth(0, g_appInfoPtr->m_fRate * 425);
  38. // ui->tablewt_envTest->setColumnWidth(1, g_appInfoPtr->m_fRate * 170);
  39. ui->tablewt_envTest->horizontalHeader()->setStretchLastSection(true);
  40. }
  41. etTestResult::~etTestResult()
  42. {
  43. delete ui;
  44. }
  45. int etTestResult::setUI(const int nLeft, const int nTop, const int nWidth)
  46. {
  47. setGeometry(nLeft, nTop, nWidth, g_appInfoPtr->m_fRate*146);
  48. ui->tablewt_envTest->setGeometry(g_appInfoPtr->m_fRate*30, 0, width() - g_appInfoPtr->m_fRate*30*2, g_appInfoPtr->m_fRate*293);
  49. QString sTextStyle = QString(R"(QLabel
  50. {
  51. font-size:%1px;
  52. font-family:"Microsoft YaHei";
  53. font-weight:400;
  54. color:rgba(153,153,153,1);
  55. })").arg((int)(g_appInfoPtr->m_fRate * 12));
  56. {
  57. int i = 0;
  58. QWidget *widget1 = new QWidget;
  59. QHBoxLayout *layout1 = new QHBoxLayout;
  60. widget1->setLayout(layout1);
  61. QLabel *icon1 = new QLabel;
  62. icon1->setStyleSheet(sTextStyle);
  63. icon1->setText(QString::fromLocal8Bit("检查项"));
  64. layout1->addWidget(icon1);
  65. layout1->addStretch();
  66. ui->tablewt_envTest->setCellWidget(i, 0, widget1);
  67. QWidget *widget = new QWidget;
  68. QHBoxLayout *layout = new QHBoxLayout;
  69. widget->setLayout(layout);
  70. QLabel *icon = new QLabel;
  71. icon->setStyleSheet(sTextStyle);
  72. icon->setText(QString::fromLocal8Bit("结果"));
  73. layout->addStretch();
  74. layout->addWidget(icon);
  75. ui->tablewt_envTest->setCellWidget(i, 1, widget);
  76. }
  77. ui->lw_ettr_unpass->setGeometry(ui->tablewt_envTest->x(), ui->tablewt_envTest->y() + ui->tablewt_envTest->height() + g_appInfoPtr->m_fRate*20,
  78. ui->tablewt_envTest->width(), ui->lw_ettr_unpass->count()*g_appInfoPtr->m_fRate*26);
  79. setGeometry(nLeft, nTop, nWidth, ui->lw_ettr_unpass->y() + ui->lw_ettr_unpass->height());
  80. return height();
  81. }
  82. int etTestResult::widgetHeight()
  83. {
  84. return ui->lw_ettr_unpass->y() + ui->lw_ettr_unpass->height();
  85. }
  86. void etTestResult::setResult(int nNetWorkStatus, int nTimekStatus, int nCameraStatus, int nVoiceStatus, int nWXStatus)
  87. {
  88. QString sTextStyle = QString(R"(QLabel
  89. {
  90. font-size:%1px;
  91. font-family:"Microsoft YaHei";
  92. font-weight:400;
  93. color:rgba(254,119,100,1);
  94. })").arg((int)(g_appInfoPtr->m_fRate*12));
  95. ui->lw_ettr_unpass->clear();
  96. ui->lw_ettr_unpass->setIconSize(QSize(g_appInfoPtr->m_fRate*16, g_appInfoPtr->m_fRate*16));
  97. int i = 1;
  98. {
  99. ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("网速")));
  100. QWidget *widget = new QWidget;
  101. QHBoxLayout *layout = new QHBoxLayout;
  102. widget->setLayout(layout);
  103. layout->addStretch();
  104. QLabel *icon = new QLabel;
  105. if(nNetWorkStatus == 1)
  106. {
  107. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  108. icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  109. }
  110. else
  111. {
  112. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  113. icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  114. QListWidgetItem *item = new QListWidgetItem(QIcon(QPixmap(":/images/icon-et-tips.png")), QString::fromLocal8Bit("检查网络是否连接,路由器是否正常工作。"));
  115. ui->lw_ettr_unpass->addItem(item);
  116. item->setSizeHint(QSize(item->sizeHint().width(), g_appInfoPtr->m_fRate*26));
  117. }
  118. layout->addWidget(icon);
  119. ui->tablewt_envTest->setCellWidget(i, 1, widget);
  120. }
  121. {
  122. i = 2;
  123. ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("时钟")));
  124. QWidget *widget = new QWidget;
  125. QHBoxLayout *layout = new QHBoxLayout;
  126. widget->setLayout(layout);
  127. layout->addStretch();
  128. QLabel *icon = new QLabel;
  129. if(nTimekStatus == 1)
  130. {
  131. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  132. icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  133. }
  134. else
  135. {
  136. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  137. icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  138. QListWidgetItem *item = new QListWidgetItem(QIcon(QPixmap(":/images/icon-et-tips.png")), QString::fromLocal8Bit("检查电脑时区及时钟是否正常。"));
  139. ui->lw_ettr_unpass->addItem(item);
  140. item->setSizeHint(QSize(item->sizeHint().width(), g_appInfoPtr->m_fRate * 26));
  141. }
  142. layout->addWidget(icon);
  143. ui->tablewt_envTest->setCellWidget(i, 1, widget);
  144. }
  145. {
  146. i = 3;
  147. ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("摄像头")));
  148. QWidget *widget = new QWidget;
  149. QHBoxLayout *layout = new QHBoxLayout;
  150. widget->setLayout(layout);
  151. layout->addStretch();
  152. QLabel *icon = new QLabel;
  153. if(nCameraStatus == 1)
  154. {
  155. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  156. icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  157. }
  158. else if(nCameraStatus == 0)
  159. {
  160. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  161. icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  162. QListWidgetItem *item = new QListWidgetItem(QIcon(QPixmap(":/images/icon-et-tips.png")), QString::fromLocal8Bit("请确认摄像头连接线正常,能正常工作,关闭杀毒软件;请确认您的电脑是否为双摄像头,启用摄像头是否正确。"));
  163. ui->lw_ettr_unpass->addItem(item);
  164. item->setSizeHint(QSize(item->sizeHint().width(), g_appInfoPtr->m_fRate * 26));
  165. }
  166. else if(nCameraStatus == 2)
  167. {
  168. icon->setStyleSheet(sTextStyle);
  169. icon->setText(QString::fromLocal8Bit("请在“摄像头”步骤进行人工确认!"));
  170. icon->adjustSize();
  171. }
  172. layout->addWidget(icon);
  173. ui->tablewt_envTest->setCellWidget(i, 1, widget);
  174. }
  175. {
  176. i = 4;
  177. ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("声音")));
  178. QWidget *widget = new QWidget;
  179. QHBoxLayout *layout = new QHBoxLayout;
  180. widget->setLayout(layout);
  181. layout->addStretch();
  182. QLabel *icon = new QLabel;
  183. if(nVoiceStatus == 1)
  184. {
  185. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  186. icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  187. }
  188. else if(nVoiceStatus == 0)
  189. {
  190. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  191. icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  192. QListWidgetItem *item = new QListWidgetItem(QIcon(QPixmap(":/images/icon-et-tips.png")), QString::fromLocal8Bit("请确认音箱连接正常,调节音量开关及大小。"));
  193. ui->lw_ettr_unpass->addItem(item);
  194. item->setSizeHint(QSize(item->sizeHint().width(), g_appInfoPtr->m_fRate * 26));
  195. }
  196. else if(nVoiceStatus == 2)
  197. {
  198. icon->setStyleSheet(sTextStyle);
  199. icon->setText(QString::fromLocal8Bit("请在“声音”步骤进行人工确认!"));
  200. icon->adjustSize();
  201. }
  202. layout->addWidget(icon);
  203. ui->tablewt_envTest->setCellWidget(i, 1, widget);
  204. }
  205. {
  206. i = 5;
  207. ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("微信小程序")));
  208. QWidget *widget = new QWidget;
  209. QHBoxLayout *layout = new QHBoxLayout;
  210. widget->setLayout(layout);
  211. layout->addStretch();
  212. QLabel *icon = new QLabel;
  213. if(nWXStatus == 1)
  214. {
  215. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  216. icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
  217. }
  218. else if(nWXStatus == 0)
  219. {
  220. icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  221. icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  222. QListWidgetItem *item = new QListWidgetItem(QIcon(QPixmap(":/images/icon-et-tips.png")), QString::fromLocal8Bit("请确认微信已登录并连接网络。"));
  223. ui->lw_ettr_unpass->addItem(item);
  224. item->setSizeHint(QSize(item->sizeHint().width(), g_appInfoPtr->m_fRate * 26));
  225. }
  226. else if(nWXStatus == 2)
  227. {
  228. icon->setStyleSheet(sTextStyle);
  229. icon->setText(QString::fromLocal8Bit("请在“微信小程序”步骤进行人工确认!"));
  230. icon->adjustSize();
  231. }
  232. layout->addWidget(icon);
  233. ui->tablewt_envTest->setCellWidget(i, 1, widget);
  234. }
  235. if(ui->lw_ettr_unpass->count() > 0)
  236. {
  237. QListWidgetItem *item = new QListWidgetItem(QIcon(QPixmap(":/images/icon-et-tips.png")), QString::fromLocal8Bit("请按提示检查并调试,调试后可再次进行环境检测。"));
  238. ui->lw_ettr_unpass->addItem(item);
  239. }
  240. }