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 : std::as_const(settings))
113 setting->setParent(
this);
137 for (
auto *setting : std::as_const(
m_targets[value]))
156 return subSettings && !subSettings->empty();
166 setValue(QString::number(newValue));
189 LOG(VB_GENERAL, LOG_DEBUG,
199 QList<StandardSetting *>::const_iterator i;
201 for (i = children->constBegin(); !
haveChanged && i != children->constEnd();
220 QList<StandardSetting *>::const_iterator i;
224 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
227 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
241 for (
auto i = children->constBegin(); i != children->constEnd(); ++i)
275 moveToThread(thread);
277 QList<StandardSetting *>::const_iterator i;
279 (*i)->MoveToThread(thread);
281 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
284 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
285 (*i)->MoveToThread(thread);
301 QCoreApplication::postEvent(screen, dce);
329 QString querystr =
"INSERT INTO " +
m_table +
334 if (!query.
exec(querystr))
348 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
349 auto id =
static_cast<QMetaType::Type
>(var.type());
351 auto id = var.typeId();
353 if (
id != QMetaType::UnknownType)
357 querystr =
"SELECT MAX(" +
m_column +
") FROM " +
359 if (query.
exec(querystr) && query.
next())
361 int lii = query.
value(0).toInt();
367 LOG(VB_GENERAL, LOG_EMERG,
368 "Can't determine the Id of the last insert "
369 "QSqlQuery.lastInsertId() failed, the workaround "
378 m_table(std::move(_table)), m_column(std::move(_column))
402 auto *settingdialog =
406 if (settingdialog->Create())
408 settingdialog->SetReturnEvent(screen,
"editsetting");
413 delete settingdialog;
449 if (settingdialog->Create())
451 settingdialog->SetReturnEvent(screen,
"editsetting");
456 delete settingdialog;
484 if (value >= 0 && value <
m_values.size())
499 return (index >= 0) ?
m_labels.at(index) : QString(
"");
505 value = value.isEmpty() ? label : value;
550 if (menuPopup->Create())
557 menuPopup->SetReturnEvent(screen,
"editsetting");
561 menuPopup->AddButtonV(QObject::tr(
"New entry"),
569 menuPopup->AddButtonV(
m_labels.at(i),
596 auto *settingdialog =
600 if (settingdialog->Create())
608 delete settingdialog;
620 QFileInfoList entries = dir.entryInfoList();
621 for (
const auto& fi : std::as_const(entries))
639 int step,
int pageMultiple,
640 QString special_value_text)
645 m_pageMultiple(pageMultiple),
646 m_specialValueText(std::move(special_value_text))
702 if (settingdialog->Create())
708 settingdialog->SetReturnEvent(screen,
"editsetting");
713 delete settingdialog;
767 QCoreApplication::postEvent(screen, dce);
799 LOG(VB_GENERAL, LOG_ERR,
"Theme elements missing.");
843 QString resultid = dce->
GetId();
845 if (resultid ==
"leveldown")
850 else if (resultid ==
"editsetting")
860 else if (resultid ==
"exit")
862 int buttonnum = dce->GetResult();
870 else if (buttonnum == 1)
930 QList<StandardSetting *> *settings =
935 QList<StandardSetting *>::const_iterator i;
937 for (i = settings->constBegin(); i != settings->constEnd(); ++i)
939 if ((*i)->isVisible())
941 if (selectedSetting == (*i))
976 if (ss && ss->haveSubSettings() && ss->isEnabled())
985 QString label = tr(
"Exit ?");
990 auto * menuPopup =
new MythDialogBox(label, popupStack,
"exitmenu");
992 if (menuPopup->Create())
996 menuPopup->SetReturnEvent(
this,
"exit");
998 menuPopup->AddButton(tr(
"Save then Exit"));
999 menuPopup->AddButton(tr(
"Exit without saving changes"));
1000 menuPopup->AddButton(tr(
"Cancel"));
1014 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"SELECT"));
1016 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"DELETE"));
1020 QStringList actions;
1039 for (
int i = 0; i < actions.size() && !handled; i++)
1041 const QString&
action = actions[i];
1052 else if (
action ==
"RIGHT")
1056 else if (
action ==
"EDIT")
1060 else if (
action ==
"DELETE")
1083 auto *
menu =
new MythMenu(source->getLabel(),
this,
"mainmenu");
1085 if (source->canDelete())
1091 menuPopup->SetReturnEvent(
this,
"mainmenu");
1093 if (menuPopup->Create())
1119 if (source->canDelete())
1121 QString message = tr(
"Do you want to delete the '%1' entry?")
1122 .arg(source->getLabel());
1139 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