MythTV  master
startprompt.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QCoreApplication>
3 
4 // MythTV stuff
5 #include "exitcodes.h"
6 #include "mythcorecontext.h"
7 #include "mythdialogbox.h"
8 #include "mythmainwindow.h"
9 #include "mythscreenstack.h"
10 #include "mythsystemlegacy.h"
11 #include "tvremoteutil.h"
12 
13 #include "startprompt.h"
14 
16 {
18  {
19  stk = GetMythMainWindow()->GetStack("popup stack");
20  }
21 
23 };
24 
26 {
28 }
29 
31 {
32  delete m_d;
33 }
34 
36 {
37  // Offer to stop the backend if sensible
39  {
41  }
42 }
43 
45 {
46  LOG(VB_GENERAL, LOG_INFO, "Continuing with backend running");
47  gCoreContext->OverrideSettingForSession("AutoRestartBackend", "0");
48 }
49 
51 {
52  LOG(VB_GENERAL, LOG_INFO, "Trying to stop backend");
53 
54  QString commandString = gCoreContext->GetSetting("BackendStopCommand");
55  if (!commandString.isEmpty())
56  {
57  myth_system(commandString);
58  }
59  gCoreContext->OverrideSettingForSession("AutoRestartBackend", "1");
60 }
61 
63 {
64  bool backendIsRecording = false;
65  // Get recording status
68  {
69  backendIsRecording = RemoteGetRecordingStatus(nullptr, false);
70  }
71 
72  QString warning = tr("WARNING: The backend is currently running.")+"\n\n"+
73  tr("Changing existing card inputs, deleting anything, "
74  "or scanning for channels may not work.")+"\n\n";
75  if (backendIsRecording)
76  {
77  warning += tr("Recording Status: RECORDING.")+"\n"+
78  tr("If you stop the backend now these recordings will be stopped!");
79  }
80  else
81  {
82  warning += tr("Recording Status: None.");
83  }
84 
85  MythDialogBox *dia = new MythDialogBox(warning, m_d->stk, "actionmenu");
86 
87  if (!dia->Create())
88  {
89  LOG(VB_GENERAL, LOG_ERR, "Can't create Prompt dialog?");
90  delete dia;
91  quit();
92  return;
93  }
94 
95  // This is a hack so that the button clicks target the correct slot:
96  dia->SetReturnEvent(this, QString());
97 
98  m_d->stk->AddScreen(dia);
99 
100  QString commandString = gCoreContext->GetSetting("BackendStopCommand");
101  if (!commandString.isEmpty())
102  {
103  // Only show option to stop backend if command is defined.
104  dia->AddButton(tr("Stop Backend and Continue"), SLOT(stopBackend()));
105  }
106  dia->AddButton(tr("Continue"), SLOT(leaveBackendRunning()));
107  dia->AddButton(tr("Exit"), SLOT(quit()));
108 }
109 
111 {
112  qApp->exit(GENERIC_EXIT_OK);
113 }
void leaveBackendRunning()
Definition: startprompt.cpp:44
void handleStart()
Definition: startprompt.cpp:35
#define GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:10
MythScreenStack * stk
Definition: startprompt.cpp:22
Basic menu dialog, message and a list of options.
bool ConnectToMasterServer(bool blockingClient=true, bool openEventSocket=true)
MythScreenStack * GetStack(const QString &stackname)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void AddButton(const QString &title, QVariant data=0, bool newMenu=false, bool setCurrent=false)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
bool IsConnectedToMaster(void)
void OverrideSettingForSession(const QString &key, const QString &value)
QString GetSetting(const QString &key, const QString &defaultval="")
bool BackendIsRunning(void)
a backend process is running on this host
uint myth_system(const QString &command, uint flags, uint timeout)
bool IsMasterHost(void)
is this the same host as the master
struct StartPrompterPrivate * m_d
Definition: startprompt.h:25
MythMainWindow * GetMythMainWindow(void)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
void SetReturnEvent(QObject *retobject, const QString &resultid)
void stopBackend()
Definition: startprompt.cpp:50
void backendRunningPrompt()
Definition: startprompt.cpp:62
int RemoteGetRecordingStatus(const ProgramInfo *pginfo, int overrecsecs, int underrecsecs)
Get status of an individual programme (with pre-post roll?).
Definition: remoteutil.cpp:505
bool Create(void) override