clMobileLogin.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #include "clMobileLogin.h"
  2. #include "ui_clMobileLogin.h"
  3. #include "CAppInfo.h"
  4. #include "CQREncode.h"
  5. #include <QGraphicsDropShadowEffect>
  6. #include <QByteArray>
  7. #include "logproc.h"
  8. clMobileLogin::clMobileLogin(QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::clMobileLogin)
  11. {
  12. ui->setupUi(this);
  13. setStyleSheet(g_appInfoPtr->m_sQssStr);
  14. }
  15. clMobileLogin::~clMobileLogin()
  16. {
  17. delete ui;
  18. }
  19. void clMobileLogin::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  20. {
  21. setGeometry(nLeft, nTop, nWidth, nHeight);
  22. ui->widget_npw_BG->setGeometry(g_appInfoPtr->m_fRate*5, g_appInfoPtr->m_fRate*5, width()-g_appInfoPtr->m_fRate*10, height()-g_appInfoPtr->m_fRate*10);
  23. ui->btn_downloadApp->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*20,
  24. g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*32);
  25. ui->btn_bindUser->setGeometry(ui->btn_downloadApp->x() + ui->btn_downloadApp->width(),
  26. ui->btn_downloadApp->y(), ui->btn_downloadApp->width(), ui->btn_downloadApp->height());
  27. ui->label_qrcode->setGeometry((ui->widget_npw_BG->width() - g_appInfoPtr->m_fRate*164)/2, ui->btn_downloadApp->y() + ui->btn_downloadApp->height() + g_appInfoPtr->m_fRate*20,
  28. g_appInfoPtr->m_fRate*164, g_appInfoPtr->m_fRate*164);
  29. ui->label_useAppScan->adjustSize();
  30. ui->label_useAppScan->setGeometry((ui->widget_npw_BG->width() - ui->label_useAppScan->width())/2,
  31. ui->label_qrcode->y() + ui->label_qrcode->height() + g_appInfoPtr->m_fRate*10,
  32. ui->label_useAppScan->width(), ui->label_useAppScan->height());
  33. QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
  34. effect->setOffset(g_appInfoPtr->m_fRate*4,g_appInfoPtr->m_fRate*4);
  35. effect->setColor(QColor(0,0,0,30));
  36. effect->setBlurRadius(g_appInfoPtr->m_fRate*16);
  37. ui->widget_npw_BG->setGraphicsEffect(effect);
  38. on_btn_downloadApp_clicked();
  39. }
  40. void clMobileLogin::setBtnDown(ML_BTN_TYPE type)
  41. {
  42. QString sDownLoadAppStyle = QString(R"(QPushButton
  43. {
  44. outline:none;
  45. background:rgba(%1,1);
  46. font-size:%2px;
  47. font-family:"Microsoft YaHei";
  48. font-weight:400;
  49. color:rgba(%3,1);
  50. border-top-left-radius:%4px;
  51. border-bottom-left-radius:%5px;
  52. })");
  53. QString sDownLoadAppNormalStyle = sDownLoadAppStyle.arg("244,243,247").arg((int)(g_appInfoPtr->m_fRate*12))
  54. .arg("102, 102, 102")
  55. .arg((int)(g_appInfoPtr->m_fRate*6))
  56. .arg((int)(g_appInfoPtr->m_fRate*6));
  57. QString sDownLoadAppCheckStyle = sDownLoadAppStyle.arg("19,187,138").arg((int)(g_appInfoPtr->m_fRate * 12))
  58. .arg("255,255,255")
  59. .arg((int)(g_appInfoPtr->m_fRate * 6))
  60. .arg((int)(g_appInfoPtr->m_fRate * 6));
  61. QString sBindUserStyle = QString(R"(QPushButton
  62. {
  63. outline:none;
  64. background:rgba(%1,1);
  65. font-size:%2px;
  66. font-family:"Microsoft YaHei";
  67. font-weight:400;
  68. color:rgba(%3,1);
  69. border-top-right-radius:%4px;
  70. border-bottom-right-radius:%5px;
  71. })");
  72. QString sBindUserNormalStyle = sBindUserStyle.arg("244,243,247").arg((int)(g_appInfoPtr->m_fRate * 12))
  73. .arg("102, 102, 102").arg((int)(g_appInfoPtr->m_fRate*6))
  74. .arg((int)(g_appInfoPtr->m_fRate*6));
  75. QString sBindUserCheckStyle = sBindUserStyle.arg("19,187,138").arg((int)(g_appInfoPtr->m_fRate * 12))
  76. .arg("255,255,255").arg((int)(g_appInfoPtr->m_fRate * 6))
  77. .arg((int)(g_appInfoPtr->m_fRate * 6));
  78. if(type == ML_BTN_TYPE::mbt_downloadApp)
  79. {
  80. ui->btn_downloadApp->setStyleSheet(sDownLoadAppCheckStyle);
  81. ui->btn_bindUser->setStyleSheet(sBindUserNormalStyle);
  82. }
  83. else
  84. {
  85. ui->btn_downloadApp->setStyleSheet(sDownLoadAppNormalStyle);
  86. ui->btn_bindUser->setStyleSheet(sBindUserCheckStyle);
  87. }
  88. }
  89. void clMobileLogin::on_btn_downloadApp_clicked()
  90. {
  91. ui->label_qrcode->setPixmap(CQREncode::GenerateQRcode(g_appInfoPtr->m_sAppDownLoadUrl, ui->label_qrcode->width()));
  92. ui->label_useAppScan->setVisible(false);
  93. setBtnDown(ML_BTN_TYPE::mbt_downloadApp);
  94. }
  95. void clMobileLogin::on_btn_bindUser_clicked()
  96. {
  97. QString sUserInfo = QString::fromLocal8Bit("%1@%2").arg(g_appInfoPtr->m_sRootOrgId).arg(g_appInfoPtr->m_sRootOrgName);
  98. sUserInfo = QByteArray(sUserInfo.toUtf8()).toBase64();
  99. ui->label_qrcode->setPixmap(CQREncode::GenerateQRcode(sUserInfo, ui->label_qrcode->width()));
  100. ui->label_useAppScan->setVisible(true);
  101. setBtnDown(ML_BTN_TYPE::mbt_bindUser);
  102. }