From 8ff688e0e6fc320c701dae28e3b125131678f3ea Mon Sep 17 00:00:00 2001 From: lh <2334563547@qq.com> Date: Sun, 20 Sep 2026 15:53:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=9B=9E=E6=94=BE=E6=9C=9F=E9=97=B4=E7=9A=84=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=9D=A1=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统一使用 PlaybackController 播放状态控制底部控件 - 播放期间禁用属性、颜色、时间、帧导航和动画设置 - 保持暂停按钮可用并持续同步当前播放时间 - 暂停、自然结束或播放失败后按当前帧恢复控件状态 - 为手动操作槽增加播放状态防御,避免排队信号中断回放 - 同步颜色设置和动画设置入口的行为注释 --- .../nmNum/nmSubWxs/nmWxPebiResultControlBar.h | 4 +- .../nmSubWxs/nmWxPebiResultControlBar.cpp | 55 +++++++++++++------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h b/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h index ea4e43d1..276a6f23 100644 --- a/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h +++ b/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h @@ -53,7 +53,7 @@ private slots: void onPropertyIndexChanged(int nIndex); /** @brief 用户选择时间时提交 itemData 中的零基帧。 */ void onTimeIndexChanged(int nIndex); - /** @brief 暂停后打开当前属性的 Saphir 风格颜色设置对话框。 */ + /** @brief 仅在非播放状态下打开当前属性的 Saphir 风格颜色设置对话框。 */ void onColorSettingsClicked(); /** @brief 响应首帧按钮。 */ void onFirstFrameClicked(); @@ -65,7 +65,7 @@ private slots: void onLastFrameClicked(); /** @brief 切换播放或暂停图标对应的回放状态。 */ void onPlayPauseClicked(); - /** @brief 暂停后打开当前窗口独立的动画设置对话框。 */ + /** @brief 仅在非播放状态下打开当前窗口独立的动画设置对话框。 */ void onAnimationSettingsClicked(); /** @brief 从 Controller getter 重建或刷新控件镜像状态。 */ void refreshFromController(); diff --git a/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp b/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp index 708648fa..1602b349 100644 --- a/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp +++ b/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp @@ -108,7 +108,8 @@ nmWxPebiResultControlBar::getPlaybackController() const void nmWxPebiResultControlBar::onPropertyIndexChanged(int nIndex) { - if(m_pPlaybackController == nullptr || nIndex < 0) { + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying() || nIndex < 0) { return; } if(m_pPlaybackController->selectProperty( @@ -119,7 +120,8 @@ void nmWxPebiResultControlBar::onPropertyIndexChanged(int nIndex) void nmWxPebiResultControlBar::onTimeIndexChanged(int nIndex) { - if(m_pPlaybackController == nullptr || nIndex < 0) { + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying() || nIndex < 0) { return; } if(m_pPlaybackController->selectFrame( @@ -131,12 +133,11 @@ void nmWxPebiResultControlBar::onTimeIndexChanged(int nIndex) void nmWxPebiResultControlBar::onColorSettingsClicked() { if(m_pPlaybackController == nullptr || m_pSceneController == nullptr || + m_pPlaybackController->isPlaying() || !m_pSceneController->hasSnapshot()) { return; } - // 打开任何结果设置都属于手动操作;关闭后不自动恢复播放。 - m_pPlaybackController->pause(); nmWxPebiResultColorScaleSettingsDlg oDialog( m_pSceneController, this); connect(&oDialog, SIGNAL(displaySettingsApplied()), @@ -148,6 +149,10 @@ void nmWxPebiResultControlBar::onColorSettingsClicked() void nmWxPebiResultControlBar::onFirstFrameClicked() { + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying()) { + return; + } if(m_pPlaybackController->selectFirstFrame()) { emit operationSucceeded(); } @@ -155,6 +160,10 @@ void nmWxPebiResultControlBar::onFirstFrameClicked() void nmWxPebiResultControlBar::onPreviousFrameClicked() { + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying()) { + return; + } if(m_pPlaybackController->selectPreviousFrame()) { emit operationSucceeded(); } @@ -162,6 +171,10 @@ void nmWxPebiResultControlBar::onPreviousFrameClicked() void nmWxPebiResultControlBar::onNextFrameClicked() { + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying()) { + return; + } if(m_pPlaybackController->selectNextFrame()) { emit operationSucceeded(); } @@ -169,6 +182,10 @@ void nmWxPebiResultControlBar::onNextFrameClicked() void nmWxPebiResultControlBar::onLastFrameClicked() { + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying()) { + return; + } if(m_pPlaybackController->selectLastFrame()) { emit operationSucceeded(); } @@ -176,6 +193,9 @@ void nmWxPebiResultControlBar::onLastFrameClicked() void nmWxPebiResultControlBar::onPlayPauseClicked() { + if(m_pPlaybackController == nullptr) { + return; + } if(m_pPlaybackController->togglePlayback()) { emit operationSucceeded(); } @@ -183,8 +203,10 @@ void nmWxPebiResultControlBar::onPlayPauseClicked() void nmWxPebiResultControlBar::onAnimationSettingsClicked() { - // 打开设置属于明确的手动操作;关闭对话框后不自动恢复播放。 - m_pPlaybackController->pause(); + if(m_pPlaybackController == nullptr || + m_pPlaybackController->isPlaying()) { + return; + } nmWxPebiResultAnimationSettingsDlg oDialog( m_pPlaybackController->getPlaybackSpeed(), m_pPlaybackController->isLoopEnabled(), this); @@ -254,9 +276,6 @@ void nmWxPebiResultControlBar::refreshFromController() const bool bPropertyBlocked = m_pPropertyCombo->blockSignals(true); m_pPropertyCombo->setCurrentIndex(nPropertyIndex); m_pPropertyCombo->blockSignals(bPropertyBlocked); - m_pPropertyCombo->setEnabled(true); - m_pColorSettingsButton->setEnabled(true); - const bool bTimeDependent = m_pPlaybackController->isPropertyTimeDependent(sPropertyId); const int nFrameCount = bTimeDependent @@ -283,19 +302,23 @@ void nmWxPebiResultControlBar::refreshFromController() const bool bHasTime = bHasCompleteTimeList; const bool bHasMultipleFrames = bHasCompleteTimeList && nFrameCount > 1; - m_pTimeCombo->setEnabled(bHasTime); + const bool bPlaying = m_pPlaybackController->isPlaying(); + m_pPropertyCombo->setEnabled(!bPlaying); + m_pColorSettingsButton->setEnabled(!bPlaying); + m_pTimeCombo->setEnabled(bHasTime && !bPlaying); m_pFirstButton->setEnabled( - bHasMultipleFrames && nCurrentFrame > 0); + bHasMultipleFrames && nCurrentFrame > 0 && !bPlaying); m_pPreviousButton->setEnabled( - bHasMultipleFrames && nCurrentFrame > 0); + bHasMultipleFrames && nCurrentFrame > 0 && !bPlaying); m_pNextButton->setEnabled( - bHasMultipleFrames && nCurrentFrame < nFrameCount - 1); + bHasMultipleFrames && + nCurrentFrame < nFrameCount - 1 && !bPlaying); m_pLastButton->setEnabled( - bHasMultipleFrames && nCurrentFrame < nFrameCount - 1); + bHasMultipleFrames && + nCurrentFrame < nFrameCount - 1 && !bPlaying); m_pPlayPauseButton->setEnabled(bHasMultipleFrames); - m_pSettingsButton->setEnabled(bHasMultipleFrames); + m_pSettingsButton->setEnabled(bHasMultipleFrames && !bPlaying); - const bool bPlaying = m_pPlaybackController->isPlaying(); m_pPlayPauseButton->setIcon(QIcon(resultControlIconPath( bPlaying ? QString::fromLatin1("NmStopAnimation.png") : QString::fromLatin1("NmStartAnimation.png"))));