Ticket #6290: 90-6290-mythtv-setup.patch
File 90-6290-mythtv-setup.patch, 7.5 KB (added by , 15 years ago) |
---|
-
mythtv/programs/mythtv-setup/startprompt.cpp
1 // ANSI C 2 #include <cstdlib> 3 4 // POSIX 5 #include <unistd.h> 6 7 // qt 8 #include <QApplication> 9 #include <QKeyEvent> 10 #include <QLabel> 11 #include <QEvent> 12 13 // myth 14 #include "libmythtv/videosource.h" 15 #include "libmythui/mythprogressdialog.h" 16 #include "channeleditor.h" 17 #include "compat.h" 18 #include "exitcodes.h" 19 #include "lcddevice.h" 20 #include "mythcontext.h" 21 #include "mythdbcon.h" 22 #include "mythdirs.h" 23 #include "myththemedmenu.h" 24 #include "mythuihelper.h" 25 #include "programinfo.h" 26 #include "uitypes.h" 27 28 #include "backendsettings.h" 29 #include "startprompt.h" 30 #include "libmythtv/videosource.h" 31 32 #include <QApplication> 33 34 // MythTV stuff 35 #include "exitcodes.h" 36 #include "mythcontext.h" 37 #include "mythdialogbox.h" 38 #include "mythmainwindow.h" 39 #include "mythscreenstack.h" 40 #include "remoteutil.h" 41 42 #include "checksetup.h" 43 #include "exitprompt.h" 44 45 struct StartPrompterPrivate 46 { 47 StartPrompterPrivate() 48 { 49 stk = GetMythMainWindow()->GetStack("popup stack"); 50 } 51 52 MythScreenStack *stk; 53 }; 54 55 StartPrompter::StartPrompter() 56 { 57 m_d = new StartPrompterPrivate; 58 } 59 60 StartPrompter::~StartPrompter() 61 { 62 delete m_d; 63 } 64 65 void StartPrompter::handleStart() 66 { 67 // Offer to stop the backend if sensible 68 if (gContext->BackendIsRunning() && gContext->IsMasterHost()) 69 { 70 backendRunningPrompt(); 71 } 72 } 73 74 void StartPrompter::leaveBackendRunning() 75 { 76 VERBOSE(VB_GENERAL, "Continuing with backend running"); 77 gContext->SetSetting("AutoRestartBackend", "0"); 78 } 79 80 void StartPrompter::stopBackend() 81 { 82 VERBOSE(VB_GENERAL, "Trying to stop backend"); 83 84 QString commandString = gContext->GetSetting("BackendStopCommand"); 85 if (!commandString.isEmpty()) 86 { 87 myth_system(commandString); 88 } 89 gContext->SetSetting("AutoRestartBackend", "1"); 90 } 91 92 void StartPrompter::backendRunningPrompt(void) 93 { 94 bool backendIsRecording = false; 95 // Get recording status 96 if (!gContext->IsConnectedToMaster()) 97 { 98 gContext->ConnectToMasterServer(false); 99 backendIsRecording = RemoteGetRecordingStatus(NULL, false); 100 } 101 102 QString warning = tr("WARNING: The backend is currently running.")+"\n\n"+ 103 tr("Changing existing card inputs, deleting anything, " 104 "or scanning for channels may not work.")+"\n\n"; 105 if (backendIsRecording) 106 { 107 warning += tr("Recording Status: RECORDING.")+"\n"+ 108 tr("If you stop the backend now these recordings will be stopped!"); 109 } 110 else 111 { 112 warning += tr("Recording Status: None."); 113 } 114 115 MythDialogBox *dia = new MythDialogBox(warning, m_d->stk, "actionmenu"); 116 117 if (!dia->Create()) 118 { 119 VERBOSE(VB_IMPORTANT, "Can't create Prompt dialog?"); 120 delete dia; 121 quit(); 122 } 123 124 // This is a hack so that the button clicks target the correct slot: 125 dia->SetReturnEvent(this, QString()); 126 127 m_d->stk->AddScreen(dia); 128 129 QString commandString = gContext->GetSetting("BackendStopCommand"); 130 if (!commandString.isEmpty()) 131 { 132 // Only show option to stop backend if command is defined. 133 dia->AddButton(tr("Stop Backend and Continue"), SLOT(stopBackend())); 134 } 135 dia->AddButton(tr("Continue"), SLOT(leaveBackendRunning())); 136 dia->AddButton(tr("Exit"), SLOT(quit())); 137 } 138 139 void StartPrompter::quit() 140 { 141 qApp->exit(GENERIC_EXIT_OK); 142 } -
mythtv/programs/mythtv-setup/startprompt.h
1 #ifndef SETUPDIALOG_H_ 2 #define SETUPDIALOG_H_ 3 4 #include <QObject> 5 6 class StartPrompter : public QObject 7 { 8 Q_OBJECT 9 10 public: 11 StartPrompter(); 12 ~StartPrompter(); 13 14 public slots: 15 void handleStart(); 16 void backendRunningPrompt(); 17 void leaveBackendRunning(); 18 void stopBackend(); 19 void quit(); 20 21 private: 22 StartPrompter(const StartPrompter &); 23 24 private: 25 struct StartPrompterPrivate *m_d; 26 }; 27 28 #endif 29 No newline at end of file -
mythtv/programs/mythtv-setup/mythtv-setup.pro
22 22 DEFINES += USING_BACKEND 23 23 } 24 24 25 HEADERS += startprompt.h 26 SOURCES += startprompt.cpp 25 27 # Input 26 28 HEADERS += backendsettings.h checksetup.h exitprompt.h importicons.h 27 29 HEADERS += channeleditor.h -
mythtv/programs/mythtv-setup/exitprompt.cpp
8 8 #include "mythmainwindow.h" 9 9 #include "mythscreenstack.h" 10 10 #include "remoteutil.h" 11 #include "mythsystem.h" 11 12 12 13 #include "checksetup.h" 13 14 #include "exitprompt.h" … … 94 95 95 96 void ExitPrompter::quit() 96 97 { 97 if (gContext->BackendIsRunning()) 98 RemoteSendMessage("CLEAR_SETTINGS_CACHE"); 98 // If the backend was stopped restart it here 99 if (gContext->GetSetting("AutoRestartBackend") == "1") 100 { 101 QString commandString = gContext->GetSetting("BackendStartCommand"); 102 if (!commandString.isEmpty()) 103 { 104 VERBOSE(VB_IMPORTANT, "backendrestart"+commandString); 105 myth_system(commandString); 106 } 107 } 108 else 109 { 110 // No need to run this if the backend has just restarted 111 if (gContext->BackendIsRunning()) 112 { 113 RemoteSendMessage("CLEAR_SETTINGS_CACHE"); 114 } 115 } 99 116 100 117 qApp->exit(GENERIC_EXIT_OK); 101 118 } -
mythtv/programs/mythtv-setup/main.cpp
31 31 #include "libmythtv/remoteutil.h" 32 32 #include "backendsettings.h" 33 33 #include "checksetup.h" 34 #include "startprompt.h" 34 35 35 36 using namespace std; 36 37 37 38 ExitPrompter *exitPrompt = NULL; 39 StartPrompter *startPrompt = NULL; 38 40 39 41 void SetupMenuCallback(void* data, QString& selection) 40 42 { … … 508 510 return GENERIC_EXIT_DB_OUTOFDATE; 509 511 } 510 512 511 QString warn = 512 QObject::tr("WARNING") + ": " + 513 QObject::tr("MythTV has detected that the backend is running.")+"\n\n"+ 514 QObject::tr("Changing existing card inputs, deleting anything, " 515 "or scanning for channels may not work."); 513 if (!startPrompt) 514 startPrompt = new StartPrompter(); 515 startPrompt->handleStart(); 516 516 517 bool backendIsRunning = gContext->BackendIsRunning();518 519 if (backendIsRunning)520 {521 DialogCode val = MythPopupBox::Show2ButtonPopup(522 mainWindow, QObject::tr("WARNING"), warn,523 QObject::tr("Continue"),524 QObject::tr("Exit"), kDialogCodeButton0);525 526 if (kDialogCodeButton1 == val)527 {528 return GENERIC_EXIT_OK;529 }530 }531 532 517 REG_KEY("qt", "DELETE", "Delete", "D"); 533 518 REG_KEY("qt", "EDIT", "Edit", "E"); 534 519