MythTV  master
mythtv-setup/exitprompt.cpp
Go to the documentation of this file.
1 #include <QCoreApplication>
2 
3 // MythTV stuff
4 #include "exitcodes.h"
5 #include "mythcorecontext.h"
6 #include "mythdialogbox.h"
7 #include "mythmainwindow.h"
8 #include "mythscreenstack.h"
9 #include "remoteutil.h"
10 #include "mythsystemlegacy.h"
11 
12 #include "checksetup.h"
13 #include "exitprompt.h"
14 
16 {
18  {
19  m_stk = GetMythMainWindow()->GetStack("popup stack");
20  }
21 
23 };
24 
26 {
28 }
29 
31 {
32  delete m_d;
33 }
34 
36 {
38  {
39  QString label = tr("If you've added or altered channels,"
40  " please run 'mythfilldatabase' on the"
41  " master backend to populate the"
42  " database with guide information.");
43 
44  auto *dia = new MythConfirmationDialog(m_d->m_stk, label, false);
45  if (!dia->Create())
46  {
47  LOG(VB_GENERAL, LOG_ERR, "Can't create fill DB prompt?");
48  delete dia;
49  quit();
50  }
51  else
52  {
53  dia->SetReturnEvent(this, "mythfillprompt");
54  m_d->m_stk->AddScreen(dia);
55  }
56  }
57  else
58  quit();
59 }
60 
62 {
63  QStringList problems;
64 
65  // Look for common problems
66  if (CheckSetup(problems))
67  {
68  problems.push_back(QString());
69  problems.push_back(tr("Do you want to go back and fix this(these) "
70  "problem(s)?", nullptr, problems.size()));
71 
72  auto *dia = new MythDialogBox(problems.join("\n"),
73  m_d->m_stk, "exit prompt");
74  if (!dia->Create())
75  {
76  LOG(VB_GENERAL, LOG_ERR, "Can't create Exit Prompt dialog?");
77  delete dia;
78  quit();
79  return;
80  }
81 
82  dia->SetReturnEvent(this, "problemprompt");
83 
84  dia->AddButton(tr("Yes please"));
85  dia->AddButton(tr("No, I know what I am doing"),
87 
88  m_d->m_stk->AddScreen(dia);
89  }
90  else
92 }
93 
94 void ExitPrompter::customEvent(QEvent *event)
95 {
96  if (event->type() == DialogCompletionEvent::kEventType)
97  {
98  auto *dce = (DialogCompletionEvent*)(event);
99 
100  QString resultid= dce->GetId();
101  int buttonnum = dce->GetResult();
102 
103  if (resultid == "mythfillprompt")
104  {
105  quit();
106  }
107  else if (resultid == "problemprompt")
108  {
109  switch (buttonnum)
110  {
111  case 0 :
112  break;
113  case 1 :
115  break;
116  }
117  }
118  }
119 }
120 
122 {
123  // If the backend was stopped restart it here
124  if (gCoreContext->GetSetting("AutoRestartBackend") == "1")
125  {
126  QString commandString = gCoreContext->GetSetting("BackendStartCommand");
127  if (!commandString.isEmpty())
128  {
129  LOG(VB_GENERAL, LOG_ERR, "backendrestart"+commandString);
130  myth_system(commandString);
131  }
132  }
133  else
134  {
135  // No need to run this if the backend has just restarted
137  {
138  gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
139  }
140  }
141 
142  qApp->exit(GENERIC_EXIT_OK);
143 }
MythCoreContext::SendMessage
void SendMessage(const QString &message)
Definition: mythcorecontext.cpp:1527
myth_system
uint myth_system(const QString &command, uint flags, uint timeout)
Definition: mythsystemlegacy.cpp:501
GENERIC_EXIT_OK
#define GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:10
ExitPrompter::m_d
struct ExitPrompterPrivate * m_d
Definition: mythtv-setup/exitprompt.h:27
mythscreenstack.h
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
checksetup.h
needsMFDBReminder
bool needsMFDBReminder()
Definition: checksetup.cpp:286
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
ExitPrompter::~ExitPrompter
~ExitPrompter() override
Definition: mythfrontend/exitprompt.cpp:26
remoteutil.h
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:329
mythsystemlegacy.h
ExitPrompter::customEvent
void customEvent(QEvent *event) override
Definition: mythtv-setup/exitprompt.cpp:94
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:278
MythCoreContext::BackendIsRunning
static bool BackendIsRunning(void)
a backend process is running on this host
Definition: mythcorecontext.cpp:721
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:167
ExitPrompterPrivate
Definition: mythtv-setup/exitprompt.cpp:16
ExitPrompter::handleExit
void handleExit(void)
Definition: mythtv-setup/exitprompt.cpp:61
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
ExitPrompterPrivate::ExitPrompterPrivate
ExitPrompterPrivate()
Definition: mythtv-setup/exitprompt.cpp:17
MythConfirmationDialog
Dialog asking for user confirmation.
Definition: mythdialogbox.h:271
mythcorecontext.h
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:42
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:108
ExitPrompter::masterPromptExit
void masterPromptExit(void)
Definition: mythtv-setup/exitprompt.cpp:35
ExitPrompterPrivate::m_stk
MythScreenStack * m_stk
Definition: mythtv-setup/exitprompt.cpp:22
MythCoreContext::IsMasterHost
bool IsMasterHost(void)
is this the same host as the master
Definition: mythcorecontext.cpp:680
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:15
exitprompt.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:919
ExitPrompter::quit
static void quit(void)
Definition: mythtv-setup/exitprompt.cpp:121