#include "HomeView.h" #include "CreateProjWidget.h" #include "ProjectStateWidget.h" #include #include #include #include #include HomeView::HomeView(QWidget *parent) : QWidget(parent) { } void HomeView::showEvent(QShowEvent *event) { qDebug() << __FUNCTION__ << __LINE__; if (m_initilized == false) { initialize(); initLayout(); connectSignalsAndSlots(); m_initilized = true; } QWidget::showEvent(event); } void HomeView::hideEvent(QHideEvent *event) { qDebug() << __FUNCTION__ << __LINE__; QWidget::hideEvent(event); } void HomeView::initialize() { m_vBoxLayout = new QVBoxLayout(this); m_titleLabel = new QLabel(this); m_titleLabel->setText("工程列表"); QFont ft("Microsoft YaHei", 12); m_titleLabel->setFont(ft); m_hBoxLayout = new QHBoxLayout(); m_searchLineEdit = new SearchLineEdit(this); m_searchLineEdit->setPlaceholderText("搜索工程"); m_searchLineEdit->setMinimumWidth(300); m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this); m_projStateWidget = new ProjectStateWidget(this); m_createProjWidget = new CreateProjWidget(this); } void HomeView::initLayout() { m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); m_vBoxLayout->setContentsMargins(15, 10, 10, 15); m_vBoxLayout->addLayout(m_hBoxLayout); m_hBoxLayout->addWidget(m_titleLabel); m_hBoxLayout->addSpacing(15); m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft); m_hBoxLayout->addWidget(m_createProjPushButton, 1, Qt::AlignLeft); m_vBoxLayout->addWidget(m_projStateWidget); } void HomeView::connectSignalsAndSlots() { connect(m_createProjPushButton, &PushButton::clicked, this, &HomeView::slotCreateProjClicked); } void HomeView::slotCreateProjClicked() { if (m_createProjWidget->isVisible() == false) { m_createProjWidget->clearInputs(); m_createProjWidget->show(); } }