File: GUIDialogNumeric.h

package info (click to toggle)
kodi 2%3A20.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 143,820 kB
  • sloc: cpp: 664,925; xml: 68,398; ansic: 37,223; python: 6,903; sh: 4,209; javascript: 2,325; makefile: 1,754; perl: 969; java: 513; cs: 390; objc: 340
file content (82 lines) | stat: -rw-r--r-- 2,776 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "XBDateTime.h"
#include "guilib/GUIDialog.h"

#include <cstdint>

enum class InputVerificationResult
{
  CANCELED,
  FAILED,
  SUCCESS
};

class CGUIDialogNumeric :
      public CGUIDialog
{
public:
  enum INPUT_MODE { INPUT_TIME = 1, INPUT_DATE, INPUT_IP_ADDRESS, INPUT_PASSWORD, INPUT_NUMBER, INPUT_TIME_SECONDS };
  CGUIDialogNumeric(void);
  ~CGUIDialogNumeric(void) override;
  bool OnMessage(CGUIMessage& message) override;
  bool OnAction(const CAction &action) override;
  bool OnBack(int actionID) override;
  void FrameMove() override;

  bool IsConfirmed() const;
  bool IsCanceled() const;
  bool IsInputHidden() const { return m_mode == INPUT_PASSWORD; }

  static bool ShowAndVerifyNewPassword(std::string& strNewPassword);
  static int ShowAndVerifyPassword(std::string& strPassword, const std::string& strHeading, int iRetries);
  static InputVerificationResult ShowAndVerifyInput(std::string& strPassword, const std::string& strHeading, bool bGetUserInput);

  void SetHeading(const std::string &strHeading);
  void SetMode(INPUT_MODE mode, const CDateTime& initial);
  void SetMode(INPUT_MODE mode, const std::string &initial);
  CDateTime GetOutput() const;
  std::string GetOutputString() const;

  static bool ShowAndGetTime(CDateTime& time, const std::string& heading);
  static bool ShowAndGetDate(CDateTime& date, const std::string& heading);
  static bool ShowAndGetIPAddress(std::string &IPAddress, const std::string &heading);
  static bool ShowAndGetNumber(std::string& strInput, const std::string &strHeading, unsigned int iAutoCloseTimeoutMs = 0, bool bSetHidden = false);
  static bool ShowAndGetSeconds(std::string& timeString, const std::string &heading);

protected:
  void OnInitWindow() override;
  void OnDeinitWindow(int nextWindowID) override;

  void OnNumber(uint32_t num);
  void VerifyDate(bool checkYear);
  void OnNext();
  void OnPrevious();
  void OnBackSpace();
  void OnOK();
  void OnCancel();

  void HandleInputIP(uint32_t num);
  void HandleInputDate(uint32_t num);
  void HandleInputSeconds(uint32_t num);
  void HandleInputTime(uint32_t num);

  bool m_bConfirmed;
  bool m_bCanceled;

  INPUT_MODE m_mode;                // the current input mode
  CDateTime m_datetime; // for time and date modes
  uint8_t m_ip[4];                  // for ip address mode
  uint32_t m_block;             // for time, date, and IP methods.
  uint32_t m_lastblock;
  bool m_dirty;                     // true if the current block has been changed.
  std::string m_number;              ///< for number or password input
};