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