Browse Source

LoginView & AboutView

chengxr 1 year ago
parent
commit
a4805dba00

+ 3 - 0
QFD/QFD.pro

@@ -71,6 +71,7 @@ SOURCES += \
     view/LoginView.cpp \
     view/MainWindow.cpp \
     view/ProjectView.cpp \
+    widgets/AppInfoWidget.cpp \
     widgets/CustomTitleBar.cpp \
     widgets/EvaluateDataWidget.cpp \
     widgets/ExpertConfigInfoWidget.cpp \
@@ -92,6 +93,7 @@ HEADERS += \
     view/LoginView.h \
     view/MainWindow.h \
     view/ProjectView.h \
+    widgets/AppInfoWidget.h \
     widgets/CustomTitleBar.h \
     widgets/EvaluateDataWidget.h \
     widgets/ExpertConfigInfoWidget.h \
@@ -126,3 +128,4 @@ RESOURCES += \
 
 FORMS +=
 
+VERSION = "2.1.2.1"

+ 3 - 0
QFD/main.cpp

@@ -6,6 +6,9 @@
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
+    a.setApplicationVersion("2.0");
+    a.setApplicationName("QFD2");
+    a.setApplicationDisplayName("专家评定数据分析软件");
 
     //    LoginView l;
     //    l.show();

+ 21 - 1
QFD/view/AboutView.cpp

@@ -1,10 +1,18 @@
 #include "AboutView.h"
 
+#include "AppInfoWidget.h"
+
+#include <QBoxLayout>
+#include <QApplication>
 #include <QPainter>
 
+#include <QDebug>
+
 AboutView::AboutView(QWidget *parent) : QWidget(parent)
 {
-    setStyleSheet("background-color: rgb(222, 222, 0);");
+    //    setStyleSheet("background-color: rgb(222, 222, 0);");
+    initialize();
+    initLayout();
 }
 
 void AboutView::paintEvent(QPaintEvent *event)
@@ -15,3 +23,15 @@ void AboutView::paintEvent(QPaintEvent *event)
     painter.drawPixmap(0, 0,
                        pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
 }
+
+void AboutView::initialize()
+{
+    m_vBoxLayout    = new QVBoxLayout(this);
+    m_appInfoWidget = new AppInfoWidget(this);
+}
+
+void AboutView::initLayout()
+{
+    //    m_vBoxLayout->setAlignment(Qt::AlignCenter);
+    m_vBoxLayout->addWidget(m_appInfoWidget);
+}

+ 10 - 0
QFD/view/AboutView.h

@@ -3,6 +3,9 @@
 
 #include <QWidget>
 
+class QVBoxLayout;
+class AppInfoWidget;
+
 ///
 /// \brief The AboutView class
 /// 关于页面
@@ -14,7 +17,14 @@ public:
 
     void paintEvent(QPaintEvent *event) override;
 
+    void initialize();
+    void initLayout();
+
 signals:
+
+private:
+    QVBoxLayout *m_vBoxLayout      = nullptr;
+    AppInfoWidget *m_appInfoWidget = nullptr;
 };
 
 #endif  // ABOUTVIEW_H

+ 2 - 0
QFD/view/LoginView.cpp

@@ -62,12 +62,14 @@ void LoginView::slotLogin()
 {
     qDebug() << __FUNCTION__ << __LINE__;
     setStackIndex(m_stackedWidget->currentIndex() + 1);
+    emit signalLogin();
 }
 
 void LoginView::slotCancelLogin()
 {
     qDebug() << __FUNCTION__ << __LINE__;
     setStackIndex(m_stackedWidget->currentIndex() + 1);
+    emit signalCancelLogin();
 }
 
 void LoginView::slotConfirmAcc()

+ 4 - 0
QFD/view/LoginView.h

@@ -22,6 +22,10 @@ public:
 
     void setStackIndex(int index);
 
+signals:
+    void signalLogin();
+    void signalCancelLogin();
+
 private:
     void initialize();
     void initLayout();

+ 26 - 16
QFD/view/MainWindow.cpp

@@ -15,6 +15,8 @@
 #include <Navigation/NavigationInterface.h>
 #include <Widgets/StackedWidget.h>
 
+#include <QApplication>
+
 #include <QDebug>
 
 StackedWidget::StackedWidget(QWidget *parent) : QFrame(parent)
