Browse Source

Config expert.

chengxr 1 year ago
parent
commit
4c29634af9

+ 6 - 0
QFD/view/ProjectView.cpp

@@ -50,6 +50,10 @@ void ProjectView::initialize()
     m_projNameLabel = new QLabel(this);
     m_projNameLabel->setText("工程名");
 
+    m_separator = new QWidget(this);
+    m_separator->setFixedWidth(1);
+    m_separator->setStyleSheet("background-color:#dddddd");
+
     m_configExpWidget = new ConfigExpertWidget(this);
     m_configExpWidget->setFixedWidth(260);
 
@@ -59,6 +63,7 @@ void ProjectView::initialize()
 void ProjectView::initLayout()
 {
     m_hBoxLayout->setMargin(0);
+    m_hBoxLayout->setSpacing(0);
 
     m_hBoxLayout->addWidget(m_listWidget);
 
@@ -74,6 +79,7 @@ void ProjectView::initLayout()
 
     m_projLayout->addWidget(m_projNameLabel, Qt::AlignTop);
 
+    m_hBoxLayout->addWidget(m_separator, Qt::AlignRight);
     m_hBoxLayout->addWidget(m_configExpWidget, Qt::AlignRight);
 }
 

+ 2 - 0
QFD/view/ProjectView.h

@@ -47,6 +47,8 @@ private:
     QVBoxLayout *m_projLayout   = nullptr;
     QLabel *m_projNameLabel     = nullptr;
 
+    QWidget *m_separator = nullptr;
+
     ConfigExpertWidget *m_configExpWidget = nullptr;
 
     RenameWidget *m_renameWidget = nullptr;

+ 103 - 10
QFD/widgets/ConfigExpertWidget.cpp

@@ -1,49 +1,142 @@
 #include "ConfigExpertWidget.h"
 
+#include <Common/Icon.h>
+#include <Widgets/Button.h>
+
 #include <QBoxLayout>
 #include <QSplitter>
 #include <QLabel>
+#include <QListWidget>
 
 ConfigExpertWidget::ConfigExpertWidget(QWidget *parent) : QWidget(parent)
 {
     initialize();
     initLayout();
     connectSignalsAndSlots();
+
+    refreshAddedList();
+    refreshExpList();
 }
 
 void ConfigExpertWidget::initialize()
 {
     QPalette pal(palette());
-    pal.setColor(QPalette::Background, QColor("#eeeeee"));
+    pal.setColor(QPalette::Background, QColor("#ffffff"));
     setAutoFillBackground(true);
     setPalette(pal);
 
     m_vBoxLayout = new QVBoxLayout(this);
-    m_titleLabel = new QLabel("配置专家", this);
+    m_titleLabel = new QLabel("专家配置", this);
     m_titleLabel->setObjectName("titleLabel");
+    m_titleLabel->setFixedHeight(50);
+    m_titleLabel->setContentsMargins(10, 0, 0, 0);
     m_splitter = new QSplitter(Qt::Vertical, this);
     m_splitter->setChildrenCollapsible(false);
+
+    m_addedWidget = new QWidget(this);
+    m_addedWidget->setObjectName("addedWidget");
+    m_addedWidgetLayout = new QVBoxLayout(m_addedWidget);
+    m_addedWidgetLayout->setSpacing(0);
+    m_addedWidgetLayout->setMargin(0);
+    m_addedListHeader       = new QWidget(this);
+    m_addedListHeaderLayout = new QHBoxLayout(m_addedListHeader);
+    m_addedListHeader->setObjectName("addedListHeader");
+    m_addedListTitleLabel = new QLabel("已添加", this);
+    m_addedListTitleLabel->setObjectName("addedListTitleLabel");
+    m_addedListTitleLabel->setMargin(5);
+    m_saveButton = new QPushButton(NEWFLICON(FluentIcon, SAVE)->icon(), "", this);
+    m_saveButton->setObjectName("saveButton");
+    m_saveButton->setFixedSize(QSize(30, 30));
+    m_saveButton->setToolTip("保存");
+    m_addedListWidget = new QListWidget(this);
+    m_addedListWidget->setObjectName("addedListWidget");
+
+    m_expWidget = new QWidget(this);
+    m_expWidget->setObjectName("expWidget");
+    m_expWidgetLayout = new QVBoxLayout(m_expWidget);
+    m_expWidgetLayout->setSpacing(0);
+    m_expWidgetLayout->setMargin(0);
+    m_expListHeader = new QWidget(this);
+    m_expListHeader->setObjectName("expListHeader");
+    m_expListHeaderLayout = new QHBoxLayout(m_expListHeader);
+    m_expListTitleLabel   = new QLabel("专家列表", this);
+    m_expListTitleLabel->setObjectName("expListTitleLabel");
+    m_expListTitleLabel->setMargin(5);
+    m_refreshButton = new QPushButton(NEWFLICON(FluentIcon, SYNC)->icon(), "", this);
+    m_refreshButton->setObjectName("refreshButton");
+    m_refreshButton->setFixedSize(QSize(30, 30));
+    m_refreshButton->setToolTip("刷新");
+    m_expListWidget = new QListWidget(this);
+    m_expListWidget->setObjectName("expListWidget");
 }
 
 void ConfigExpertWidget::initLayout()
 {
     m_vBoxLayout->setMargin(0);
+    m_vBoxLayout->setSpacing(0);
     m_vBoxLayout->addWidget(m_titleLabel);
     m_vBoxLayout->addWidget(m_splitter);
 
-    QWidget *w1 = new QWidget();
-    QWidget *w2 = new QWidget();
-    w1->setMinimumHeight(100);
-    w2->setMinimumHeight(100);
+    m_splitter->addWidget(m_addedWidget);
+    m_splitter->addWidget(m_expWidget);
 
-    w1->setStyleSheet("background-color:#f4f4f4");
-    w2->setStyleSheet("background-color:#f4f4f4");
+    m_addedWidgetLayout->addWidget(m_addedListHeader);
+    m_addedWidgetLayout->addWidget(m_addedListWidget);
 
-    m_splitter->addWidget(w1);
-    m_splitter->addWidget(w2);
+    m_expWidgetLayout->addWidget(m_expListHeader);
+    m_expWidgetLayout->addWidget(m_expListWidget);
+
+    m_addedListHeaderLayout->setMargin(0);
+    m_addedListHeaderLayout->addWidget(m_addedListTitleLabel, Qt::AlignLeft);
+    m_addedListHeaderLayout->addWidget(m_saveButton, Qt::AlignRight);
+
+    m_expListHeaderLayout->setMargin(0);
+    m_expListHeaderLayout->addWidget(m_expListTitleLabel, Qt::AlignLeft);
+    m_expListHeaderLayout->addWidget(m_refreshButton, Qt::AlignRight);
 
     m_splitter->setStretchFactor(0, 2);
     m_splitter->setStretchFactor(1, 3);
+
+    setStyleSheet(
+            "#titleLabel {color:#666666; font-size:16px}"
+            "#addedListHeader {background-color:#f8f8f8;border: 1px solid rgba(0, 0, 0, 0.073);}"
+            "#expListHeader {background-color:#f8f8f8;border: 1px solid rgba(0, 0, 0, 0.073);}"
+            "QPushButton {border: 1px solid rgba(0, 0, 0, 0.073);background-color: qlineargradient(x1: 0, y1: 0, x2: "
+            "0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde);height:15px;width:30px;}"
+            "QPushButton::hover {border: 0;}"
+            "QPushButton::pressed {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, "
+            "stop: 1 #f6f7fa);}"
+            "QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);}"
+            "QListView::item {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ffffff, stop: 0.9 "
+            "#ffffff,stop: 1 #eeeeee);height:44;}");
 }
 
 void ConfigExpertWidget::connectSignalsAndSlots() { }
