chengxr 1 year ago
parent
commit
8255344603

+ 2 - 0
QFD/QFD.pro

@@ -68,6 +68,7 @@ SOURCES += \
     view/LoginView.cpp \
     view/LoginView.cpp \
     view/MainWindow.cpp \
     view/MainWindow.cpp \
     view/ProjectView.cpp \
     view/ProjectView.cpp \
+    widgets/CustomTitleBar.cpp \
     widgets/LoginWidget.cpp \
     widgets/LoginWidget.cpp \
     widgets/RegisterWidget.cpp
     widgets/RegisterWidget.cpp
 
 
@@ -79,6 +80,7 @@ HEADERS += \
     view/LoginView.h \
     view/LoginView.h \
     view/MainWindow.h \
     view/MainWindow.h \
     view/ProjectView.h \
     view/ProjectView.h \
+    widgets/CustomTitleBar.h \
     widgets/LoginWidget.h \
     widgets/LoginWidget.h \
     widgets/RegisterWidget.h
     widgets/RegisterWidget.h
 
 

+ 41 - 1
QFD/view/HomeView.cpp

@@ -1,6 +1,46 @@
-#include "HomeView.h"
+#include "HomeView.h"
+
+#include <Widgets/Button.h>
+#include <Widgets/LineEdit.h>
+
+#include <QBoxLayout>
+#include <QLabel>
 
 
 HomeView::HomeView(QWidget *parent) : QWidget(parent)
 HomeView::HomeView(QWidget *parent) : QWidget(parent)
 {
 {
+    initialize();
+    initLayout();
+    connectSignalsAndSlots();
+
+    //    this->setStyleSheet("background-color: rgb(250, 250, 250);");
+}
+
+void HomeView::initialize()
+{
+    m_vBoxLayout = new QVBoxLayout(this);
 
 
+    m_titleLabel = new QLabel(this);
+    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->setMinimumWidth(300);
+    m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this);
 }
 }
+
+void HomeView::initLayout()
+{
+    m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+    m_vBoxLayout->setContentsMargins(100, 10, 0, 0);
+    m_vBoxLayout->addLayout(m_hBoxLayout);
+
+    m_hBoxLayout->addSpacing(10);
+    m_hBoxLayout->addWidget(m_titleLabel);
+    m_hBoxLayout->addSpacing(15);
+    m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
+    m_hBoxLayout->addWidget(m_createProjPushButton, 1, Qt::AlignLeft);
+}
+
+void HomeView::connectSignalsAndSlots() { }

+ 19 - 3
QFD/view/HomeView.h

@@ -1,16 +1,32 @@
-#ifndef HOMEVIEW_H
+#ifndef HOMEVIEW_H
 #define HOMEVIEW_H
 #define HOMEVIEW_H
 
 
 #include <QWidget>
 #include <QWidget>
 
 
+class PushButton;
+class SearchLineEdit;
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QLabel;
+
 class HomeView : public QWidget
 class HomeView : public QWidget
 {
 {
     Q_OBJECT
     Q_OBJECT
 public:
 public:
     explicit HomeView(QWidget *parent = nullptr);
     explicit HomeView(QWidget *parent = nullptr);
 
 
-signals:
+private:
+    void initialize();
+    void initLayout();
+    void connectSignalsAndSlots();
 
 
+private:
+    QVBoxLayout *m_vBoxLayout          = nullptr;
+    QLabel *m_titleLabel               = nullptr;
+    QHBoxLayout *m_hBoxLayout          = nullptr;
+    SearchLineEdit *m_searchLineEdit   = nullptr;
+    PushButton *m_createProjPushButton = nullptr;
 };
 };
 
 
-#endif // HOMEVIEW_H
+#endif  // HOMEVIEW_H

+ 8 - 2
QFD/view/MainWindow.cpp

@@ -1,5 +1,6 @@
 #include "MainWindow.h"
 #include "MainWindow.h"
 
 
