MythTV  master
mythtv-setup/exitprompt.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QCoreApplication>
3 
4 // MythTV stuff
12 
13 // MythTV Setup
14 #include "checksetup.h"
15 #include "exitprompt.h"
16 
18 {
20  {
21  m_stk = GetMythMainWindow()->GetStack("popup stack");
22  }
23 
25 };
26 
28 {
30 }
31 
33 {
34  delete m_d;
35 }
36 
38 {
40  {
41  QString label = tr("If you've added or altered channels,"
42  " please run 'mythfilldatabase' on the"
43  " master backend to populate the"
44  " database with guide information.");
45 
46  auto *dia = new MythConfirmationDialog(m_d->m_stk, label, false);
47  if (!dia->Create())
48  {
49  LOG(VB_GENERAL, LOG_ERR, "Can't create fill DB prompt?");
50  delete dia;
51  quit();
52  }
53  else
54  {
55  dia->SetReturnEvent(this, "mythfillprompt");
56  m_d->m_stk->AddScreen(dia);
57  }
58  }
59  else
60  quit();
61 }
62 
64 {
65  QStringList allproblems;
66 
67  // Look for common problems
68  if (CheckSetup(allproblems))
69  {
70  // Only report the first 4 problems
71  QStringList problems;
72  int limit = std::min(4, static_cast<int>(allproblems.size()));
73  for (int i = 0; i < limit; ++i)
74  {
75  problems.push_back(allproblems[i]);
76  }
77  if (problems.size() < allproblems.size())
78  {
79  problems.push_back(tr("...and more..."));
80  }
81  else
82  {
83  problems.push_back(QString());
84  }
85 
86  problems.push_back(tr("Do you want to go back and fix this(these) "
87  "problem(s)?", nullptr, problems.size()));
88 
89  auto *dia = new MythDialogBox(tr("Configuration Problems"), problems.join("\n"),
90  m_d->m_stk, "exit prompt", true);
91  if (!dia->Create())
92  {
93  LOG(VB_GENERAL, LOG_ERR, "Can't create Exit Prompt dialog?");
94  delete dia;
95  quit();
96  return;
97  }
98 
99  dia->SetReturnEvent(this, "problemprompt");
100 
101  dia->AddButton(tr("Yes please"));
102  dia->AddButton(tr("No, I know what I am doing"),
104 
105  m_d->m_stk->AddScreen(dia);
106  }
107  else
109 }
110 
111 void ExitPrompter::customEvent(QEvent *event)
112 {
113  if (event->type() == DialogCompletionEvent::kEventType)
114  {
115  auto *dce = (DialogCompletionEvent*)(event);
116 
117  QString resultid= dce->GetId();
118  int buttonnum = dce->GetResult();
119 
120  if (resultid == "mythfillprompt")
121  {
122  quit();
123  }
124  else if (resultid == "problemprompt")
125  {
126  switch (buttonnum)
127  {
128  case 0 :
129  break;
130  case 1 :
132  break;
133  }
134  }
135  }
136 }
137 
139 {
140  // If the backend was stopped restart it here
141  if (gCoreContext->GetSetting("AutoRestartBackend") == "1")
142  {
143  QString commandString = gCoreContext->GetSetting("BackendStartCommand");
144  if (!commandString.isEmpty())
145  {
146  LOG(VB_GENERAL, LOG_ERR, "backendrestart"+commandString);
147  myth_system(commandString);
148  }
149  }
150  else
151  {
152  // No need to run this if the backend has just restarted
154  {
155  gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
156  }
157  }
158 
159  qApp->exit(GENERIC_EXIT_OK);
160 }
MythCoreContext::SendMessage
void SendMessage(const QString &message)
Definition: mythcorecontext.cpp:1516
ExitPrompter::m_d
struct ExitPrompterPrivate * m_d
Definition: mythtv-setup/exitprompt.h:29
mythscreenstack.h
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
checksetup.h
needsMFDBReminder
bool needsMFDBReminder()
Definition: checksetup.cpp:293
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
ExitPrompter::~ExitPrompter
~ExitPrompter() override
Definition: mythfrontend/exitprompt.cpp:27
myth_system
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
Definition: mythsystemlegacy.cpp:506
GENERIC_EXIT_OK
@ GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:11
remoteutil.h
mythsystemlegacy.h
ExitPrompter::customEvent
void customEvent(QEvent *event) override
Definition: mythtv-setup/exitprompt.cpp:111
CheckSetup
bool CheckSetup(QStringList &problems)
Build up a string of common problems that the user should correct in the MythTV-Setup program.
Definition: checksetup.cpp:285
MythCoreContext::BackendIsRunning
static bool BackendIsRunning(void)
a backend process is running on this host
Definition: mythcorecontext.cpp:699
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:166
ExitPrompterPrivate
Definition: mythtv-setup/exitprompt.cpp:17
ExitPrompter::handleExit
void handleExit(void)
Definition: mythtv-setup/exitprompt.cpp:63
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
ExitPrompterPrivate::ExitPrompterPrivate
ExitPrompterPrivate()
Definition: mythtv-setup/exitprompt.cpp:19
MythConfirmationDialog
Dialog asking for user confirmation. Ok and optional Cancel button.
Definition: mythdialogbox.h:272
mythcorecontext.h
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
DialogCompletionEvent::kEventType
static const Type kEventType
Definition: mythdialogbox.h:57
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:104
ExitPrompter::masterPromptExit
void masterPromptExit(void)
Definition: mythtv-setup/exitprompt.cpp:37
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:323
ExitPrompterPrivate::m_stk
MythScreenStack * m_stk
Definition: mythtv-setup/exitprompt.cpp:24
MythCoreContext::IsMasterHost
bool IsMasterHost(void)
is this the same host as the master
Definition: mythcorecontext.cpp:658
exitcodes.h
mythmainwindow.h
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:52
ExitPrompter::ExitPrompter
ExitPrompter()
Definition: mythfrontend/exitprompt.cpp:16
exitprompt.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:897
ExitPrompter::quit
static void quit(void)
Definition: mythtv-setup/exitprompt.cpp:138