- rework recording menu and infobar style of recording icon (patch by micha-bbg) -> todo: add proper localization

*add possibility to start recording of current channel via menu
*add timeshift to menu
*add stop all recordings to menu
*change infobar style (shows number of running recordings beside recording icon)

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1627 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
striper
2011-08-26 17:55:25 +00:00
parent c05f64c116
commit 605cfe4c25
4 changed files with 139 additions and 26 deletions

View File

@@ -40,6 +40,7 @@
#include <global.h>
#include <neutrino.h>
#include <gui/filebrowser.h>
#include <gui/movieplayer.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/messagebox.h>
#include <gui/widget/mountchooser.h>
@@ -1023,51 +1024,159 @@ int CRecordManager::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
return messages_return::unhandled;
}
int CRecordManager::exec(CMenuTarget* parent, const std::string & /*actionKey */)
int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
{
if(parent)
parent->hide();
if(actionKey == "StopAll")
{
char rec_msg[256];
int records = recmap.size();
int i = 0;
snprintf(rec_msg, sizeof(rec_msg)-1, "Wirklich alle %d Aufnahmen beenden?", records);
if(ShowMsgUTF(LOCALE_SHUTDOWN_RECODING_QUERY, rec_msg,
CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes)
{
snprintf(rec_msg, sizeof(rec_msg)-1, "%d Aufnahmen werden beendet.", records);
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, rec_msg);
hintBox->paint();
int recording_ids[RECORD_MAX_COUNT];
t_channel_id channel_ids[RECORD_MAX_COUNT];
t_channel_id channel_id;
recmap_iterator_t it;
mutex.lock();
for(it = recmap.begin(); it != recmap.end(); it++)
{
recording_ids[i] = 0;
channel_id = it->first;
CRecordInstance * inst = it->second;
if(inst)
{
channel_ids[i] = channel_id;
recording_ids[i] = inst->GetRecordingId();
printf("CRecordManager::exec(ExitAll) found channel %llx recording_id %d\n", channel_ids[i], recording_ids[i]);
i++;
}
}
mutex.unlock();
if (i > 0)
{
for(int i2 = 0; i2 < i; i2++)
{
mutex.lock();
CRecordInstance * inst = FindInstance(channel_ids[i2]);
if(inst == NULL || recording_ids[i2] != inst->GetRecordingId())
{
printf("CRecordManager::exec(ExitAll) channel %llx event id %d not found\n", channel_ids[i2], recording_ids[i2]);
}else
{
usleep(500000);
g_Timerd->stopTimerEvent(recording_ids[i2]);
}
mutex.unlock();
}
}
hintBox->hide();
delete hintBox;
}
return menu_return::RETURN_EXIT_ALL;
}else if(actionKey == "Record")
{
printf("[neutrino] direct record\n");
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id))
CRecordManager::getInstance()->AskToStop(live_channel_id);
else
CRecordManager::getInstance()->Record(live_channel_id);
return menu_return::RETURN_EXIT_ALL;
}else if(actionKey == "Timeshift")
{
if(g_RemoteControl->is_video_started)
{
std::string tmode;
bool res = true;
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id))
{
tmode = "ptimeshift"; // already recording, pause
}else
{
if(g_settings.temp_timeshift)
res = CRecordManager::getInstance()->StartAutoRecord();
else
res = CRecordManager::getInstance()->Record(live_channel_id);
tmode = "timeshift"; // record just started
}
if(res)
CMoviePlayerGui::getInstance().exec(NULL, tmode);
}
return menu_return::RETURN_EXIT_ALL;
}
ShowMenu();
return menu_return::RETURN_REPAINT;
}
bool CRecordManager::ShowMenu(void)
{
int select = -1, i = 0;
int select = -1, i = 0, shortcut = 1, recmap_size = recmap.size();
char cnt[5];
CMenuForwarderNonLocalized * item;
t_channel_id channel_ids[RECORD_MAX_COUNT];
int recording_ids[RECORD_MAX_COUNT];
CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select);
CMenuWidget menu(LOCALE_MAINMENU_RECORDING, NEUTRINO_ICON_SETTINGS /*, width*/);
menu.addIntroItems(NONEXISTANT_LOCALE, LOCALE_MAINMENU_RECORDING_STOP, CMenuWidget::BTN_TYPE_CANCEL);
menu.addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
//FIXME do we need "Start current channel record" menu point ?
// Record / Timeshift
item = new CMenuForwarderNonLocalized("Aufnahme aktueller Kanal", true, NULL,
this, "Record", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);
menu.addItem(item, false);
item = new CMenuForwarderNonLocalized("Timeshift", true, NULL,
this, "Timeshift", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
menu.addItem(item, false);
mutex.lock();
for(recmap_iterator_t it = recmap.begin(); it != recmap.end(); it++) {
t_channel_id channel_id = it->first;
CRecordInstance * inst = it->second;
if(recmap_size > 0)
{
menu.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MAINMENU_RECORDING_STOP));
channel_ids[i] = channel_id;
recording_ids[i] = inst->GetRecordingId();
//FIXME do we need "Start current channel record" menu point ?
mutex.lock();
for(recmap_iterator_t it = recmap.begin(); it != recmap.end(); it++) {
t_channel_id channel_id = it->first;
CRecordInstance * inst = it->second;
std::string title;
inst->GetRecordString(title);
sprintf(cnt, "%d", i);
CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(title.c_str(), true, NULL, selector, cnt, CRCInput::RC_nokey, NULL);
item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
menu.addItem(item, false);
i++;
channel_ids[i] = channel_id;
recording_ids[i] = inst->GetRecordingId();
std::string title;
inst->GetRecordString(title);
sprintf(cnt, "%d", i);
item = new CMenuForwarderNonLocalized(title.c_str(), true, NULL,
selector, cnt, CRCInput::convertDigitToKey((recmap_size == 1) ? 0 : shortcut++));
item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
menu.addItem(item, false);
i++;
}
if(i > 1) // Men<65>punkt "alle Aufn. verenden"
{
menu.addItem(GenericMenuSeparatorLine);
item = new CMenuForwarderNonLocalized("Alle Aufnahmen beenden", true, NULL,
this, "StopAll", CRCInput::convertDigitToKey(0));
item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
menu.addItem(item, false);
}
mutex.unlock();
}
mutex.unlock();
#if 0
if(i == 0)
{
// neutrino.cpp #2458 + #2449
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Keine Aufnahme zum Anzeigen oder Stoppen.",
CMessageBox::mbrOk, CMessageBox::mbOk,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8
return false;
}
#endif
menu.exec(NULL, "");
delete selector;
@@ -1325,7 +1434,7 @@ bool CRecordManager::MountDirectory(const char *recordingDir)
strcat(msg,recordingDir);
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, msg,
CMessageBox::mbrBack, CMessageBox::mbBack,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8
CMessageBox::mbrOk, CMessageBox::mbOk,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8
ret = false;
}
break;

