Skip to content

Commit

Permalink
Channel settings (HD,DAB,WX): Enable add button only if there are sub…
Browse files Browse the repository at this point in the history
…channels available. Channel listings: Ignore DAB ensemble, only list real channels.
  • Loading branch information
ksooo committed Apr 3, 2024
1 parent 3e8be30 commit d931bc9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ msgctxt "#30338"
msgid "%.1f MHz"
msgstr ""

msgctxt "#30339"
msgid "Add channels..."
msgstr ""

#
# 304XX - PVR Client implementation
#
Expand Down
26 changes: 13 additions & 13 deletions src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void enumerate_dabradio_channels(sqlite3* instance, enumerate_channels_callback

// frequency | channelnumber | subchannelnumber | name | logourl
auto sql = "select channel.frequency as frequency, namedchannel.number as channelnumber, "
"ifnull(subchannel.number, 0) as subchannelnumber, "
"ifnull(subchannel.number, -1) as subchannelnumber, "
"ifnull(subchannel.name, channel.name) as name, ifnull(subchannel.logourl, "
"channel.logourl) as logourl "
"from channel inner join namedchannel on channel.frequency = namedchannel.frequency "
Expand All @@ -523,18 +523,18 @@ void enumerate_dabradio_channels(sqlite3* instance, enumerate_channels_callback
// Execute the query and iterate over all returned rows
while (sqlite3_step(statement) == SQLITE_ROW)
{

struct channel item = {};
channelid channelid(sqlite3_column_int(statement, 0), sqlite3_column_int(statement, 2),
modulation::dab);

item.id = channelid.id();
item.channel = sqlite3_column_int(statement, 1);
item.subchannel = sqlite3_column_int(statement, 2);
item.name = reinterpret_cast<char const*>(sqlite3_column_text(statement, 3));
item.logourl = reinterpret_cast<char const*>(sqlite3_column_text(statement, 4));

callback(item); // Invoke caller-supplied callback
const int subchannel{sqlite3_column_int(statement, 2)};
if (subchannel >= 0) // skip the ensemble itself, only enumerate subchannels
{
struct channel item = {};
channelid channelid(sqlite3_column_int(statement, 0), subchannel, modulation::dab);
item.id = channelid.id();
item.channel = sqlite3_column_int(statement, 1);
item.subchannel = subchannel;
item.name = reinterpret_cast<char const*>(sqlite3_column_text(statement, 3));
item.logourl = reinterpret_cast<char const*>(sqlite3_column_text(statement, 4));
callback(item); // Invoke caller-supplied callback
}
}

sqlite3_finalize(statement); // Finalize the SQLite statement
Expand Down
17 changes: 15 additions & 2 deletions src/gui/channelsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,9 @@ void channelsettings::mux_data(struct muxscanner::multiplex const& muxdata)
m_channelprops.name = m_muxdata.name;
m_edit_channelname->SetText(m_channelprops.name);
}

if (!m_muxdata.subchannels.empty())
m_button_ok->SetEnabled(true);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -1266,7 +1269,17 @@ bool channelsettings::OnInit(void)

// Change the text of the OK button to "Add" if we are in new channel mode
if (m_isnew)
m_button_ok->SetLabel(kodi::addon::GetLocalizedString(15019));
{
if ((m_channelprops.modulation == modulation::hd) ||
(m_channelprops.modulation == modulation::dab) ||
(m_channelprops.modulation == modulation::wx))
{
m_button_ok->SetLabel(kodi::addon::GetLocalizedString(30339)); // Add channels...
m_button_ok->SetEnabled(false); // disable until we have at least one subchannel
}
else
m_button_ok->SetLabel(kodi::addon::GetLocalizedString(15019)); // Add
}

// Set the channel frequency in XXX.X MHz (FM/HD) or XXX.XXX format (DAB/WX)
char freqstr[128];
Expand All @@ -1278,7 +1291,7 @@ bool channelsettings::OnInit(void)
frequency);
else
snprintf(freqstr, std::extent<decltype(freqstr)>::value,
kodi::addon::GetLocalizedString(30338).c_str(), // %.1f MHz
kodi::addon::GetLocalizedString(30338).c_str(), // %.1f MHz
frequency);
m_edit_frequency->SetText(freqstr);

Expand Down

0 comments on commit d931bc9

Please sign in to comment.