Skip to content

Commit

Permalink
And the remainders
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Mar 8, 2012
1 parent b597f99 commit 33186c6
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 97 deletions.
56 changes: 39 additions & 17 deletions mythtv/programs/mythtv-setup/channeleditor.cpp
Expand Up @@ -21,6 +21,7 @@
#include "cardutil.h"
#include "settings.h"
#include "mythdb.h"
#include "mythactions.h"

ChannelWizard::ChannelWizard(int id, int default_sourceid)
: ConfigurationWizard()
Expand Down Expand Up @@ -56,15 +57,30 @@ ChannelWizard::ChannelWizard(int id, int default_sourceid)

/////////////////////////////////////////////////////////

ChannelEditor::ChannelEditor(MythScreenStack *parent)
: MythScreenType(parent, "channeleditor"),
static struct ActionDefStruct<ChannelEditor> ceActions[] = {
{ "EDIT", &ChannelEditor::doEdit },
{ "MENU", &ChannelEditor::doMenu },
{ "DELETE", &ChannelEditor::doDelete }
};
static int ceActionCount = NELEMS(ceActions);


ChannelEditor::ChannelEditor(MythScreenStack *parent) :
MythScreenType(parent, "channeleditor"),
m_sourceFilter(FILTER_ALL),
m_currentSortMode(QObject::tr("Channel Name")),
m_currentHideMode(false),
m_channelList(NULL), m_sourceList(NULL), m_preview(NULL),
m_channame(NULL), m_channum(NULL), m_callsign(NULL),
m_chanid(NULL), m_sourcename(NULL), m_compoundname(NULL)
m_chanid(NULL), m_sourcename(NULL), m_compoundname(NULL),
m_actions(new MythActions<ChannelEditor>(this, ceActions, ceActionCount))
{
}

ChannelEditor::~ChannelEditor()
{
if (m_actions)
delete m_actions;
}

bool ChannelEditor::Create()
Expand Down Expand Up @@ -169,6 +185,24 @@ bool ChannelEditor::Create()
return true;
}

bool ChannelEditor::doEdit(const QString &action)
{
edit();
return true;
}

bool ChannelEditor::doMenu(const QString &action)
{
menu();
return true;
}

bool ChannelEditor::doDelete(const QString &action)
{
del();
return true;
}

bool ChannelEditor::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
Expand All @@ -178,20 +212,8 @@ bool ChannelEditor::keyPressEvent(QKeyEvent *event)
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);

for (int i = 0; i < actions.size() && !handled; i++)
{
QString action = actions[i];
handled = true;

if (action == "MENU")
menu();
else if (action == "DELETE")
del();
else if (action == "EDIT")
edit();
else
handled = false;
}
if (!handled)
handled = m_actions->handleActions(actions);

if (!handled && MythScreenType::keyPressEvent(event))
handled = true;
Expand Down
8 changes: 8 additions & 0 deletions mythtv/programs/mythtv-setup/channeleditor.h
Expand Up @@ -4,6 +4,7 @@
#include "mythscreentype.h"

#include "mythconfigdialogs.h"
#include "mythactions.h"

class MythUIButton;
class MythUIButtonList;
Expand All @@ -15,11 +16,16 @@ class ChannelEditor : public MythScreenType
Q_OBJECT
public:
ChannelEditor(MythScreenStack *parent);
~ChannelEditor();

bool Create(void);
bool keyPressEvent(QKeyEvent *);
void customEvent(QEvent *event);

bool doEdit(const QString &action);
bool doMenu(const QString &action);
bool doDelete(const QString &action);

protected slots:
void menu(void);
void del(void);
Expand Down Expand Up @@ -57,6 +63,8 @@ class ChannelEditor : public MythScreenType
MythUIText *m_chanid;
MythUIText *m_sourcename;
MythUIText *m_compoundname;

MythActions<ChannelEditor> *m_actions;
};

class ChannelID;
Expand Down
187 changes: 107 additions & 80 deletions mythtv/programs/mythwelcome/welcomedialog.cpp
Expand Up @@ -22,22 +22,37 @@