@@ -74,7 +76,8 @@ MainWindow::~MainWindow() { }
 
 void MainWindow::initialize()
 {
-    m_titleBar = new CustomTitleBar(this);
+    m_titleBar   = new CustomTitleBar(this);
+    m_mainWidget = new QWidget(this);
 
     m_widgetLayout  = new QHBoxLayout();
     m_stackWidget   = new StackedWidget(this);
@@ -92,19 +95,21 @@ void MainWindow::initWindow()
 {
     setMinimumSize(QSize(1000, 800));
 
+    m_hBoxLayout = new QHBoxLayout(m_mainWidget);
+
     QFramelessHelper *helper = new QFramelessHelper(this);
     helper->setTitleBar(m_titleBar);
 
-    QWidget *w   = new QWidget();
-    m_hBoxLayout = new QHBoxLayout(w);
-    setCentralWidget(w);
-
-    m_titleBar->setGeometry(QRect(titleBarIndent(), 0, width() - titleBarIndent(), m_titleBar->height()));
     setWindowTitle("专家评定数据分析软件");
 
     QIcon icon = QIcon(":/resource/logo.png");
+    qApp->setWindowIcon(icon);
+
+    m_titleBar->setGeometry(QRect(titleBarIndent(), 0, width() - titleBarIndent(), m_titleBar->height()));
     m_titleBar->setIcon(icon);
-    setWindowIcon(icon);
+    m_titleBar->setHidden(true);
+
+    setCentralWidget(m_loginView);
 }
 
 void MainWindow::initLayout()
@@ -143,11 +148,6 @@ void MainWindow::initNavigation()
 
     m_naviInterface->addSeparator();
 
-    m_loginView->setObjectName("loginView");
-    m_stackWidget->addWidget(m_loginView);
-    m_naviInterface->addItem(m_loginView->objectName(), NEWFLICON(QFDIcon, User), "用户", this,
-                             SLOT(loginViewClicked()), true, NavigationItemPosition::BOTTOM);
-
     m_aboutView->setObjectName("aboutView");
     m_stackWidget->addWidget(m_aboutView);
     m_naviInterface->addItem(m_aboutView->objectName(), NEWFLICON(FluentIcon, INFO), "关于", this,
@@ -163,6 +163,8 @@ void MainWindow::initNavigation()
 
 void MainWindow::connectSignalsAndSlots()
 {
+    connect(m_loginView, &LoginView::signalLogin, this, &MainWindow::slotLogin);
+    connect(m_loginView, &LoginView::signalCancelLogin, this, &MainWindow::slotCancelLogin);
     connect(m_naviInterface, &NavigationInterface::displayModeChanged, m_titleBar, &StandardTitleBar::raise);
 }
 
@@ -183,20 +185,28 @@ void MainWindow::resizeEvent(QResizeEvent *event)
     m_titleBar->resize(width() - titleBarIndent(), m_titleBar->height());
 }
 
+void MainWindow::showMainWidget() { }
+
 void MainWindow::switchTo(QWidget *widget, bool triggerByUser)
 {
     qDebug() << __FUNCTION__ << __LINE__;
     m_stackWidget->setCurrentWidget(widget, !triggerByUser);
 }
 
-void MainWindow::homeViewClicked()
+void MainWindow::slotLogin()
 {
-    switchTo(m_homeView);
+    setCentralWidget(m_mainWidget);
+    m_titleBar->setHidden(false);
+}
+
+void MainWindow::slotCancelLogin()
+{
+    exit(0);
 }
 
-void MainWindow::loginViewClicked()
+void MainWindow::homeViewClicked()
 {
-    switchTo(m_loginView);
+    switchTo(m_homeView);
 }
 
 void MainWindow::projectViewClicked()

+ 5 - 1
QFD/view/MainWindow.h

@@ -60,11 +60,14 @@ private:
 
     void resizeEvent(QResizeEvent *event) override;
 
+    void showMainWidget();
+
     void switchTo(QWidget *widget, bool triggerByUser = true);
 
 private slots:
+    void slotLogin();
+    void slotCancelLogin();
     void homeViewClicked();
-    void loginViewClicked();
     void projectViewClicked();
     void expertViewClicked();
     void aboutViewClicked();
@@ -72,6 +75,7 @@ private slots:
 
 private:
     CustomTitleBar *m_titleBar;
+    QWidget *m_mainWidget;
     QHBoxLayout *m_hBoxLayout;
     QHBoxLayout *m_widgetLayout;
     StackedWidget *m_stackWidget;

+ 93 - 0
QFD/widgets/AppInfoWidget.cpp

@@ -0,0 +1,93 @@
+#include "AppInfoWidget.h"
+
+#include <Widgets/Button.h>
+#include <helper/SysInfoExt.h>
+
+#include <QBoxLayout>
+#include <QGridLayout>
+#include <QLabel>
+#include <QApplication>
+#include <QPixmap>
+
+static const QString buildTime = "2023年7月24日";
+
+AppInfoWidget::AppInfoWidget(QWidget *parent) : QWidget(parent)
+{
+    initilaize();
+    initLayout();
+    refresh();
+}
+
+void AppInfoWidget::initilaize()
+{
+    /// 图标,版本号,更新内容,构建时间,当前环境,版权声明
+    m_vBoxLayout = new QVBoxLayout(this);
+
+    m_iconLabel = new QLabel(this);
+    m_iconLabel->setFixedSize(QSize(50, 50));
+    m_iconLabel->setScaledContents(true);
+    QPixmap pixmap = QPixmap(":/resource/logo.png");
+    pixmap.scaled(m_iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    m_iconLabel->setPixmap(pixmap);
+
+    m_gridLayout = new QGridLayout();
+
+    m_verNameLabel  = new QLabel("版本号:", this);
+    m_verValueLabel = new QLabel(this);
+
+    m_contentNameLabel  = new QLabel("更新内容:", this);
+    m_contentValueLabel = new QLabel(this);
+    m_dateNameLabel     = new QLabel("构建时间:", this);
+    m_dateValueLabel    = new QLabel(this);
+    m_envNameLabel      = new QLabel("当前环境:", this);
+    m_envValueLabel     = new QLabel(this);
+    m_copyRightLabel    = new QLabel("Copyright © 2022", this);
+
+    m_hBoxLayout    = new QHBoxLayout();
+    m_confirmButton = new PushButton("确认", this);
+
+    setStyleSheet("QLabel {font-size: 14px;font:Normal;font-family: 'Microsoft YaHei UI';}");
+}
+
+void AppInfoWidget::initLayout()
+{
+    m_vBoxLayout->setContentsMargins(20, 20, 20, 20);
+
+    m_vBoxLayout->addStretch();
+
+    m_vBoxLayout->addWidget(m_iconLabel, 0, Qt::AlignHCenter);
+    m_vBoxLayout->addSpacing(50);
+
+    m_vBoxLayout->addLayout(m_gridLayout);
+    m_gridLayout->setAlignment(Qt::AlignHCenter);
+
+    m_gridLayout->addWidget(m_verNameLabel, 0, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_verValueLabel, 0, 1, 1, 1, Qt::AlignLeft);
+
+    m_gridLayout->addWidget(m_contentNameLabel, 1, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_contentValueLabel, 1, 1, 1, 1, Qt::AlignLeft);
+
+    m_gridLayout->addWidget(m_dateNameLabel, 2, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_dateValueLabel, 2, 1, 1, 1, Qt::AlignLeft);
+
+    m_gridLayout->addWidget(m_envNameLabel, 3, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_envValueLabel, 3, 1, 1, 1, Qt::AlignLeft);
+
+    m_vBoxLayout->addSpacing(30);
+    m_vBoxLayout->addWidget(m_copyRightLabel, 0, Qt::AlignHCenter);
+
+    m_vBoxLayout->addStretch();
+
+    m_vBoxLayout->addLayout(m_hBoxLayout);
+    m_hBoxLayout->setAlignment(Qt::AlignRight);
+    m_hBoxLayout->addWidget(m_confirmButton);
+}
+
+void AppInfoWidget::refresh()
+{
+    m_verValueLabel->setText(qApp->applicationVersion());
+    m_contentValueLabel->setText("Bug fixes and improvements");
+    m_dateValueLabel->setText("2023年7月24日");
+    m_envValueLabel->setText(SysInfoExt::getCpuName());
+    m_confirmButton->hide();
+}

+ 46 - 0
QFD/widgets/AppInfoWidget.h

@@ -0,0 +1,46 @@
+#ifndef APPINFOWIDGET_H
+#define APPINFOWIDGET_H
+
+#include <QWidget>
+
+class QVBoxLayout;
+class QGridLayout;
+class QHBoxLayout;
+class QLabel;
+class PushButton;
+
+class AppInfoWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit AppInfoWidget(QWidget *parent = nullptr);
+
+signals:
+
+private:
+    void initilaize();
+    void initLayout();
+    void refresh();
+
+private:
+    /// 图标,版本号,更新内容,构建时间,当前环境,版权声明
+
+    QVBoxLayout *m_vBoxLayout = nullptr;
+
+    QGridLayout *m_gridLayout   = nullptr;
+    QLabel *m_iconLabel         = nullptr;
+    QLabel *m_verNameLabel      = nullptr;
+    QLabel *m_verValueLabel     = nullptr;
+    QLabel *m_contentNameLabel  = nullptr;
+    QLabel *m_contentValueLabel = nullptr;
+    QLabel *m_dateNameLabel     = nullptr;
+    QLabel *m_dateValueLabel    = nullptr;
+    QLabel *m_envNameLabel      = nullptr;
+    QLabel *m_envValueLabel     = nullptr;
+    QLabel *m_copyRightLabel    = nullptr;
+
+    QHBoxLayout *m_hBoxLayout   = nullptr;
+    PushButton *m_confirmButton = nullptr;
+};
+
+#endif  // APPINFOWIDGET_H

+ 9 - 1
QFD/widgets/ProjectStateWidget.cpp

@@ -31,7 +31,15 @@ void ProjectStateWidget::initialize()
     m_projTableWidget->setStyleSheet(
             "QTableWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(244, 244, "
             "255);alternate-background-color: rgb(255, 255, 255);}"
-            "QHeaderView::section{font-size: 14px;font:bold;font-family: 'Microsoft YaHei UI';}");
+            //            "QHeaderView::section{font-size: 14px;font:bold;font-family: 'Microsoft YaHei UI';}"
+            "QHeaderView::section {"
+            "background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
+            "stop:0 #616161, stop: 0.5 #505050,"
+            "stop: 0.6 #434343, stop:1 #656565);"
+            "color: white;"
+            "padding-left: 4px;"
+            "border: 1px solid #6c6c6c;"
+            "}");
 }
 
 void ProjectStateWidget::initLayout()