zhuizhu преди 7 месеца
родител
ревизия
6033cf3787
променени са 3 файла, в които са добавени 186 реда и са изтрити 97 реда
  1. 69 59
      MainPanel.cpp
  2. 2 2
      main.cpp
  3. 115 36
      widgets/meetingselectionwidget.cpp

+ 69 - 59
MainPanel.cpp

@@ -2,11 +2,13 @@
 #include "utils/iconutils.h"
 
 // Qt Core
+#include <QApplication>
 #include <QDebug>
 #include <QJsonDocument>
 #include <QJsonObject>
 #include <QJsonParseError>
 #include <QResizeEvent>
+#include <QScreen>
 #include <QSizePolicy>
 #include <QTimer>
 #include <QtConcurrent>
@@ -138,66 +140,66 @@ void MainPanel::initFunctionButtons()
     // Popover *searchPopover = new Popover(this);
     // buttonGroup->addButton(searchBtn, searchPopover);
 
-    FunctionButton *userBtn = new FunctionButton(IconUtils::createUserIcon(), "用户", this);
-    Popover *userPopover = new Popover(this);
-    // 构建用户Popover内容:提供“退出”操作
-    {
-        QWidget *userContent = new QWidget(userPopover);
-        QVBoxLayout *userLayout = new QVBoxLayout(userContent);
-        userLayout->setContentsMargins(8, 8, 8, 8);
-        userLayout->setSpacing(8);
-
-        QPushButton *logoutBtn = new QPushButton(tr("退出"), userContent);
-        logoutBtn->setMinimumWidth(120);
-        connect(logoutBtn, &QPushButton::clicked, this, [this]() {
-            emit logoutClicked();
-        });
-        userLayout->addWidget(logoutBtn);
-
-        userPopover->setContentWidget(userContent);
-    }
-    buttonGroup->addButton(userBtn, userPopover);
+    // FunctionButton *userBtn = new FunctionButton(IconUtils::createUserIcon(), "用户", this);
+    // Popover *userPopover = new Popover(this);
+    // // 构建用户Popover内容:提供“退出”操作
+    // {
+    //     QWidget *userContent = new QWidget(userPopover);
+    //     QVBoxLayout *userLayout = new QVBoxLayout(userContent);
+    //     userLayout->setContentsMargins(8, 8, 8, 8);
+    //     userLayout->setSpacing(8);
+
+    //     QPushButton *logoutBtn = new QPushButton(tr("退出"), userContent);
+    //     logoutBtn->setMinimumWidth(120);
+    //     connect(logoutBtn, &QPushButton::clicked, this, [this]() {
+    //         emit logoutClicked();
+    //     });
+    //     userLayout->addWidget(logoutBtn);
+
+    //     userPopover->setContentWidget(userContent);
+    // }
+    // buttonGroup->addButton(userBtn, userPopover);
 
     // 添加音频设备选择按钮
