MythTV master
standardsettings.cpp
Go to the documentation of this file.
1#include "standardsettings.h"
2#include <QApplication>
3#include <QCoreApplication>
4#include <QThread>
5#include <utility>
6
15
17{
18 setting->updateButton(this);
19}
20
22{
23 QList<StandardSetting *>::const_iterator i;
24 for (i = m_children.constBegin(); i != m_children.constEnd(); ++i)
25 delete *i;
26 m_children.clear();
27
28 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
29 for (iMap = m_targets.constBegin(); iMap != m_targets.constEnd(); ++iMap)
30 {
31 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
32 delete *i;
33 }
34 m_targets.clear();
35}
36
38{
39 auto *item = new MythUIButtonListItemSetting(list, m_label);
40 item->SetData(QVariant::fromValue(this));
41 connect(this, &StandardSetting::ShouldRedraw,
43 updateButton(item);
44 return item;
45}
46
48{
49 m_enabled = enabled;
50 emit ShouldRedraw(this);
51}
52
54{
55 m_readonly = readonly;
56 emit ShouldRedraw(this);
57}
58
60{
61 m_visible = visible;
62 emit settingsChanged(this);
63}
64
66{
67 m_parent = parent;
68}
69
71{
72 if (!child)
73 return;
74
75 m_children.append(child);
76 child->setParent(this);
77}
78
80{
81 m_children.removeAll(child);
82 emit settingsChanged(this);
83}
84
85bool StandardSetting::keyPressEvent(QKeyEvent * /*e*/)
86{
87 return false;
88}
89
96{
97 item->setVisible(m_visible);
98 item->DisplayState("standard", "widgettype");
99 item->setEnabled(isEnabled());
100 item->SetText(m_label);
101 item->SetText(m_settingValue, "value");
102 item->SetText(getHelpText(), "description");
104}
105
106void StandardSetting::addTargetedChildren(const QString &value,
107 std::initializer_list<StandardSetting *> settings)
108{
109 m_targets[value].reserve(settings.size());
110 for (auto *setting : std::as_const(settings))
111 {
112 m_targets[value].append(setting);
113 setting->setParent(this);
114 }
115}
116void StandardSetting::addTargetedChild(const QString &value,
117 StandardSetting * setting)
118{
119 m_targets[value].append(setting);
120 setting->setParent(this);
121}
122
123void StandardSetting::removeTargetedChild(const QString &value,
124 StandardSetting *child)
125{
126 if (m_targets.contains(value))
127 {
128 m_targets[value].removeAll(child);
129 delete child;
130 }
131}
132
134{
135 if (m_targets.contains(value))
136 {
137 for (auto *setting : std::as_const(m_targets[value]))
138 {
139 delete setting;
140 }
141 m_targets[value].clear();
142 }
143}
144
145QList<StandardSetting *> *StandardSetting::getSubSettings()
146{
147 if (m_targets.contains(m_settingValue) &&
148 !m_targets[m_settingValue].empty())
149 return &m_targets[m_settingValue];
150 return &m_children;
151}
152
154{
155 QList<StandardSetting *> *subSettings = getSubSettings();
156 return subSettings && !subSettings->empty();
157}
158
160{
161 m_children.clear();
162}
163
165{
166 setValue(QString::number(newValue));
167}
168
169void StandardSetting::setValue(const QString &newValue)
170{
171 if (m_settingValue != newValue)
172 {
173 m_settingValue = newValue;
174 m_haveChanged = true;
175
176 emit valueChanged(newValue);
177 emit valueChanged(this);
178 }
179 emit ShouldRedraw(this);
180}
181
186{
187 if (m_haveChanged)
188 {
189 LOG(VB_GENERAL, LOG_DEBUG,
190 QString("Setting '%1' changed to %2").arg(getLabel(), getValue()));
191 return true;
192 }
193
194 //we check only the relevant children
195 QList<StandardSetting *> *children = getSubSettings();
196 if (!children)
197 return false;
198
199 QList<StandardSetting *>::const_iterator i;
200 bool haveChanged = false;
201 for (i = children->constBegin(); !haveChanged && i != children->constEnd();
202 ++i)
203 haveChanged = (*i)->haveChanged();
204
205 return haveChanged;
206}
207
209{
210 m_haveChanged = changed;
211}
212
214{
215 if (m_storage)
216 m_storage->Load();
217
218 m_haveChanged = false;
219
220 QList<StandardSetting *>::const_iterator i;
221 for (i = m_children.constBegin(); i != m_children.constEnd(); ++i)
222 (*i)->Load();
223
224 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
225 for (iMap = m_targets.constBegin(); iMap != m_targets.constEnd(); ++iMap)
226 {
227 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
228 (*i)->Load();
229 }
230}
231
233{
234 if (m_storage)
235 m_storage->Save();
236
237 //we save only the relevant children
238 QList<StandardSetting *> *children = getSubSettings();
239 if (children)
240 {
241 for (auto i = children->constBegin(); i != children->constEnd(); ++i)
242 (*i)->Save();
243 }
244
245 if (!m_haveChanged)
246 return;
247
248 m_haveChanged = false;
249 emit ChangeSaved();
250}
251
252void StandardSetting::setName(const QString &name)
253{
254 m_name = name;
255 if (m_label.isEmpty())
256 setLabel(name);
257}
258
260{
261 if (name == m_name)
262 return this;
263
264 for (auto *setting : std::as_const(*getSubSettings()))
265 {
266 StandardSetting *s = setting->byName(name);
267 if (s)
268 return s;
269 }
270 return nullptr;
271}
272
273void StandardSetting::MoveToThread(QThread *thread)
274{
275 moveToThread(thread);
276
277 QList<StandardSetting *>::const_iterator i;
278 for (i = m_children.constBegin(); i != m_children.constEnd(); ++i)
279 (*i)->MoveToThread(thread);
280
281 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
282 for (iMap = m_targets.constBegin(); iMap != m_targets.constEnd(); ++iMap)
283 {
284 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
285 (*i)->MoveToThread(thread);
286 }
287}
288
289/******************************************************************************
290 Group Setting
291*******************************************************************************/
293{
294 if (!isEnabled())
295 return;
296
297 if (isReadOnly())
298 return;
299
300 auto *dce = new DialogCompletionEvent("leveldown", 0, "", "");
301 QCoreApplication::postEvent(screen, dce);
302}
303
305{
306 item->DisplayState("group", "widgettype");
307 item->setEnabled(isEnabled());
308 item->SetText(m_label);
309 item->SetText(m_settingValue, "value");
310 item->SetText(getHelpText(), "description");
312}
313
315{
316 setLabel(label);
317}
318
320{
321 emit clicked();
322}
323
325{
326 if (getValue() == "0")
327 {
328 // Generate a new, unique ID
329 QString querystr = "INSERT INTO " + m_table +
330 " (" + m_column + ") VALUES (0);";
331
333
334 if (!query.exec(querystr))
335 {
336 MythDB::DBError("inserting row", query);
337 return;
338 }
339 // XXX -- HACK BEGIN:
340 // lastInsertID fails with "QSqlQuery::value: not positioned on a valid
341 // record" if we get a invalid QVariant we workaround the problem by
342 // taking advantage of mysql always incrementing the auto increment
343 // pointer this breaks if someone modifies the auto increment pointer
344 //setValue(query.lastInsertId().toInt());
345
346 QVariant var = query.lastInsertId();
347
348#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
349 auto id = static_cast<QMetaType::Type>(var.type());
350#else
351 auto id = var.typeId();
352#endif
353 if (id != QMetaType::UnknownType)
354 {
355 setValue(var.toInt());
356 }
357 else
358 {
359 querystr = "SELECT MAX(" + m_column + ") FROM " +
360 m_table + ";";
361 if (query.exec(querystr) && query.next())
362 {
363 int lii = query.value(0).toInt();
364 lii = lii ? lii : 1;
365 setValue(lii);
366 }
367 else
368 {
369 LOG(VB_GENERAL, LOG_EMERG,
370 "Can't determine the Id of the last insert "
371 "QSqlQuery.lastInsertId() failed, the workaround "
372 "failed too!");
373 }
374 }
375 // XXX -- HACK END:
376 }
377}
378
379AutoIncrementSetting::AutoIncrementSetting(QString _table, QString _column) :
380 m_table(std::move(_table)), m_column(std::move(_column))
381{
382 setValue("0");
383}
384
385/******************************************************************************
386 Text Setting
387*******************************************************************************/
388
390{
391 m_passwordEcho = b;
392}
393
395{
396 if (!isEnabled())
397 return;
398
399 if (isReadOnly())
400 return;
401
402 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
403
404 auto *settingdialog =
405 new MythTextInputDialog(popupStack, getLabel(), FilterNone,
407
408 if (settingdialog->Create())
409 {
410 settingdialog->SetReturnEvent(screen, "editsetting");
411 popupStack->AddScreen(settingdialog);
412 }
413 else
414 {
415 delete settingdialog;
416 }
417}
418
420{
421 if (m_settingValue != dce->GetResultText())
422 setValue(dce->GetResultText());
423}
424
425
427{
429 item->DisplayState("textedit", "widgettype");
430}
431
432
433/******************************************************************************
434 Directory Setting
435*******************************************************************************/
436
438{
439 if (!isEnabled())
440 return;
441
442 if (isReadOnly())
443 return;
444
445 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
446
447 auto *settingdialog = new MythUIFileBrowser(popupStack, m_settingValue);
448 settingdialog->SetTypeFilter(m_typeFilter);
449 settingdialog->SetNameFilter(m_nameFilter);
450
451 if (settingdialog->Create())
452 {
453 settingdialog->SetReturnEvent(screen, "editsetting");
454 popupStack->AddScreen(settingdialog);
455 }
456 else
457 {
458 delete settingdialog;
459 }
460}
461
463{
464 if (m_settingValue != dce->GetResultText())
465 setValue(dce->GetResultText());
466}
467
469{
471 item->DisplayState("filebrowser", "widgettype");
472}
473
474
475/******************************************************************************
476 ComboBoxSetting
477*******************************************************************************/
479{
480 m_labels.clear();
481 m_values.clear();
482}
483
485{
486 if (value >= 0 && value < m_values.size())
487 {
489 m_isSet = true;
490 }
491}
492
493int MythUIComboBoxSetting::getValueIndex(const QString &value) const
494{
495 return m_values.indexOf(value);
496}
497
499{
500 int index = getValueIndex(getValue());
501 return (index >= 0) ? m_labels.at(index) : QString("");
502}
503
504void MythUIComboBoxSetting::addSelection(const QString &label, QString value,
505 bool select)
506{
507 value = value.isEmpty() ? label : value;
508 m_labels.push_back(label);
509 m_values.push_back(value);
510
511 if (select || !m_isSet)
512 {
514 if (!m_isSet)
515 m_isSet = true;
516 }
517}
518
520{
521 m_isSet = false;
522 m_labels.clear();
523 m_values.clear();
524}
525
527{
528 item->DisplayState("combobox", "widgettype");
529 item->setEnabled(isEnabled());
530 item->SetText(m_label);
531 int indexValue = m_values.indexOf(m_settingValue);
532 if (indexValue >= 0)
533 item->SetText(m_labels.value(indexValue), "value");
534 else
535 item->SetText(m_settingValue, "value");
536 item->SetText(getHelpText(), "description");
538}
539
541{
542 if (!isEnabled())
543 return;
544
545 if (isReadOnly())
546 return;
547
548 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
549
550 auto *menuPopup = new MythDialogBox(getLabel(), popupStack, "optionmenu");
551
552 if (menuPopup->Create())
553 {
554 popupStack->AddScreen(menuPopup);
555
556 //connect(menuPopup, &MythDialogBox::haveResult,
557 //this, qOverload<const QString&>(&MythUIComboBoxSetting::setValue));
558
559 menuPopup->SetReturnEvent(screen, "editsetting");
560
561 if (m_rewrite)
562 {
563 menuPopup->AddButtonV(QObject::tr("New entry"),
564 QString("NEWENTRY"),
565 false,
566 m_settingValue == "");
567 }
568 for (int i = 0; i < m_labels.size() && !m_values.empty(); ++i)
569 {
570 QString value = m_values.at(i);
571 menuPopup->AddButtonV(m_labels.at(i),
572 value,
573 false,
574 value == m_settingValue);
575 }
576 }
577 else
578 {
579 delete menuPopup;
580 }
581}
582
583void MythUIComboBoxSetting::setValue(const QString& newValue)
584{
586 m_isSet = true;
587}
588
590{
591 if (dce->GetResult() != -1)
592 {
593 if (m_rewrite && dce->GetData().toString() == "NEWENTRY")
594 {
595 MythScreenStack *popupStack =
596 GetMythMainWindow()->GetStack("popup stack");
597
598 auto *settingdialog =
599 new MythTextInputDialog(popupStack, getLabel(), FilterNone,
600 false, m_settingValue);
601
602 if (settingdialog->Create())
603 {
604 connect(settingdialog, &MythTextInputDialog::haveResult,
605 this, qOverload<const QString&>(&MythUIComboBoxSetting::setValue));
606 popupStack->AddScreen(settingdialog);
607 }
608 else
609 {
610 delete settingdialog;
611 }
612 }
613 else if (m_settingValue != dce->GetData().toString())
614 {
615 StandardSetting::setValue(dce->GetData().toString());
616 }
617 }
618}
619
620void MythUIComboBoxSetting::fillSelectionsFromDir(const QDir &dir, bool absPath)
621{
622 QFileInfoList entries = dir.entryInfoList();
623 for (const auto& fi : std::as_const(entries))
624 {
625 if (absPath)
626 addSelection( fi.absoluteFilePath() );
627 else
628 addSelection( fi.fileName() );
629 }
630}
631
633{
634 return m_labels.size();
635}
636
637/******************************************************************************
638 SpinBox Setting
639*******************************************************************************/
641 int step, int pageMultiple,
642 QString special_value_text)
643 : StandardSetting(_storage),
644 m_min(min),
645 m_max(max),
646 m_step(step),
647 m_pageMultiple(pageMultiple),
648 m_specialValueText(std::move(special_value_text))
649{
650 // We default to 0 unless 0 is out of range.
651 if (m_min > 0 || m_max < 0)
652 m_settingValue = QString::number(m_min);
653
654 // The settings pages were coded to assume a parameter true/false
655 // meaning allow_single_step. Many pages use this but it was not
656 // implemented. It is difficult to implement using the current
657 // UI widget design. So I have changed it so you can specify
658 // the size of pageup / pagedown increments as an integer instead.
659 // For compatibility with callers still using true to indicate
660 // allowing single step, the code will set the step size as 1 and
661 // the pageup / pagedown as the requested step.
662
663 if (m_pageMultiple == 1)
664 {
665 m_pageMultiple = step;
666 m_step = 1;
667 }
668 if (m_pageMultiple == 0)
669 {
670 m_pageMultiple = 5;
671 }
672}
673
675{
676 item->DisplayState("spinbox", "widgettype");
677 item->setEnabled(isEnabled());
678 item->SetText(m_label);
679 if (m_settingValue.toInt() == m_min && !m_specialValueText.isEmpty())
680 item->SetText(m_specialValueText, "value");
681 else
682 item->SetText(m_settingValue, "value");
683 item->SetText(getHelpText(), "description");
685}
686
688{
689 return m_settingValue.toInt();
690}
691
693{
694 if (!isEnabled())
695 return;
696
697 if (isReadOnly())
698 return;
699
700 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
701
702 auto *settingdialog = new MythSpinBoxDialog(popupStack, getLabel());
703
704 if (settingdialog->Create())
705 {
706 settingdialog->SetRange(m_min, m_max, m_step, m_pageMultiple);
707 if (!m_specialValueText.isEmpty())
708 settingdialog->AddSelection(m_specialValueText, m_min);
709 settingdialog->SetValue(m_settingValue);
710 settingdialog->SetReturnEvent(screen, "editsetting");
711 popupStack->AddScreen(settingdialog);
712 }
713 else
714 {
715 delete settingdialog;
716 }
717}
718
720{
721 if (m_settingValue != dce->GetResultText())
722 setValue(dce->GetResultText());
723}
724
725/******************************************************************************
726 MythUICheckBoxSetting
727*******************************************************************************/
728
730 StandardSetting(_storage)
731{
732}
733
734void MythUICheckBoxSetting::setValue(const QString &value)
735{
737 if (haveChanged())
738 emit valueChanged(value == "1");
739}
740
742{
743 StandardSetting::setValue(value ? "1" : "0");
744 if (haveChanged())
745 emit valueChanged(value);
746}
747
749{
751 item->DisplayState("checkbox", "widgettype");
752 item->setCheckable(true);
753 item->SetText("", "value");
754 if (m_settingValue == "1")
756 else
758}
759
761{
762 if (!isEnabled())
763 return;
764
765 if (isReadOnly())
766 return;
767
768 auto *dce = new DialogCompletionEvent("editsetting", 0, "", "");
769 QCoreApplication::postEvent(screen, dce);
770}
771
773{
775}
776
777/******************************************************************************
778 Standard setting dialog
779*******************************************************************************/
780
782{
783 if (m_settingsTree)
784 m_settingsTree->deleteLater();
785}
786
788{
789 if (!LoadWindowFromXML("standardsetting-ui.xml", "settingssetup", this))
790 return false;
791
792 bool error = false;
793 UIUtilE::Assign(this, m_title, "title", &error);
794 UIUtilW::Assign(this, m_groupHelp, "grouphelp", &error);
795 UIUtilE::Assign(this, m_buttonList, "settingslist", &error);
796
797 UIUtilW::Assign(this, m_selectedSettingHelp, "selectedsettinghelp");
798
799 if (error)
800 {
801 LOG(VB_GENERAL, LOG_ERR, "Theme elements missing.");
802 return false;
803 }
804
809
811
813
814 return true;
815}
816
818{
819 if (!item)
820 return;
821
822 auto *setting = item->GetData().value<StandardSetting*>();
823 if (setting && m_selectedSettingHelp)
824 {
825 disconnect(m_selectedSettingHelp);
826 m_selectedSettingHelp->SetText(setting->getHelpText());
828 }
829}
830
832{
833 auto* setting = item->GetData().value<StandardSetting*>();
834 if (setting)
835 setting->edit(this);
836}
837
839{
840 if (event->type() == DialogCompletionEvent::kEventType)
841 {
842 auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
843 if (dce == nullptr)
844 return;
845 QString resultid = dce->GetId();
846
847 if (resultid == "leveldown")
848 {
849 //a GroupSetting have been clicked
850 LevelDown();
851 }
852 else if (resultid == "editsetting")
853 {
855 if (item)
856 {
857 auto *ss = item->GetData().value<StandardSetting*>();
858 if (ss)
859 ss->resultEdit(dce);
860 }
861 }
862 else if (resultid == "exit")
863 {
864 int buttonnum = dce->GetResult();
865 if (buttonnum == 0)
866 {
867 Save();
869 if (m_settingsTree)
871 }
872 else if (buttonnum == 1)
873 {
875 }
876 }
877 }
878}
879
881{
882 if (m_settingsTree)
883 {
885 m_settingsTree->MoveToThread(QApplication::instance()->thread());
886 }
887}
888
890{
892}
893
895{
896 return m_settingsTree;
897}
898
900 StandardSetting *groupSettings, StandardSetting *selectedSetting)
901{
902 if (!groupSettings)
903 return;
904
906 {
907 disconnect(m_currentGroupSetting,
908 &StandardSetting::settingsChanged, nullptr, nullptr);
910 }
911
912 m_currentGroupSetting = groupSettings;
914
916 if (m_groupHelp)
917 {
919 }
920 updateSettings(selectedSetting);
921 connect(m_currentGroupSetting,
924}
925
927{
930 return;
931
932 QList<StandardSetting *> *settings =
934 if (!settings)
935 return;
936
937 QList<StandardSetting *>::const_iterator i;
938 MythUIButtonListItem *selectedItem = nullptr;
939 for (i = settings->constBegin(); i != settings->constEnd(); ++i)
940 {
941 if ((*i)->isVisible())
942 {
943 if (selectedSetting == (*i))
944 selectedItem = (*i)->createButton(m_buttonList);
945 else
946 (*i)->createButton(m_buttonList);
947 }
948 }
949 if (selectedItem)
950 m_buttonList->SetItemCurrent(selectedItem);
952}
953
955{
956 if (m_settingsTree)
958}
959
961{
963 return;
964
966 {
969 }
970}
971
973{
975 if (item)
976 {
977 auto *ss = item->GetData().value<StandardSetting*>();
978 if (ss && ss->haveSubSettings() && ss->isEnabled())
980 }
981}
982
984{
986 {
987 QString label = tr("Exit ?");
988
989 MythScreenStack *popupStack =
990 GetMythMainWindow()->GetStack("popup stack");
991
992 auto * menuPopup = new MythDialogBox(label, popupStack, "exitmenu");
993
994 if (menuPopup->Create())
995 {
996 popupStack->AddScreen(menuPopup);
997
998 menuPopup->SetReturnEvent(this, "exit");
999
1000 menuPopup->AddButton(tr("Save then Exit"));
1001 menuPopup->AddButton(tr("Exit without saving changes"));
1002 menuPopup->AddButton(tr("Cancel"));
1003 }
1004 else
1005 {
1006 delete menuPopup;
1007 }
1008 }
1009 else
1010 {
1012 }
1013}
1014
1015static QKeyEvent selectEvent
1016 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,"SELECT"));
1017static QKeyEvent deleteEvent
1018 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,"DELETE"));
1019
1021{
1022 QStringList actions;
1023
1024 bool handled = m_buttonList->keyPressEvent(e);
1025 if (handled)
1026 return true;
1027
1028 handled = GetMythMainWindow()->TranslateKeyPress("Global", e, actions);
1029
1030 //send the key to the selected Item first
1032 if (item)
1033 {
1034 auto *ss = item->GetData().value<StandardSetting*>();
1035 if (ss)
1036 handled = ss->keyPressEvent(e);
1037 }
1038 if (handled)
1039 return true;
1040
1041 for (int i = 0; i < actions.size() && !handled; i++)
1042 {
1043 const QString& action = actions[i];
1044 handled = true;
1045
1046 if (action == "LEFT")
1047 {
1050 Close();
1051 else
1052 LevelUp();
1053 }
1054 else if (action == "RIGHT")
1055 {
1056 LevelDown();
1057 }
1058 else if (action == "EDIT")
1059 {
1061 }
1062 else if (action == "DELETE")
1063 {
1064 deleteEntry();
1065 }
1066 else
1067 {
1068 handled = MythScreenType::keyPressEvent(e);
1069 }
1070 }
1071
1072 return handled;
1073}
1074
1076{
1078 if (!item)
1079 return;
1080
1081 auto *source = item->GetData().value<GroupSetting*>();
1082 if (!source)
1083 return;
1084 // m_title->GetText() for screen title
1085 auto *menu = new MythMenu(source->getLabel(), this, "mainmenu");
1086 menu->AddItem(tr("Edit"), &StandardSettingDialog::editEntry);
1087 if (source->canDelete())
1088 menu->AddItem(tr("Delete"), &StandardSettingDialog::deleteSelected);
1089
1090 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1091
1092 auto *menuPopup = new MythDialogBox(menu, popupStack, "menudialog");
1093 menuPopup->SetReturnEvent(this, "mainmenu");
1094
1095 if (menuPopup->Create())
1096 popupStack->AddScreen(menuPopup);
1097 else
1098 delete menuPopup;
1099}
1100
1102{
1104}
1105
1107{
1109}
1110
1112{
1114 if (!item)
1115 return;
1116
1117 auto *source = item->GetData().value<GroupSetting*>();
1118 if (!source)
1119 return;
1120
1121 if (source->canDelete())
1122 {
1123 QString message = tr("Do you want to delete the '%1' entry?")
1124 .arg(source->getLabel());
1126 }
1127}
1128
1130{
1131 if (ok)
1132 {
1134 if (!item)
1135 return;
1136 auto *source = item->GetData().value<GroupSetting*>();
1137 if (!source)
1138 return;
1139 source->deleteEntry();
1140// m_settingsTree->removeChild(source);
1141 source->getParent()->removeChild(source);
1142 m_buttonList->RemoveItem(item);
1143 }
1144
1145}
AutoIncrementSetting(QString _table, QString _column)
void Save(void) override
void edit(MythScreenType *screen) override
ButtonStandardSetting(const QString &label)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:40
static const Type kEventType
Definition: mythdialogbox.h:55
virtual void applyChange()
virtual void deleteEntry(void)
void edit(MythScreenType *screen) override
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:128
QVariant value(int i) const
Definition: mythdbcon.h:204
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:619
QVariant lastInsertId()
Return the id of the last inserted row.
Definition: mythdbcon.cpp:936
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:813
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:551
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:225
Basic menu dialog, message and a list of options.
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 LoadInBackground(const QString &message="")
void BuildFocusList(void)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
virtual void Close()
Dialog prompting the user to enter a number using a spin box.
Dialog prompting the user to enter a text string.
void haveResult(QString)
void ShouldUpdate(StandardSetting *setting)
void setVisible(bool flag)
void setEnabled(bool flag)
void setCheckable(bool flag)
void DisplayState(const QString &state, const QString &name)
void setDrawArrow(bool flag)
void setChecked(CheckState state)
void SetText(const QString &text, const QString &name="", const QString &state="")
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
MythUIButtonListItem * GetItemCurrent() const
void SetItemCurrent(MythUIButtonListItem *item)
void RemoveItem(MythUIButtonListItem *item)
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void itemClicked(MythUIButtonListItem *item)
void itemSelected(MythUIButtonListItem *item)
void setValue(const QString &newValue) override
void resultEdit(DialogCompletionEvent *dce) override
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
MythUICheckBoxSetting(Storage *_storage=nullptr)
void edit(MythScreenType *screen) override
virtual int size(void) const
QVector< QString > m_labels
virtual void addSelection(const QString &label, QString value=QString(), bool select=false)
QString getValueLabel(void) const
void edit(MythScreenType *screen) override
virtual void fillSelectionsFromDir(const QDir &dir, bool absPath=true)
QVector< QString > m_values
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 setValue(int value) override
int getValueIndex(const QString &value) const
void resultEdit(DialogCompletionEvent *dce) override
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 edit(MythScreenType *screen) override
void resultEdit(DialogCompletionEvent *dce) override
void edit(MythScreenType *screen) override
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 resultEdit(DialogCompletionEvent *dce) override
MythUISpinBoxSetting(Storage *_storage, int min, int max, int step, int pageMultiple=8, QString special_value_text=QString())
void resultEdit(DialogCompletionEvent *dce) override
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 edit(MythScreenType *screen) override
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
StandardSetting * m_currentGroupSetting
bool Create(void) override
void settingClicked(MythUIButtonListItem *item)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void deleteEntryConfirmed(bool ok)
void settingSelected(MythUIButtonListItem *item)
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
void Close(void) override
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void updateSettings(StandardSetting *selectedSetting=nullptr)
MythUIButtonList * m_buttonList
void customEvent(QEvent *event) override
GroupSetting * m_settingsTree
MythUIText * m_selectedSettingHelp
void setCurrentGroupSetting(StandardSetting *groupSettings, StandardSetting *selectedSetting=nullptr)
GroupSetting * GetGroupSettings(void) const
void ShowMenu(void) override
virtual void addChild(StandardSetting *child)
virtual void Save(void)
StandardSetting * m_parent
void helpTextChanged(const QString &newValue)
QString getHelpText(void) const
virtual void Load(void)
virtual void setName(const QString &name)
void MoveToThread(QThread *thread)
virtual void Open(void)
bool isEnabled() const
virtual void setReadOnly(bool readonly)
void addTargetedChild(const QString &value, StandardSetting *setting)
virtual bool haveSubSettings()
virtual void clearSettings()
void settingsChanged(StandardSetting *selectedSetting=nullptr)
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 getLabel(void) const
StandardSetting * getParent() const
virtual void Close(void)
void addTargetedChildren(const QString &value, std::initializer_list< StandardSetting * > settings)
virtual void removeChild(StandardSetting *child)
virtual void edit(MythScreenType *screen)=0
void ShouldRedraw(StandardSetting *setting)
void setVisible(bool visible)
StandardSetting * byName(const QString &name)
virtual QList< StandardSetting * > * getSubSettings()
bool haveChanged()
Return true if the setting have changed or any of its children.
QMap< QString, QList< StandardSetting * > > m_targets
virtual void resultEdit(DialogCompletionEvent *dce)=0
virtual void setValue(const QString &newValue)
MythUIButtonListItem * createButton(MythUIButtonList *list)
void removeTargetedChild(const QString &value, StandardSetting *child)
~StandardSetting() override
virtual bool keyPressEvent(QKeyEvent *event)
QList< StandardSetting * > m_children
bool isReadOnly() const
void clearTargetedSettings(const QString &value)
void valueChanged(const QString &newValue)
virtual QString getValue(void) const
virtual void setEnabled(bool enabled)
void setParent(StandardSetting *parent)
virtual void setLabel(QString str)
void setChanged(bool changed)
virtual void Load(void)=0
virtual void Save(void)=0
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
static MythThemedMenu * menu
@ FilterNone
def error(message)
Definition: smolt.py:409
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
static QKeyEvent selectEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"SELECT"))
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27