ProjectView.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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->setText("工程名");
  40. m_separator = new QWidget(this);
  41. m_separator->setFixedWidth(1);
  42. m_separator->setStyleSheet("background-color:#dddddd");
  43. m_configExpWidget = new ConfigExpertWidget(this);
  44. m_configExpWidget->setFixedWidth(260);
  45. m_renameWidget = new RenameWidget(this);
  46. }
  47. void ProjectView::initLayout()
  48. {
  49. m_hBoxLayout->setMargin(0);
  50. m_hBoxLayout->setSpacing(0);
  51. m_hBoxLayout->addWidget(m_listWidget);
  52. m_listLayout->addLayout(m_buttonLayout);
  53. m_buttonLayout->addWidget(m_searchLineEdit);
  54. m_buttonLayout->addWidget(m_newProjButton);
  55. m_buttonLayout->addWidget(m_renameButton);
  56. m_buttonLayout->addWidget(m_deleteButton);
  57. m_listLayout->addWidget(m_projListWidget);
  58. m_hBoxLayout->addWidget(m_projDetailWidget);
  59. m_projLayout->addWidget(m_projNameLabel, Qt::AlignTop);
  60. m_hBoxLayout->addWidget(m_separator, Qt::AlignRight);
  61. m_hBoxLayout->addWidget(m_configExpWidget, Qt::AlignRight);
  62. }
  63. void ProjectView::connectSiganlsAndSlots()
  64. {
  65. connect(m_renameButton, &ToolButton::clicked, this, &ProjectView::showRenameWidget);
  66. }
  67. void ProjectView::showRenameWidget()
  68. {
  69. if (m_renameWidget->isVisible() == false) {
  70. m_renameWidget->clearInputs();
  71. m_renameWidget->show();
  72. }
  73. }