effectIdx = ui->cbox_effectSlots->currentData(Qt::UserRole).toInt(&ok);
if (!ok) {
- QMessageBox::critical(this, "Runtime error", "Nonsensical data passed as effect slot index.");
+ showErrorMsgBox(ErrorMessages::BAD_EFFECT_SLOT);
return;
}
FFBEffectTypes etype = m_activeDevice->effectTypeByEffectIdx(effectIdx);
if (m_activeDevice == nullptr)
return;
if (!m_activeDevice->removeAndEraseEffect(ui->cbox_effectSlots->currentIndex()))
- QMessageBox::warning(this, res_deviceErrorCap, "Unable to remove the effect.");
+ showErrorMsgBox(ErrorMessages::CANT_REMOVE_EFFECT);
else
setEffectStatusText(FFBEffect::FFBEffectStatus::NOT_LOADED);
}
std::shared_ptr<FFBEffectParameters> params;
effectSlot = ui->cbox_effectSlots->currentData().toInt(&ok);
if (!ok) {
- QMessageBox::critical(this, "Runtime error", "Nonsensical data passed as effect slot index.");
+ showErrorMsgBox(ErrorMessages::BAD_EFFECT_SLOT);
return;
}
if (ret)
setEffectStatusText(m_activeDevice->effectStatusByIdx(effectSlot));
else
- QMessageBox::warning(this, res_deviceErrorCap, "Unable to start the effect.");
+ showErrorMsgBox(ErrorMessages::CANT_START_EFFECT);
}
void MainWindow::onStopEffectClicked()
effectSlot = ui->cbox_effectSlots->currentData().toInt(&ok);
if (!ok) {
- QMessageBox::critical(this, "Runtime error", "Nonsensical data passed as effect slot index.");
+ showErrorMsgBox(ErrorMessages::BAD_EFFECT_SLOT);
return;
}
m_activeDevice->stopEffect(effectSlot);
std::shared_ptr<FFBEffectParameters> params;
effectSlot = ui->cbox_effectSlots->currentData().toInt(&ok);
if (!ok) {
- QMessageBox::critical(this, "Runtime error", "Nonsensical data passed as effect slot index.");
+ showErrorMsgBox(ErrorMessages::BAD_EFFECT_SLOT);
return;
}
if (ret)
setEffectStatusText(m_activeDevice->effectStatusByIdx(effectSlot));
else
- QMessageBox::warning(this, res_deviceErrorCap, "Unable to upload the effect.");
+ showErrorMsgBox(ErrorMessages::CANT_UPLOAD_EFFECT);
}
bool MainWindow::readEnvelopeParameters(std::shared_ptr<FFBEnvelopeParameters> params, const EnvelopeSettings* es)
}
}
+void MainWindow::showErrorMsgBox(const ErrorMessages msgCode)
+{
+ switch (msgCode) {
+ case ErrorMessages::BAD_EFFECT_SLOT:
+ QMessageBox::critical(this, "Runtime error", "Nonsensical data passed as effect slot index.");
+ break;
+ case ErrorMessages::CANT_REMOVE_EFFECT:
+ QMessageBox::warning(this, res_deviceErrorCap, "Unable to remove the effect.");
+ break;
+ case ErrorMessages::CANT_START_EFFECT:
+ QMessageBox::warning(this, res_deviceErrorCap, "Unable to start the effect.");
+ break;
+ case ErrorMessages::CANT_UPLOAD_EFFECT:
+ QMessageBox::warning(this, res_deviceErrorCap, "Unable to upload effect.");
+ break;
+ }
+}
+
+
MainWindow::~MainWindow()
{
delete ui;
~MainWindow();
private:
+ enum class ErrorMessages { BAD_EFFECT_SLOT,
+ CANT_REMOVE_EFFECT,
+ CANT_START_EFFECT,
+ CANT_UPLOAD_EFFECT };
+
EffectSettings* effectSettingsByType(FFBEffectTypes type);
QString effectTypeToEffectName(const FFBEffectTypes type) const;
void fillDeviceList();
bool readGeneralEffectParameters(std::shared_ptr<FFBEffectParameters> params);
void setEffectStatusText(const FFBEffect::FFBEffectStatus status);
void setEffectTypeIndexByType(const FFBEffectTypes etype);
+ void showErrorMsgBox(const ErrorMessages msgCode);
std::shared_ptr<FFBDevice> m_activeDevice;
ConditionEffectSettings* m_conditionEffSet;