chengxr 1 year ago
parent
commit
f03f32d8e0

+ 2 - 0
QFD/QFD.pro

@@ -60,6 +60,7 @@ INCLUDEPATH += $$PWD/widgets
 INCLUDEPATH += $$PWD/common
 
 SOURCES += \
+    common/QFDIcon.cpp \
     main.cpp \
     view/AboutView.cpp \
     view/CreateProjView.cpp \
@@ -81,6 +82,7 @@ SOURCES += \
     widgets/RegisterWidget.cpp
 
 HEADERS += \
+    common/QFDIcon.h \
     view/AboutView.h \
     view/CreateProjView.h \
     view/EvaluateView.h \

+ 68 - 0
QFD/common/QFDIcon.cpp

@@ -0,0 +1,68 @@
+#include "QFDIcon.h"
+
+#include <QFluentWidgets.h>
+
+QString QFDIcon::iconName(QFDIcon::IconType type)
+{
+    switch (type) {
+    case Data:
+        return "Data";
+    case Expert:
+        return "Expert";
+    case Project:
+        return "Project";
+    case User:
+        return "User";
+    }
+
+    return "Unknown";
+}
+
+QFDIcon::QFDIcon(IconType type, Qfw::Theme t) : FluentIconBase(""), m_theme(t), m_type(type)
+{
+    iconEngine->setIconPath(iconPath());
+}
+
+QString QFDIcon::iconPath()
+{
+    QString colorName;
+    if (m_theme == Qfw::Theme::AUTO) {
+        colorName = QFWIns.isDarkTheme() ? "white" : "black";
+    } else {
+        colorName = Qfw::ThemeString(m_theme).toLower();
+    }
+
+    return QString(":/resource/svg/%1_%2.svg").arg(iconName(m_type)).arg(colorName);
+}
+
+QIcon QFDIcon::icon()
+{
+    return QIcon(iconEngine->clone());
+}
+
+QString QFDIcon::typeName() const
+{
+    return iconName(m_type);
+}
+
+QString QFDIcon::enumName() const
+{
+    QMetaEnum metaEnum = QMetaEnum::fromType<IconType>();
+    return metaEnum.valueToKey(m_type);
+}
+
+FluentIconBase *QFDIcon::clone()
+{
+    return new QFDIcon(m_type, m_theme);
+}
+
+Qfw::Theme QFDIcon::theme() const
+{
+    return m_theme;
+}
+
+void QFDIcon::setTheme(const Qfw::Theme &theme)
+{
+    m_theme = theme;
+    iconEngine->setIconPath(iconPath());
+}

+ 40 - 0
QFD/common/QFDIcon.h

@@ -0,0 +1,40 @@
+#ifndef QFDICON_H
+#define QFDICON_H
+
+#include <Common/Icon.h>
+
+class QFDIcon : public FluentIconBase
+{
+    Q_OBJECT
+
+public:
+    enum IconType
+    {
+        Data,
+        Expert,
+        Project,
+        User,
+    };
+
+    Q_ENUM(IconType)
+
+    static QString iconName(IconType type);
+
+    QFDIcon(IconType type, Qfw::Theme t = Qfw::AUTO);
+
+    QString iconPath();
+
+    QIcon icon() override;
+    QString typeName() const override;
+    QString enumName() const override;
+    FluentIconBase *clone() override;
+
+    Qfw::Theme theme() const;
+    void setTheme(const Qfw::Theme &theme) override;
+
+private:
+    Qfw::Theme m_theme;
+    IconType m_type;
+};
+
+#endif  // QFDICON_H

+ 8 - 0
QFD/resource.qrc

@@ -354,5 +354,13 @@
         <file>resource/xiangqing.png</file>
         <file>resource/xiugai.png</file>
         <file>resource/yulan.png</file>
+        <file>resource/svg/Data_black.svg</file>
+        <file>resource/svg/Data_white.svg</file>
+        <file>resource/svg/Expert_black.svg</file>
+        <file>resource/svg/Expert_white.svg</file>
+        <file>resource/svg/Project_black.svg</file>
+        <file>resource/svg/Project_white.svg</file>
+        <file>resource/svg/User_black.svg</file>
+        <file>resource/svg/User_white.svg</file>
     </qresource>
 </RCC>

File diff suppressed because it is too large
+ 0 - 0
QFD/resource/svg/Data_black.svg


File diff suppressed because it is too large
+ 0 - 0
QFD/resource/svg/Data_white.svg


File diff suppressed because it is too large
+ 0 - 0
QFD/resource/svg/Expert_black.svg


File diff suppressed because it is too large
+ 0 - 0
QFD/resource/svg/Expert_white.svg


File diff suppressed because it is too large
+ 0 - 0
QFD/resource/svg/Project_black.svg


File diff suppressed because it is too large
+ 0 - 0
QFD/resource/svg/Project_white.svg


+ 1 - 0
QFD/resource/svg/User_black.svg

@@ -0,0 +1 @@
+<svg t="1689935790107" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4088" width="16" height="16"><path d="M642.8 531.8c64.3-42.6 106.9-115.4 106.9-198.1C749.7 202.6 643.1 96 512 96S274.3 202.6 274.3 333.7c0 82.7 42.6 155.6 106.9 198.1C215.8 582.9 96 727.7 96 898.3c0 16.4 13.3 29.7 29.7 29.7s29.7-13.3 29.7-29.7c0-180.2 159.9-326.9 356.6-326.9 196.6 0 356.6 146.6 356.6 326.9 0 16.4 13.3 29.7 29.7 29.7s29.7-13.3 29.7-29.7c0-170.6-119.8-315.4-285.2-366.5zM333.7 333.7c0-98.3 80-178.3 178.3-178.3s178.3 80 178.3 178.3S610.3 512 512 512s-178.3-80-178.3-178.3z" fill="#000000" p-id="4089"></path></svg>

