MythTV master
mythuispinbox.h
Go to the documentation of this file.
1#ifndef MYTHUISPINBOX_H_
2#define MYTHUISPINBOX_H_
3
4#if __has_include("libmythbase/mythconfig.h")
5#include "libmythbase/mythconfig.h"
6#else
7#include "mythconfig.h"
8#endif
9
10#include "mythuibuttonlist.h"
11
23{
24 Q_OBJECT
25 public:
26 MythUISpinBox(MythUIType *parent, const QString &name)
27 : MythUIButtonList(parent, name) {}
28 ~MythUISpinBox() override = default;
29
30 void SetRange(int low, int high, int step, uint pageMultiple = 5);
31
32 void SetValue(int val) override // MythUIButtonList
33 { SetValueByData(val); }
34 void SetValue(const QString &val) override // MythUIButtonList
35 { SetValueByData(val.toInt()); }
36 void AddSelection (int value, const QString &label = "");
37 QString GetValue(void) const override // MythUIButtonList
38 { return GetDataValue().toString(); }
39 int GetIntValue(void) const override // MythUIButtonList
40 { return GetDataValue().toInt(); }
41 bool keyPressEvent(QKeyEvent *event) override; // MythUIButtonList
42
43 template <typename T>
44#if HAVE_IS_DURATION_V
45 std::enable_if_t<std::chrono::__is_duration_v<T>, T>
46#else
47 std::enable_if_t<std::chrono::__is_duration<T>::value, T>
48#endif
50 { return T(GetDataValue().toInt()); }
51 template <typename T>
52#if HAVE_IS_DURATION_V
53 std::enable_if_t<std::chrono::__is_duration_v<T>, void>
54#else
55 std::enable_if_t<std::chrono::__is_duration<T>::value, void>
56#endif
58 { SetValueByData(static_cast<int>(val.count())); }
59
60 protected:
61 bool ParseElement(const QString &filename, QDomElement &element,
62 bool showWarnings) override; // MythUIButtonList
63 void CopyFrom(MythUIType *base) override; // MythUIButtonList
64 void CreateCopy(MythUIType *parent) override; // MythUIButtonList
65
66 bool MoveDown(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
67 bool MoveUp(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
68 void ShowEntryDialog(QString initialEntry);
69
70 bool m_hasTemplate {false};
74
75 uint m_moveAmount {0};
76 int m_low {0};
77 int m_high {0};
78 int m_step {0};
79};
80
81// Convenience Dialog to allow entry of a Spinbox value
82
84{
85 Q_OBJECT
86 public:
87 SpinBoxEntryDialog(MythScreenStack *parent, const char *name,
88 MythUIButtonList *parentList, QString searchText,
89 int low, int high, int step);
90 ~SpinBoxEntryDialog(void) override = default;
91
92 bool Create(void) override; // MythScreenType
93
94 protected slots:
95 void entryChanged(void);
96 void okClicked(void);
97
98 protected:
101 MythUITextEdit *m_entryEdit { nullptr };
102 MythUIButton *m_cancelButton { nullptr };
103 MythUIButton *m_okButton { nullptr };
104 MythUIText *m_rulesText { nullptr };
106 bool m_okClicked { false };
107 int m_low;
110
111
112};
113
114#endif
Screen in which all other widgets are contained and rendered.
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
virtual bool MoveDown(MovementUnit unit=MoveItem, uint amount=0)
virtual bool MoveUp(MovementUnit unit=MoveItem, uint amount=0)
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void SetValueByData(const QVariant &data)
QVariant GetDataValue() const
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
A single button widget.
Definition: mythuibutton.h:22
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:23
QString m_positiveTemplate
Definition: mythuispinbox.h:73
~MythUISpinBox() override=default
void SetValue(const QString &val) override
Definition: mythuispinbox.h:34
void SetValue(int val) override
Definition: mythuispinbox.h:32
MythUISpinBox(MythUIType *parent, const QString &name)
Definition: mythuispinbox.h:26
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDuration()
Definition: mythuispinbox.h:49
QString m_negativeTemplate
Definition: mythuispinbox.h:71
std::enable_if_t< std::chrono::__is_duration< T >::value, void > SetDuration(T val)
Definition: mythuispinbox.h:57
QString GetValue(void) const override
Definition: mythuispinbox.h:37
QString m_zeroTemplate
Definition: mythuispinbox.h:72
int GetIntValue(void) const override
Definition: mythuispinbox.h:39
A text entry and edit widget.
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
MythUIButtonList * m_parentList
Definition: mythuispinbox.h:99
~SpinBoxEntryDialog(void) override=default
unsigned int uint
Definition: freesurround.h:24
#define MUI_PUBLIC
Definition: mythuiexp.h:9