+
+void ConfigExpertWidget::refreshAddedList()
+{
+    m_addedListWidget->clear();
+
+    for (int i = 1; i <= 5; i++) {
+        QListWidgetItem *item = new QListWidgetItem;
+        m_addedListWidget->addItem(item);
+
+        QWidget *w = new QWidget();
+        m_addedListWidget->setItemWidget(item, w);
+
+        QHBoxLayout *hBox = new QHBoxLayout(w);
+        hBox->setSpacing(0);
+        hBox->setMargin(10);
+
+        QLabel *idx = new QLabel(QString::number(i));
+        idx->setFixedWidth(20);
+        hBox->addWidget(idx);
+        QLabel *name = new QLabel(QString("专家%1").arg(i));
+        hBox->addWidget(name);
+        hBox->addStretch();
+
+        idx->setStyleSheet("font-size:14px; color:#aaaaaa");
+    }
+}
+
+void ConfigExpertWidget::refreshExpList() { }

+ 22 - 0
QFD/widgets/ConfigExpertWidget.h

@@ -7,9 +7,11 @@ class ToolButton;
 class PushButton;
 
 class QVBoxLayout;
+class QHBoxLayout;
 class QLabel;
 class QSplitter;
 class QPushButton;
+class QListWidget;
 
 class ConfigExpertWidget : public QWidget
 {
@@ -23,10 +25,30 @@ public:
 
 signals:
 
+private:
+    void refreshAddedList();
+    void refreshExpList();
+
 private:
     QVBoxLayout *m_vBoxLayout = nullptr;
     QLabel *m_titleLabel      = nullptr;
     QSplitter *m_splitter     = nullptr;
+
+    QWidget *m_addedWidget               = nullptr;
+    QVBoxLayout *m_addedWidgetLayout     = nullptr;
+    QWidget *m_addedListHeader           = nullptr;
+    QHBoxLayout *m_addedListHeaderLayout = nullptr;
+    QLabel *m_addedListTitleLabel        = nullptr;
+    QPushButton *m_saveButton            = nullptr;
+    QListWidget *m_addedListWidget       = nullptr;
+
+    QWidget *m_expWidget               = nullptr;
+    QVBoxLayout *m_expWidgetLayout     = nullptr;
+    QWidget *m_expListHeader           = nullptr;
+    QHBoxLayout *m_expListHeaderLayout = nullptr;
+    QLabel *m_expListTitleLabel        = nullptr;
+    QPushButton *m_refreshButton       = nullptr;
+    QListWidget *m_expListWidget       = nullptr;
 };
 
 #endif  // CONFIGEXPERTWIDGET_H