Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a standby mode screen, this is a significantly cutdown version of…
… mythwelcome, accessed directly from the frontend so by design doesn't duplicate any information or actions which can be accessed elsewhere in the frontend. Standby mode is currently accessed from the Main Menu context menu and the option to make it the default exit action will follow. When in 'standby mode' the backend will be allowed to shut down and when that happens, optionally the frontend may be shut down as well. You may continue to use mythwelcome as before if this new mode doesn't suit. The initial default theme is very basic, I hope to add some icons to the status statetype before the 0.25 release.
- Loading branch information
Showing
10 changed files
with
324 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
|
||
#include "idlescreen.h" | ||
|
||
#include <QTimer> | ||
|
||
#include <mythcontext.h> | ||
#include <mythsystem.h> | ||
|
||
#include <mythuibuttonlist.h> | ||
#include <mythuistatetype.h> | ||
#include <mythmainwindow.h> | ||
|
||
#include <programinfo.h> | ||
|
||
#include <tvremoteutil.h> | ||
|
||
#define UPDATE_STATUS_INTERVAL 30000 | ||
|
||
IdleScreen::IdleScreen(MythScreenStack *parent) | ||
:MythScreenType(parent, "standbymode"), | ||
m_updateStatusTimer(new QTimer(this)), m_statusState(NULL), | ||
m_secondsToShutdown(0), m_backendRecording(false) | ||
{ | ||
gCoreContext->addListener(this); | ||
GetMythMainWindow()->EnterStandby(); | ||
|
||
connect(m_updateStatusTimer, SIGNAL(timeout()), | ||
this, SLOT(UpdateStatus())); | ||
m_updateStatusTimer->start(UPDATE_STATUS_INTERVAL); | ||
} | ||
|
||
IdleScreen::~IdleScreen() | ||
{ | ||
GetMythMainWindow()->ExitStandby(); | ||
gCoreContext->removeListener(this); | ||
|
||
if (m_updateStatusTimer) | ||
m_updateStatusTimer->disconnect(); | ||
} | ||
|
||
bool IdleScreen::Create(void) | ||
{ | ||
bool foundtheme = false; | ||
|
||
// Load the theme for this screen | ||
foundtheme = LoadWindowFromXML("status-ui.xml", "standbymode", this); | ||
|
||
if (!foundtheme) | ||
return false; | ||
|
||
m_statusState = dynamic_cast<MythUIStateType*> | ||
(GetChild("backendstatus")); | ||
|
||
if (!m_statusState) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
void IdleScreen::Load(void) | ||
{ | ||
MythScreenType::Load(); | ||
} | ||
|
||
void IdleScreen::Init(void) | ||
{ | ||
UpdateScreen(); | ||
} | ||
|
||
bool IdleScreen::CheckConnectionToServer(void) | ||
{ | ||
m_updateStatusTimer->stop(); | ||
|
||
bool bRes = false; | ||
|
||
if (gCoreContext->IsConnectedToMaster()) | ||
bRes = true; | ||
else | ||
{ | ||
if (gCoreContext->ConnectToMasterServer(false)) | ||
bRes = true; | ||
} | ||
|
||
if (bRes) | ||
m_updateStatusTimer->start(UPDATE_STATUS_INTERVAL); | ||
else | ||
m_updateStatusTimer->start(5000); | ||
|
||
return bRes; | ||
} | ||
|
||
void IdleScreen::UpdateStatus(void) | ||
{ | ||
QString state = "idle"; | ||
|
||
if (CheckConnectionToServer()) | ||
{ | ||
if (m_secondsToShutdown) | ||
state = "shuttingdown"; | ||
else if (RemoteGetRecordingStatus()) | ||
state = "recording"; | ||
} | ||
else | ||
{ | ||
state = "offline"; | ||
} | ||
|
||
m_statusState->DisplayState(state); | ||
} | ||
|
||
void IdleScreen::UpdateScreen(void) | ||
{ | ||
|
||
MythUIText *statusText = dynamic_cast<MythUIText *>(GetChild("status")); | ||
|
||
if (statusText) | ||
{ | ||
QString status; | ||
|
||
if (m_secondsToShutdown) | ||
status = tr("MythTV is idle and will shutdown in %n " | ||
"second(s).", "", m_secondsToShutdown); | ||
|
||
if (!status.isEmpty()) | ||
statusText->SetText(status); | ||
else | ||
statusText->Reset(); | ||
} | ||
|
||
UpdateStatus(); | ||
} | ||
|
||
bool IdleScreen::keyPressEvent(QKeyEvent* event) | ||
{ | ||
return MythScreenType::keyPressEvent(event); | ||
} | ||
|
||
void IdleScreen::customEvent(QEvent* event) | ||
{ | ||
|
||
if ((MythEvent::Type)(event->type()) == MythEvent::MythEventMessage) | ||
{ | ||
MythEvent *me = static_cast<MythEvent *>(event); | ||
|
||
if (me->Message().left(18) == "SHUTDOWN_COUNTDOWN") | ||
{ | ||
QString secs = me->Message().mid(19); | ||
m_secondsToShutdown = secs.toInt(); | ||
UpdateStatus(); | ||
} | ||
else if (me->Message().left(12) == "SHUTDOWN_NOW") | ||
{ | ||
if (gCoreContext->IsFrontendOnly()) | ||
{ | ||
// does the user want to shutdown this frontend only machine | ||
// when the BE shuts down? | ||
if (gCoreContext->GetNumSetting("ShutdownWithMasterBE", 0) == 1) | ||
{ | ||
LOG(VB_GENERAL, LOG_NOTICE, | ||
"Backend has gone offline, Shutting down frontend"); | ||
QString poweroff_cmd = | ||
gCoreContext->GetSetting("MythShutdownPowerOff", ""); | ||
if (!poweroff_cmd.isEmpty()) | ||
myth_system(poweroff_cmd); | ||
} | ||
} | ||
} | ||
} | ||
|
||
MythUIType::customEvent(event); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef _IDLESCREEN_H_ | ||
#define _IDLESCREEN_H_ | ||
|
||
#include <mythscreentype.h> | ||
|
||
class MythUIStateType; | ||
class MythUIButtonList; | ||
class QTimer; | ||
|
||
class IdleScreen : public MythScreenType | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
IdleScreen(MythScreenStack *parent); | ||
virtual ~IdleScreen(); | ||
|
||
bool Create(void); | ||
bool keyPressEvent(QKeyEvent *event); | ||
void customEvent(QEvent *e); | ||
|
||
|
||
public slots: | ||
void UpdateStatus(void); | ||
void UpdateScreen(void); | ||
|
||
protected: | ||
void Load(void); | ||
void Init(void); | ||
|
||
private: | ||
bool CheckConnectionToServer(void); | ||
|
||
QTimer *m_updateStatusTimer; | ||
|
||
MythUIButtonList *m_upcomingList; | ||
MythUIStateType *m_statusState; | ||
|
||
int m_secondsToShutdown; | ||
bool m_backendRecording; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.