RenameWidget.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "RenameWidget.h"
  2. #include <Widgets/Button.h>
  3. #include <Widgets/LineEdit.h>
  4. #include <QBoxLayout>
  5. #include <QLabel>
  6. RenameWidget::RenameWidget(QWidget *parent) : QDialog(parent)
  7. {
  8. initWindow();
  9. initialize();
  10. initLayout();
  11. connectSignalsAndSlots();
  12. }
  13. void RenameWidget::clearInputs()
  14. {
  15. m_nameLineEdit->clear();
  16. }
  17. void RenameWidget::initWindow()
  18. {
  19. setWindowTitle("修改工程名称");
  20. setModal(true);
  21. setWindowFlags(Qt::Dialog);
  22. setWindowFlag(Qt::WindowContextHelpButtonHint, false);
  23. resize(350, 180);
  24. }
  25. void RenameWidget::initialize()
  26. {
  27. m_vBoxLayout = new QVBoxLayout(this);
  28. m_oldNameLayout = new QHBoxLayout();
  29. m_oldNameLabel = new QLabel(this);
  30. m_oldNameLabel->setObjectName("oldNameLabel");
  31. m_oldNameLabel->setText("原名称:");
  32. m_oldNameValueLabel = new QLabel(this);
  33. m_oldNameValueLabel->setObjectName("oldNameValueLabel");
  34. m_oldNameValueLabel->setText("工程1");
  35. m_nameLineEdit = new LineEdit(this);
  36. m_nameLineEdit->setPlaceholderText("请输入新工程名");
  37. m_buttonLayout = new QHBoxLayout();
  38. m_confirmButton = new PushButton("确定", this);
  39. m_cancelButton = new PushButton("取消", this);
  40. setStyleSheet("QLabel {color:rgb(88,88,88); font-size:14px}");
  41. }
  42. void RenameWidget::initLayout()
  43. {
  44. m_vBoxLayout->setMargin(20);
  45. m_vBoxLayout->addLayout(m_oldNameLayout);
  46. m_oldNameLayout->addWidget(m_oldNameLabel);
  47. m_oldNameLayout->addWidget(m_oldNameValueLabel);
  48. m_oldNameLayout->addStretch();
  49. m_vBoxLayout->addSpacing(10);
  50. m_vBoxLayout->addWidget(m_nameLineEdit);
  51. m_vBoxLayout->addStretch();
  52. m_vBoxLayout->addLayout(m_buttonLayout);
  53. m_buttonLayout->addStretch();
  54. m_buttonLayout->addWidget(m_confirmButton);
  55. m_buttonLayout->addWidget(m_cancelButton);
  56. }
  57. void RenameWidget::connectSignalsAndSlots()
  58. {
  59. connect(m_confirmButton, &ToolButton::clicked, this, &RenameWidget::slotConfirmClicked);
  60. connect(m_cancelButton, &ToolButton::clicked, this, &RenameWidget::slotCancelClicked);
  61. }
  62. void RenameWidget::updateRenameButtonState() { }
  63. void RenameWidget::slotTextChanged(const QString &) { }
  64. void RenameWidget::slotConfirmClicked()
  65. {
  66. close();
  67. }
  68. void RenameWidget::slotCancelClicked()
  69. {
  70. close();
  71. }