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