RegisterWidget.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "RegisterWidget.h"
  2. #include <Widgets/LineEdit.h>
  3. #include <Widgets/Button.h>
  4. #include <QBoxLayout>
  5. #include <QLabel>
  6. RegisterWidget::RegisterWidget(QWidget *parent) : QWidget(parent)
  7. {
  8. initialize();
  9. initLayout();
  10. connectSignalsAndSlots();
  11. }
  12. const QString RegisterWidget::account() const
  13. {
  14. return m_accLineEdit->text();
  15. }
  16. const QString RegisterWidget::password() const
  17. {
  18. return m_pwLineEdit->text();
  19. }
  20. const QString RegisterWidget::repeatPassword() const
  21. {
  22. return m_pw2LineEdit->text();
  23. }
  24. void RegisterWidget::initialize()
  25. {
  26. m_vBoxLayout = new QVBoxLayout(this);
  27. m_titleLabel = new QLabel(this);
  28. m_titleLabel->setText("初次使用,请修改账号和密码");
  29. m_titleLabel->setStyleSheet("color:#ffffff;");
  30. QFont ft;
  31. ft.setPointSize(12);
  32. ft.setBold(true);
  33. m_titleLabel->setFont(ft);
  34. m_accLineEdit = new LineEdit(this);
  35. m_accLineEdit->setIsClearButtonEnabled(true);
  36. m_accLineEdit->setPlaceholderText("新账号id");
  37. m_accLineEdit->setFixedWidth(250);
  38. m_pwLineEdit = new PasswordLineEdit(this);
  39. m_pwLineEdit->setPlaceholderText("新密码");
  40. m_pwLineEdit->setFixedWidth(250);
  41. m_pw2LineEdit = new PasswordLineEdit(this);
  42. m_pw2LineEdit->setPlaceholderText("确认密码");
  43. m_pw2LineEdit->setFixedWidth(250);
  44. m_buttonLayout = new QHBoxLayout();
  45. m_confirmButton = new PushButton("确定", this);
  46. m_cancelButton = new PushButton("取消", this);
  47. }
  48. void RegisterWidget::initLayout()
  49. {
  50. setLayout(m_vBoxLayout);
  51. m_vBoxLayout->setAlignment(Qt::AlignCenter);
  52. m_vBoxLayout->addWidget(m_titleLabel);
  53. m_vBoxLayout->addSpacing(20);
  54. m_vBoxLayout->addWidget(m_accLineEdit);
  55. m_vBoxLayout->addSpacing(20);
  56. m_vBoxLayout->addWidget(m_pwLineEdit);
  57. m_vBoxLayout->addSpacing(20);
  58. m_vBoxLayout->addWidget(m_pw2LineEdit);
  59. m_vBoxLayout->addSpacing(40);
  60. m_vBoxLayout->addLayout(m_buttonLayout);
  61. m_buttonLayout->addWidget(m_confirmButton);
  62. m_buttonLayout->addSpacing(20);
  63. m_buttonLayout->addWidget(m_cancelButton);
  64. }
  65. void RegisterWidget::connectSignalsAndSlots()
  66. {
  67. connect(m_confirmButton, &PushButton::clicked, this, &RegisterWidget::signalConfirm);
  68. connect(m_cancelButton, &PushButton::clicked, this, &RegisterWidget::signalCancel);
  69. }