#include "welcomedialog.h"
#include "welcomesettings.h"
#include "mythactions.h"

#define UPDATE_STATUS_INTERVAL 30000
#define UPDATE_SCREEN_INTERVAL 15000


WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name)
:MythScreenType(parent, name),
static struct ActionDefStruct<WelcomeDialog> wdActions[] = {
{ "ESCAPE", &WelcomeDialog::doEscape },
{ "MENU", &WelcomeDialog::doMenu },
{ "INFO", &WelcomeDialog::doInfo },
{ "SHOWSETTINGS", &WelcomeDialog::doShowSettings },
{ "NEXTVIEW", &WelcomeDialog::doNextView },
{ "0", &WelcomeDialog::doZero },
{ "STARTXTERM", &WelcomeDialog::doStartXTerm },
{ "STARTSETUP", &WelcomeDialog::doStartSetup }
};
static int wdActionCount = NELEMS(wdActions);


WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name) :
MythScreenType(parent, name),
m_status_text(NULL), m_recording_text(NULL), m_scheduled_text(NULL),
m_warning_text(NULL), m_startfrontend_button(NULL),
m_menuPopup(NULL), m_updateStatusTimer(new QTimer(this)),
m_updateScreenTimer(new QTimer(this)), m_isRecording(false),
m_hasConflicts(false), m_bWillShutdown(false),
m_secondsToShutdown(-1), m_preRollSeconds(0), m_idleWaitForRecordingTime(0),
m_secondsToShutdown(-1), m_preRollSeconds(0),
m_idleWaitForRecordingTime(0),
m_idleTimeoutSecs(0), m_screenTunerNo(0), m_screenScheduledNo(0),
m_statusListNo(0), m_frontendIsRunning(false),
m_pendingRecListUpdate(false), m_pendingSchedUpdate(false)
m_pendingRecListUpdate(false), m_pendingSchedUpdate(false),
m_actions(new MythActions<WelcomeDialog>(this, wdActions, wdActionCount))
{
gCoreContext->addListener(this);

Expand Down Expand Up @@ -219,6 +234,88 @@ void WelcomeDialog::customEvent(QEvent *e)
}
}

bool WelcomeDialog::doEscape(const QString &action)
{
// eat escape key
return true;
}

bool WelcomeDialog::doMenu(const QString &action)
{
showMenu();
return true;
}

bool WelcomeDialog::doInfo(const QString &action)
{
MythWelcomeSettings settings;
if (kDialogCodeAccepted == settings.exec())
{
gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
updateStatus();
updateScreen();

m_dateFormat = gCoreContext->GetSetting("MythWelcomeDateFormat",
"dddd\\ndd MMM yyyy");
m_dateFormat.replace("\\n", "\n");
}
return true;
}

bool WelcomeDialog::doShowSettings(const QString &action)
{
MythShutdownSettings settings;
if (kDialogCodeAccepted == settings.exec())
gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
return true;
}

bool WelcomeDialog::doNextView(const QString &action)
{
Close();
return true;
}

bool WelcomeDialog::doZero(const QString &action)
{
QString mythshutdown_status = m_installDir + "/bin/mythshutdown --status 0";
QString mythshutdown_unlock = m_installDir + "/bin/mythshutdown --unlock";
QString mythshutdown_lock = m_installDir + "/bin/mythshutdown --lock";

uint statusCode;
statusCode = myth_system(mythshutdown_status + logPropagateArgs);

// is shutdown locked by a user
if (!(statusCode & 0xFF00) && statusCode & 16)
{
myth_system(mythshutdown_unlock + logPropagateArgs);
}
else
{
myth_system(mythshutdown_lock + logPropagateArgs);
}

updateStatusMessage();
updateScreen();
return true;
}

bool WelcomeDialog::doStartXTerm(const QString &action)
{
QString cmd = gCoreContext->GetSetting("MythShutdownXTermCmd", "");
if (!cmd.isEmpty())
myth_system(cmd);
return true;
}

