ProjectView.cpp 2.9 KB

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