ProjectView.cpp 3.0 KB

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