HomeView.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "HomeView.h"
  2. #include "CreateProjWidget.h"
  3. #include "ProjectStateWidget.h"
  4. #include <Widgets/Button.h>
  5. #include <Widgets/LineEdit.h>
  6. #include <QBoxLayout>
  7. #include <QLabel>
  8. #include <QDebug>
  9. HomeView::HomeView(QWidget *parent) : QWidget(parent)
  10. {
  11. initialize();
  12. initLayout();
  13. connectSignalsAndSlots();
  14. }
  15. void HomeView::initialize()
  16. {
  17. m_vBoxLayout = new QVBoxLayout(this);
  18. m_titleLabel = new QLabel(this);
  19. m_titleLabel->setText("工程列表");
  20. QFont ft("Microsoft YaHei", 12);
  21. m_titleLabel->setFont(ft);
  22. m_hBoxLayout = new QHBoxLayout();
  23. m_searchLineEdit = new SearchLineEdit(this);
  24. m_searchLineEdit->setPlaceholderText("搜索工程");
  25. m_searchLineEdit->setMinimumWidth(300);
  26. m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this);
  27. m_projStateWidget = new ProjectStateWidget(this);
  28. m_createProjWidget = new CreateProjWidget(this);
  29. }
  30. void HomeView::initLayout()
  31. {
  32. m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  33. m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
  34. m_vBoxLayout->addLayout(m_hBoxLayout);
  35. m_hBoxLayout->addWidget(m_titleLabel);
  36. m_hBoxLayout->addSpacing(15);
  37. m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
  38. m_hBoxLayout->addWidget(m_createProjPushButton, 1, Qt::AlignLeft);
  39. m_vBoxLayout->addWidget(m_projStateWidget);
  40. }
  41. void HomeView::connectSignalsAndSlots()
  42. {
  43. connect(m_createProjPushButton, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
  44. }
  45. void HomeView::slotCreateProjClicked()
  46. {
  47. if (m_createProjWidget->isVisible() == false) {
  48. m_createProjWidget->clearInputs();
  49. m_createProjWidget->show();
  50. }
  51. }