-    FunctionButton *audioDeviceBtn = new FunctionButton(IconUtils::createAudioDeviceIcon(), "音频设备", this);
-    Popover *audioDevicePopover = new Popover(this);
-
-    // // 使用解耦合版本的音频设备选择器
-    // m_audioDeviceSelectorDecoupled = new AudioDeviceSelectorIconDecoupled(this);
-    // audioDevicePopover->setContentWidget(m_audioDeviceSelectorDecoupled);
-
-    // 使用 RecorderAudioWidget 作为 Popover 内容(麦克风 + 扬声器)
-    QWidget *audioContent = new QWidget(audioDevicePopover);
-    QVBoxLayout *audioLayout = new QVBoxLayout(audioContent);
-    audioLayout->setContentsMargins(8, 8, 8, 8);
-    audioLayout->setSpacing(8);
-
-    // 麦克风区域
-    QLabel *micTitle = new QLabel(tr("麦克风"), audioContent);
-    micTitle->setStyleSheet("font-weight:600;");
-    m_micWidget = new QComboBox(audioContent);
-    m_micWidget->setEditable(false);
-    audioLayout->addWidget(micTitle);
-    audioLayout->addWidget(m_micWidget);
-
-    // 扬声器区域
-    QLabel *speakerTitle = new QLabel(tr("扬声器"), audioContent);
-    speakerTitle->setStyleSheet("font-weight:600;");
-    m_speakerWidget = new QComboBox(audioContent);
-    m_speakerWidget->setEditable(false);
-    audioLayout->addWidget(speakerTitle);
-    audioLayout->addWidget(m_speakerWidget);
-
-    // 视频编码器区域
-    QLabel *encoderTitle = new QLabel(tr("视频编码器"), audioContent);
-    encoderTitle->setStyleSheet("font-weight:600;");
-    m_encoderWidget = new QComboBox(audioContent);
-    m_encoderWidget->setEditable(false);
-    audioLayout->addWidget(encoderTitle);
-    audioLayout->addWidget(m_encoderWidget);
-
-    audioDevicePopover->setContentWidget(audioContent);
-    buttonGroup->addButton(audioDeviceBtn, audioDevicePopover);
+    // FunctionButton *audioDeviceBtn = new FunctionButton(IconUtils::createAudioDeviceIcon(), "音频设备", this);
+    // Popover *audioDevicePopover = new Popover(this);
+
+    // // // 使用解耦合版本的音频设备选择器
+    // // m_audioDeviceSelectorDecoupled = new AudioDeviceSelectorIconDecoupled(this);
+    // // audioDevicePopover->setContentWidget(m_audioDeviceSelectorDecoupled);
+
+    // // 使用 RecorderAudioWidget 作为 Popover 内容(麦克风 + 扬声器)
+    // QWidget *audioContent = new QWidget(audioDevicePopover);
+    // QVBoxLayout *audioLayout = new QVBoxLayout(audioContent);
+    // audioLayout->setContentsMargins(8, 8, 8, 8);
+    // audioLayout->setSpacing(8);
+
+    // // 麦克风区域
+    // QLabel *micTitle = new QLabel(tr("麦克风"), audioContent);
+    // micTitle->setStyleSheet("font-weight:600;");
+    // m_micWidget = new QComboBox(audioContent);
+    // m_micWidget->setEditable(false);
+    // audioLayout->addWidget(micTitle);
+    // audioLayout->addWidget(m_micWidget);
+
+    // // 扬声器区域
+    // QLabel *speakerTitle = new QLabel(tr("扬声器"), audioContent);
+    // speakerTitle->setStyleSheet("font-weight:600;");
+    // m_speakerWidget = new QComboBox(audioContent);
+    // m_speakerWidget->setEditable(false);
+    // audioLayout->addWidget(speakerTitle);
+    // audioLayout->addWidget(m_speakerWidget);
+
+    // // 视频编码器区域
+    // QLabel *encoderTitle = new QLabel(tr("视频编码器"), audioContent);
+    // encoderTitle->setStyleSheet("font-weight:600;");
+    // m_encoderWidget = new QComboBox(audioContent);
+    // m_encoderWidget->setEditable(false);
+    // audioLayout->addWidget(encoderTitle);
+    // audioLayout->addWidget(m_encoderWidget);
+
+    // audioDevicePopover->setContentWidget(audioContent);
+    // buttonGroup->addButton(audioDeviceBtn, audioDevicePopover);
 
     // 新增:独立的推流按钮(无弹层)
     m_streamButton = new FunctionButton(IconUtils::createStreamIcon(), tr("推流"), this);
