/xbmc/dialogs/GUIDialogNumeric.h

http://github.com/xbmc/xbmc · C Header · 82 lines · 61 code · 14 blank · 7 comment · 1 complexity · 5ff9f8fdb60af478f16d9a4a7d76ad08 MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-2018 Team Kodi
  3. * This file is part of Kodi - https://kodi.tv
  4. *
  5. * SPDX-License-Identifier: GPL-2.0-or-later
  6. * See LICENSES/README.md for more information.
  7. */
  8. #pragma once
  9. #include "XBDateTime.h"
  10. #include "guilib/GUIDialog.h"
  11. #include <cstdint>
  12. enum class InputVerificationResult
  13. {
  14. CANCELED,
  15. FAILED,
  16. SUCCESS
  17. };
  18. class CGUIDialogNumeric :
  19. public CGUIDialog
  20. {
  21. public:
  22. enum INPUT_MODE { INPUT_TIME = 1, INPUT_DATE, INPUT_IP_ADDRESS, INPUT_PASSWORD, INPUT_NUMBER, INPUT_TIME_SECONDS };
  23. CGUIDialogNumeric(void);
  24. ~CGUIDialogNumeric(void) override;
  25. bool OnMessage(CGUIMessage& message) override;
  26. bool OnAction(const CAction &action) override;
  27. bool OnBack(int actionID) override;
  28. void FrameMove() override;
  29. bool IsConfirmed() const;
  30. bool IsCanceled() const;
  31. bool IsInputHidden() const { return m_mode == INPUT_PASSWORD; };
  32. static bool ShowAndVerifyNewPassword(std::string& strNewPassword);
  33. static int ShowAndVerifyPassword(std::string& strPassword, const std::string& strHeading, int iRetries);
  34. static InputVerificationResult ShowAndVerifyInput(std::string& strPassword, const std::string& strHeading, bool bGetUserInput);
  35. void SetHeading(const std::string &strHeading);
  36. void SetMode(INPUT_MODE mode, const KODI::TIME::SystemTime& initial);
  37. void SetMode(INPUT_MODE mode, const std::string &initial);
  38. KODI::TIME::SystemTime GetOutput() const;
  39. std::string GetOutputString() const;
  40. static bool ShowAndGetTime(KODI::TIME::SystemTime& time, const std::string& heading);
  41. static bool ShowAndGetDate(KODI::TIME::SystemTime& date, const std::string& heading);
  42. static bool ShowAndGetIPAddress(std::string &IPAddress, const std::string &heading);
  43. static bool ShowAndGetNumber(std::string& strInput, const std::string &strHeading, unsigned int iAutoCloseTimeoutMs = 0, bool bSetHidden = false);
  44. static bool ShowAndGetSeconds(std::string& timeString, const std::string &heading);
  45. protected:
  46. void OnInitWindow() override;
  47. void OnDeinitWindow(int nextWindowID) override;
  48. void OnNumber(uint32_t num);
  49. void VerifyDate(bool checkYear);
  50. void OnNext();
  51. void OnPrevious();
  52. void OnBackSpace();
  53. void OnOK();
  54. void OnCancel();
  55. void HandleInputIP(uint32_t num);
  56. void HandleInputDate(uint32_t num);
  57. void HandleInputSeconds(uint32_t num);
  58. void HandleInputTime(uint32_t num);
  59. bool m_bConfirmed;
  60. bool m_bCanceled;
  61. INPUT_MODE m_mode; // the current input mode
  62. KODI::TIME::SystemTime m_datetime; // for time and date modes
  63. uint8_t m_ip[4]; // for ip address mode
  64. uint32_t m_block; // for time, date, and IP methods.
  65. uint32_t m_lastblock;
  66. bool m_dirty; // true if the current block has been changed.
  67. std::string m_number; ///< for number or password input
  68. };