#include "nmWxPebiResultAnimationSettingsDlg.h" #include "nmPebiResultPlaybackController.h" #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)) { setWindowTitle(tr("Animation settings")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setModal(true); m_pSpeedSpin->setRange( nmPebiResultPlaybackController::MinimumPlaybackSpeed, INT_MAX); m_pSpeedSpin->setValue(qMax( static_cast( nmPebiResultPlaybackController::MinimumPlaybackSpeed), nStepsPerSecond)); m_pLoopCheck->setChecked(bLoopEnabled); QFormLayout* pFormLayout = new QFormLayout(); pFormLayout->addRow(tr("Speed (steps/second)"), m_pSpeedSpin); pFormLayout->addRow(QString(), m_pLoopCheck); 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())); QVBoxLayout* pMainLayout = new QVBoxLayout(this); pMainLayout->addLayout(pFormLayout); pMainLayout->addWidget(pButtonBox); setMinimumWidth(320); } nmWxPebiResultAnimationSettingsDlg:: ~nmWxPebiResultAnimationSettingsDlg() { } int nmWxPebiResultAnimationSettingsDlg::getPlaybackSpeed() const { return m_pSpeedSpin->value(); } 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())); }