@@ -353,7 +355,7 @@ void MainPanel::setPlayerWidget(QWidget *newPlayer)
             if (!m_compactFrame) {
                 m_compactFrame = new TMainWindow();
                 m_compactFrame->setWindowTitle(tr("共享控制"));
-                m_compactFrame->setWindowFlag(Qt::Tool, true);
+                // m_compactFrame->setWindowFlag(Qt::Tool, true);
                 // m_compactFrame->setAttribute(Qt::WA_DeleteOnClose);
 
                 if (buttonGroup) {
@@ -382,6 +384,14 @@ void MainPanel::setPlayerWidget(QWidget *newPlayer)
             }
             m_compactFrame->show();
             m_compactFrame->raise();
+            m_compactFrame->activateWindow();
+            
+            // 将窗口移动到屏幕中上位置
+            QRect screenGeometry = QApplication::primaryScreen()->availableGeometry();
+            int x = (screenGeometry.width() - m_compactFrame->width()) / 2;
+            int y = screenGeometry.height() / 4; // 屏幕高度的1/4位置,即中上
+            m_compactFrame->move(screenGeometry.x() + x, screenGeometry.y() + y);
+
             m_compactMode = true;
 
             // 主窗口保持原几何但隐藏

+ 2 - 2
main.cpp

@@ -118,8 +118,8 @@ zlmediakit/zlmediakit:master
     // RecorderWidget testRecorder;
     // testRecorder.show();
 
-    AVPlayerWidget avPlayerWidget;
-    avPlayerWidget.show();
+    // AVPlayerWidget avPlayerWidget;
+    // avPlayerWidget.show();
 
     int ret = a.exec();
 

+ 115 - 36
widgets/meetingselectionwidget.cpp

@@ -30,8 +30,14 @@ void MeetingSelectionWidget::setupUI()
 {
     // 主布局
     m_mainLayout = new QVBoxLayout(this);
-    m_mainLayout->setContentsMargins(50, 50, 50, 50);
-    m_mainLayout->setSpacing(30);
+    m_mainLayout->setContentsMargins(40, 35, 40, 35);
+    m_mainLayout->setSpacing(25);
+    
+    // 标题区域
+    QWidget *headerWidget = new QWidget(this);
+    QVBoxLayout *headerLayout = new QVBoxLayout(headerWidget);
+    headerLayout->setContentsMargins(0, 0, 0, 20);
+    headerLayout->setSpacing(8);
     
     // 标题
     m_titleLabel = new QLabel("智能学习客户端", this);
@@ -42,28 +48,59 @@ void MeetingSelectionWidget::setupUI()
     m_welcomeLabel = new QLabel("欢迎使用!请选择您要进行的操作:", this);
     m_welcomeLabel->setAlignment(Qt::AlignCenter);
     m_welcomeLabel->setObjectName("welcomeLabel");
+    
+    headerLayout->addWidget(m_titleLabel);
+    headerLayout->addWidget(m_welcomeLabel);
+
+    // 创建信息卡片区域容器
+    QWidget *cardsContainer = new QWidget(this);
+    QHBoxLayout *cardsLayout = new QHBoxLayout(cardsContainer);
+    cardsLayout->setContentsMargins(0, 0, 0, 0);
+    cardsLayout->setSpacing(20);
+
+    // 创建用户信息卡片容器
+    QFrame *userCardFrame = new QFrame(this);
+    userCardFrame->setObjectName("userCardFrame");
+    QVBoxLayout *userCardLayout = new QVBoxLayout(userCardFrame);
+    userCardLayout->setContentsMargins(30, 25, 30, 25);
+    userCardLayout->setSpacing(0);
 
     // 用户资料卡片(复用现有组件)
     m_userProfile = new UserProfileWidget(this);
+    m_userProfile->setObjectName("userProfileCard");
+    userCardLayout->addWidget(m_userProfile);
+
+    // 创建统计信息卡片容器
+    QFrame *statsCardFrame = new QFrame(this);
+    statsCardFrame->setObjectName("statsCardFrame");
+    QVBoxLayout *statsCardLayout = new QVBoxLayout(statsCardFrame);
+    statsCardLayout->setContentsMargins(30, 25, 30, 25);
+    statsCardLayout->setSpacing(0);
 
     // 消息统计(临时迁移到此)
     m_statsWidget = new StatsWidget(this);
+    m_statsWidget->setObjectName("statsWidgetCard");
+    statsCardLayout->addWidget(m_statsWidget);
+
+    // 将卡片添加到水平布局
+    cardsLayout->addWidget(userCardFrame);
+    cardsLayout->addWidget(statsCardFrame);
 
     // 按钮容器
     m_buttonFrame = new QFrame(this);
     m_buttonFrame->setObjectName("buttonFrame");
     m_buttonLayout = new QVBoxLayout(m_buttonFrame);
-    m_buttonLayout->setContentsMargins(20, 20, 20, 20);
-    m_buttonLayout->setSpacing(20);
+    m_buttonLayout->setContentsMargins(30, 30, 30, 30);
+    m_buttonLayout->setSpacing(18);
     
     // 加入会议按钮
-    m_joinMeetingBtn = new QPushButton("加入会议", this);
+    m_joinMeetingBtn = new QPushButton("🚀 加入会议", this);
     m_joinMeetingBtn->setObjectName("joinMeetingBtn");
     m_joinMeetingBtn->setMinimumHeight(60);
     connect(m_joinMeetingBtn, &QPushButton::clicked, this, &MeetingSelectionWidget::onJoinMeetingClicked);
     
     // 创建会议按钮
-    m_createMeetingBtn = new QPushButton("创建会议", this);
+    m_createMeetingBtn = new QPushButton("创建会议", this);
     m_createMeetingBtn->setObjectName("createMeetingBtn");
     m_createMeetingBtn->setMinimumHeight(60);
     connect(m_createMeetingBtn, &QPushButton::clicked, this, &MeetingSelectionWidget::onCreateMeetingClicked);
@@ -71,7 +108,7 @@ void MeetingSelectionWidget::setupUI()
     // 退出登录按钮
     m_logoutBtn = new QPushButton("退出登录", this);
     m_logoutBtn->setObjectName("logoutBtn");
-    m_logoutBtn->setMinimumHeight(40);
+    m_logoutBtn->setMinimumHeight(45);
     connect(m_logoutBtn, &QPushButton::clicked, this, &MeetingSelectionWidget::onLogoutClicked);
     
     // 添加按钮到布局
@@ -81,17 +118,18 @@ void MeetingSelectionWidget::setupUI()
     m_buttonLayout->addWidget(m_logoutBtn);
     
     // 添加到主布局
-    m_mainLayout->addStretch();
-    m_mainLayout->addWidget(m_titleLabel);
-    m_mainLayout->addWidget(m_welcomeLabel);
-    m_mainLayout->addWidget(m_userProfile, 0, Qt::AlignCenter);
-    m_mainLayout->addWidget(m_statsWidget, 0, Qt::AlignCenter); // 新增:消息统计
-    m_mainLayout->addStretch();
+    m_mainLayout->addWidget(headerWidget);
+    m_mainLayout->addSpacing(10);
+    m_mainLayout->addWidget(cardsContainer, 0, Qt::AlignCenter);
+    m_mainLayout->addSpacing(25);
     m_mainLayout->addWidget(m_buttonFrame, 0, Qt::AlignCenter);
     m_mainLayout->addStretch();
     
-    // 设置按钮框架的固定宽度
-    m_buttonFrame->setFixedWidth(300);
+    // 设置容器的固定宽度
+    userCardFrame->setFixedWidth(280);
+    statsCardFrame->setFixedWidth(280);
+    m_buttonFrame->setFixedWidth(380);
+    cardsContainer->setFixedWidth(580);
 }
 
 void MeetingSelectionWidget::setUserRoles(const QStringList &roles)
@@ -156,79 +194,120 @@ void MeetingSelectionWidget::applyStyles()
 {
     // 设置整体样式
     setStyleSheet("MeetingSelectionWidget {"
-                  "    background-color: #f5f5f5;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #f8f9fa, stop:1 #e9ecef);"
                   "}"
 
                   "#titleLabel {"
-                  "    font-size: 28px;"
+                  "    font-size: 32px;"
                   "    font-weight: bold;"
                   "    color: #2c3e50;"
-                  "    margin-bottom: 10px;"
+                  "    margin-bottom: 5px;"
                   "}"
 
                   "#welcomeLabel {"
                   "    font-size: 16px;"
-                  "    color: #7f8c8d;"
-                  "    margin-bottom: 10px;"
+                  "    color: #6c757d;"
+                  "    margin-bottom: 5px;"
+                  "}"
+
+                  "#userCardFrame {"
+                  "    background-color: white;"
+                  "    border: none;"
+                  "    border-radius: 15px;"
+                  "    margin: 5px;"
+                  "    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);"
+                  "}"
+
+                  "#statsCardFrame {"
+                  "    background-color: white;"
+                  "    border: none;"
+                  "    border-radius: 15px;"
+                  "    margin: 5px;"
+                  "    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);"
+                  "}"
+
+                  "#userProfileCard {"
+                  "    background-color: transparent;"
+                  "    border: none;"
+                  "}"
+
+                  "#statsWidgetCard {"
+                  "    background-color: transparent;"
+                  "    border: none;"
                   "}"
 
                   "#buttonFrame {"
                   "    background-color: white;"
-                  "    border: 1px solid #e0e0e0;"
-                  "    border-radius: 10px;"
+                  "    border: none;"
+                  "    border-radius: 15px;"
+                  "    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);"
                   "}"
 
                   "#joinMeetingBtn {"
-                  "    background-color: #3498db;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #4fc3f7, stop:1 #29b6f6);"
                   "    color: white;"
                   "    border: none;"
-                  "    border-radius: 8px;"
+                  "    border-radius: 12px;"
                   "    font-size: 16px;"
                   "    font-weight: bold;"
                   "    padding: 15px;"
                   "}"
 
                   "#joinMeetingBtn:hover {"
-                  "    background-color: #2980b9;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #29b6f6, stop:1 #0288d1);"
+                  "    transform: translateY(-2px);"
                   "}"
 
                   "#joinMeetingBtn:pressed {"
-                  "    background-color: #21618c;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #0288d1, stop:1 #0277bd);"
+                  "    transform: translateY(0px);"
                   "}"
 
                   "#createMeetingBtn {"
-                  "    background-color: #27ae60;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #81c784, stop:1 #66bb6a);"
                   "    color: white;"
                   "    border: none;"
-                  "    border-radius: 8px;"
+                  "    border-radius: 12px;"
                   "    font-size: 16px;"
                   "    font-weight: bold;"
                   "    padding: 15px;"
                   "}"
 
                   "#createMeetingBtn:hover {"
-                  "    background-color: #229954;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #66bb6a, stop:1 #4caf50);"
+                  "    transform: translateY(-2px);"
                   "}"
 
                   "#createMeetingBtn:pressed {"
-                  "    background-color: #1e8449;"
+                  "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+                  "        stop:0 #4caf50, stop:1 #43a047);"
+                  "    transform: translateY(0px);"
                   "}"
 
                   "#logoutBtn {"
-                  "    background-color: #e74c3c;"
-                  "    color: white;"
-                  "    border: none;"
-                  "    border-radius: 6px;"
+                  "    background-color: #f8f9fa;"
+                  "    color: #6c757d;"
+                  "    border: 1px solid #dee2e6;"
+                  "    border-radius: 8px;"
                   "    font-size: 14px;"
                   "    padding: 10px;"
                   "}"
 
                   "#logoutBtn:hover {"
-                  "    background-color: #c0392b;"
+                  "    background-color: #e9ecef;"
+                  "    color: #495057;"
+                  "    border-color: #adb5bd;"
                   "}"
 
                   "#logoutBtn:pressed {"
-                  "    background-color: #a93226;"
+                  "    background-color: #dee2e6;"
+                  "    color: #343a40;"
                   "}");
 }