feat: 优化结果动画播放速度设置

- 移除每秒 60 步的播放速度上限,支持正整数范围输入
- 保留最小 1ms 的定时器间隔,避免高速设置产生零间隔
- 对话框显示后自动聚焦并全选当前速度
- 移除标题栏帮助按钮并统一确定、取消按钮样式
- 更新播放速度校验提示、接口注释和中文翻译资源
feature/nmNum-postprocessing-view-20260910
lh 2 weeks ago
parent 8ff688e0e6
commit 6bf1d28940

Binary file not shown.

@ -2836,7 +2836,7 @@ Reason: %1</source>
<message><source>Result playback is unavailable.</source><translation>结果回放不可用。</translation></message>
<message><source>The selected result property is unavailable.</source><translation>所选结果属性不可用。</translation></message>
<message><source>The selected result frame is unavailable.</source><translation>所选结果帧不可用。</translation></message>
<message><source>Playback speed must be between 1 and 60 steps per second.</source><translation>回放速度必须介于每秒 1 到 60 步之间。</translation></message>
<message><source>Playback speed must be a positive integer.</source><translation>播放速度必须为正整数。</translation></message>
</context>
<context>
<name>nmWxPebiResultControlBar</name>

@ -22,11 +22,10 @@ class NM_SUB_WXS_EXPORT nmPebiResultPlaybackController : public QObject
Q_OBJECT
public:
/** @brief 回放速度的合法下限、上限和窗口默认值,单位均为步/秒。 */
/** @brief 回放速度的合法下限和窗口默认值,单位均为步/秒。 */
enum
{
MinimumPlaybackSpeed = 1,
MaximumPlaybackSpeed = 60,
DefaultPlaybackSpeed = 5
};

@ -6,6 +6,7 @@
#include <QDialog>
class QCheckBox;
class QShowEvent;
class QSpinBox;
/**
@ -22,7 +23,7 @@ class NM_SUB_WXS_EXPORT nmWxPebiResultAnimationSettingsDlg
public:
/**
* @brief 使用当前窗口偏好初始化临时编辑值。
* @param nStepsPerSecond 初始速度,防御性限制到 1~60 步/秒。
* @param nStepsPerSecond 初始速度,防御性限制为正整数步/秒。
* @param bLoopEnabled 初始循环开关。
* @param pParent 所属窗口,用于 Qt 对象树和模态定位。
*/
@ -38,10 +39,14 @@ public:
/** @brief 返回尚未提交的循环播放选择。 */
bool isLoopEnabled() const;
protected:
/** @brief 显示后聚焦并延迟全选当前速度,便于直接覆盖输入。 */
virtual void showEvent(QShowEvent* pEvent);
private:
Q_DISABLE_COPY(nmWxPebiResultAnimationSettingsDlg)
/** @brief 限制在 1~60 步/秒的速度输入框。 */
/** @brief 限制为正整数步/秒的速度输入框。 */
QSpinBox* m_pSpeedSpin;
/** @brief 是否在末帧之后回到第 0 帧。 */
QCheckBox* m_pLoopCheck;

@ -20,7 +20,7 @@ static const char* const s_pPlaybackTranslationMarkers[] =
QT_TRANSLATE_NOOP("nmPebiResultPlaybackController",
"The selected result frame is unavailable."),
QT_TRANSLATE_NOOP("nmPebiResultPlaybackController",
"Playback speed must be between 1 and 60 steps per second.")
"Playback speed must be a positive integer.")
};
QString playbackText(const char* pText)
@ -244,11 +244,10 @@ bool nmPebiResultPlaybackController::setPlaybackSettings(
int nStepsPerSecond,
bool bLoopEnabled)
{
if(nStepsPerSecond < MinimumPlaybackSpeed ||
nStepsPerSecond > MaximumPlaybackSpeed) {
if(nStepsPerSecond < MinimumPlaybackSpeed) {
// 公开接口不能依赖设置对话框兜底;非法参数也执行统一失败收尾。
return finishFailedOperation(playbackText(
"Playback speed must be between 1 and 60 steps per second."));
"Playback speed must be a positive integer."));
}
if(m_nStepsPerSecond == nStepsPerSecond &&
m_bLoopEnabled == bLoopEnabled) {

@ -3,12 +3,32 @@
#include "nmPebiResultPlaybackController.h"
#include <QCheckBox>
#include <QCoreApplication>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QIcon>
#include <QLayout>
#include <QPushButton>
#include <QShowEvent>
#include <QSize>
#include <QSpinBox>
#include <QTimer>
#include <QVBoxLayout>
#include <QtGlobal>
#include <limits.h>
namespace {
QString resultAnimationIconPath(const QString& sFileName)
{
const QString sApplicationDir = QCoreApplication::applicationDirPath();
return sApplicationDir.section('/', 0, -2) +
"/Res/Icon/" + sFileName;
}
}
nmWxPebiResultAnimationSettingsDlg::
nmWxPebiResultAnimationSettingsDlg(
int nStepsPerSecond,
@ -19,17 +39,16 @@ nmWxPebiResultAnimationSettingsDlg(
m_pLoopCheck(new QCheckBox(tr("Loop enabled"), this))
{
setWindowTitle(tr("Animation settings"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setModal(true);
m_pSpeedSpin->setRange(
nmPebiResultPlaybackController::MinimumPlaybackSpeed,
nmPebiResultPlaybackController::MaximumPlaybackSpeed);
m_pSpeedSpin->setValue(qBound(
INT_MAX);
m_pSpeedSpin->setValue(qMax(
static_cast<int>(
nmPebiResultPlaybackController::MinimumPlaybackSpeed),
nStepsPerSecond,
static_cast<int>(
nmPebiResultPlaybackController::MaximumPlaybackSpeed)));
nStepsPerSecond));
m_pLoopCheck->setChecked(bLoopEnabled);
QFormLayout* pFormLayout = new QFormLayout();
@ -39,6 +58,21 @@ nmWxPebiResultAnimationSettingsDlg(
QDialogButtonBox* pButtonBox = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
QPushButton* pOkButton = pButtonBox->button(QDialogButtonBox::Ok);
QPushButton* pCancelButton =
pButtonBox->button(QDialogButtonBox::Cancel);
const QSize oButtonIconSize(16, 16);
pOkButton->setIcon(QIcon(resultAnimationIconPath(
QString::fromLatin1("OK.png"))));
pCancelButton->setIcon(QIcon(resultAnimationIconPath(
QString::fromLatin1("Cancel.png"))));
pOkButton->setIconSize(oButtonIconSize);
pCancelButton->setIconSize(oButtonIconSize);
pOkButton->setMinimumWidth(72);
pCancelButton->setMinimumWidth(72);
if(pButtonBox->layout() != nullptr) {
pButtonBox->layout()->setSpacing(6);
}
connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
@ -62,3 +96,10 @@ bool nmWxPebiResultAnimationSettingsDlg::isLoopEnabled() const
{
return m_pLoopCheck->isChecked();
}
void nmWxPebiResultAnimationSettingsDlg::showEvent(QShowEvent* pEvent)
{
QDialog::showEvent(pEvent);
m_pSpeedSpin->setFocus(Qt::OtherFocusReason);
QTimer::singleShot(0, m_pSpeedSpin, SLOT(selectAll()));
}

Loading…
Cancel
Save