+ 1 - 0
QFD/resource/svg/User_white.svg

@@ -0,0 +1 @@
+<svg t="1689935790107" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4088" width="16" height="16"><path d="M642.8 531.8c64.3-42.6 106.9-115.4 106.9-198.1C749.7 202.6 643.1 96 512 96S274.3 202.6 274.3 333.7c0 82.7 42.6 155.6 106.9 198.1C215.8 582.9 96 727.7 96 898.3c0 16.4 13.3 29.7 29.7 29.7s29.7-13.3 29.7-29.7c0-180.2 159.9-326.9 356.6-326.9 196.6 0 356.6 146.6 356.6 326.9 0 16.4 13.3 29.7 29.7 29.7s29.7-13.3 29.7-29.7c0-170.6-119.8-315.4-285.2-366.5zM333.7 333.7c0-98.3 80-178.3 178.3-178.3s178.3 80 178.3 178.3S610.3 512 512 512s-178.3-80-178.3-178.3z" fill="#ffffff" p-id="4089"></path></svg>

+ 17 - 2
QFD/view/ExpertInfoView.cpp

@@ -16,9 +16,24 @@ ExpertInfoView::ExpertInfoView(QWidget *parent) : QWidget(parent)
     updateState();
 }
 
-void ExpertInfoView::setMode(ExpertInfoView::Mode mode) { }
+void ExpertInfoView::setMode(ExpertInfoView::Mode mode)
+{
+    m_mode = mode;
+    updateState();
+}
 
-void ExpertInfoView::clearInputs() { }
+void ExpertInfoView::clearInputs()
+{
+    m_idLineEdit->clear();
+    m_passwordLineEdit->clear();
+    m_nameLineEdit->clear();
+    m_companyLineEdit->clear();
+    m_jobLineEdit->clear();
+    m_majorLineEdit->clear();
+    m_contactInfoLineEdit->clear();
+    m_noteTextEdit->clear();
+    updateState();
+}
 
 void ExpertInfoView::initWindow()
 {

+ 3 - 3
QFD/view/ExpertManageView.cpp

@@ -22,14 +22,14 @@ void ExpertManageView::initialize()
     m_vBoxLayout = new QVBoxLayout(this);
 
     m_titleLabel = new QLabel(this);
-    m_titleLabel->setText("用户列表");
+    m_titleLabel->setText("专家列表");
     QFont ft("Microsoft YaHei", 12);
     m_titleLabel->setFont(ft);
     m_hBoxLayout     = new QHBoxLayout();
     m_searchLineEdit = new SearchLineEdit(this);
-    m_searchLineEdit->setPlaceholderText("搜索用户");
+    m_searchLineEdit->setPlaceholderText("搜索");
     m_searchLineEdit->setMinimumWidth(300);
-    m_addExpertPushButton = new PushButton("添加用户", NEWFLICON(FluentIcon, ADD), this);
+    m_addExpertPushButton = new PushButton("添加", NEWFLICON(FluentIcon, ADD), this);
 
     m_expertInfoView = new ExpertInfoView(this);
 }

+ 6 - 4
QFD/view/MainWindow.cpp

@@ -8,6 +8,8 @@
 #include "LoginView.h"
 #include "AboutView.h"
 
+#include "common/QFDIcon.h"
+
 #include <QFramelessWindow.h>
 
 #include <Navigation/NavigationInterface.h>
@@ -126,24 +128,24 @@ void MainWindow::initNavigation()
 
     m_projectView->setObjectName("projectView");
     m_stackWidget->addWidget(m_projectView);
-    m_naviInterface->addItem(m_projectView->objectName(), NEWFLICON(FluentIcon, DOCUMENT), "工程", this,
+    m_naviInterface->addItem(m_projectView->objectName(), NEWFLICON(QFDIcon, Project), "工程", this,
                              SLOT(projectViewClicked()));
 
     m_expertManageView->setObjectName("expertManageView");
     m_stackWidget->addWidget(m_expertManageView);
-    m_naviInterface->addItem(m_expertManageView->objectName(), NEWFLICON(FluentIcon, SETTING), "专家信息管理", this,
+    m_naviInterface->addItem(m_expertManageView->objectName(), NEWFLICON(QFDIcon, Expert), "专家信息管理", this,
                              SLOT(expertViewClicked()));
 
     m_evaluateView->setObjectName("evaluateView");
     m_stackWidget->addWidget(m_evaluateView);
-    m_naviInterface->addItem(m_evaluateView->objectName(), NEWFLICON(FluentIcon, BOOK_SHELF), "评估数据分析", this,
+    m_naviInterface->addItem(m_evaluateView->objectName(), NEWFLICON(QFDIcon, Data), "评估数据分析", this,
                              SLOT(dataViewClicked()));
 
     m_naviInterface->addSeparator();
 
     m_loginView->setObjectName("loginView");
     m_stackWidget->addWidget(m_loginView);
-    m_naviInterface->addItem(m_loginView->objectName(), NEWFLICON(FluentIcon, HEART), "用户", this,
+    m_naviInterface->addItem(m_loginView->objectName(), NEWFLICON(QFDIcon, User), "用户", this,
                              SLOT(loginViewClicked()), true, NavigationItemPosition::BOTTOM);
 
     m_aboutView->setObjectName("aboutView");

Some files were not shown because too many files changed in this diff