11#include <QCoreApplication>
12#include <QDomDocument>
28 if ((high == low) || step == 0)
45 while ((reverse && (value >= high)) ||
46 (!reverse && (value <= high)))
63 if (temp.contains(
"%n"))
65 text = QCoreApplication::translate(
"ThemeUI",
66 temp.toUtf8().constData(),
67 nullptr, qAbs(value));
71 text = QCoreApplication::translate(
"ThemeUI",
72 temp.toUtf8().constData());
78 text = QString::number(value);
100 if (!label.isEmpty())
112 for (
int pos = 0; pos <
m_itemList.size(); pos++)
115 if (item->
GetData().toInt() > value)
123 QVariant::fromValue(value), insertPos);
130 const QString &
filename, QDomElement &element,
bool showWarnings)
132 if (element.tagName() ==
"template")
136 if (element.attribute(
"type") ==
"negative")
138 else if (element.attribute(
"type") ==
"zero")
158 bool handled =
false;
173 bool handled =
false;
189 spinbox->CopyFrom(
this);
220 bool handled =
false;
229 QString initialEntry = item->
GetText();
230 bool doEntry =
false;
233 bool isNumber =
false;
234 (void)initialEntry.toLongLong(&isNumber,10);
238 for (
const QString&
action : std::as_const(actions))
253 if (actions.empty() && event->text() ==
"-")
288 int low,
int high,
int step)
290 m_parentList(parentList),
291 m_searchText(std::move(searchText)),
292 m_selection(parentList->GetCurrentPos()),
313 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'SpinBoxEntryDialog'");
322 infoMap[
"low"] = QString::number(
m_low);
323 infoMap[
"high"] = QString::number(
m_high);
324 infoMap[
"step"] = QString::number(
m_step);
344 for (currPos = 0; currPos < count; currPos++)
347 Qt::CaseInsensitive) == 0)
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
A widget for offering a range of numerical values where only the the bounding values and interval are...
QString m_positiveTemplate
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
MythUISpinBox(MythUIType *parent, const QString &name)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void AddSelection(int value, const QString &label="")
Add a special label for a value of the spinbox, it does not need to be in the range.
QString m_negativeTemplate
bool MoveDown(MovementUnit unit=MoveItem, uint amount=0) override
bool MoveUp(MovementUnit unit=MoveItem, uint amount=0) override
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
void ShowEntryDialog(QString initialEntry)
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
void SetTextFromMap(const InfoMap &map)
The base class on which all widgets and screens are based.
void SetEnabled(bool enable)
MythUIButtonList * m_parentList
SpinBoxEntryDialog(MythScreenStack *parent, const char *name, MythUIButtonList *parentList, QString searchText, int low, int high, int step)
bool Create(void) override
MythUIButton * m_cancelButton
MythUIButton * m_okButton
MythUITextEdit * m_entryEdit
static bool CopyWindowFromBase(const QString &windowname, MythScreenType *win)
static QString parseText(QDomElement &element)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
QHash< QString, QString > InfoMap
static constexpr const char * ACTION_0
static constexpr const char * ACTION_SELECT
static constexpr const char * ACTION_9
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)