diff --git a/Bin/Config/Lang/cn/nmNum_cn.qm b/Bin/Config/Lang/cn/nmNum_cn.qm index af18f1e9..3cdbc85b 100644 Binary files a/Bin/Config/Lang/cn/nmNum_cn.qm and b/Bin/Config/Lang/cn/nmNum_cn.qm differ diff --git a/Bin/Config/Lang/cn/nmNum_cn.ts b/Bin/Config/Lang/cn/nmNum_cn.ts index 8e9c16d1..82f1b050 100644 --- a/Bin/Config/Lang/cn/nmNum_cn.ts +++ b/Bin/Config/Lang/cn/nmNum_cn.ts @@ -3423,6 +3423,8 @@ No valid error was returned; keep the last accepted result and reduce the step.< Animation settings动画设置 Loop enabled启用循环 Speed (steps/second)速度(步/秒) + OK确定 + Cancel取消 nmWxPebiResultFilterSettingsDlg diff --git a/Include/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.h b/Include/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.h index 6888c76b..8d062f5e 100644 --- a/Include/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.h +++ b/Include/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.h @@ -1,10 +1,9 @@ #ifndef NMWXPEBIRESULTANIMATIONSETTINGSDLG_H #define NMWXPEBIRESULTANIMATIONSETTINGSDLG_H +#include "iDlgBase.h" #include "nmSubWxs_global.h" -#include - class QCheckBox; class QShowEvent; class QSpinBox; @@ -16,7 +15,7 @@ class QSpinBox; * 两个值并事务式提交,因此取消或关闭对话框不会改变窗口偏好。 */ class NM_SUB_WXS_EXPORT nmWxPebiResultAnimationSettingsDlg - : public QDialog + : public iDlgBase { Q_OBJECT @@ -46,6 +45,13 @@ protected: private: Q_DISABLE_COPY(nmWxPebiResultAnimationSettingsDlg) + /** @brief 创建统一主题下的表单与底栏,纵向余量不拉高输入控件。 */ + void createUi(); + /** @brief 创建随窗口横向伸展的速度输入框和循环选项。 */ + QWidget* createFields(); + /** @brief 创建靠右的标准确认、取消按钮,连接原有接受/拒绝流程。 */ + QWidget* createFooter(); + /** @brief 限制为正整数步/秒的速度输入框。 */ QSpinBox* m_pSpeedSpin; /** @brief 是否在末帧之后回到第 0 帧。 */ diff --git a/Src/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.cpp b/Src/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.cpp index f77c247e..c102e439 100644 --- a/Src/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.cpp +++ b/Src/nmNum/nmSubWxs/nmWxPebiResultAnimationSettingsDlg.cpp @@ -1,45 +1,38 @@ #include "nmWxPebiResultAnimationSettingsDlg.h" #include "nmPebiResultPlaybackController.h" +#include "ZxBaseUtil.h" #include -#include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include #include #include #include #include -namespace { - -QString resultAnimationIconPath(const QString& sFileName) -{ - const QString sApplicationDir = QCoreApplication::applicationDirPath(); - return sApplicationDir.section('/', 0, -2) + - "/Res/Icon/" + sFileName; -} - -} - nmWxPebiResultAnimationSettingsDlg:: nmWxPebiResultAnimationSettingsDlg( int nStepsPerSecond, bool bLoopEnabled, QWidget* pParent) - : QDialog(pParent), - m_pSpeedSpin(new QSpinBox(this)), - m_pLoopCheck(new QCheckBox(tr("Loop enabled"), this)) + : iDlgBase(pParent), + m_pSpeedSpin(nullptr), + m_pLoopCheck(nullptr) { setWindowTitle(tr("Animation settings")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setModal(true); + // 接入统一窗口主题,同时沿用原窗口按 Esc 取消的行为。 + setIgnoreEsc(false); + createUi(); + // 控件只保存临时值,播放参数仍由调用方在确认后统一提交。 m_pSpeedSpin->setRange( nmPebiResultPlaybackController::MinimumPlaybackSpeed, nmPebiResultPlaybackController::MaximumPlaybackSpeed); @@ -51,35 +44,72 @@ nmWxPebiResultAnimationSettingsDlg( nmPebiResultPlaybackController::MaximumPlaybackSpeed))); m_pLoopCheck->setChecked(bLoopEnabled); - QFormLayout* pFormLayout = new QFormLayout(); - pFormLayout->addRow(tr("Speed (steps/second)"), m_pSpeedSpin); - pFormLayout->addRow(QString(), m_pLoopCheck); + // 范围及初值回填后计算推荐尺寸,窗口宽高由内容、字体及主题共同决定。 + adjustSize(); +} + +void nmWxPebiResultAnimationSettingsDlg::createUi() +{ + QVBoxLayout* pMainLayout = new QVBoxLayout(this); + pMainLayout->setContentsMargins(12, 10, 12, 0); + pMainLayout->setSpacing(10); + pMainLayout->addWidget(createFields()); + // 纵向余量留在内容与底栏之间,速度输入框和复选框不随窗口拉高。 + pMainLayout->addStretch(1); + pMainLayout->addWidget(createFooter()); +} + +QWidget* nmWxPebiResultAnimationSettingsDlg::createFields() +{ + QWidget* pFields = new QWidget(this); + pFields->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + QGridLayout* pLayout = new QGridLayout(pFields); + pLayout->setContentsMargins(0, 0, 0, 0); + pLayout->setHorizontalSpacing(6); + pLayout->setVerticalSpacing(6); + pLayout->setColumnStretch(1, 1); + QLabel* pSpeedLabel = new QLabel(tr("Speed (steps/second)"), pFields); + pSpeedLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); + m_pSpeedSpin = new QSpinBox(pFields); + // 横向由布局分配剩余空间,纵向采用主题推荐高度,不固定像素尺寸。 + m_pSpeedSpin->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + m_pLoopCheck = new QCheckBox(tr("Loop enabled"), pFields); + pLayout->addWidget(pSpeedLabel, 0, 0); + pLayout->addWidget(m_pSpeedSpin, 0, 1); + pLayout->addWidget(m_pLoopCheck, 1, 1); + return pFields; +} + +QWidget* nmWxPebiResultAnimationSettingsDlg::createFooter() +{ + QWidget* pFooter = new QWidget(this); + pFooter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + QHBoxLayout* pLayout = new QHBoxLayout(pFooter); + pLayout->setContentsMargins(4, 5, 4, 5); + pLayout->setSpacing(8); + pLayout->addStretch(); + + // 与已统一的窗口共用底部边距和框架图标,按钮尺寸交给主题。 QDialogButtonBox* pButtonBox = new QDialogButtonBox( - QDialogButtonBox::Ok | QDialogButtonBox::Cancel, - Qt::Horizontal, this); + QDialogButtonBox::Ok | QDialogButtonBox::Cancel, + Qt::Horizontal, pFooter); 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); - } + QPushButton* pCancelButton = pButtonBox->button(QDialogButtonBox::Cancel); + pOkButton->setText(tr("OK")); + pOkButton->setIcon(zxLoadIcon("OK")); + pOkButton->setDefault(true); + pCancelButton->setText(tr("Cancel")); + pCancelButton->setIcon(zxLoadIcon("Cancel")); + pCancelButton->setAutoDefault(false); + pLayout->addWidget(pButtonBox); connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject())); - QVBoxLayout* pMainLayout = new QVBoxLayout(this); - pMainLayout->addLayout(pFormLayout); - pMainLayout->addWidget(pButtonBox); - setMinimumWidth(320); + setTabOrder(m_pSpeedSpin, m_pLoopCheck); + setTabOrder(m_pLoopCheck, pOkButton); + setTabOrder(pOkButton, pCancelButton); + return pFooter; } nmWxPebiResultAnimationSettingsDlg:: @@ -99,7 +129,7 @@ bool nmWxPebiResultAnimationSettingsDlg::isLoopEnabled() const void nmWxPebiResultAnimationSettingsDlg::showEvent(QShowEvent* pEvent) { - QDialog::showEvent(pEvent); + iDlgBase::showEvent(pEvent); m_pSpeedSpin->setFocus(Qt::OtherFocusReason); QTimer::singleShot(0, m_pSpeedSpin, SLOT(selectAll())); }