CustomResolutionDlg.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. // Description : A dialog for getting a resolution info from users
  9. // Notice : Refer to ViewportTitleDlg cpp for a use case
  10. #include "EditorDefs.h"
  11. #include "CustomResolutionDlg.h"
  12. // Qt
  13. #include <QTextStream>
  14. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  15. #include <ui_CustomResolutionDlg.h>
  16. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  17. #define MIN_RES 64
  18. #define MAX_RES 8192
  19. CCustomResolutionDlg::CCustomResolutionDlg(int w, int h, QWidget* pParent /*=nullptr*/)
  20. : QDialog(pParent)
  21. , m_wDefault(w)
  22. , m_hDefault(h)
  23. , m_ui(new Ui::CustomResolutionDlg)
  24. {
  25. m_ui->setupUi(this);
  26. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  27. OnInitDialog();
  28. }
  29. CCustomResolutionDlg::~CCustomResolutionDlg()
  30. {
  31. }
  32. void CCustomResolutionDlg::OnInitDialog()
  33. {
  34. m_ui->m_width->setRange(MIN_RES, MAX_RES);
  35. m_ui->m_width->setValue(m_wDefault);
  36. m_ui->m_height->setRange(MIN_RES, MAX_RES);
  37. m_ui->m_height->setValue(m_hDefault);
  38. QString maxDimensionString;
  39. QTextStream(&maxDimensionString)
  40. << "Maximum Dimension: " << MAX_RES << Qt::endl
  41. << Qt::endl
  42. << "Note: Dimensions over 8K may be" << Qt::endl
  43. << "unstable depending on hardware.";
  44. m_ui->m_maxDimension->setText(maxDimensionString);
  45. }
  46. int CCustomResolutionDlg::GetWidth() const
  47. {
  48. return m_ui->m_width->value();
  49. }
  50. int CCustomResolutionDlg::GetHeight() const
  51. {
  52. return m_ui->m_height->value();
  53. }