FBXExporterDialog.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "EditorDefs.h"
  9. #include "FBXExporterDialog.h"
  10. #include <QMessageBox>
  11. #include <ui_FBXExporterDialog.h>
  12. CFBXExporterDialog::CFBXExporterDialog(bool bDisplayOnlyFPSSetting, QWidget* pParent)
  13. : QDialog(pParent)
  14. , m_ui(new Ui::FBXExporterDialog)
  15. {
  16. m_ui->setupUi(this);
  17. setFixedSize(size());
  18. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  19. m_ui->m_exportLocalCoordsCheckbox->setChecked(false);
  20. m_bDisplayOnlyFPSSetting = bDisplayOnlyFPSSetting;
  21. connect(m_ui->m_fpsCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &CFBXExporterDialog::OnFPSChange);
  22. }
  23. CFBXExporterDialog::~CFBXExporterDialog()
  24. {
  25. }
  26. float CFBXExporterDialog::GetFPS() const
  27. {
  28. return m_ui->m_fpsCombo->currentText().toFloat();
  29. }
  30. bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const
  31. {
  32. return m_ui->m_exportLocalCoordsCheckbox->isChecked();
  33. }
  34. bool CFBXExporterDialog::GetExportOnlyPrimaryCamera() const
  35. {
  36. return m_ui->m_exportOnlyPrimaryCameraCheckBox->isChecked();
  37. }
  38. void CFBXExporterDialog::SetExportLocalCoordsCheckBoxEnable(bool checked)
  39. {
  40. if (!m_bDisplayOnlyFPSSetting)
  41. {
  42. m_ui->m_exportLocalCoordsCheckbox->setEnabled(checked);
  43. }
  44. }
  45. void CFBXExporterDialog::accept()
  46. {
  47. const QString fpsStr = m_ui->m_fpsCombo->currentText();
  48. bool ok;
  49. const double fps = fpsStr.toDouble(&ok);
  50. if (fps <= 0 && !fpsStr.isEmpty() || fpsStr.isEmpty() || !ok)
  51. {
  52. QMessageBox::information(this, QString(), tr("Please enter a correct FPS value"));
  53. m_ui->m_fpsCombo->setCurrentIndex(2);
  54. return;
  55. }
  56. QDialog::accept();
  57. }
  58. void CFBXExporterDialog::OnFPSChange()
  59. {
  60. const QString fpsStr = m_ui->m_fpsCombo->currentText();
  61. if (QString::compare(fpsStr, tr("Custom"), Qt::CaseInsensitive) == 0)
  62. {
  63. m_ui->m_fpsCombo->setCurrentIndex(-1);
  64. }
  65. }
  66. int CFBXExporterDialog::exec()
  67. {
  68. if (m_bDisplayOnlyFPSSetting)
  69. {
  70. m_ui->m_exportLocalCoordsCheckbox->setEnabled(false);
  71. m_ui->m_exportOnlyPrimaryCameraCheckBox->setEnabled(false);
  72. }
  73. m_ui->m_fpsCombo->addItem("24");
  74. m_ui->m_fpsCombo->addItem("25");
  75. m_ui->m_fpsCombo->addItem("30");
  76. m_ui->m_fpsCombo->addItem("48");
  77. m_ui->m_fpsCombo->addItem("60");
  78. m_ui->m_fpsCombo->addItem(tr("Custom"));
  79. m_ui->m_fpsCombo->setCurrentIndex(2);
  80. return QDialog::exec();
  81. }
  82. #include <moc_FBXExporterDialog.cpp>