Go to the documentation of this file.
2 #include <QApplication>
3 #include <QCoreApplication>
24 QList<StandardSetting *>::const_iterator i;
29 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
32 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
41 item->SetData(QVariant::fromValue(
this));
108 std::initializer_list<StandardSetting *> settings)
110 m_targets[value].reserve(settings.size());
111 for (
auto *setting : qAsConst(settings))
114 setting->setParent(
this);
138 for (
auto *setting : qAsConst(
m_targets[value]))
157 return subSettings && !subSettings->empty();
167 setValue(QString::number(newValue));
190 LOG(VB_GENERAL, LOG_DEBUG,
200 QList<StandardSetting *>::const_iterator i;
202 for (i = children->constBegin(); !
haveChanged && i != children->constEnd();
221 QList<StandardSetting *>::const_iterator i;
225 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
228 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
242 for (
auto i = children->constBegin(); i != children->constEnd(); ++i)
276 moveToThread(thread);
278 QList<StandardSetting *>::const_iterator i;
280 (*i)->MoveToThread(thread);
282 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
285 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
286 (*i)->MoveToThread(thread);
302 QCoreApplication::postEvent(screen, dce);
330 QString querystr =
"INSERT INTO " +
m_table +
335 if (!query.
exec(querystr))
349 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
350 auto id =
static_cast<QMetaType::Type
>(var.type());
352 auto id = var.typeId();
354 if (
id != QMetaType::UnknownType)
358 querystr =
"SELECT MAX(" +
m_column +
") FROM " +
360 if (query.
exec(querystr) && query.
next())
362 int lii = query.
value(0).toInt();
368 LOG(VB_GENERAL, LOG_EMERG,
369 "Can't determine the Id of the last insert "
370 "QSqlQuery.lastInsertId() failed, the workaround "
379 m_table(
std::move(_table)), m_column(
std::move(_column))
403 auto *settingdialog =
407 if (settingdialog->Create())
409 settingdialog->SetReturnEvent(screen,
"editsetting");
413 delete settingdialog;
448 if (settingdialog->Create())
450 settingdialog->SetReturnEvent(screen,
"editsetting");
454 delete settingdialog;
481 if (value >= 0 && value <
m_values.size())
496 return (index >= 0) ?
m_labels.at(index) : QString(
"");
502 value = value.isEmpty() ? label : value;
547 if (menuPopup->Create())
554 menuPopup->SetReturnEvent(screen,
"editsetting");
558 menuPopup->AddButtonV(QObject::tr(
"New entry"),
566 menuPopup->AddButtonV(
m_labels.at(i),
591 auto *settingdialog =
595 if (settingdialog->Create())
602 delete settingdialog;
611 QFileInfoList entries = dir.entryInfoList();
612 for (
const auto& fi : qAsConst(entries))
630 int step,
int pageMultiple,
631 QString special_value_text)
636 m_pageMultiple(pageMultiple),
637 m_specialValueText(
std::move(special_value_text))
693 if (settingdialog->Create())
699 settingdialog->SetReturnEvent(screen,
"editsetting");
703 delete settingdialog;
756 QCoreApplication::postEvent(screen, dce);
788 LOG(VB_GENERAL, LOG_ERR,
"Theme elements missing.");
832 QString resultid = dce->
GetId();
834 if (resultid ==
"leveldown")
839 else if (resultid ==
"editsetting")
849 else if (resultid ==
"exit")
851 int buttonnum = dce->GetResult();
859 else if (buttonnum == 1)
917 QList<StandardSetting *> *settings =
922 QList<StandardSetting *>::const_iterator i;
924 for (i = settings->constBegin(); i != settings->constEnd(); ++i)
926 if ((*i)->isVisible())
928 if (selectedSetting == (*i))
963 if (ss && ss->haveSubSettings() && ss->isEnabled())
972 QString label = tr(
"Exit ?");
977 auto * menuPopup =
new MythDialogBox(label, popupStack,
"exitmenu");
979 if (menuPopup->Create())
983 menuPopup->SetReturnEvent(
this,
"exit");
985 menuPopup->AddButton(tr(
"Save then Exit"));
986 menuPopup->AddButton(tr(
"Exit without saving changes"));
987 menuPopup->AddButton(tr(
"Cancel"));
997 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"SELECT"));
999 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"DELETE"));
1003 QStringList actions;
1022 for (
int i = 0; i < actions.size() && !handled; i++)
1024 QString
action = actions[i];
1035 else if (
action ==
"RIGHT")
1037 else if (
action ==
"EDIT")
1041 else if (
action ==
"DELETE")
1060 auto *
menu =
new MythMenu(source->getLabel(),
this,
"mainmenu");
1062 if (source->canDelete())
1068 menuPopup->SetReturnEvent(
this,
"mainmenu");
1070 if (menuPopup->Create())
1096 if (source->canDelete())
1098 QString message = tr(
"Do you want to delete the '%1' entry?")
1099 .arg(source->getLabel());
1116 source->getParent()->removeChild(source);
MythUISpinBoxSetting(Storage *_storage, int min, int max, int step, int pageMultiple=8, QString special_value_text=QString())
void LoadInBackground(const QString &message="")
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
void edit(MythScreenType *screen) override
virtual bool haveSubSettings()
virtual void setName(const QString &name)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
StandardSetting * m_currentGroupSetting
QString getLabel(void) const
void fillSelectionsFromDir(const QDir &dir, bool absPath=true)
virtual void setValue(const QString &newValue)
static void error(const char *str,...)
void clearTargetedSettings(const QString &value)
void helpTextChanged(const QString &newValue)
void removeTargetedChild(const QString &value, StandardSetting *child)
MythUIButtonList * m_buttonList
QVariant lastInsertId()
Return the id of the last inserted row.
QVariant value(int i) const
GroupSetting * GetGroupSettings(void) const
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void edit(MythScreenType *screen) override
virtual void clearSettings()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void addTargetedChild(const QString &value, StandardSetting *setting)
Screen in which all other widgets are contained and rendered.
MythUIText * m_selectedSettingHelp
~StandardSettingDialog() override
~MythUIComboBoxSetting() override
void Close(void) override
QVector< QString > m_labels
bool haveChanged()
Return true if the setting have changed or any of its children.
void updateSettings(StandardSetting *selectedSetting=nullptr)
QDir::Filters m_typeFilter
void setChanged(bool changed)
void settingsChanged(StandardSetting *selectedSetting=nullptr)
virtual void addChild(StandardSetting *child)
bool Create(void) override
void setCurrentGroupSetting(StandardSetting *groupSettings, StandardSetting *selectedSetting=nullptr)
virtual QList< StandardSetting * > * getSubSettings()
MythUIButtonListItem * createButton(MythUIButtonList *list)
void resultEdit(DialogCompletionEvent *dce) override
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
QString m_specialValueText
void resultEdit(DialogCompletionEvent *dce) override
virtual void resultEdit(DialogCompletionEvent *dce)=0
Basic menu dialog, message and a list of options.
virtual void Load(void)=0
static MythThemedMenu * menu
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
virtual void deleteEntry(void)
StandardSetting * getParent() const
static void DBError(const QString &where, const MSqlQuery &query)
void SetPasswordEcho(bool b)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
void BuildFocusList(void)
void resultEdit(DialogCompletionEvent *dce) override
int getValueIndex(const QString &value) const
void resultEdit(DialogCompletionEvent *dce) override
QMap< QString, QList< StandardSetting * > > m_targets
void edit(MythScreenType *screen) override
virtual void setReadOnly(bool readonly)
virtual QString getValue(void) const
void edit(MythScreenType *screen) override
void edit(MythScreenType *screen) override
virtual bool keyPressEvent(QKeyEvent *event)
void ShouldRedraw(StandardSetting *setting)
virtual void Save(void)=0
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
virtual void setLabel(QString str)
void valueChanged(const QString &newValue)
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
AutoIncrementSetting(QString _table, QString _column)
virtual void setEnabled(bool enabled)
void addSelection(const QString &label, QString value=QString(), bool select=false)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void customEvent(QEvent *event) override
virtual void applyChange()
void settingSelected(MythUIButtonListItem *item)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void MoveToThread(QThread *thread)
void resultEdit(DialogCompletionEvent *dce) override
virtual void edit(MythScreenType *screen)=0
StandardSetting * byName(const QString &name)
virtual void removeChild(StandardSetting *child)
QString getHelpText(void) const
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
virtual void SetText(const QString &text)
static const Type kEventType
MythMainWindow * GetMythMainWindow(void)
GroupSetting * m_settingsTree
MythUICheckBoxSetting(Storage *_storage=nullptr)
StandardSetting * m_parent
~StandardSetting() override
MythScreenStack * GetStack(const QString &Stackname)
void setVisible(bool visible)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Dialog prompting the user to enter a text string.
void settingClicked(MythUIButtonListItem *item)
void setParent(StandardSetting *parent)
Dialog prompting the user to enter a number using a spin box.
void addTargetedChildren(const QString &value, std::initializer_list< StandardSetting * > settings)
virtual void updateButton(MythUIButtonListItem *item)
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
QString getValueLabel(void) const
void setValue(const QString &newValue) override
void deleteEntryConfirmed(bool ok)
QList< StandardSetting * > m_children
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void edit(MythScreenType *screen) override
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
static QKeyEvent selectEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"SELECT"))
void setValue(int value) override
QVector< QString > m_values
void deleteSelected(void)
void ShowMenu(void) override
virtual int size(void) const