From ce41197324188d303a658e839b75f31f977c5197 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Sat, 1 Aug 2015 13:55:29 +0200 Subject: [PATCH] Make the parameter error caption in the warning messagebox global for all effects --- ffbeffect.cpp | 2 ++ ffbeffect.h | 2 ++ linuxffbrampeffect.h | 2 +- sdl2ffbconditioneffect.cpp | 24 ++++++++++++------------ sdl2ffbconstanteffect.cpp | 2 +- sdl2ffbeffect.cpp | 16 +++++++--------- sdl2ffbeffect.h | 2 -- sdl2ffbperiodiceffect.cpp | 10 +++++----- sdl2ffbrampeffect.cpp | 4 ++-- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ffbeffect.cpp b/ffbeffect.cpp index a496094..4a69340 100644 --- a/ffbeffect.cpp +++ b/ffbeffect.cpp @@ -1,6 +1,8 @@ #include "ffbeffect.h" #include "globalsettings.h" +const QString FFBEffect::PRERR_CAPTION("Invalid FFB parameter"); + FFBEffect::FFBEffect(FFBEffectTypes type) { m_status = FFBEffectStatus::NOT_LOADED; diff --git a/ffbeffect.h b/ffbeffect.h index aa294ae..7313338 100644 --- a/ffbeffect.h +++ b/ffbeffect.h @@ -22,6 +22,8 @@ public: protected: virtual bool checkGenericParameters(const std::shared_ptr params) = 0; + static const QString PRERR_CAPTION; + private: FFBEffectStatus m_status; FFBEffectTypes m_type; diff --git a/linuxffbrampeffect.h b/linuxffbrampeffect.h index 4ed4865..9293e3a 100644 --- a/linuxffbrampeffect.h +++ b/linuxffbrampeffect.h @@ -18,4 +18,4 @@ private: std::shared_ptr m_params; }; -#endif // FFBRAMPEFFECT_H +#endif // LINUXFFBRAMPEFFECT_H diff --git a/sdl2ffbconditioneffect.cpp b/sdl2ffbconditioneffect.cpp index fa7c6e6..d76f56b 100644 --- a/sdl2ffbconditioneffect.cpp +++ b/sdl2ffbconditioneffect.cpp @@ -73,62 +73,62 @@ bool SDL2FFBConditionEffect::setParameters(std::shared_ptrleftSat.at(FFBConditionEffectParameters::Axis::X), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Left X saturation must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Left X saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->leftSat.at(FFBConditionEffectParameters::Axis::Y), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Left Y saturation must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Left Y saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->rightSat.at(FFBConditionEffectParameters::Axis::X), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Right X saturation must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Right X saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->rightSat.at(FFBConditionEffectParameters::Axis::Y), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Right Y saturation must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Right Y saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->leftCoeff.at(FFBConditionEffectParameters::Axis::X), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Left X coefficient must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Left X coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->leftCoeff.at(FFBConditionEffectParameters::Axis::Y), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Left Y coefficient must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Left Y coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->rightCoeff.at(FFBConditionEffectParameters::Axis::X), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Right X coefficient must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Right X coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->rightCoeff.at(FFBConditionEffectParameters::Axis::Y), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Right Y coefficient must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Right Y coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->deadband.at(FFBConditionEffectParameters::Axis::X), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Deadband X must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Deadband X must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->deadband.at(FFBConditionEffectParameters::Axis::Y), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Deadband Y must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Deadband Y must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->center.at(FFBConditionEffectParameters::Axis::X), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Center X must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Center X must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->center.at(FFBConditionEffectParameters::Axis::Y), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Center Y must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Center Y must be within <-32767; 32767>"); return false; } diff --git a/sdl2ffbconstanteffect.cpp b/sdl2ffbconstanteffect.cpp index d21f1db..e913468 100644 --- a/sdl2ffbconstanteffect.cpp +++ b/sdl2ffbconstanteffect.cpp @@ -55,7 +55,7 @@ bool SDL2FFBConstantEffect::setParameters(const std::shared_ptrlevel, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Level parameters must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Level parameters must be within <-32767; 32767>"); return false; } diff --git a/sdl2ffbeffect.cpp b/sdl2ffbeffect.cpp index c527ea5..c18955e 100644 --- a/sdl2ffbeffect.cpp +++ b/sdl2ffbeffect.cpp @@ -2,8 +2,6 @@ #include "globalsettings.h" #include -const QString SDL2FFBEffect::CAPTION("Invalid FFB parameter"); - SDL_HapticEffect* SDL2FFBEffect::createFFstruct() { SDL_HapticEffect* effect = new SDL_HapticEffect; @@ -21,22 +19,22 @@ bool SDL2FFBEffect::checkEnvelopeParameters(const int attackLength, const int at return true; if (!checkBoundsInclusive(attackLength, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Attack length must be within <0; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Attack length must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(attackLevel, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Attack level must be within <0; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Attack level must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(fadeLength, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Fade length must be within <0; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Fade length must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(fadeLevel, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Fade level must be within <0; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Fade level must be within <0; 32767>"); return false; } @@ -49,17 +47,17 @@ bool SDL2FFBEffect::checkGenericParameters(const std::shared_ptrdirection, 0, 36000)) { - QMessageBox::warning(nullptr, CAPTION, "Direction must be within <0; 36000)"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Direction must be within <0; 36000)"); return false; } if (!checkBoundsInclusive(params->replayLength, static_cast(0), static_cast(0x7FFF))) { - QMessageBox::warning(nullptr, CAPTION, "Replay length must be within <0; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Replay length must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(params->replayDelay, 0, 0xFFFF)) { - QMessageBox::warning(nullptr, CAPTION, "Replay delay must be within <0; 65535>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Replay delay must be within <0; 65535>"); return false; } diff --git a/sdl2ffbeffect.h b/sdl2ffbeffect.h index 833727f..27ffa00 100644 --- a/sdl2ffbeffect.h +++ b/sdl2ffbeffect.h @@ -13,8 +13,6 @@ public: protected: virtual bool checkGenericParameters(const std::shared_ptr params); bool checkEnvelopeParameters(const int attackLength, const int attackLevel, const int fadeLength, const int fadeLevel); - - static const QString CAPTION; }; #endif // SDL2FFBEFFECT_H diff --git a/sdl2ffbperiodiceffect.cpp b/sdl2ffbperiodiceffect.cpp index c8302f6..1c1f100 100644 --- a/sdl2ffbperiodiceffect.cpp +++ b/sdl2ffbperiodiceffect.cpp @@ -75,28 +75,28 @@ bool SDL2FFBPeriodicEffect::setParameters(const std::shared_ptrperiod, 0, 36000)) { - QMessageBox::warning(nullptr, CAPTION, "Period must be within <0; 36000>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Period must be within <0; 36000>"); return false; } if (!checkBoundsInclusive(params->magnitude, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Magnitude must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Magnitude must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->offset, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Offset must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Offset must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->phase, 0, 36000)) { - QMessageBox::warning(nullptr, CAPTION, "Phase must be withing <0; 36000>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Phase must be withing <0; 36000>"); return false; } if (params->waveform == PeriodicWaveforms::NONE || params->waveform == PeriodicWaveforms::SQUARE) { - QMessageBox::warning(nullptr, CAPTION, "Unsupported waveform"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Unsupported waveform"); return false; } diff --git a/sdl2ffbrampeffect.cpp b/sdl2ffbrampeffect.cpp index ba60f72..279b4ca 100644 --- a/sdl2ffbrampeffect.cpp +++ b/sdl2ffbrampeffect.cpp @@ -58,12 +58,12 @@ bool SDL2FFBRampEffect::setParameters(const std::shared_ptrstartLevel, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "Start level must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "Start level must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->endLevel, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, CAPTION, "End level must be within <-32767; 32767>"); + QMessageBox::warning(nullptr, PRERR_CAPTION, "End level must be within <-32767; 32767>"); return false; } -- 2.43.5