View File

@@ -191,5 +191,6 @@ class CRecordManager : public CMenuTarget, public CChangeObserver
int recordingstatus;
bool doGuiRecord();
bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
int GetRecmapSize() { return recmap.size(); };
};
#endif

View File

@@ -291,20 +291,23 @@ void CInfoViewer::showRecordIcon (const bool show)
//recordModeActive = CNeutrinoApp::getInstance ()->recordingstatus || shift_timer;
recordModeActive = CRecordManager::getInstance()->RecordingStatus() || CRecordManager::getInstance()->Timeshift();
if (recordModeActive) {
printf("CInfoViewer::showRecordIcon RecordingStatus() %d Timeshift() %d\n", CRecordManager::getInstance()->RecordingStatus(), CRecordManager::getInstance()->Timeshift());
//printf("CInfoViewer::showRecordIcon RecordingStatus() %d Timeshift() %d\n", CRecordManager::getInstance()->RecordingStatus(), CRecordManager::getInstance()->Timeshift());
int icon_w = 0,icon_h = 0;
frameBuffer->getIconSize(autoshift ? NEUTRINO_ICON_AUTO_SHIFT : NEUTRINO_ICON_REC, &icon_w, &icon_h);
int chanH = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight ();
int ChanName_X = BoxStartX + ChanWidth + SHADOW_OFFSET;
const int icon_space = 3, box_len = 300, box_pos= 12;
const int icon_space = 3, box_len = 34 + icon_w, box_pos = 12;
if (show) {
//if (!autoshift && !shift_timer)
if(!CRecordManager::getInstance()->Timeshift())
{
frameBuffer->paintBoxRel (ChanName_X + SHADOW_OFFSET, BoxStartY + box_pos + SHADOW_OFFSET, box_len, chanH, COL_INFOBAR_SHADOW_PLUS_0);
frameBuffer->paintBoxRel (ChanName_X , BoxStartY + box_pos , box_len, chanH, COL_INFOBAR_PLUS_0);
char records_msg[8];
int records = CRecordManager::getInstance()->GetRecmapSize();
snprintf(records_msg, sizeof(records_msg)-1, "%d%s", records, "x");
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString (ChanName_X +icon_w + (icon_space*2), BoxStartY + box_pos + chanH, box_len,
g_Zapit->getChannelName(rec_channel_id)/*ext_channel_name.c_str()*/, COL_INFOBAR, 0, true);
records_msg, COL_INFOBAR, 0, true);
} else {
frameBuffer->paintBackgroundBoxRel (ChanName_X , BoxStartY + box_pos, box_len + SHADOW_OFFSET, chanH + SHADOW_OFFSET);
}

View File

@@ -531,7 +531,7 @@ bool CNeutrinoApp::showUserMenu(int button)
menu_items++;
menu_prev = SNeutrinoSettings::ITEM_RECORD;
keyhelper.get(&key,&icon,CRCInput::RC_red);
#if 0 //NEW, show menu, how better ?
#if 1 //NEW, show menu, how better ?
menu_item = new CMenuForwarder(LOCALE_MAINMENU_RECORDING, true, NULL, CRecordManager::getInstance(), "-1", key, icon);
#else //OLD, show start/stop chooser
menu_item = new CMenuOptionChooser(LOCALE_MAINMENU_RECORDING, &CRecordManager::getInstance()->recordingstatus,