- zapit-setup: formatting code using astyle; some manual code nicenings

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-12-06 05:18:19 +01:00
committed by Thilo Graf
parent 42da414020
commit bbd59e63eb
2 changed files with 57 additions and 57 deletions

View File

@@ -28,7 +28,6 @@
#include <config.h> #include <config.h>
#endif #endif
#include "zapit_setup.h" #include "zapit_setup.h"
#include <global.h> #include <global.h>
@@ -38,7 +37,6 @@
#include <driver/screen_max.h> #include <driver/screen_max.h>
CZapitSetup::CZapitSetup() CZapitSetup::CZapitSetup()
{ {
width = 40; width = 40;
@@ -48,7 +46,7 @@ CZapitSetup::~CZapitSetup()
{ {
} }
int CZapitSetup::exec(CMenuTarget* parent, const std::string &/*actionKey*/) int CZapitSetup::exec(CMenuTarget *parent, const std::string &/*actionKey*/)
{ {
printf("[neutrino] init zapit menu setup...\n"); printf("[neutrino] init zapit menu setup...\n");
if (parent) if (parent)
@@ -57,7 +55,7 @@ int CZapitSetup::exec(CMenuTarget* parent, const std::string &/*actionKey*/)
return showMenu(); return showMenu();
} }
void CZapitSetup::changeStartChannel(CMenuForwarder* zapit1, CMenuForwarder* zapit2) void CZapitSetup::changeStartChannel(CMenuForwarder *zapit1, CMenuForwarder *zapit2)
{ {
zapit1->paint(); zapit1->paint();
zapit2->paint(); zapit2->paint();
@@ -65,30 +63,32 @@ void CZapitSetup::changeStartChannel(CMenuForwarder* zapit1, CMenuForwarder* zap
int CZapitSetup::showMenu() int CZapitSetup::showMenu()
{ {
//menue init // menue init
CMenuWidget *zapit = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_ZAPIT); CMenuWidget *zapit = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_ZAPIT);
zapit->addIntroItems(LOCALE_ZAPITSETUP_INFO); zapit->addIntroItems(LOCALE_ZAPITSETUP_HEAD);
COnOffNotifier* miscZapitNotifier = new COnOffNotifier(1); COnOffNotifier *miscZapitNotifier = new COnOffNotifier(1);
//zapit
CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_ZAPITSETUP_LAST_USE, &g_settings.uselastchannel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, miscZapitNotifier, CRCInput::RC_red); // zapit
CMenuOptionChooser *mc = new CMenuOptionChooser(LOCALE_ZAPITSETUP_LAST_USE, &g_settings.uselastchannel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, miscZapitNotifier, CRCInput::RC_red);
mc->setHint("", LOCALE_MENU_HINT_LAST_USE); mc->setHint("", LOCALE_MENU_HINT_LAST_USE);
CSelectChannelWidget select1; CSelectChannelWidget select1;
CSelectChannelWidget select2; CSelectChannelWidget select2;
CMenuForwarder *zapit1 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_TV , !g_settings.uselastchannel, g_settings.StartChannelTV, &select1, "tv", CRCInput::RC_green); CMenuForwarder *zapit1 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_TV, !g_settings.uselastchannel, g_settings.StartChannelTV, &select1, "tv", CRCInput::RC_green);
zapit1->setHint("", LOCALE_MENU_HINT_LAST_TV); zapit1->setHint("", LOCALE_MENU_HINT_LAST_TV);
CMenuForwarder *zapit2 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_RADIO , !g_settings.uselastchannel, g_settings.StartChannelRadio, &select2, "radio", CRCInput::RC_yellow); CMenuForwarder *zapit2 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_RADIO, !g_settings.uselastchannel, g_settings.StartChannelRadio, &select2, "radio", CRCInput::RC_yellow);
zapit2->setHint("", LOCALE_MENU_HINT_LAST_RADIO); zapit2->setHint("", LOCALE_MENU_HINT_LAST_RADIO);
#define CHANNEL_LIST_MODE_OPTION_COUNT 5 #define CHANNEL_LIST_MODE_OPTION_COUNT 5
const CMenuOptionChooser::keyval CHANNEL_LIST_MODE_OPTIONS[CHANNEL_LIST_MODE_OPTION_COUNT] = { const CMenuOptionChooser::keyval CHANNEL_LIST_MODE_OPTIONS[CHANNEL_LIST_MODE_OPTION_COUNT] =
{ -1, LOCALE_CHANNELLIST_REMEMBER } {
, { LIST_MODE_FAV, LOCALE_CHANNELLIST_FAVS } { -1, LOCALE_CHANNELLIST_REMEMBER },
, { LIST_MODE_PROV, LOCALE_CHANNELLIST_PROVS } { LIST_MODE_FAV, LOCALE_CHANNELLIST_FAVS },
, { LIST_MODE_SAT, LOCALE_CHANNELLIST_SATS } { LIST_MODE_PROV, LOCALE_CHANNELLIST_PROVS },
, { LIST_MODE_ALL, LOCALE_CHANNELLIST_HEAD } { LIST_MODE_SAT, LOCALE_CHANNELLIST_SATS },
{ LIST_MODE_ALL, LOCALE_CHANNELLIST_HEAD }
}; };
CMenuOptionChooser *channel_mode = new CMenuOptionChooser(LOCALE_ZAPITSETUP_CHANNELMODE, &g_settings.channel_mode_initial, CHANNEL_LIST_MODE_OPTIONS, CHANNEL_LIST_MODE_OPTION_COUNT, true, NULL, CRCInput::RC_1); CMenuOptionChooser *channel_mode = new CMenuOptionChooser(LOCALE_ZAPITSETUP_CHANNELMODE, &g_settings.channel_mode_initial, CHANNEL_LIST_MODE_OPTIONS, CHANNEL_LIST_MODE_OPTION_COUNT, true, NULL, CRCInput::RC_1);
@@ -116,7 +116,7 @@ int CZapitSetup::showMenu()
return res; return res;
} }
//select menu // select menu
CSelectChannelWidget::CSelectChannelWidget() CSelectChannelWidget::CSelectChannelWidget()
{ {
width = 40; width = 40;
@@ -124,21 +124,20 @@ CSelectChannelWidget::CSelectChannelWidget()
CSelectChannelWidget::~CSelectChannelWidget() CSelectChannelWidget::~CSelectChannelWidget()
{ {
} }
int CSelectChannelWidget::exec(CMenuTarget* parent, const std::string& actionKey) int CSelectChannelWidget::exec(CMenuTarget *parent, const std::string &actionKey)
{ {
int res = menu_return::RETURN_REPAINT; int res = menu_return::RETURN_REPAINT;
if (parent) if (parent)
parent->hide(); parent->hide();
if(actionKey == "tv") if (actionKey == "tv")
{ {
return InitZapitChannelHelper(CZapitClient::MODE_TV); return InitZapitChannelHelper(CZapitClient::MODE_TV);
} }
else if(actionKey == "radio") else if (actionKey == "radio")
{ {
return InitZapitChannelHelper(CZapitClient::MODE_RADIO); return InitZapitChannelHelper(CZapitClient::MODE_RADIO);
} }
@@ -146,20 +145,20 @@ int CSelectChannelWidget::exec(CMenuTarget* parent, const std::string& actionKey
{ {
unsigned int cnr = 0; unsigned int cnr = 0;
t_channel_id channel_id = 0; t_channel_id channel_id = 0;
sscanf(&(actionKey[4]),"%u|%" SCNx64 "", &cnr, &channel_id); sscanf(&(actionKey[4]), "%u|%" SCNx64 "", &cnr, &channel_id);
if (strncmp(actionKey.c_str(), "ZCT:", 4) == 0)//...tv if (strncmp(actionKey.c_str(), "ZCT:", 4) == 0) // tv
{ {
g_settings.StartChannelTV = actionKey.substr(actionKey.find_first_of("#")+1); g_settings.StartChannelTV = actionKey.substr(actionKey.find_first_of("#") + 1);
g_settings.startchanneltv_id = channel_id; g_settings.startchanneltv_id = channel_id;
} }
else if (strncmp(actionKey.c_str(), "ZCR:", 4) == 0)//...radio else if (strncmp(actionKey.c_str(), "ZCR:", 4) == 0) // radio
{ {
g_settings.StartChannelRadio = actionKey.substr(actionKey.find_first_of("#")+1); g_settings.StartChannelRadio = actionKey.substr(actionKey.find_first_of("#") + 1);
g_settings.startchannelradio_id= channel_id; g_settings.startchannelradio_id = channel_id;
} }
// ...leave bouquet/channel menu and show a refreshed zapit menu with current start channel(s) // leave bouquet/channel menu and show a refreshed zapit menu with current start channel(s)
g_RCInput->postMsg(CRCInput::RC_timeout, 0); g_RCInput->postMsg(CRCInput::RC_timeout, 0);
return menu_return::RETURN_EXIT; return menu_return::RETURN_EXIT;
} }
@@ -174,8 +173,9 @@ int CSelectChannelWidget::InitZapitChannelHelper(CZapitClient::channelsMode mode
CMenuWidget mctv(LOCALE_TIMERLIST_BOUQUETSELECT, NEUTRINO_ICON_SETTINGS, width); CMenuWidget mctv(LOCALE_TIMERLIST_BOUQUETSELECT, NEUTRINO_ICON_SETTINGS, width);
mctv.addIntroItems(); mctv.addIntroItems();
for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++) { for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++)
CMenuWidget* mwtv = new CMenuWidget(LOCALE_TIMERLIST_CHANNELSELECT, NEUTRINO_ICON_SETTINGS, width); {
CMenuWidget *mwtv = new CMenuWidget(LOCALE_TIMERLIST_CHANNELSELECT, NEUTRINO_ICON_SETTINGS, width);
toDelete.push_back(mwtv); toDelete.push_back(mwtv);
mwtv->addIntroItems(); mwtv->addIntroItems();
ZapitChannelList channels; ZapitChannelList channels;
@@ -183,27 +183,28 @@ int CSelectChannelWidget::InitZapitChannelHelper(CZapitClient::channelsMode mode
g_bouquetManager->Bouquets[i]->getRadioChannels(channels); g_bouquetManager->Bouquets[i]->getRadioChannels(channels);
else else
g_bouquetManager->Bouquets[i]->getTvChannels(channels); g_bouquetManager->Bouquets[i]->getTvChannels(channels);
for(int j = 0; j < (int) channels.size(); j++) { for (int j = 0; j < (int) channels.size(); j++)
CZapitChannel * channel = channels[j]; {
CZapitChannel *channel = channels[j];
char cChannelId[60] = {0}; char cChannelId[60] = {0};
snprintf(cChannelId, sizeof(cChannelId), "ZC%c:%d|%" PRIx64 "#", (mode==CZapitClient::MODE_TV)?'T':'R', channel->number, channel->getChannelID()); snprintf(cChannelId, sizeof(cChannelId), "ZC%c:%d|%" PRIx64 "#", (mode == CZapitClient::MODE_TV) ? 'T' : 'R', channel->number, channel->getChannelID());
CMenuForwarder * chan_item = new CMenuForwarder(channel->getName(), true, NULL, this, CMenuForwarder *chan_item = new CMenuForwarder(channel->getName(), true, NULL, this,
(std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL, (std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL,
channel->scrambled ? NEUTRINO_ICON_MARKER_SCRAMBLED : (channel->getUrl().empty() ? NULL : NEUTRINO_ICON_MARKER_STREAMING)); channel->scrambled ? NEUTRINO_ICON_MARKER_SCRAMBLED : (channel->getUrl().empty() ? NULL : NEUTRINO_ICON_MARKER_STREAMING));
chan_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); chan_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
mwtv->addItem(chan_item); mwtv->addItem(chan_item);
} }
if(!channels.empty() && (!g_bouquetManager->Bouquets[i]->bHidden )) if (!channels.empty() && (!g_bouquetManager->Bouquets[i]->bHidden))
{ {
mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwtv)); mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwtv));
} }
} }
int res = mctv.exec (NULL, ""); int res = mctv.exec(NULL, "");
// delete dynamic created objects // delete dynamic created objects
for(unsigned int count=0;count<toDelete.size();count++) for (unsigned int count = 0; count < toDelete.size(); count++)
{ {
delete toDelete[count]; delete toDelete[count];
} }

View File

@@ -33,30 +33,29 @@
class CZapitSetup : public CMenuTarget class CZapitSetup : public CMenuTarget
{ {
private: private:
int width; int width;
int showMenu(); int showMenu();
void changeStartChannel(CMenuForwarder* zapit1, CMenuForwarder* zapit2); void changeStartChannel(CMenuForwarder *zapit1, CMenuForwarder *zapit2);
public: public:
CZapitSetup(); CZapitSetup();
~CZapitSetup(); ~CZapitSetup();
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget *parent, const std::string &actionKey);
}; };
class CSelectChannelWidget : public CMenuWidget class CSelectChannelWidget : public CMenuWidget
{ {
private: private:
int width; int width;
int InitZapitChannelHelper(CZapitClient::channelsMode mode); int InitZapitChannelHelper(CZapitClient::channelsMode mode);
public: public:
CSelectChannelWidget(); CSelectChannelWidget();
~CSelectChannelWidget(); ~CSelectChannelWidget();
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget *parent, const std::string &actionKey);
}; };
#endif #endif