chengxr 1 жил өмнө
parent
commit
5e8a054f10

+ 2 - 0
QFD/main.cpp

@@ -12,5 +12,7 @@ int main(int argc, char *argv[]) {
   MainWindow m;
   m.show();
 
+  Q_INIT_RESOURCE(qfluentwidgets);
+
   return a.exec();
 }

+ 3 - 4
QFD/pages/Login.h

@@ -1,12 +1,11 @@
-#ifndef LOGIN_H
+#ifndef LOGIN_H
 #define LOGIN_H
 
 #include <QDialog>
 
-class Login : public QDialog
-{
+class Login : public QDialog {
 public:
-    Login();
+  Login();
 };
 
 #endif // LOGIN_H

+ 37 - 6
QFD/pages/MainWindow.cpp

@@ -4,6 +4,7 @@
 #include <QFramelessWindow.h>
 #include <TitleBar.h>
 
+#include <Navigation/NavigationInterface.h>
 #include <Widgets/StackedWidget.h>
 
 #include <QDebug>
@@ -40,17 +41,47 @@ void StackedWidget::setCurrentIndex(int index, bool popOut) {
 PopUpAniStackedWidget *StackedWidget::view() const { return m_view; }
 
 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
-  QFramelessHelper *helper = new QFramelessHelper(this);
-  StandardTitleBar *titleBar = new StandardTitleBar(this);
-  helper->setTitleBar(titleBar);
+  initWindow();
+  initLayout();
+}
 
-  setMinimumSize(QSize(800, 600));
+MainWindow::~MainWindow() {}
+
+void MainWindow::initWindow() {
+
+  QWidget *w = new QWidget();
+  m_hBoxLayout = new QHBoxLayout(w);
+  setCentralWidget(w);
+
+  m_widgetLayout = new QHBoxLayout();
+  m_stackWidget = new StackedWidget(this);
+  m_navigationInterface = new NavigationInterface(true, true, this);
+
+  QFramelessHelper *helper = new QFramelessHelper(this);
+  m_titleBar = new StandardTitleBar(this);
+  m_titleBar->setGeometry(QRect(46, 0, width() - 46, m_titleBar->height()));
+  helper->setTitleBar(m_titleBar);
 
   QIcon icon = QIcon(":/resource/logo.png");
   setWindowIcon(icon);
-  titleBar->setIcon(icon);
+  m_titleBar->setIcon(icon);
 
   setWindowTitle("专家评定数据分析软件");
+  setMinimumSize(QSize(800, 600));
 }
 
-MainWindow::~MainWindow() {}
+void MainWindow::initLayout() {
+  m_hBoxLayout->setSpacing(0);
+  m_hBoxLayout->setContentsMargins(0, 0, 0, 0);
+  m_hBoxLayout->addWidget(m_navigationInterface);
+  m_hBoxLayout->addLayout(m_widgetLayout);
+  m_hBoxLayout->setStretchFactor(m_widgetLayout, 1);
+
+  m_widgetLayout->addWidget(m_stackWidget);
+  m_widgetLayout->setContentsMargins(0, 32, 0, 0);
+}
+
+void MainWindow::resizeEvent(QResizeEvent *event) {
+  m_navigationInterface->resize(m_navigationInterface->width(), height());
+  m_titleBar->resize(width() - 46, m_titleBar->height());
+}

+ 15 - 0
QFD/pages/MainWindow.h

@@ -6,6 +6,8 @@
 
 class PopUpAniStackedWidget;
 class QHBoxLayout;
+class NavigationInterface;
+class StandardTitleBar;
 
 class StackedWidget : public QFrame {
   Q_OBJECT
@@ -34,5 +36,18 @@ class MainWindow : public QMainWindow {
 public:
   MainWindow(QWidget *parent = nullptr);
   ~MainWindow();
+
+private:
+  void initWindow();
+  void initLayout();
+
+  void resizeEvent(QResizeEvent *event) override;
+
+private:
+  StandardTitleBar *m_titleBar;
+  QHBoxLayout *m_hBoxLayout;
+  QHBoxLayout *m_widgetLayout;
+  StackedWidget *m_stackWidget;
+  NavigationInterface *m_navigationInterface;
 };
 #endif // MAINWINDOW_H