Index: themes/default/osdedit-ui.xml
===================================================================
--- themes/default/osdedit-ui.xml (revision 0)
+++ themes/default/osdedit-ui.xml (revision 0)
@@ -0,0 +1,59 @@
+
+
+
+
+
+ #ffffff
+ 16
+ yes
+
+
+
+
+
+
+ 56,140,200,200
+
+
+
+
+
+ 260,140,400,400
+
+
+
+
+
+ 0,0,400,30
+
+
+
+
+
+
+
+
+ 0, 0, 400, 30
+
+
+
+
+
+
+
+
+
+
+
+
+ no
+
+
+
Index: themes/defaultmenu/tv_settings.xml
===================================================================
--- themes/defaultmenu/tv_settings.xml (revision 20006)
+++ themes/defaultmenu/tv_settings.xml (working copy)
@@ -91,6 +91,11 @@
SETTINGS OSD
+
-
Index: themes/default-wide/osdedit-ui.xml
===================================================================
--- themes/default-wide/osdedit-ui.xml (revision 0)
+++ themes/default-wide/osdedit-ui.xml (revision 0)
@@ -0,0 +1,60 @@
+
+
+
+
+
+ #ffffff
+ 18
+ yes
+
+
+
+
+
+
+ 100,140,300,300
+ no
+
+
+
+
+
+ 402,140,500,500
+
+
+
+
+
+ 0,0,500,30
+
+
+
+
+
+
+
+
+ 0, 0, 500, 30
+
+
+
+
+
+
+
+
+
+
+
+
+ no
+
+
+
Index: themes/button_types.txt
===================================================================
--- themes/button_types.txt (revision 20006)
+++ themes/button_types.txt (working copy)
@@ -141,6 +141,7 @@
5. TV_SETTINGS_RECORDING_PROFILES
6. TV_SETTINGS_RECPRIORITIES
7. TV_SETTINGS_PLAYBACK_OSD
+ 8. TV_SETTINGS_OSD_MENU_EDITOR
util_menu.xml
Index: libs/libmythtv/tv.h
===================================================================
--- libs/libmythtv/tv.h (revision 20006)
+++ libs/libmythtv/tv.h (working copy)
@@ -17,7 +17,7 @@
/** \brief TVState is an enumeration of the states used by TV and TVRec.
*/
-typedef enum
+typedef enum
{
/** \brief Error State, if we ever try to enter this state errored is set.
*/
@@ -35,6 +35,12 @@
* watching a pre-existing recording.
*/
kState_WatchingPreRecorded,
+ /** \brief Watching Video is the state when we are watching a video and is not
+ * a dvd
+ */
+ kState_WatchingVideo,
+ /** \brief Watching DVD is the state when we are watching a DVD */
+ kState_WatchingDVD,
/** \brief Watching Recording is the state for when we are watching
* an in progress recording, but the user does not have control
* over the channel and recorder to use.
@@ -51,7 +57,7 @@
kState_ChangingState,
} TVState;
-QString StateToString(TVState state);
+QString StateToString(TVState state, bool brief = false);
typedef enum PictureAdjustType
{
@@ -72,5 +78,4 @@
kCommSkipIncr,
} CommSkipMode;
QString toString(CommSkipMode type);
-
#endif
Index: libs/libmythtv/libmythtv.pro
===================================================================
--- libs/libmythtv/libmythtv.pro (revision 20006)
+++ libs/libmythtv/libmythtv.pro (working copy)
@@ -280,11 +280,11 @@
HEADERS += osd.h osdtypes.h
HEADERS += osdsurface.h osdlistbtntype.h
HEADERS += osdimagecache.h osdtypeteletext.h
- HEADERS += udpnotify.h
+ HEADERS += udpnotify.h tvosdmenuentry.h
SOURCES += osd.cpp osdtypes.cpp
SOURCES += osdsurface.cpp osdlistbtntype.cpp
SOURCES += osdimagecache.cpp osdtypeteletext.cpp
- SOURCES += udpnotify.cpp
+ SOURCES += udpnotify.cpp tvosdmenuentry.cpp
# Video output
HEADERS += videooutbase.h videoout_null.h
Index: libs/libmythtv/tv_play.h
===================================================================
--- libs/libmythtv/tv_play.h (revision 20006)
+++ libs/libmythtv/tv_play.h (working copy)
@@ -43,6 +43,7 @@
class OSDGenericTree;
class PlayerContext;
class UDPNotifyOSDSet;
+class TVOSDMenuEntryList;
typedef QMap InfoMap;
typedef QMap DDValueMap;
@@ -84,7 +85,7 @@
class VBIMode
{
public:
- typedef enum
+ typedef enum
{
None = 0,
PAL_TT = 1,
@@ -363,7 +364,7 @@
// key queue commands
void AddKeyToInputQueue(PlayerContext*, char key);
- void ClearInputQueues(const PlayerContext*, bool hideosd);
+ void ClearInputQueues(const PlayerContext*, bool hideosd);
bool CommitQueuedInput(PlayerContext*);
bool ProcessSmartChannel(const PlayerContext*, QString&);
@@ -381,7 +382,7 @@
void SwitchSource(uint source_direction);
void SwitchInputs(PlayerContext*, uint inputid);
- void ToggleInputs(PlayerContext*, uint inputid = 0);
+ void ToggleInputs(PlayerContext*, uint inputid = 0);
void SwitchCards(PlayerContext*,
uint chanid = 0, QString channum = "", uint inputid = 0);
@@ -434,7 +435,7 @@
static void *load_dd_map_thunk(void*);
static void *load_dd_map_post_thunk(void*);
- void DoQueueTranscode(PlayerContext*,QString profile);
+ void DoQueueTranscode(PlayerContext*,QString profile);
void SetAutoCommercialSkip(const PlayerContext*,
CommSkipMode skipMode = kCommSkipOff);
@@ -445,9 +446,9 @@
const QStringList &actions);
void DoDisplayJumpMenu(void);
-
+
bool ClearOSD(const PlayerContext*);
- void ToggleOSD(const PlayerContext*, bool includeStatusOSD);
+ void ToggleOSD(const PlayerContext*, bool includeStatusOSD);
void UpdateOSDProgInfo(const PlayerContext*, const char *whichInfo);
void UpdateOSDSeekMessage(const PlayerContext*,
const QString &mesg, int disptime);
@@ -507,8 +508,8 @@
void ShowOSDTreeMenu(const PlayerContext*);
- void FillOSDTreeMenu( const PlayerContext*, OSDGenericTree*) const;
- void FillMenuPlaying( const PlayerContext*, OSDGenericTree*) const;
+ void FillOSDTreeMenu( const PlayerContext*, OSDGenericTree*, QString category) const;
+ void FillMenuPlaying( const PlayerContext*, OSDGenericTree*, QString category) const;
void FillMenuPxP( const PlayerContext*, OSDGenericTree*) const;
void FillMenuInputSwitching(const PlayerContext*, OSDGenericTree*) const;
void FillMenuVideoAspect( const PlayerContext*, OSDGenericTree*) const;
@@ -559,7 +560,7 @@
static bool StateIsLiveTV(TVState state);
static TVState RemoveRecording(TVState state);
void RestoreScreenSaver(const PlayerContext*);
-
+
void InitUDPNotifyEvent(void);
/// true if dialog is either videoplayexit, playexit or askdelete dialog
@@ -606,7 +607,7 @@
int stickykeys;
float ff_rew_repos;
bool ff_rew_reverse;
- bool jumped_back; ///< Used by PromptDeleteRecording
+ bool jumped_back; ///< Used by PromptDeleteRecording
vector ff_rew_speeds;
uint vbimode;
@@ -716,6 +717,7 @@
// OSD info
OSDGenericTree *treeMenu; ///< OSD menu, 'm' using default keybindings
QMap osd_lctx;
+ TVOSDMenuEntryList *osdMenuEntries;
/// UDPNotify instance which shows messages sent
/// to the "UDPNotifyPort" in an OSD dialog.
Index: libs/libmythtv/tvosdmenuentry.h
===================================================================
--- libs/libmythtv/tvosdmenuentry.h (revision 0)
+++ libs/libmythtv/tvosdmenuentry.h (revision 0)
@@ -0,0 +1,72 @@
+#ifndef TVOSDMENUENTRY_H_
+#define TVOSDMENUENTRY_H_
+
+#include
+#include
+#include
+#include
+#include "tv.h"
+
+class TVOSDMenuEntry
+{
+ public:
+ TVOSDMenuEntry(QString category_entry, int livetv_setting,
+ int recorded_setting, int video_setting,
+ int dvd_setting, QString description_entry)
+ {
+ category = category_entry;
+ livetv = livetv_setting;
+ recorded = recorded_setting;
+ video = video_setting;
+ dvd = dvd_setting,
+ description = description_entry;
+
+ }
+ ~TVOSDMenuEntry(void) {}
+ QString GetCategory(void) { return category; }
+ QString GetDescription(void) { return description; }
+ int LiveTVSetting(void) { return livetv; }
+ int RecordedSetting(void) { return recorded; }
+ int VideoSetting(void) { return video; }
+ int DVDSetting(void) { return dvd; }
+ int GetEntry(TVState state);
+ QStringList GetData(void);
+ void UpdateEntry(int change, TVState state);
+ void UpdateEntry(int livetv_entry, int recorded_entry,
+ int video, int dvd);
+ void UpdateDBEntry(void);
+ void CreateDBEntry(void);
+
+ private:
+ QString category;
+ int livetv;
+ int recorded;
+ int video;
+ int dvd;
+ QString description;
+ QMutex updateEntryLock;
+
+};
+
+Q_DECLARE_METATYPE(TVOSDMenuEntry*)
+
+class TVOSDMenuEntryList
+{
+ public:
+ TVOSDMenuEntryList(void);
+ ~TVOSDMenuEntryList(void);
+ bool ShowOSDMenuOption(QString category, TVState state);
+ void UpdateDB(void);
+ int GetCount(void);
+ QListIterator GetIterator(void);
+ TVOSDMenuEntry* FindEntry(QString category);
+
+ private:
+ void GetEntriesFromDB(void);
+ void InitDefaultEntries(void);
+
+ private:
+ QList curMenuEntries;
+};
+
+#endif
Index: libs/libmythtv/playercontext.cpp
===================================================================
--- libs/libmythtv/playercontext.cpp (revision 20006)
+++ libs/libmythtv/playercontext.cpp (working copy)
@@ -38,7 +38,7 @@
// Other state
paused(false), playingState(kState_None),
errored(false),
- // pseudo states
+ // pseudo states
pseudoLiveTVRec(NULL), pseudoLiveTVState(kPseudoNormalLiveTV),
// DB values
fftime(0), rewtime(0),
@@ -47,7 +47,7 @@
playingInfoLock(QMutex::Recursive), deleteNVPLock(QMutex::Recursive),
stateLock(QMutex::Recursive),
// pip
- pipState(kPIPOff), pipRect(0,0,0,0), parentWidget(NULL),
+ pipState(kPIPOff), pipRect(0,0,0,0), parentWidget(NULL),
useNullVideo(false),
// embedding
embedWinID(0), embedBounds(0,0,0,0)
@@ -100,6 +100,13 @@
if (curtime < recendts && !playingInfo->isVideo)
newState = kState_WatchingRecording;
+ else if (playingInfo->isVideo)
+ {
+ if (playingInfo->pathname.startsWith("dvd:"))
+ newState = kState_WatchingDVD;
+ else
+ newState = kState_WatchingVideo;
+ }
else
newState = kState_WatchingPreRecorded;
@@ -174,7 +181,7 @@
}
else
name = "pip player";
-
+
if (widget)
parentWidget = widget;
@@ -230,18 +237,18 @@
// Centre video in the y axis
if (img.height() < pipRect.height())
- video_y = pipRect.y() +
+ video_y = pipRect.y() +
(pipRect.height() - img.height()) / 2;
else
video_y = pipRect.y();
// Centre video in the x axis
if (img.width() < pipRect.width())
- video_x = pipRect.x() +
+ video_x = pipRect.x() +
(pipRect.width() - img.width()) / 2;
else
video_x = pipRect.x();
-
+
p->drawImage(video_x, video_y, img);
}
}
@@ -257,8 +264,8 @@
parentWidget->winId(), &rect);
}
- if (useNullVideo || !ok)
- {
+ if (useNullVideo || !ok)
+ {
SetNVP(NULL);
useNullVideo = true;
ok = CreateNVP(tv, NULL, desiredState,
@@ -270,7 +277,7 @@
/**
- * \brief stop NVP but pause the ringbuffer. used in PIP/PBP swap or
+ * \brief stop NVP but pause the ringbuffer. used in PIP/PBP swap or
* switching from PIP <-> PBP or enabling PBP
*/
@@ -450,7 +457,7 @@
{
_nvp->LoadExternalSubtitles(buffer->GetFilename());
}
-
+
if ((embedwinid > 0) && embedbounds)
{
_nvp->EmbedInWidget(
@@ -502,20 +509,20 @@
gContext->SaveSetting("AudioNag", 0);
if (kDialogCodeButton2 == ret)
gContext->SetSetting("AudioNag", 0);
- else if ((kDialogCodeButton3 == ret) ||
+ else if ((kDialogCodeButton3 == ret) ||
(kDialogCodeRejected == ret))
{
return false;
} */
}
-
+
}
else if (pipState == kPBPRight)
nvp->SetMuted(true);
int maxWait = -1;
//if (isPIP())
- // maxWait = 1000;
+ // maxWait = 1000;
return StartDecoderThread(maxWait);
}
@@ -634,7 +641,7 @@
// This method builds the stack of previous channels
QString curChan = tvchain->GetChannelName(-1);
- if (prevChan.size() == 0 ||
+ if (prevChan.size() == 0 ||
curChan != prevChan[prevChan.size() - 1])
{
QString chan = curChan;
@@ -789,7 +796,7 @@
{
filters = chanFilters;
}
- else
+ else
{
if (!filters.isEmpty() && (filters.right(1) != ","))
filters += ",";
Index: libs/libmythtv/tv_play.cpp
===================================================================
--- libs/libmythtv/tv_play.cpp (revision 20006)
+++ libs/libmythtv/tv_play.cpp (working copy)
@@ -55,6 +55,7 @@
#include "mythdialogbox.h"
#include "mythmainwindow.h"
#include "mythscreenstack.h"
+#include "tvosdmenuentry.h"
#ifndef HAVE_ROUND
#define round(x) ((int) ((x) + 0.5))
@@ -687,7 +688,7 @@
//Recorder switching info
switchToRec(NULL),
// OSD info
- treeMenu(NULL), udpnotify(NULL),
+ treeMenu(NULL), osdMenuEntries(NULL), udpnotify(NULL),
// LCD Info
lcdTitle(""), lcdSubtitle(""), lcdCallsign(""),
// Window info (GUI is optional, transcoding, preview img, etc)
@@ -749,6 +750,8 @@
sleep_times.push_back(SleepTimerInfo(QObject::tr("1h30m"), 90*60));
sleep_times.push_back(SleepTimerInfo(QObject::tr("2h"), 120*60));
+ osdMenuEntries = new TVOSDMenuEntryList();
+
gContext->addListener(this);
gContext->addCurrentLocation("Playback");
@@ -948,6 +951,9 @@
pthread_detach(ddMapLoader);
}
}
+
+ if (osdMenuEntries)
+ delete osdMenuEntries;
PlayerContext *mctx = GetPlayerWriteLock(0, __FILE__, __LINE__);
while (!player.empty())
@@ -1736,6 +1742,8 @@
SET_NEXT();
}
else if (TRANSITION(kState_None, kState_WatchingPreRecorded) ||
+ TRANSITION(kState_None, kState_WatchingVideo) ||
+ TRANSITION(kState_None, kState_WatchingDVD) ||
TRANSITION(kState_None, kState_WatchingRecording))
{
ctx->LockPlayingInfo(__FILE__, __LINE__);
@@ -1809,6 +1817,8 @@
}
}
else if (TRANSITION(kState_WatchingPreRecorded, kState_None) ||
+ TRANSITION(kState_WatchingVideo, kState_None) ||
+ TRANSITION(kState_WatchingDVD, kState_None) ||
TRANSITION(kState_WatchingRecording, kState_None))
{
SET_NEXT();
@@ -9499,6 +9509,7 @@
void TV::ShowOSDTreeMenu(const PlayerContext *ctx)
{
+ int osdMenuCount = osdMenuEntries->GetCount();
if (treeMenu)
{
for (uint i = 0; i < player.size(); i++)
@@ -9513,7 +9524,13 @@
treeMenu = new OSDGenericTree(NULL, "treeMenu");
- FillOSDTreeMenu(ctx, treeMenu);
+ QListIterator cm = osdMenuEntries->GetIterator();
+ while(cm.hasNext())
+ {
+ TVOSDMenuEntry *entry = cm.next();
+ if (entry->GetEntry(GetState(ctx)) > 0)
+ FillOSDTreeMenu(ctx, treeMenu, entry->GetCategory());
+ }
OSDListTreeType *tree = NULL;
@@ -9521,7 +9538,13 @@
OSD *osd = GetOSDLock(ctx);
if (osd)
- tree = osd->ShowTreeMenu("menu", treeMenu);
+ {
+ // something is wrong with reading osd menu DB table
+ if (osdMenuCount == 0)
+ osd->SetSettingsText("Cannot Display OSD Menu", 5);
+ else
+ tree = osd->ShowTreeMenu("menu", treeMenu);
+ }
ReturnOSDLock(ctx, osd);
if (tree)
@@ -9539,25 +9562,13 @@
}
void TV::FillOSDTreeMenu(
- const PlayerContext *ctx, OSDGenericTree *treeMenu) const
+ const PlayerContext *ctx, OSDGenericTree *treeMenu,
+ QString category) const
{
- new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
-
- FillMenuPxP(ctx, treeMenu);
-
- TVState state = GetState(ctx);
- bool liveTV = StateIsLiveTV(state);
- bool playingRec = StateIsPlaying(state);
- bool playingDVD = playingRec && ctx->buffer && ctx->buffer->isDVD();
bool mainCtx = ctx == GetPlayer(ctx, 0);
-
- if (liveTV)
+ // DVD menu stuff first
+ if (category == "DVD")
{
- FillMenuInputSwitching(ctx, treeMenu);
- new OSDGenericTree(treeMenu, tr("Edit Channel"), "TOGGLEEDIT");
- }
- else if (playingDVD)
- {
new OSDGenericTree(
treeMenu, tr("DVD Root Menu"), "JUMPTODVDROOTMENU");
new OSDGenericTree(
@@ -9565,126 +9576,157 @@
new OSDGenericTree(
treeMenu, tr("DVD Chapter Menu"), "JUMPTODVDCHAPTERMENU");
}
- else if (playingRec && mainCtx)
+ else if (category == "GUIDE")
+ new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
+ else if (category == "PIP")
+ FillMenuPxP(ctx, treeMenu);
+ else if (category == "INPUTSWITCHING")
+ FillMenuInputSwitching(ctx, treeMenu);
+ else if (category == "EDITCHANNEL")
+ new OSDGenericTree(treeMenu, tr("Edit Channel"), "TOGGLEEDIT");
+ else if (category == "EDITRECORDING")
+ new OSDGenericTree(treeMenu, tr("Edit Recording"), "TOGGLEEDIT");
+ else if (category == "JUMPREC")
{
- new OSDGenericTree(treeMenu, tr("Edit Recording"), "TOGGLEEDIT");
+ OSDGenericTree *jtp_item =
+ new OSDGenericTree(treeMenu, tr("Jump to Program"));
+ new OSDGenericTree(jtp_item, tr("Recorded Program"), "JUMPREC");
+ if (lastProgram != NULL)
+ new OSDGenericTree(jtp_item, lastProgram->title, "JUMPPREV");
}
-
- OSDGenericTree *jtp_item =
- new OSDGenericTree(treeMenu, tr("Jump to Program"));
- new OSDGenericTree(jtp_item, tr("Recorded Program"), "JUMPREC");
- if (lastProgram != NULL)
- new OSDGenericTree(jtp_item, lastProgram->title, "JUMPPREV");
-
- if (liveTV)
+ else if (category == "TOGGLEBROWSE")
{
if (!db_browse_always)
{
new OSDGenericTree(
treeMenu, tr("Enable Browse Mode"), "TOGGLEBROWSE");
}
+ }
+ else if ( category == "PREVCHAN")
new OSDGenericTree(treeMenu, tr("Previous Channel"), "PREVCHAN");
- }
- else if (playingRec && !playingDVD)
- FillMenuPlaying(ctx, treeMenu);
- FillMenuTracks(ctx, treeMenu, kTrackTypeAudio);
- FillMenuTracks(ctx, treeMenu, kTrackTypeSubtitle);
- FillMenuTracks(ctx, treeMenu, kTrackTypeCC708);
+ FillMenuPlaying(ctx, treeMenu, category);
- if (VBIMode::NTSC_CC == vbimode)
- FillMenuTracks(ctx, treeMenu, kTrackTypeCC608);
- else if (VBIMode::PAL_TT == vbimode)
+ if (category == "AUDIOTRACKS")
+ FillMenuTracks(ctx, treeMenu, kTrackTypeAudio);
+ else if (category == "SUBTITLETRACKS")
+ FillMenuTracks(ctx, treeMenu, kTrackTypeSubtitle);
+ else if (category == "CCTRACKS")
{
- new OSDGenericTree(
- treeMenu, tr("Toggle Teletext Captions"), "TOGGLETTC");
- new OSDGenericTree(
- treeMenu, tr("Toggle Teletext Menu"), "TOGGLETTM");
- FillMenuTracks(ctx, treeMenu, kTrackTypeTeletextCaptions);
+ FillMenuTracks(ctx, treeMenu, kTrackTypeCC708);
+ if (VBIMode::NTSC_CC == vbimode)
+ FillMenuTracks(ctx, treeMenu, kTrackTypeCC608);
+ else if (VBIMode::PAL_TT == vbimode)
+ {
+ new OSDGenericTree(
+ treeMenu, tr("Toggle Teletext Captions"), "TOGGLETTC");
+ new OSDGenericTree(
+ treeMenu, tr("Toggle Teletext Menu"), "TOGGLETTM");
+ FillMenuTracks(ctx, treeMenu, kTrackTypeTeletextCaptions);
+ }
}
if (mainCtx)
{
- FillMenuVideoAspect(ctx, treeMenu);
- FillMenuAdjustFill(ctx, treeMenu);
- new OSDGenericTree(treeMenu, tr("Manual Zoom Mode"), "TOGGLEMANUALZOOM");
- FillMenuAdjustPicture(ctx, treeMenu);
+ if (category == "VIDEOASPECT")
+ FillMenuVideoAspect(ctx, treeMenu);
+ else if (category == "ADJUSTFILL")
+ FillMenuAdjustFill(ctx, treeMenu);
+ else if (category == "MANUAL_ZOOM")
+ new OSDGenericTree(treeMenu, tr("Manual Zoom Mode"), "TOGGLEMANUALZOOM");
+ else if (category == "ADJUSTPICTURE")
+ FillMenuAdjustPicture(ctx, treeMenu);
}
- new OSDGenericTree(treeMenu, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
- FillMenuTimeStretch(ctx, treeMenu);
- FillMenuVideoScan(ctx, treeMenu);
- FillMenuSleepMode(ctx, treeMenu);
+ if (category == "AUDIOSYNC")
+ new OSDGenericTree(treeMenu, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
+ else if (category == "TIMESTRETCH")
+ FillMenuTimeStretch(ctx, treeMenu);
+ else if (category == "VIDEOSCAN")
+ FillMenuVideoScan(ctx, treeMenu);
+ else if (category == "SLEEP")
+ FillMenuSleepMode(ctx, treeMenu);
}
void TV::FillMenuPlaying(
- const PlayerContext *ctx, OSDGenericTree *treeMenu) const
+ const PlayerContext *ctx, OSDGenericTree *treeMenu,
+ QString category) const
{
ctx->LockPlayingInfo(__FILE__, __LINE__);
- if (JobQueue::IsJobQueuedOrRunning(
+ if (category == "TRANSCODE")
+ {
+ if (JobQueue::IsJobQueuedOrRunning(
JOB_TRANSCODE, ctx->playingInfo->chanid,
ctx->playingInfo->startts))
- {
- new OSDGenericTree(treeMenu, tr("Stop Transcoding"), "QUEUETRANSCODE");
- }
- else
- {
- OSDGenericTree *bt_item =
- new OSDGenericTree(treeMenu, tr("Begin Transcoding"));
- new OSDGenericTree(bt_item, tr("Default"),
- "QUEUETRANSCODE");
- new OSDGenericTree(bt_item, tr("Autodetect"),
+ {
+ new OSDGenericTree(treeMenu, tr("Stop Transcoding"), "QUEUETRANSCODE");
+ }
+ else
+ {
+ OSDGenericTree *bt_item =
+ new OSDGenericTree(treeMenu, tr("Begin Transcoding"));
+ new OSDGenericTree(bt_item, tr("Default"),
+ "QUEUETRANSCODE");
+ new OSDGenericTree(bt_item, tr("Autodetect"),
"QUEUETRANSCODE_AUTO");
- new OSDGenericTree(bt_item, tr("High Quality"),
+ new OSDGenericTree(bt_item, tr("High Quality"),
"QUEUETRANSCODE_HIGH");
- new OSDGenericTree(bt_item, tr("Medium Quality"),
+ new OSDGenericTree(bt_item, tr("Medium Quality"),
"QUEUETRANSCODE_MEDIUM");
- new OSDGenericTree(bt_item, tr("Low Quality"),
+ new OSDGenericTree(bt_item, tr("Low Quality"),
"QUEUETRANSCODE_LOW");
+ }
}
- OSDGenericTree *cas_item =
- new OSDGenericTree(treeMenu, tr("Commercial Auto-Skip"));
- uint cas_ord[] = { 0, 2, 1 };
+ else if (category == "COMMSKIP")
+ {
+ OSDGenericTree *cas_item =
+ new OSDGenericTree(treeMenu, tr("Commercial Auto-Skip"));
+ uint cas_ord[] = { 0, 2, 1 };
- ctx->LockDeleteNVP(__FILE__, __LINE__);
- CommSkipMode cur = kCommSkipOff;
- if (ctx->nvp)
- cur = ctx->nvp->GetAutoCommercialSkip();
- ctx->UnlockDeleteNVP(__FILE__, __LINE__);
+ ctx->LockDeleteNVP(__FILE__, __LINE__);
+ CommSkipMode cur = kCommSkipOff;
+ if (ctx->nvp)
+ cur = ctx->nvp->GetAutoCommercialSkip();
+ ctx->UnlockDeleteNVP(__FILE__, __LINE__);
- for (uint i = 0; i < sizeof(cas_ord)/sizeof(uint); i++)
- {
- const CommSkipMode mode = (CommSkipMode) cas_ord[i];
- new OSDGenericTree(
- cas_item, toString(mode),
- QString("TOGGLECOMMSKIP%1").arg(cas_ord[i]),
- (mode == cur) ? 1 : 0, NULL, "COMMSKIPGROUP");
+ for (uint i = 0; i < sizeof(cas_ord)/sizeof(uint); i++)
+ {
+ const CommSkipMode mode = (CommSkipMode) cas_ord[i];
+ new OSDGenericTree(
+ cas_item, toString(mode),
+ QString("TOGGLECOMMSKIP%1").arg(cas_ord[i]),
+ (mode == cur) ? 1 : 0, NULL, "COMMSKIPGROUP");
+ }
}
- if (ctx->playingInfo->GetAutoExpireFromRecorded())
+ else if (category == "TOGGLEEXPIRE")
{
- new OSDGenericTree(
- treeMenu, tr("Turn Auto-Expire OFF"), "TOGGLEAUTOEXPIRE");
+ if (ctx->playingInfo->GetAutoExpireFromRecorded())
+ {
+ new OSDGenericTree(
+ treeMenu, tr("Turn Auto-Expire OFF"), "TOGGLEAUTOEXPIRE");
+ }
+ else
+ {
+ new OSDGenericTree(
+ treeMenu, tr("Turn Auto-Expire ON"), "TOGGLEAUTOEXPIRE");
+ }
}
- else
+
+ ctx->UnlockPlayingInfo(__FILE__, __LINE__);
+
+ if (category == "SCHEDULERECORDING")
{
+ OSDGenericTree *sr_item =
+ new OSDGenericTree(treeMenu, tr("Schedule Recordings"));
+ new OSDGenericTree(
+ sr_item, tr("Upcoming Recordings"), "VIEWSCHEDULED");
new OSDGenericTree(
- treeMenu, tr("Turn Auto-Expire ON"), "TOGGLEAUTOEXPIRE");
+ sr_item, tr("Program Finder"), "FINDER");
+ new OSDGenericTree(
+ sr_item, tr("Edit Recording Schedule"), "SCHEDULE");
}
-
- ctx->UnlockPlayingInfo(__FILE__, __LINE__);
-
- OSDGenericTree *sr_item =
- new OSDGenericTree(treeMenu, tr("Schedule Recordings"));
- new OSDGenericTree(
- sr_item, tr("Program Guide"), "GUIDE");
- new OSDGenericTree(
- sr_item, tr("Upcoming Recordings"), "VIEWSCHEDULED");
- new OSDGenericTree(
- sr_item, tr("Program Finder"), "FINDER");
- new OSDGenericTree(
- sr_item, tr("Edit Recording Schedule"), "SCHEDULE");
}
/// \brief Constructs Picture-X-Picture portion of menu
@@ -11238,5 +11280,4 @@
ctx = NULL;
}
-
/* vim: set expandtab tabstop=4 shiftwidth=4: */
Index: libs/libmythtv/tvosdmenuentry.cpp
===================================================================
--- libs/libmythtv/tvosdmenuentry.cpp (revision 0)
+++ libs/libmythtv/tvosdmenuentry.cpp (revision 0)
@@ -0,0 +1,316 @@
+#include "tvosdmenuentry.h"
+#include "libmyth/mythcontext.h"
+#include "libmythdb/mythdb.h"
+#include "libmythdb/mythverbose.h"
+#define LOC QString("OSDMenuEntry:")
+#define LOC_ERR QString("OSDMenuEntry Error:")
+
+/**\class TVOSDMenuEntry
+ * \brief Holds information on which tv state one can view
+ * a tv osd menu option. There are 4 states. LiveTV, prerecorded , Video,
+ * and DVD. Values can be directly edited in the tvosdmenu table
+ * or through the TV OSD Menu Editor
+ */
+
+/**
+ * \brief returns the contents of the osd menu entry
+ * in the form of a qstringlist
+ */
+QStringList TVOSDMenuEntry::GetData(void)
+{
+ QStringList values;
+ values << category
+ << QString("%1").arg(livetv)
+ << QString("%1").arg(recorded)
+ << QString("%1").arg(video)
+ << QString("%1").arg(dvd)
+ << description;
+ return values;
+}
+
+/**
+ * \brief returns whether or not this osd menu entry
+ * should be displayed in the mentioned TVState
+ * return -1 if not applicable to the TVState provided
+ */
+int TVOSDMenuEntry::GetEntry(TVState state)
+{
+ switch (state)
+ {
+ case kState_WatchingLiveTV:
+ return livetv;
+ case kState_WatchingPreRecorded:
+ return recorded;
+ case kState_WatchingRecording:
+ return recorded;
+ case kState_WatchingVideo:
+ return video;
+ case kState_WatchingDVD:
+ return dvd;
+ default:
+ return -1;
+ }
+
+ return -1;
+}
+
+/**
+ * \brief update the OSD Menu Entry livetv, recorded, video and
+ * dvd settings
+ */
+void TVOSDMenuEntry::UpdateEntry(int livetv_setting, int recorded_setting,
+ int video_setting, int dvd_setting)
+{
+ QMutexLocker locker(&updateEntryLock);
+ livetv = livetv_setting;
+ recorded = recorded_setting;
+ video = video_setting;
+ dvd = dvd_setting;
+}
+
+/**
+ * \brief update the tv state option in the tv osd menu entry
+ */
+void TVOSDMenuEntry::UpdateEntry(int change, TVState state)
+{
+ QMutexLocker locker(&updateEntryLock);
+ switch (state)
+ {
+ case kState_WatchingLiveTV:
+ livetv = change;
+ break;
+ case kState_WatchingPreRecorded:
+ recorded = change;
+ break;
+ case kState_WatchingVideo:
+ video = change;
+ break;
+ case kState_WatchingDVD:
+ dvd = change;
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * \brief save the entry to the tvosdmenu table
+ */
+void TVOSDMenuEntry::UpdateDBEntry(void)
+{
+ QMutexLocker locker(&updateEntryLock);
+ MSqlQuery query(MSqlQuery::InitCon());
+ if (!query.isConnected())
+ return;
+
+ query.prepare( " UPDATE tvosdmenu "
+ " SET livetv = :LIVETV, recorded = :RECORDED, "
+ " video = :VIDEO, dvd = :DVD "
+ " WHERE osdcategory = :OSDCATEGORY;");
+
+ query.bindValue(":LIVETV", QString("%1").arg(livetv));
+ query.bindValue(":RECORDED", QString("%1").arg(recorded));
+ query.bindValue(":VIDEO", QString("%1").arg(video));
+ query.bindValue(":DVD", QString("%1").arg(dvd));
+ query.bindValue(":OSDCATEGORY", QString("%1").arg(category));
+
+ if (!query.exec())
+ MythDB::DBError(LOC + "UpdateDBEntry", query);
+}
+
+/**
+ * \brief add the tv osd menu entry to the tvosdmenu db table
+ */
+void TVOSDMenuEntry::CreateDBEntry(void)
+{
+ QMutexLocker locker(&updateEntryLock);
+ MSqlQuery query(MSqlQuery::InitCon());
+ if (!query.isConnected())
+ return;
+
+ query.prepare( "INSERT IGNORE INTO tvosdmenu "
+ " (osdcategory, livetv, recorded, "
+ " video, dvd, description) "
+ " VALUES ( :OSDCATEGORY, :LIVETV, "
+ " :RECORDED, :VIDEO, :DVD, :DESCRIPTION);");
+
+ query.bindValue(":OSDCATEGORY", category);
+ query.bindValue(":LIVETV", QString("%1").arg(livetv));
+ query.bindValue(":RECORDED", QString("%1").arg(recorded));
+ query.bindValue(":VIDEO", QString("%1").arg(video));
+ query.bindValue(":DVD", QString("%1").arg(dvd));
+ query.bindValue(":DESCRIPTION", description);
+
+ if (!query.exec())
+ MythDB::DBError(LOC + "CreateDBEntry", query);
+}
+
+TVOSDMenuEntryList::TVOSDMenuEntryList(void)
+{
+ InitDefaultEntries();
+}
+
+TVOSDMenuEntryList::~TVOSDMenuEntryList(void)
+{
+ if (curMenuEntries.isEmpty())
+ return;
+ while (!curMenuEntries.isEmpty())
+ delete curMenuEntries.takeFirst();
+}
+
+bool TVOSDMenuEntryList::ShowOSDMenuOption(QString category, TVState state)
+{
+ TVOSDMenuEntry *entry = FindEntry(category);
+ if (!entry)
+ return false;
+ return (entry->GetEntry(state) > 0);
+}
+
+TVOSDMenuEntry *TVOSDMenuEntryList::FindEntry(QString category)
+{
+ TVOSDMenuEntry *entry = NULL;
+ QListIterator cm = GetIterator();
+ while(cm.hasNext())
+ {
+ entry = cm.next();
+ if (category.compare(entry->GetCategory()) == 0)
+ return entry;
+ }
+ return NULL;
+}
+
+
+/* \brief List default settings for the osd menu. settings are as follows:
+* -1: not allowed.
+* 0: disabled, can be enabled through osd menu editor,
+* 1: active by default
+*/
+void TVOSDMenuEntryList::InitDefaultEntries(void)
+{
+ curMenuEntries.append(
+ new TVOSDMenuEntry("DVD", -1, -1, -1, 1, "DVD Menu"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("GUIDE", 1, 1, 0, 0, "Program Guide"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("PIP", 1, 1, 1, -1, "Picture-in-Picture"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("INPUTSWITCHING", 1, -1, -1, -1, "Change TV Input"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("EDITCHANNEL", 1, -1, -1, -1, "Edit Channel"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("EDITRECORDING", -1, 1, -1, -1, "Edit Recording"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("JUMPREC", 1, 1, 1, 0, "List of Recorded Shows"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("TOGGLEBROWSE", 1, -1, -1, -1, "Live TV Browse Mode"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("PREVCHAN", 1, -1, -1, -1, "Previous TV Channel"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("TRANSCODE", 1, 1, -1, -1, "Transcode Show"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("COMMSKIP", 1, 1, 0, -1, "Commercial Skip"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("TOGGLEEXPIRE", 1, 1, -1, -1, "Toggle Expire"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("SCHEDULEREC", 1, 1, 0, 0, "Schedule Recordings"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("AUDIOTRACKS", 1, 1, 1, 1, "Audio Tracks"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("SUBTITLETRACKS", 1, 1, 1, 1, "Subtitle Tracks"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("CCTRACKS", 1, 1, 1, 1, "Closed Caption Tracks"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("VIDEOASPECT", 1, 1, 1, 1, "Video Aspect"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("ADJUSTFILL", 1, 1, 1, 1, "Adjust Fill"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("MANUALZOOM", 1, 1, 1, 1, "Manual Zoom"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("ADJUSTPICTURE", 1, 1, 1, 1, "Adjust Picture"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("AUDIOSYNC", 1, 1, 1, 1 , "Audio Sync"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("TIMESTRETCH", 1, 1, 1, 1, "Time Stretch"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("VIDEOSCAN", 1, 1, 1, 1, "Video Scan"));
+ curMenuEntries.append(
+ new TVOSDMenuEntry("SLEEP", 1, 1, 1, 1, "Sleep"));
+
+ GetEntriesFromDB();
+ if (GetCount() != curMenuEntries.count())
+ UpdateDB();
+}
+
+int TVOSDMenuEntryList::GetCount(void)
+{
+ MSqlQuery query(MSqlQuery::InitCon());
+ if (!query.isConnected())
+ return curMenuEntries.count();
+
+ query.prepare ("SELECT COUNT(osdcategory) FROM tvosdmenu;");
+ if (query.exec() && query.isActive() && query.size() > 0)
+ {
+ query.next();
+ return query.value(0).toUInt();
+ }
+
+ MythDB::DBError(LOC + "GetCount()", query);
+ return 0;
+}
+
+void TVOSDMenuEntryList::GetEntriesFromDB(void)
+{
+ MSqlQuery query(MSqlQuery::InitCon());
+ if (!query.isConnected())
+ return;
+
+ TVOSDMenuEntry *entry = NULL;
+ QString osdcategory;
+ QListIterator cm = GetIterator();
+ while (cm.hasNext())
+ {
+ entry = cm.next();
+ osdcategory = entry->GetCategory();
+ query.prepare("SELECT livetv, recorded, video, dvd "
+ "FROM tvosdmenu WHERE osdcategory = :OSDCATEGORY;");
+ query.bindValue(":OSDCATEGORY", osdcategory);
+
+ if (query.exec() && query.isActive() && query.size() == 1)
+ {
+ query.next();
+ entry->UpdateEntry(query.value(0).toInt(),
+ query.value(1).toInt(),
+ query.value(2).toInt(),
+ query.value(3).toInt());
+ }
+ }
+}
+
+void TVOSDMenuEntryList::UpdateDB(void)
+{
+ MSqlQuery query(MSqlQuery::InitCon());
+ if (!query.isConnected())
+ return;
+
+ TVOSDMenuEntry *entry = NULL;
+ QString osdcategory;
+ QListIterator cm = GetIterator();
+ while (cm.hasNext())
+ {
+ entry = cm.next();
+ osdcategory = entry->GetCategory();
+ query.prepare("SELECT osdcategory FROM tvosdmenu "
+ "WHERE osdcategory = :OSDCATEGORY;");
+ query.bindValue(":OSDCATEGORY", osdcategory);
+ if (query.exec() && query.isActive() && query.size() > 0)
+ entry->UpdateDBEntry();
+ else
+ entry->CreateDBEntry();
+ }
+}
+
+
+QListIterator TVOSDMenuEntryList::GetIterator(void)
+{
+ return QListIterator(curMenuEntries);
+}
Index: libs/libmythtv/tv.cpp
===================================================================
--- libs/libmythtv/tv.cpp (revision 20006)
+++ libs/libmythtv/tv.cpp (working copy)
@@ -9,20 +9,42 @@
* \brief Returns a human readable QString representing a TVState.
* \param state State to print.
*/
-QString StateToString(TVState state)
+QString StateToString(TVState state, bool brief)
{
+ bool appendWatching = false;
QString statestr = QString("Unknown(%1)").arg((int)state);
switch (state) {
case kState_Error: statestr = "Error"; break;
case kState_None: statestr = "None"; break;
- case kState_WatchingLiveTV: statestr = "WatchingLiveTV"; break;
+ case kState_WatchingLiveTV:
+ statestr = "WatchingLiveTV";
+ appendWatching = true;
+ break;
case kState_WatchingPreRecorded:
- statestr = "WatchingPreRecorded"; break;
- case kState_WatchingRecording: statestr = "WatchingRecording"; break;
- case kState_RecordingOnly: statestr = "RecordingOnly"; break;
+ statestr = "WatchingPreRecorded";
+ appendWatching = true;
+ break;
+ case kState_WatchingVideo:
+ statestr = "Video";
+ appendWatching = true;
+ break;
+ case kState_WatchingDVD:
+ statestr = "DVD";
+ appendWatching = true;
+ break;
+ case kState_WatchingRecording:
+ statestr = "WatchingRecording";
+ appendWatching = true;
+ break;
+ case kState_RecordingOnly:
+ statestr = "RecordingOnly";
+ appendWatching = true;
+ break;
case kState_ChangingState: statestr = "ChangingState"; break;
}
statestr.detach();
+ if (!brief && appendWatching)
+ statestr.prepend("Watching ");
return statestr;
}
Index: programs/mythfrontend/main.cpp
===================================================================
--- programs/mythfrontend/main.cpp (revision 20006)
+++ programs/mythfrontend/main.cpp (working copy)
@@ -61,6 +61,7 @@
#include "mythcontrols.h"
#include "mythuihelper.h"
#include "mythdirs.h"
+#include "mythosdmenueditor.h"
static ExitPrompter *exitPopup = NULL;
static MythThemedMenu *menu;
@@ -142,6 +143,18 @@
delete mythcontrols;
}
+void startOSDMenuEditor(void)
+{
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+
+ MythOSDMenuEditor *mythosdmenueditor =
+ new MythOSDMenuEditor(mainStack, "mythosdmenueditor");
+
+ if (mythosdmenueditor->Create())
+ mainStack->AddScreen(mythosdmenueditor);
+}
+
+
void startGuide(void)
{
uint chanid = 0;
@@ -458,6 +471,10 @@
{
startAppearWiz();
}
+ else if (sel == "osdmenueditor")
+ {
+ startOSDMenuEditor();
+ }
else if (sel == "setup_keys")
{
startKeysSetup();
Index: programs/mythfrontend/mythosdmenueditor.h
===================================================================
--- programs/mythfrontend/mythosdmenueditor.h (revision 0)
+++ programs/mythfrontend/mythosdmenueditor.h (revision 0)
@@ -0,0 +1,45 @@
+#ifndef MYTHOSDMENUEDITOR_H
+#define MYTHOSDMENUEDITOR_H
+
+#include "mythscreentype.h"
+#include "tv.h"
+//#include "tvosdmenuentry.h"
+
+class MythUIButtonList;
+class MythUIButton;
+class TVOSDMenuEntryList;
+
+class MythOSDMenuEditor : public MythScreenType
+{
+ Q_OBJECT
+
+ public:
+ MythOSDMenuEditor(MythScreenStack *parent, const char *name);
+ ~MythOSDMenuEditor();
+
+ bool Create(void);
+ bool keyPressEvent(QKeyEvent *);
+
+ private:
+ TVOSDMenuEntryList *m_menuEntryList;
+
+ static TVState WatchingLiveTV;
+ static TVState WatchingPreRecorded;
+ static TVState WatchingVideo;
+ static TVState WatchingDVD;
+
+ MythUIButtonList *m_states;
+ MythUIButtonList *m_categories;
+ MythUIButton *m_doneButton;
+ TVState m_tvstate;
+
+ void updateCategoryList(bool active = true);
+ bool moveUpOrDown(QString direction);
+ void moveRightOrLeft(QString direction);
+
+ private slots:
+ void slotStateChanged(MythUIButtonListItem *item);
+ void slotToggleItem(MythUIButtonListItem *item);
+};
+
+#endif
Index: programs/mythfrontend/mythfrontend.pro
===================================================================
--- programs/mythfrontend/mythfrontend.pro (revision 20006)
+++ programs/mythfrontend/mythfrontend.pro (working copy)
@@ -26,6 +26,7 @@
HEADERS += mediarenderer.h mythfexml.h playbackboxlistitem.h
HEADERS += mythappearance.h exitprompt.h proglist.h
HEADERS += action.h mythcontrols.h keybindings.h keygrabber.h
+HEADERS += mythosdmenueditor.h
SOURCES += main.cpp playbackbox.cpp viewscheduled.cpp
SOURCES += globalsettings.cpp manualschedule.cpp programrecpriority.cpp
@@ -33,7 +34,7 @@
SOURCES += mediarenderer.cpp mythfexml.cpp playbackboxlistitem.cpp
SOURCES += custompriority.cpp mythappearance.cpp exitprompt.cpp proglist.cpp
SOURCES += action.cpp actionset.cpp mythcontrols.cpp keybindings.cpp
-SOURCES += keygrabber.cpp
+SOURCES += keygrabber.cpp mythosdmenueditor.cpp
macx {
mac_bundle {
Index: programs/mythfrontend/mythosdmenueditor.cpp
===================================================================
--- programs/mythfrontend/mythosdmenueditor.cpp (revision 0)
+++ programs/mythfrontend/mythosdmenueditor.cpp (revision 0)
@@ -0,0 +1,243 @@
+#define MYTHOSDMENUEDITOR_CPP
+
+/* QT includes */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* MythTV includes */
+#include "mythcontext.h"
+#include "mythdbcon.h"
+#include "mythmainwindow.h"
+#include "myththemebase.h"
+#include "mythuibuttonlist.h"
+#include "mythuibutton.h"
+#include "mythosdmenueditor.h"
+#include "tvosdmenuentry.h"
+
+
+using namespace std;
+
+/* Static data members */
+TVState MythOSDMenuEditor::WatchingLiveTV = kState_WatchingLiveTV;
+TVState MythOSDMenuEditor::WatchingPreRecorded = kState_WatchingPreRecorded;
+TVState MythOSDMenuEditor::WatchingVideo = kState_WatchingVideo;
+TVState MythOSDMenuEditor::WatchingDVD = kState_WatchingDVD;
+
+Q_DECLARE_METATYPE(TVState*)
+
+
+MythOSDMenuEditor::MythOSDMenuEditor(MythScreenStack *parent, const char *name)
+ : MythScreenType(parent, name), m_menuEntryList(NULL), m_states(NULL),
+ m_categories(NULL), m_doneButton(NULL), m_tvstate(WatchingLiveTV)
+{
+ m_menuEntryList = new TVOSDMenuEntryList();
+}
+
+MythOSDMenuEditor::~MythOSDMenuEditor() {
+ m_menuEntryList->UpdateDB();
+ delete m_menuEntryList;
+}
+
+void MythOSDMenuEditor::updateCategoryList(bool active)
+{
+ QString state_name = (active)? "entrycolors" : "inactivecolors";
+
+ m_categories->Reset();
+ QListIterator cm = m_menuEntryList->GetIterator();
+ while(cm.hasNext())
+ {
+ TVOSDMenuEntry *entry = cm.next();
+ MythUIButtonListItem::CheckState checked =
+ MythUIButtonListItem::NotChecked;
+ int enable_entry = entry->GetEntry(m_tvstate);
+ QString entry_state = "inactive";
+ if (enable_entry > 0)
+ {
+ checked = MythUIButtonListItem::FullChecked;
+ if (active)
+ entry_state = "active";
+ }
+ if (enable_entry > -1)
+ {
+ MythUIButtonListItem *item =
+ new MythUIButtonListItem(m_categories, entry->GetDescription(),
+ 0, true, checked);
+ item->SetData(qVariantFromValue(entry));
+ item->DisplayState(entry_state, state_name);
+ }
+ }
+}
+
+bool MythOSDMenuEditor::Create()
+{
+ bool foundtheme = false;
+
+ // Load the theme for this screen
+ foundtheme = LoadWindowFromXML("osdedit-ui.xml", "osdmenueditor", this);
+
+ if (!foundtheme)
+ return false;
+
+ bool err = false;
+ UIUtilE::Assign(this, m_states, "states", &err);
+ UIUtilE::Assign(this, m_categories, "categories", &err);
+ UIUtilE::Assign(this, m_doneButton, "done", &err);
+
+ if (err)
+ {
+ VERBOSE(VB_IMPORTANT, "Cannot load screen 'MythOSDMenuEditor'");
+ return false;
+ }
+
+ m_doneButton->SetText("Return");
+
+ connect(m_doneButton, SIGNAL(Clicked()), this, SLOT(Close()));
+ connect(m_states, SIGNAL(itemSelected(MythUIButtonListItem*)),
+ this, SLOT(slotStateChanged(MythUIButtonListItem*)));
+ connect(m_categories, SIGNAL(itemClicked(MythUIButtonListItem*)),
+ this, SLOT(slotToggleItem(MythUIButtonListItem*)));
+
+ if (!BuildFocusList())
+ VERBOSE(VB_IMPORTANT, "Failed to build a focuslist. Something is wrong");
+
+ MythUIButtonListItem* item = new MythUIButtonListItem(m_states, "Live TV");
+ item->SetData(qVariantFromValue(&WatchingLiveTV));
+
+ item = new MythUIButtonListItem(m_states, "Recorded TV");
+ item->SetData(qVariantFromValue(&WatchingPreRecorded));
+
+ item = new MythUIButtonListItem(m_states, "Video");
+ item->SetData(qVariantFromValue(&WatchingVideo));
+
+ item = new MythUIButtonListItem(m_states, "DVD");
+ item->SetData(qVariantFromValue(&WatchingDVD));
+
+ updateCategoryList(false);
+ SetFocusWidget(m_states);
+
+ return true;
+}
+
+bool MythOSDMenuEditor::keyPressEvent(QKeyEvent *event)
+{
+ if (GetFocusWidget()->keyPressEvent(event))
+ return true;
+
+ QStringList actions;
+ bool handled = false;
+
+ gContext->GetMainWindow()->TranslateKeyPress("Global", event, actions);
+
+ for (int i = 0; i < actions.size() && !handled; i++)
+ {
+ QString action = actions[i];
+ handled = true;
+
+ if (action == "RIGHT" || action == "LEFT")
+ moveRightOrLeft(action);
+ else if (action == "UP")
+ handled = moveUpOrDown("up");
+ else if (action == "DOWN")
+ handled = moveUpOrDown("down");
+ else
+ handled = false;
+ }
+
+ if (!handled && MythScreenType::keyPressEvent(event))
+ handled = true;
+
+ return handled;
+}
+
+bool MythOSDMenuEditor::moveUpOrDown(QString direction)
+{
+ MythUIButtonList *buttonlist = (MythUIButtonList *)GetFocusWidget();
+ int current_pos = buttonlist->GetCurrentPos();
+ int count = buttonlist->GetCount();
+ bool handled = true;
+ if (direction == "up" && current_pos == 0)
+ buttonlist->SetItemCurrent(count - 1);
+ else if (direction == "down" && current_pos == (count - 1))
+ buttonlist->SetItemCurrent(0);
+ else
+ handled = false;
+
+ return handled;
+}
+
+void MythOSDMenuEditor::moveRightOrLeft(QString direction)
+{
+ QString entry_state = "inactive";
+ MythUIType *widget = GetFocusWidget();
+ if (widget == m_categories)
+ {
+ if (direction == "LEFT")
+ SetFocusWidget(m_states);
+ else
+ SetFocusWidget(m_doneButton);
+ }
+ else if (widget == m_states)
+ {
+ if (direction == "LEFT")
+ SetFocusWidget(m_doneButton);
+ else
+ {
+ entry_state = "active";
+ SetFocusWidget(m_categories);
+ }
+ }
+ else if (widget == m_doneButton)
+ {
+ if (direction == "LEFT")
+ {
+ entry_state = "active";
+ SetFocusWidget(m_categories);
+ }
+ else
+ SetFocusWidget(m_states);
+ }
+
+ updateCategoryList(entry_state == "active");
+
+}
+
+void MythOSDMenuEditor::slotStateChanged(MythUIButtonListItem *item)
+{
+ TVState *state = qVariantValue(item->GetData());
+
+ if (state == NULL || *state == m_tvstate) return;
+ m_tvstate = *state;
+ updateCategoryList(false);
+
+}
+
+void MythOSDMenuEditor::slotToggleItem(MythUIButtonListItem *item)
+{
+
+ TVOSDMenuEntry *entry =
+ qVariantValue(item->GetData());
+
+ if (entry == NULL) return;
+
+ QString entry_state = "inactive";
+ int enable_entry = 0;
+ MythUIButtonListItem::CheckState entry_checkstate =
+ MythUIButtonListItem::NotChecked;
+ if (item->state() == MythUIButtonListItem::NotChecked)
+ {
+ enable_entry = 1;
+ entry_checkstate = MythUIButtonListItem::FullChecked;
+ entry_state = "active";
+ }
+
+ item->setChecked(entry_checkstate);
+ item->DisplayState(entry_state, "entrycolors");
+ entry->UpdateEntry(enable_entry, m_tvstate);
+}