CheckOutDialog.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #pragma once
  9. //////////////////////////////////////////////////////////////////////////
  10. // CCheckOutDialog dialog
  11. #if !defined(Q_MOC_RUN)
  12. #include <QDialog>
  13. #endif
  14. namespace Ui
  15. {
  16. class CheckOutDialog;
  17. }
  18. class CCheckOutDialog
  19. : public QDialog
  20. {
  21. Q_OBJECT
  22. public:
  23. // Checkout dialog result.
  24. enum EResult
  25. {
  26. CHECKOUT = QDialog::Accepted,
  27. OVERWRITE,
  28. CANCEL = QDialog::Rejected
  29. };
  30. CCheckOutDialog(const QString& file, QWidget* pParent = nullptr); // standard constructor
  31. virtual ~CCheckOutDialog();
  32. // Dialog Data
  33. void OnInitDialog();
  34. // Enable functionality For All. In the end call with false to return it in init state.
  35. // Returns previous enable state
  36. static bool EnableForAll(bool isEnable);
  37. static bool IsForAll() { return InstanceIsForAll(); }
  38. static int LastResult() { return m_lastResult; }
  39. protected:
  40. void OnBnClickedCancel();
  41. void OnBnClickedCheckout();
  42. void OnBnClickedOverwrite();
  43. private:
  44. static bool& InstanceEnableForAll();
  45. static bool& InstanceIsForAll();
  46. void HandleResult(int result);
  47. QString m_file;
  48. QScopedPointer<Ui::CheckOutDialog> m_ui;
  49. static int m_lastResult;
  50. };
  51. //////////////////////////////////////////////////////////////////////////
  52. class CAutoCheckOutDialogEnableForAll
  53. {
  54. public:
  55. CAutoCheckOutDialogEnableForAll()
  56. {
  57. m_bPrevState = CCheckOutDialog::EnableForAll(true);
  58. }
  59. ~CAutoCheckOutDialogEnableForAll()
  60. {
  61. CCheckOutDialog::EnableForAll(m_bPrevState);
  62. }
  63. private:
  64. bool m_bPrevState;
  65. };