Skip to content

Commit

Permalink
Allow default to last channel in Manual Record
Browse files Browse the repository at this point in the history
A new configuration option has been introduced to allow
the user to specify how the starting channel should be
set in a new Manual Record rule.

Setup -> General -> General

has a new line "Starting channel for Manual Record"
with a choice between "Guide Starting Channel" and
"Last Manual Record Channel". The default configuration
is "Guide Starting Channel" which provides the existing
behavior of always setting the starting channel to
DefaultTVChannel. This value is set at

Setup -> Video -> Program Guide -> Guide Starts at Channel

If the user chooses the new behavior, "Last Manual Record Channel",
then when a new Manual Record rule is started, the channel will
be initialized to the value used in the previous Manual Record
rule. The very first time a Manual Record rule is entered, there
will be no previously used channel, so it will default to
DefaultTVChannel.

With this implementation, the existing behavior will not
change unless the user requests "Last Manual Record Channel"
option. When they do pick "Last Manual Record Channel", the
new behavior will bring them joy.

Resolves #655
  • Loading branch information
SteveErl committed Nov 17, 2022
1 parent 67e1449 commit 7e389f1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
14 changes: 14 additions & 0 deletions mythtv/programs/mythfrontend/globalsettings.cpp
Expand Up @@ -2941,6 +2941,19 @@ static GlobalTextEditSetting *SortPrefixExceptions()
return gc;
}

static GlobalComboBoxSetting *ManualRecordStartChanType()
{
auto *gc = new GlobalComboBoxSetting("ManualRecordStartChanType");

gc->setLabel(GeneralSettings::tr("Starting channel for Manual Record"));
gc->addSelection(GeneralSettings::tr("Guide Starting Channel"), "1", true);
gc->addSelection(GeneralSettings::tr("Last Manual Record Channel"), "2");
gc->setHelpText(GeneralSettings::tr(
"When entering a new Manual Record Rule, "
"the starting channel will default to this."));
return gc;
}

// General RecPriorities settings

static GlobalComboBoxSetting *GRSchedOpenEnd()
Expand Down Expand Up @@ -4121,6 +4134,7 @@ MainGeneralSettings::MainGeneralSettings()
general->addChild(stripPrefixes);
stripPrefixes->addTargetedChild("1", SortPrefixExceptions());
}
general->addChild(ManualRecordStartChanType());
addChild(general);

addChild(EnableMediaMon());
Expand Down
31 changes: 22 additions & 9 deletions mythtv/programs/mythfrontend/manualschedule.cpp
Expand Up @@ -56,6 +56,8 @@ bool ManualSchedule::Create(void)

QString startchan = gCoreContext->GetSetting("DefaultTVChannel", "");
QString chanorder = gCoreContext->GetSetting("ChannelOrdering", "channum");
QString lastManualRecordChan = gCoreContext->GetSetting("LastManualRecordChan", startchan);
int manStartChanType = gCoreContext->GetNumSetting("ManualRecordStartChanType", 1);
ChannelInfoList channels = ChannelUtil::GetChannels(0, true, "channum,callsign");
ChannelUtil::SortChannels(channels, chanorder);

Expand All @@ -67,19 +69,27 @@ bool ManualSchedule::Create(void)
InfoMap infomap;
channels[i].ToMap(infomap);
item->SetTextFromMap(infomap);
if (channels[i].m_chanNum == startchan)
if (manStartChanType == 1)
{
m_channelList->SetItemCurrent(i);
startchan = "";
// Use DefaultTVChannel as starting channel
if (channels[i].m_chanNum == startchan)
{
m_channelList->SetItemCurrent(i);
startchan = "";
}
}
else
{
// Use LastManualRecordChan as starting channel
if (channels[i].m_chanNum == lastManualRecordChan)
{
m_channelList->SetItemCurrent(i);
lastManualRecordChan = "";
}
}
m_chanids.push_back(channels[i].m_chanId);
}

if (s_lastChannelIndex != -1)
{
m_channelList->SetItemCurrent(s_lastChannelIndex);
}

for (uint index = 0; index <= 60; index++)
{
QString dinfo = MythDate::toString(
Expand Down Expand Up @@ -213,7 +223,10 @@ void ManualSchedule::recordClicked(void)
m_chanids[m_channelList->GetCurrentPos()],
m_startDateTime, endts);

s_lastChannelIndex = m_channelList->GetCurrentPos();
// Save the channel because we might want to use it as the
// starting channel for the next Manual Record rule.
gCoreContext->SaveSetting("LastManualRecordChan",
ChannelUtil::GetChanNum(m_chanids[m_channelList->GetCurrentPos()]));

auto *record = new RecordingRule();
record->LoadByProgram(&p);
Expand Down
3 changes: 0 additions & 3 deletions mythtv/programs/mythfrontend/manualschedule.h
Expand Up @@ -60,9 +60,6 @@ class ManualSchedule : public MythScreenType
QString m_startString;
QString m_chanidString;

/// Index of channel used in the last Manual Schedule rule.
/** Special value -1 indicates there is no previous rule. */
inline static int s_lastChannelIndex = -1;
};

#endif

0 comments on commit 7e389f1

Please sign in to comment.