mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-02 02:11:11 +02:00
api4: upgrade channel and bouquet edit (testing)
This commit is contained in:
@@ -44,9 +44,10 @@
|
||||
#include <driver/fontrenderer.h>
|
||||
#include <driver/screen_max.h>
|
||||
#include "bouqueteditor_chanselect.h"
|
||||
#include <gui/components/cc.h>
|
||||
#include <gui/widget/buttons.h>
|
||||
#include <gui/widget/icons.h>
|
||||
#include <gui/widget/stringinput.h>
|
||||
#include <gui/widget/keyboard_input.h>
|
||||
|
||||
#include <zapit/getservices.h>
|
||||
#include <zapit/femanager.h>
|
||||
@@ -76,7 +77,10 @@ CBEChannelWidget::CBEChannelWidget(const std::string & Caption, unsigned int Bou
|
||||
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_YELLOW, &icol_w, &icol_h);
|
||||
iheight = std::max(fheight, icol_h+2);
|
||||
iconoffset = std::max(iconoffset, icol_w);
|
||||
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_LOCK, &icol_w, &icol_h);
|
||||
iheight = std::max(fheight, icol_h+2);
|
||||
iconoffset = std::max(iconoffset, icol_w);
|
||||
|
||||
liststart = 0;
|
||||
@@ -122,15 +126,16 @@ void CBEChannelWidget::paintItem(int pos)
|
||||
frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, bgcolor);
|
||||
}
|
||||
|
||||
if ((current == selected) && (state == beMoving))
|
||||
{
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + 10, ypos, iheight);
|
||||
if ((current == selected) && (state == beMoving)) {
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + 5, ypos, iheight);
|
||||
}
|
||||
if(current < Channels->size())
|
||||
{
|
||||
if(current < Channels->size()) {
|
||||
if ((*Channels)[current]->bLocked) {
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + 22, ypos, iheight);
|
||||
}
|
||||
//g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10, ypos+ fheight, width- numwidth- 20- 15, (*Channels)[current]->getName(), color);
|
||||
//FIXME numwidth ? we not show chan numbers
|
||||
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 20 + iconoffset, ypos + iheight - (iheight-fheight)/2, width- iconoffset- 20, (*Channels)[current]->getName(), color);
|
||||
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 22 + iconoffset, ypos + iheight - (iheight-fheight)/2, width- iconoffset- 20, (*Channels)[current]->getName(), color);
|
||||
if((*Channels)[current]->scrambled)
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x+width- 15 - 28, ypos, fheight);
|
||||
else if (!(*Channels)[current]->getUrl().empty())
|
||||
@@ -177,17 +182,20 @@ void CBEChannelWidget::paintHead()
|
||||
header.paint(CC_SAVE_SCREEN_NO);
|
||||
}
|
||||
|
||||
const struct button_label CBEChannelWidgetButtons[4] =
|
||||
const struct button_label CBEChannelWidgetButtons[6] =
|
||||
{
|
||||
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_BOUQUETEDITOR_DELETE },
|
||||
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_BOUQUETEDITOR_ADD },
|
||||
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETEDITOR_MOVE },
|
||||
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_BOUQUETEDITOR_SWITCHMODE }
|
||||
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_BOUQUETEDITOR_RENAME },
|
||||
{ NEUTRINO_ICON_BUTTON_DUMMY_SMALL, LOCALE_BOUQUETEDITOR_SWITCHMODE },
|
||||
//{ NEUTRINO_ICON_BUTTON_FORWARD , LOCALE_BOUQUETEDITOR_MOVE_TO }, // TODO upgrade
|
||||
{ NEUTRINO_ICON_BUTTON_STOP , LOCALE_BOUQUETEDITOR_LOCK }
|
||||
};
|
||||
|
||||
void CBEChannelWidget::paintFoot()
|
||||
{
|
||||
::paintButtons(x, y + (height-footerHeight), width, 4, CBEChannelWidgetButtons, width, footerHeight);
|
||||
::paintButtons(x, y + (height-footerHeight), width, 6, CBEChannelWidgetButtons, width, footerHeight);
|
||||
}
|
||||
|
||||
std::string CBEChannelWidget::getInfoText(int index)
|
||||
@@ -313,7 +321,14 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
|
||||
x = ConnectLineBox_Width;
|
||||
y = getScreenStartY(height + info_height);
|
||||
|
||||
|
||||
mode = CZapitClient::MODE_TV;
|
||||
if (g_bouquetManager->Bouquets[bouquet]->tvChannels.empty())
|
||||
mode = CZapitClient::MODE_RADIO;
|
||||
else if (g_bouquetManager->Bouquets[bouquet]->radioChannels.empty())
|
||||
mode = CZapitClient::MODE_TV;
|
||||
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
|
||||
|
||||
paintHead();
|
||||
paint();
|
||||
paintFoot();
|
||||
@@ -389,21 +404,6 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
|
||||
if (state == beDefault)
|
||||
addChannel();
|
||||
}
|
||||
else if(msg==CRCInput::RC_blue)
|
||||
{
|
||||
if (state == beDefault)
|
||||
{
|
||||
if (mode == CZapitClient::MODE_TV)
|
||||
mode = CZapitClient::MODE_RADIO;
|
||||
else
|
||||
mode = CZapitClient::MODE_TV;
|
||||
|
||||
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
|
||||
|
||||
selected = 0;
|
||||
paint();
|
||||
}
|
||||
}
|
||||
else if(msg==CRCInput::RC_yellow)
|
||||
{
|
||||
liststart = (selected/listmaxshow)*listmaxshow;
|
||||
@@ -411,6 +411,46 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
|
||||
beginMoveChannel();
|
||||
paintItem(selected - liststart);
|
||||
}
|
||||
else if(msg==CRCInput::RC_blue)
|
||||
{
|
||||
if (selected < Channels->size()) /* Channels->size() might be 0 */
|
||||
{
|
||||
if (state == beDefault)
|
||||
renameChannel();
|
||||
}
|
||||
}
|
||||
else if(msg==CRCInput::RC_stop)
|
||||
{
|
||||
if (selected < Channels->size()) /* Channels->size() might be 0 */
|
||||
{
|
||||
if (state == beDefault)
|
||||
switchLockChannel();
|
||||
}
|
||||
}
|
||||
/* TODO upgrade
|
||||
else if (msg == CRCInput::RC_forward )
|
||||
{
|
||||
if (selected < Channels->size())
|
||||
{
|
||||
if (state == beDefault)
|
||||
moveChannelToBouquet();
|
||||
}
|
||||
}
|
||||
*/
|
||||
else if( msg == (neutrino_msg_t) g_settings.key_tvradio_mode ) {
|
||||
if (mode == CZapitClient::MODE_TV)
|
||||
mode = CZapitClient::MODE_RADIO;
|
||||
else
|
||||
mode = CZapitClient::MODE_TV;
|
||||
|
||||
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
|
||||
|
||||
selected = 0;
|
||||
paintHead();
|
||||
paint();
|
||||
paintFoot();
|
||||
}
|
||||
|
||||
else if(msg==CRCInput::RC_ok)
|
||||
{
|
||||
if (state == beDefault)
|
||||
@@ -465,6 +505,34 @@ void CBEChannelWidget::deleteChannel()
|
||||
paint();
|
||||
}
|
||||
|
||||
void CBEChannelWidget::renameChannel()
|
||||
{
|
||||
std::string newName= inputName((*Channels)[selected]->getName().c_str(), LOCALE_BOUQUETEDITOR_NEWBOUQUETNAME);
|
||||
|
||||
if (newName != (*Channels)[selected]->getName())
|
||||
{
|
||||
if(newName.empty())
|
||||
(*Channels)[selected]->setUserName("");
|
||||
else
|
||||
(*Channels)[selected]->setUserName(newName);
|
||||
|
||||
channelsChanged = true;
|
||||
}
|
||||
paintHead();
|
||||
paint();
|
||||
paintFoot();
|
||||
}
|
||||
|
||||
void CBEChannelWidget::switchLockChannel()
|
||||
{
|
||||
(*Channels)[selected]->bLocked = !(*Channels)[selected]->bLocked;
|
||||
channelsChanged = true;
|
||||
paintItem(selected - liststart);
|
||||
|
||||
if (selected + 1 < (*Channels).size())
|
||||
g_RCInput->postMsg((neutrino_msg_t) CRCInput::RC_down, 0);
|
||||
}
|
||||
|
||||
void CBEChannelWidget::addChannel()
|
||||
{
|
||||
CBEChannelSelectWidget* channelSelectWidget = new CBEChannelSelectWidget(caption, g_bouquetManager->Bouquets[bouquet], mode);
|
||||
@@ -491,6 +559,7 @@ void CBEChannelWidget::beginMoveChannel()
|
||||
void CBEChannelWidget::finishMoveChannel()
|
||||
{
|
||||
state = beDefault;
|
||||
channelsChanged = channelsChanged | true;
|
||||
paint();
|
||||
}
|
||||
|
||||
@@ -498,9 +567,19 @@ void CBEChannelWidget::cancelMoveChannel()
|
||||
{
|
||||
state = beDefault;
|
||||
internalMoveChannel( newPosition, origPosition);
|
||||
channelsChanged = false;
|
||||
channelsChanged = channelsChanged | false;
|
||||
}
|
||||
/* TODO upgrade (taken from channellist.cpp)
|
||||
void CBEChannelWidget::moveChannelToBouquet()
|
||||
{
|
||||
if (addChannelToBouquet())
|
||||
deleteChannel(false);
|
||||
else
|
||||
paint();
|
||||
|
||||
paintHead();
|
||||
}
|
||||
*/
|
||||
void CBEChannelWidget::internalMoveChannel( unsigned int fromPosition, unsigned int toPosition)
|
||||
{
|
||||
if ( (int) toPosition == -1 ) return;
|
||||
@@ -509,7 +588,7 @@ void CBEChannelWidget::internalMoveChannel( unsigned int fromPosition, unsigned
|
||||
g_bouquetManager->Bouquets[bouquet]->moveService(fromPosition, toPosition,
|
||||
mode == CZapitClient::MODE_TV ? 1 : 2);
|
||||
|
||||
channelsChanged = true;
|
||||
//channelsChanged = true;
|
||||
Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
|
||||
|
||||
selected = toPosition;
|
||||
@@ -517,6 +596,18 @@ void CBEChannelWidget::internalMoveChannel( unsigned int fromPosition, unsigned
|
||||
paint();
|
||||
}
|
||||
|
||||
std::string CBEChannelWidget::inputName(const char * const defaultName, const neutrino_locale_t _caption)
|
||||
{
|
||||
std::string Name = defaultName;
|
||||
|
||||
CKeyboardInput * nameInput = new CKeyboardInput(_caption, &Name);
|
||||
nameInput->exec(this, "");
|
||||
|
||||
delete nameInput;
|
||||
|
||||
return std::string(Name);
|
||||
}
|
||||
|
||||
bool CBEChannelWidget::hasChanged()
|
||||
{
|
||||
return (channelsChanged);
|
||||
|
Reference in New Issue
Block a user