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 MoveDown(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
38 bool MoveUp(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
39 bool keyPressEvent(QKeyEvent *event) override; // MythUIButtonList
40
41 template <typename T>
43#if HAVE_IS_DURATION_V
44 requires (std::chrono::__is_duration_v<T>)
45#else
46 requires (std::chrono::__is_duration<T>::value)
47#endif
48 { return T(GetDataValue().toInt()); }
49
50 template <typename T>
51 void SetDuration(T val)
52#if HAVE_IS_DURATION_V
53 requires (std::chrono::__is_duration_v<T>)
54#else
55 requires (std::chrono::__is_duration<T>::value)
56#endif
57 { SetValueByData(static_cast<int>(val.count())); }
58
59 protected:
60 bool ParseElement(const QString &filename, QDomElement &element,
61 bool showWarnings) override; // MythUIButtonList
62 void CopyFrom(MythUIType *base) override; // MythUIButtonList
63 void CreateCopy(MythUIType *parent) override; // MythUIButtonList
64
65 void ShowEntryDialog(QString initialEntry);
66
67 bool m_hasTemplate {false};
71
72 uint m_moveAmount {0};
73 int m_low {0};
74 int m_high {0};
75 int m_step {0};
76};
77
78// Convenience Dialog to allow entry of a Spinbox value
79
81{
82 Q_OBJECT
83 public:
84 SpinBoxEntryDialog(MythScreenStack *parent, const char *name,
85 MythUIButtonList *parentList, QString searchText,
86 int low, int high, int step);
87 ~SpinBoxEntryDialog(void) override = default;
88
89 bool Create(void) override; // MythScreenType
90
91 protected slots:
92 void entryChanged(void);
93 void okClicked(void);
94
95 protected:
97 QString m_searchText;
98 MythUITextEdit *m_entryEdit { nullptr };
99 MythUIButton *m_cancelButton { nullptr };
100 MythUIButton *m_okButton { nullptr };
101 MythUIText *m_rulesText { nullptr };
103 bool m_okClicked { false };
104 int m_low;
107
108
109};
110
111#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:70
~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
QString m_negativeTemplate
Definition: mythuispinbox.h:68
QString GetValue(void) const override
Definition: mythuispinbox.h:33
void SetDuration(T val)
Definition: mythuispinbox.h:51
QString m_zeroTemplate
Definition: mythuispinbox.h:69
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:97
MythUIButtonList * m_parentList
Definition: mythuispinbox.h:96
~SpinBoxEntryDialog(void) override=default
unsigned int uint
Definition: compat.h:60
#define MUI_PUBLIC
Definition: mythuiexp.h:9