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