Go to the documentation of this file.
2 #include <QApplication>
3 #include <QCoreApplication>
23 QList<StandardSetting *>::const_iterator i;
28 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
31 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
40 item->SetData(QVariant::fromValue(
this));
107 std::initializer_list<StandardSetting *> settings)
109 m_targets[value].reserve(settings.size());
110 for (
auto *setting : qAsConst(settings))
113 setting->setParent(
this);
137 for (
auto *setting : qAsConst(
m_targets[value]))
156 return subSettings && !subSettings->empty();
166 setValue(QString::number(newValue));
189 LOG(VB_GENERAL, LOG_DEBUG,
190 QString(
"Setting '%1' changed to %2").arg(
getLabel())
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))
353 querystr =
"SELECT MAX(" +
m_column +
") FROM " +
355 if (query.
exec(querystr) && query.
next())
357 int lii = query.
value(0).toInt();
363 LOG(VB_GENERAL, LOG_EMERG,
364 "Can't determine the Id of the last insert "
365 "QSqlQuery.lastInsertId() failed, the workaround "
374 m_table(
std::move(_table)), m_column(
std::move(_column))
398 auto *settingdialog =
402 if (settingdialog->Create())
404 settingdialog->SetReturnEvent(screen,
"editsetting");
408 delete settingdialog;
443 if (settingdialog->Create())
445 settingdialog->SetReturnEvent(screen,
"editsetting");
449 delete settingdialog;
476 if (value >= 0 && value <
m_values.size())
491 return (index >= 0) ?
m_labels.at(index) : QString(
"");
497 value = value.isEmpty() ? label : value;
542 if (menuPopup->Create())
549 menuPopup->SetReturnEvent(screen,
"editsetting");
553 menuPopup->AddButtonV(QObject::tr(
"New entry"),
561 menuPopup->AddButtonV(
m_labels.at(i),
586 auto *settingdialog =
590 if (settingdialog->Create())
597 delete settingdialog;
606 QFileInfoList entries = dir.entryInfoList();
607 for (
const auto& fi : qAsConst(entries))
625 int step,
int pageMultiple,
626 QString special_value_text)
631 m_pageMultiple(pageMultiple),
632 m_specialValueText(
std::move(special_value_text))
688 if (settingdialog->Create())
694 settingdialog->SetReturnEvent(screen,
"editsetting");
698 delete settingdialog;
751 QCoreApplication::postEvent(screen, dce);
783 LOG(VB_GENERAL, LOG_ERR,
"Theme elements missing.");
827 QString resultid = dce->
GetId();
829 if (resultid ==
"leveldown")
834 else if (resultid ==
"editsetting")
844 else if (resultid ==
"exit")
846 int buttonnum = dce->GetResult();
854 else if (buttonnum == 1)
912 QList<StandardSetting *> *settings =
917 QList<StandardSetting *>::const_iterator i;
919 for (i = settings->constBegin(); i != settings->constEnd(); ++i)
921 if ((*i)->isVisible())
923 if (selectedSetting == (*i))
958 if (ss && ss->haveSubSettings() && ss->isEnabled())
967 QString label = tr(
"Exit ?");
972 auto * menuPopup =
new MythDialogBox(label, popupStack,
"exitmenu");
974 if (menuPopup->Create())
978 menuPopup->SetReturnEvent(
this,
"exit");
980 menuPopup->AddButton(tr(
"Save then Exit"));
981 menuPopup->AddButton(tr(
"Exit without saving changes"));
982 menuPopup->AddButton(tr(
"Cancel"));
992 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"SELECT"));
994 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"DELETE"));
1017 for (
int i = 0; i < actions.size() && !handled; i++)
1019 QString
action = actions[i];
1030 else if (
action ==
"RIGHT")
1032 else if (
action ==
"EDIT")
1036 else if (
action ==
"DELETE")
1055 auto *
menu =
new MythMenu(source->getLabel(),
this,
"mainmenu");
1057 if (source->canDelete())
1063 menuPopup->SetReturnEvent(
this,
"mainmenu");
1065 if (menuPopup->Create())
1091 if (source->canDelete())
1093 QString message = tr(
"Do you want to delete the '%1' entry?")
1094 .arg(source->getLabel());
1111 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
static MythThemedMenu * menu
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 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)
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