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