ProjectView.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "ProjectView.h"
  2. #include "ProjectListWidget.h"
  3. #include "RenameWidget.h"
  4. #include <Widgets/Button.h>
  5. #include <Widgets/LineEdit.h>
  6. #include <QBoxLayout>
  7. #include <QLabel>
  8. ProjectView::ProjectView(QWidget *parent) : QWidget(parent)
  9. {
  10. initialize();
  11. initLayout();
  12. connectSiganlsAndSlots();
  13. }
  14. void ProjectView::initialize()
  15. {
  16. m_hBoxLayout = new QHBoxLayout(this);
  17. m_listWidget = new QWidget(this);
  18. m_listWidget->setFixedWidth(300);
  19. QPalette pal(m_listWidget->palette());
  20. pal.setColor(QPalette::Background, QColor("#f3f3f3"));
  21. m_listWidget->setAutoFillBackground(true);
  22. m_listWidget->setPalette(pal);
  23. m_listLayout = new QVBoxLayout(m_listWidget);
  24. m_buttonLayout = new QHBoxLayout();
  25. m_searchLineEdit = new LineEdit(this);
  26. m_searchLineEdit->setIsClearButtonEnabled(true);
  27. m_searchLineEdit->setPlaceholderText("搜索工程");
  28. m_renameButton = new ToolButton(NEWFLICON(FluentIcon, EDIT), this);
  29. m_renameButton->setToolTip("修改工程名");
  30. m_newProjButton = new ToolButton(NEWFLICON(FluentIcon, ADD), this);
  31. m_newProjButton->setToolTip("新建工程");
  32. m_deleteButton = new ToolButton(NEWFLICON(FluentIcon, DELETE), this);
  33. m_deleteButton->setToolTip("删除工程");
  34. m_projListWidget = new ProjectListWidget(this);
  35. m_projDetailWidget = new QWidget(this);
  36. m_projLayout = new QVBoxLayout();
  37. m_projNameLabel = new QLabel(this);
  38. m_projNameLabel->setText("工程名");
  39. m_renameWidget = new RenameWidget(this);
  40. }
  41. void ProjectView::initLayout()
  42. {
  43. m_hBoxLayout->setMargin(0);
  44. m_hBoxLayout->addWidget(m_listWidget);
  45. m_listLayout->addLayout(m_buttonLayout);
  46. m_buttonLayout->addWidget(m_searchLineEdit);
  47. m_buttonLayout->addWidget(m_newProjButton);
  48. m_buttonLayout->addWidget(m_renameButton);
  49. m_buttonLayout->addWidget(m_deleteButton);
  50. m_listLayout->addWidget(m_projListWidget);
  51. m_hBoxLayout->addWidget(m_projDetailWidget);
  52. m_projDetailWidget->setLayout(m_projLayout);
  53. m_projLayout->addWidget(m_projNameLabel, Qt::AlignTop);
  54. }
  55. void ProjectView::connectSiganlsAndSlots()
  56. {
  57. connect(m_renameButton, &ToolButton::clicked, this, &ProjectView::showRenameWidget);
  58. }
  59. void ProjectView::showRenameWidget()
  60. {
  61. if (m_renameWidget->isVisible() == false) {
  62. m_renameWidget->clearInputs();
  63. m_renameWidget->show();
  64. }
  65. }