CustomResolutionDlg.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include <ui_CustomResolutionDlg.h>
  15. #define MIN_RES 64
  16. #define MAX_RES 8192
  17. CCustomResolutionDlg::CCustomResolutionDlg(int w, int h, QWidget* pParent /*=nullptr*/)
  18. : QDialog(pParent)
  19. , m_wDefault(w)
  20. , m_hDefault(h)
  21. , m_ui(new Ui::CustomResolutionDlg)
  22. {
  23. m_ui->setupUi(this);
  24. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  25. OnInitDialog();
  26. }
  27. CCustomResolutionDlg::~CCustomResolutionDlg()
  28. {
  29. }
  30. void CCustomResolutionDlg::OnInitDialog()
  31. {
  32. m_ui->m_width->setRange(MIN_RES, MAX_RES);
  33. m_ui->m_width->setValue(m_wDefault);
  34. m_ui->m_height->setRange(MIN_RES, MAX_RES);
  35. m_ui->m_height->setValue(m_hDefault);
  36. QString maxDimensionString;
  37. QTextStream(&maxDimensionString)
  38. << "Maximum Dimension: " << MAX_RES << Qt::endl
  39. << Qt::endl
  40. << "Note: Dimensions over 8K may be" << Qt::endl
  41. << "unstable depending on hardware.";
  42. m_ui->m_maxDimension->setText(maxDimensionString);
  43. }
  44. int CCustomResolutionDlg::GetWidth() const
  45. {
  46. return m_ui->m_width->value();
  47. }
  48. int CCustomResolutionDlg::GetHeight() const
  49. {
  50. return m_ui->m_height->value();
  51. }