bool WelcomeDialog::doStartSetup(const QString &action)
{
QString mythtv_setup = m_installDir + "/bin/mythtv-setup";
myth_system(mythtv_setup + logPropagateArgs);
return true;
}


bool WelcomeDialog::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
Expand All @@ -228,81 +325,8 @@ bool WelcomeDialog::keyPressEvent(QKeyEvent *event)
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("Welcome", event, actions);

for (int i = 0; i < actions.size() && !handled; i++)
{
QString action = actions[i];
handled = true;

if (action == "ESCAPE")
{
return true; // eat escape key
}
else if (action == "MENU")
{
showMenu();
}
else if (action == "NEXTVIEW")
{
Close();
}
else if (action == "INFO")
{
MythWelcomeSettings settings;
if (kDialogCodeAccepted == settings.exec())
{
gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
updateStatus();
updateScreen();

m_dateFormat = gCoreContext->GetSetting("MythWelcomeDateFormat", "dddd\\ndd MMM yyyy");
m_dateFormat.replace("\\n", "\n");
}
}
else if (action == "SHOWSETTINGS")
{
MythShutdownSettings settings;
if (kDialogCodeAccepted == settings.exec())
gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
}
else if (action == "0")
{
QString mythshutdown_status =
m_installDir + "/bin/mythshutdown --status 0";
QString mythshutdown_unlock =
m_installDir + "/bin/mythshutdown --unlock";
QString mythshutdown_lock =
m_installDir + "/bin/mythshutdown --lock";

uint statusCode;
statusCode = myth_system(mythshutdown_status + logPropagateArgs);

// is shutdown locked by a user
if (!(statusCode & 0xFF00) && statusCode & 16)
{
myth_system(mythshutdown_unlock + logPropagateArgs);
}
else
{
myth_system(mythshutdown_lock + logPropagateArgs);
}

updateStatusMessage();
updateScreen();
}
else if (action == "STARTXTERM")
{
QString cmd = gCoreContext->GetSetting("MythShutdownXTermCmd", "");
if (!cmd.isEmpty())
myth_system(cmd);
}
else if (action == "STARTSETUP")
{
QString mythtv_setup = m_installDir + "/bin/mythtv-setup";
myth_system(mythtv_setup + logPropagateArgs);
}
else
handled = false;
}
if (!handled)
handled = m_actions->handleActions(actions);

if (!handled && MythScreenType::keyPressEvent(event))
handled = true;
Expand All @@ -324,6 +348,9 @@ WelcomeDialog::~WelcomeDialog()

if (m_updateScreenTimer)
m_updateScreenTimer->disconnect();

if (m_actions)
delete m_actions;
}

void WelcomeDialog::updateStatus(void)
Expand Down
11 changes: 11 additions & 0 deletions mythtv/programs/mythwelcome/welcomedialog.h
Expand Up @@ -15,6 +15,7 @@
#include "mythuibutton.h"
#include "mythuitext.h"
#include "mythdialogbox.h"
#include "mythactions.h"

class WelcomeDialog : public MythScreenType
{
Expand All @@ -30,6 +31,15 @@ class WelcomeDialog : public MythScreenType
bool keyPressEvent(QKeyEvent *event);
void customEvent(QEvent *e);

bool doEscape(const QString &action);
bool doMenu(const QString &action);
bool doInfo(const QString &action);
bool doShowSettings(const QString &action);
bool doNextView(const QString &action);
bool doZero(const QString &action);
bool doStartXTerm(const QString &action);
bool doStartSetup(const QString &action);

protected slots:
void startFrontendClick(void);
void startFrontend(void);
Expand Down Expand Up @@ -98,6 +108,7 @@ class WelcomeDialog : public MythScreenType
bool pendingSchedUpdate() const { return m_pendingSchedUpdate; }
void setPendingSchedUpdate(bool newState) { m_pendingSchedUpdate = newState; }

MythActions<WelcomeDialog> *m_actions;
};

#endif

0 comments on commit 33186c6

Please sign in to comment.