MythTV master
mythuispinbox.h
Go to the documentation of this file.
1#ifndef MYTHUISPINBOX_H_
2#define MYTHUISPINBOX_H_
3
4#include "libmythbase/mythconfig.h"
5
6#include "mythuibuttonlist.h"
7
19{
20 Q_OBJECT
21 public:
22 MythUISpinBox(MythUIType *parent, const QString &name)
23 : MythUIButtonList(parent, name) {}
24 ~MythUISpinBox() override = default;
25
26 void SetRange(int low, int high, int step, uint pageMultiple = 5);
27
28 void SetValue(int val) override // MythUIButtonList
29 { SetValueByData(val); }
30 void SetValue(const QString &val) override // MythUIButtonList
31 { SetValueByData(val.toInt()); }
32 void AddSelection (int value, const QString &label = "");
33 QString GetValue(void) const override // MythUIButtonList
34 { return GetDataValue().toString(); }
35 int GetIntValue(void) const override // MythUIButtonList
36 { return GetDataValue().toInt(); }
37 bool keyPressEvent(QKeyEvent *event) override; // MythUIButtonList
38
39 template <typename T>
40#if HAVE_IS_DURATION_V
41 std::enable_if_t<std::chrono::__is_duration_v<T>, T>
42#else
43 std::enable_if_t<std::chrono::__is_duration<T>::value, T>
44#endif
46 { return T(GetDataValue().toInt()); }
47 template <typename T>
48#if HAVE_IS_DURATION_V
49 std::enable_if_t<std::chrono::__is_duration_v<T>, void>
50#else
51 std::enable_if_t<std::chrono::__is_duration<T>::value, void>
52#endif
54 { SetValueByData(static_cast<int>(val.count())); }
55
56 protected:
57 bool ParseElement(const QString &filename, QDomElement &element,
58 bool showWarnings) override; // MythUIButtonList
59 void CopyFrom(MythUIType *base) override; // MythUIButtonList
60 void CreateCopy(MythUIType *parent) override; // MythUIButtonList
61
62 bool MoveDown(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
63 bool MoveUp(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
64 void ShowEntryDialog(QString initialEntry);
65
66 bool m_hasTemplate {false};
70
71 uint m_moveAmount {0};
72 int m_low {0};
73 int m_high {0};
74 int m_step {0};
75};
76
77// Convenience Dialog to allow entry of a Spinbox value
78
80{
81 Q_OBJECT
82 public:
83 SpinBoxEntryDialog(MythScreenStack *parent, const char *name,
84 MythUIButtonList *parentList, QString searchText,
85 int low, int high, int step);
86 ~SpinBoxEntryDialog(void) override = default;
87
88 bool Create(void) override; // MythScreenType
89
90 protected slots:
91 void entryChanged(void);
92 void okClicked(void);
93
94 protected:
96 QString m_searchText;
97 MythUITextEdit *m_entryEdit { nullptr };
98 MythUIButton *m_cancelButton { nullptr };
99 MythUIButton *m_okButton { nullptr };
100 MythUIText *m_rulesText { nullptr };
102 bool m_okClicked { false };
103 int m_low;
106
107
108};
109
110#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:19
QString m_positiveTemplate
Definition: mythuispinbox.h:69
~MythUISpinBox() override=default
void SetValue(const QString &val) override
Definition: mythuispinbox.h:30
void SetValue(int val) override
Definition: mythuispinbox.h:28
MythUISpinBox(MythUIType *parent, const QString &name)
Definition: mythuispinbox.h:22
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDuration()
Definition: mythuispinbox.h:45
QString m_negativeTemplate
Definition: mythuispinbox.h:67
std::enable_if_t< std::chrono::__is_duration< T >::value, void > SetDuration(T val)
Definition: mythuispinbox.h:53
QString GetValue(void) const override
Definition: mythuispinbox.h:33
QString m_zeroTemplate
Definition: mythuispinbox.h:68
int GetIntValue(void) const override
Definition: mythuispinbox.h:35
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:95
~SpinBoxEntryDialog(void) override=default
unsigned int uint
Definition: compat.h:60
#define MUI_PUBLIC
Definition: mythuiexp.h:9