HomeView.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "HomeView.h"
  2. #include "CreateProjView.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. // this->setStyleSheet("background-color: rgb(250, 250, 250);");
  15. }
  16. void HomeView::initialize()
  17. {
  18. m_vBoxLayout = new QVBoxLayout(this);
  19. m_titleLabel = new QLabel(this);
  20. m_titleLabel->setText("工程列表");
  21. QFont ft("Microsoft YaHei", 12);
  22. m_titleLabel->setFont(ft);
  23. m_hBoxLayout = new QHBoxLayout();
  24. m_searchLineEdit = new SearchLineEdit(this);
  25. m_searchLineEdit->setPlaceholderText("搜索工程");
  26. m_searchLineEdit->setMinimumWidth(300);
  27. m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this);
  28. m_projStateWidget = new ProjectStateWidget(this);
  29. m_createProjView = new CreateProjView(this);
  30. }
  31. void HomeView::initLayout()
  32. {
  33. m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  34. m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
  35. m_vBoxLayout->addLayout(m_hBoxLayout);
  36. m_hBoxLayout->addWidget(m_titleLabel);
  37. m_hBoxLayout->addSpacing(15);
  38. m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
  39. m_hBoxLayout->addWidget(m_createProjPushButton, 1, Qt::AlignLeft);
  40. m_vBoxLayout->addWidget(m_projStateWidget);
  41. }
  42. void HomeView::connectSignalsAndSlots()
  43. {
  44. connect(m_createProjPushButton, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
  45. }
  46. void HomeView::slotCreateProjClicked()
  47. {
  48. if (m_createProjView->isVisible() == false) {
  49. m_createProjView->clearInputs();
  50. m_createProjView->show();
  51. }
  52. }