+#include "CustomTitleBar.h"
 #include "HomeView.h"
 #include "HomeView.h"
 #include "ProjectView.h"
 #include "ProjectView.h"
 #include "ExpertView.h"
 #include "ExpertView.h"
@@ -8,7 +9,6 @@
 #include "AboutView.h"
 #include "AboutView.h"
 
 
 #include <QFramelessWindow.h>
 #include <QFramelessWindow.h>
-#include <TitleBar.h>
 
 
 #include <Navigation/NavigationInterface.h>
 #include <Navigation/NavigationInterface.h>
 #include <Widgets/StackedWidget.h>
 #include <Widgets/StackedWidget.h>
@@ -25,6 +25,11 @@ StackedWidget::StackedWidget(QWidget *parent) : QFrame(parent)
 
 
     connect(m_view, &PopUpAniStackedWidget::currentChanged, this,
     connect(m_view, &PopUpAniStackedWidget::currentChanged, this,
             [this](int index) { emit currentWidgetChanged(m_view->widget(index)); });
             [this](int index) { emit currentWidgetChanged(m_view->widget(index)); });
+
+    QPalette pal(palette());
+    pal.setColor(QPalette::Background, QColor("#fffff8"));
+    setAutoFillBackground(true);
+    setPalette(pal);
 }
 }
 
 
 void StackedWidget::addWidget(QWidget *widget)
 void StackedWidget::addWidget(QWidget *widget)
@@ -67,7 +72,8 @@ MainWindow::~MainWindow() { }
 
 
 void MainWindow::initialize()
 void MainWindow::initialize()
 {
 {
-    m_titleBar      = new StandardTitleBar(this);
+    m_titleBar = new CustomTitleBar(this);
+
     m_widgetLayout  = new QHBoxLayout();
     m_widgetLayout  = new QHBoxLayout();
     m_stackWidget   = new StackedWidget(this);
     m_stackWidget   = new StackedWidget(this);
     m_naviInterface = new NavigationInterface(true, true, this);
     m_naviInterface = new NavigationInterface(true, true, this);

+ 2 - 2
QFD/view/MainWindow.h

@@ -7,7 +7,7 @@
 class PopUpAniStackedWidget;
 class PopUpAniStackedWidget;
 class QHBoxLayout;
 class QHBoxLayout;
 class NavigationInterface;
 class NavigationInterface;
-class StandardTitleBar;
+class CustomTitleBar;
 
 
 class HomeView;
 class HomeView;
 class ProjectView;
 class ProjectView;
@@ -71,7 +71,7 @@ private slots:
     void dataViewClicked();
     void dataViewClicked();
 
 
 private:
 private:
-    StandardTitleBar *m_titleBar;
+    CustomTitleBar *m_titleBar;
     QHBoxLayout *m_hBoxLayout;
     QHBoxLayout *m_hBoxLayout;
     QHBoxLayout *m_widgetLayout;
     QHBoxLayout *m_widgetLayout;
     StackedWidget *m_stackWidget;
     StackedWidget *m_stackWidget;

+ 6 - 0
QFD/widgets/CustomTitleBar.cpp

@@ -0,0 +1,6 @@
+#include "CustomTitleBar.h"
+
+CustomTitleBar::CustomTitleBar(QWidget *parent) : StandardTitleBar(parent)
+{
+    setStyleSheet("background-color: rgb(243, 243, 243);");
+}

+ 13 - 0
QFD/widgets/CustomTitleBar.h

@@ -0,0 +1,13 @@
+#ifndef CUSTOMTITLEBAR_H
+#define CUSTOMTITLEBAR_H
+
+#include <TitleBar.h>
+
+class CustomTitleBar : public StandardTitleBar
+{
+    Q_OBJECT
+public:
+    CustomTitleBar(QWidget *parent = nullptr);
+};
+
+#endif  // CUSTOMTITLEBAR_H