#include "ProjectView.h" #include "ProjectListWidget.h" #include "RenameWidget.h" #include "ConfigExpertWidget.h" #include #include #include #include #include ProjectView::ProjectView(QWidget *parent) : QWidget(parent) { } void ProjectView::showEvent(QShowEvent *event) { qDebug() << __FUNCTION__ << __LINE__; if (m_initilized == false) { initialize(); initLayout(); connectSigalsAndSlots(); m_initilized = true; } QWidget::showEvent(event); } void ProjectView::hideEvent(QHideEvent *event) { QWidget::hideEvent(event); } void ProjectView::initialize() { m_hBoxLayout = new QHBoxLayout(this); m_listWidget = new QWidget(this); m_listWidget->setFixedWidth(260); QPalette pal(m_listWidget->palette()); pal.setColor(QPalette::Background, QColor("#f3f3f3")); m_listWidget->setAutoFillBackground(true); m_listWidget->setPalette(pal); m_listLayout = new QVBoxLayout(m_listWidget); m_buttonLayout = new QHBoxLayout(); m_searchLineEdit = new LineEdit(this); m_searchLineEdit->setIsClearButtonEnabled(true); m_searchLineEdit->setPlaceholderText("搜索工程"); m_renameButton = new ToolButton(NEWFLICON(FluentIcon, EDIT), this); m_renameButton->setToolTip("修改工程名"); m_newProjButton = new ToolButton(NEWFLICON(FluentIcon, ADD), this); m_newProjButton->setToolTip("新建工程"); m_deleteButton = new ToolButton(NEWFLICON(FluentIcon, DELETE), this); m_deleteButton->setToolTip("删除工程"); m_projListWidget = new ProjectListWidget(this); m_projDetailWidget = new QWidget(this); m_projLayout = new QVBoxLayout(m_projDetailWidget); m_projNameLabel = new QLabel(this); m_projNameLabel->setObjectName("projNameLabel"); m_projNameLabel->setText("工程1-技术方案评估"); m_separator = new QWidget(this); m_separator->setFixedWidth(1); m_separator->setStyleSheet("background-color:#dddddd"); m_configExpWidget = new ConfigExpertWidget(this); m_configExpWidget->setFixedWidth(260); m_renameWidget = new RenameWidget(this); } void ProjectView::initLayout() { m_hBoxLayout->setMargin(0); m_hBoxLayout->setSpacing(0); m_hBoxLayout->addWidget(m_listWidget); m_listLayout->addLayout(m_buttonLayout); m_buttonLayout->addWidget(m_searchLineEdit); m_buttonLayout->addWidget(m_newProjButton); m_buttonLayout->addWidget(m_renameButton); m_buttonLayout->addWidget(m_deleteButton); m_listLayout->addWidget(m_projListWidget); m_hBoxLayout->addWidget(m_projDetailWidget); m_projLayout->addWidget(m_projNameLabel); m_projLayout->addStretch(); m_hBoxLayout->addWidget(m_separator, Qt::AlignRight); m_hBoxLayout->addWidget(m_configExpWidget, Qt::AlignRight); setStyleSheet("#projNameLabel {font-size:20px;font:bold;color:#333333}"); } void ProjectView::connectSigalsAndSlots() { connect(m_renameButton, &ToolButton::clicked, this, &ProjectView::showRenameWidget); } void ProjectView::showRenameWidget() { if (m_renameWidget->isVisible() == false) { m_renameWidget->clearInputs(); m_renameWidget->show(); } }