|
|
@@ -12,6 +12,9 @@ AVPlayerWidget::AVPlayerWidget(QWidget *parent)
|
|
|
, m_isPlaying(false)
|
|
|
, m_isPaused(false)
|
|
|
{
|
|
|
+ // 设置尺寸策略,确保能够正确填充空间
|
|
|
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
+
|
|
|
setupUI();
|
|
|
connectSignals();
|
|
|
|
|
|
@@ -33,26 +36,46 @@ AVPlayerWidget::~AVPlayerWidget()
|
|
|
void AVPlayerWidget::setupUI()
|
|
|
{
|
|
|
m_mainLayout = new QVBoxLayout(this);
|
|
|
+ m_mainLayout->setContentsMargins(5, 5, 5, 5); // 减少主布局边距
|
|
|
+ m_mainLayout->setSpacing(5); // 减少组件间距
|
|
|
|
|
|
// 添加OpenGL视频渲染组件
|
|
|
m_mainLayout->addWidget(m_openglWidget, 1);
|
|
|
|
|
|
- // 创建控制面板
|
|
|
- m_controlLayout = new QHBoxLayout();
|
|
|
+ // 创建控制面板容器
|
|
|
+ QWidget *controlWidget = new QWidget(this);
|
|
|
+ controlWidget->setFixedHeight(60); // 设置控制面板固定高度
|
|
|
+ controlWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
+
|
|
|
+ m_controlLayout = new QHBoxLayout(controlWidget);
|
|
|
+ m_controlLayout->setContentsMargins(5, 5, 5, 5); // 减少控制面板内边距
|
|
|
+ m_controlLayout->setSpacing(5); // 减少控件间距
|
|
|
|
|
|
// URL输入框
|
|
|
m_urlEdit = new QLineEdit(this);
|
|
|
m_urlEdit->setPlaceholderText("输入视频文件路径或URL");
|
|
|
+ m_urlEdit->setFixedHeight(30); // 固定高度适应控制面板
|
|
|
+ m_urlEdit->setFont(QFont("Arial", 9));
|
|
|
m_controlLayout->addWidget(m_urlEdit, 2);
|
|
|
|
|
|
// 测试播放按钮
|
|
|
m_testPlayButton = new QPushButton("测试播放", this);
|
|
|
+ m_testPlayButton->setFixedSize(70, 30); // 固定尺寸
|
|
|
+ m_testPlayButton->setFont(QFont("Arial", 9, QFont::Bold));
|
|
|
m_controlLayout->addWidget(m_testPlayButton);
|
|
|
|
|
|
// 播放控制按钮
|
|
|
m_playButton = new QPushButton("播放", this);
|
|
|
+ m_playButton->setFixedSize(50, 30); // 固定尺寸
|
|
|
+ m_playButton->setFont(QFont("Arial", 9, QFont::Bold));
|
|
|
+
|
|
|
m_pauseButton = new QPushButton("暂停", this);
|
|
|
+ m_pauseButton->setFixedSize(50, 30); // 固定尺寸
|
|
|
+ m_pauseButton->setFont(QFont("Arial", 9, QFont::Bold));
|
|
|
+
|
|
|
m_stopButton = new QPushButton("停止", this);
|
|
|
+ m_stopButton->setFixedSize(50, 30); // 固定尺寸
|
|
|
+ m_stopButton->setFont(QFont("Arial", 9, QFont::Bold));
|
|
|
|
|
|
m_controlLayout->addWidget(m_playButton);
|
|
|
m_controlLayout->addWidget(m_pauseButton);
|
|
|
@@ -60,19 +83,22 @@ void AVPlayerWidget::setupUI()
|
|
|
|
|
|
// 音量控制
|
|
|
QLabel *volumeLabel = new QLabel("音量:", this);
|
|
|
+ volumeLabel->setFont(QFont("Arial", 9));
|
|
|
m_volumeSlider = new QSlider(Qt::Horizontal, this);
|
|
|
m_volumeSlider->setRange(0, 100);
|
|
|
m_volumeSlider->setValue(50);
|
|
|
- m_volumeSlider->setMaximumWidth(100);
|
|
|
+ m_volumeSlider->setFixedSize(100, 20); // 固定尺寸
|
|
|
|
|
|
m_controlLayout->addWidget(volumeLabel);
|
|
|
m_controlLayout->addWidget(m_volumeSlider);
|
|
|
|
|
|
// 时间显示
|
|
|
m_timeLabel = new QLabel("00:00 / 00:00", this);
|
|
|
+ m_timeLabel->setFont(QFont("Arial", 9));
|
|
|
+ m_timeLabel->setFixedWidth(80);
|
|
|
m_controlLayout->addWidget(m_timeLabel);
|
|
|
|
|
|
- m_mainLayout->addLayout(m_controlLayout);
|
|
|
+ m_mainLayout->addWidget(controlWidget, 0); // 拉伸因子为0,不占用额外空间
|
|
|
|
|
|
// 设置初始状态
|
|
|
m_pauseButton->setEnabled(false);
|