CRecordInstance::GetRecordString(): Fix calculation of duration

- Use locales for time string
- Show recording duration right aligned in stop menu
This commit is contained in:
Michael Liebmann
2013-07-03 22:11:04 +02:00
parent b5d1322617
commit 0ce25a86d5
6 changed files with 30 additions and 14 deletions

View File

@@ -665,7 +665,7 @@ record_error_msg_t CRecordInstance::MakeFileName(CZapitChannel * channel)
return RECORD_OK;
}
void CRecordInstance::GetRecordString(std::string &str)
void CRecordInstance::GetRecordString(std::string &str, std::string &dur)
{
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
if(channel == NULL) {
@@ -676,12 +676,14 @@ void CRecordInstance::GetRecordString(std::string &str)
char stime[15];
int err = GetStatus();
strftime(stime, sizeof(stime), "%H:%M:%S ", localtime(&start_time));
time_t duration = time(0) - start_time;
time_t duration = (time(0) - start_time) / 60;
char dtime[20];
int h = duration/3600;
int m = duration/60;
snprintf(dtime, sizeof(dtime), " (%02d %s %02d min)", h, h == 1 ? "hour" : "hours", m);
str = stime + channel->getName() + ": " + GetEpgTitle() + ((err & REC_STATUS_OVERFLOW) ? " [!]" : "") + dtime;
int h = duration / 60;
int m = duration - (h * 60);
snprintf(dtime, sizeof(dtime), "(%d %s %02d %s)", h, h == 1 ? g_Locale->getText(LOCALE_RECORDING_TIME_HOUR) : g_Locale->getText(LOCALE_RECORDING_TIME_HOURS),
m, g_Locale->getText(LOCALE_RECORDING_TIME_MIN));
str = stime + channel->getName() + ": " + GetEpgTitle() + ((err & REC_STATUS_OVERFLOW) ? " [!] " : " ");
dur = dtime;
}
//-------------------------------------------------------------------------
@@ -1372,8 +1374,9 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey )
bool tostart = true;
CRecordInstance * inst = FindInstance(live_channel_id);
if (inst) {
std::string title;
inst->GetRecordString(title);
std::string title, duration;
inst->GetRecordString(title, duration);
title += duration;
tostart = (ShowMsgUTF(LOCALE_RECORDING_IS_RUNNING, title.c_str(),
CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes);
}
@@ -1449,8 +1452,8 @@ bool CRecordManager::ShowMenu(void)
channel_ids[i] = inst->GetChannelId();
recording_ids[i] = inst->GetRecordingId();
std::string title;
inst->GetRecordString(title);
std::string title, duration;
inst->GetRecordString(title, duration);
const char* mode_icon = NULL;
//if (inst->tshift_mode)
@@ -1465,7 +1468,7 @@ bool CRecordManager::ShowMenu(void)
rc_key = CRCInput::RC_stop;
btn_icon = NEUTRINO_ICON_BUTTON_STOP;
}
item = new CMenuForwarderNonLocalized(title.c_str(), true, NULL, selector, cnt, rc_key, NULL, mode_icon);
item = new CMenuForwarderNonLocalized(title.c_str(), true, duration, selector, cnt, rc_key, NULL, mode_icon);
item->setItemButton(btn_icon, true);
//if only one recording is running, set the focus to this menu item
@@ -1508,7 +1511,7 @@ bool CRecordManager::ShowMenu(void)
bool CRecordManager::AskToStop(const t_channel_id channel_id, const int recid)
{
//int recording_id = 0;
std::string title;
std::string title, duration;
CRecordInstance * inst;
mutex.lock();
@@ -1519,7 +1522,8 @@ bool CRecordManager::AskToStop(const t_channel_id channel_id, const int recid)
if(inst) {
//recording_id = inst->GetRecordingId();
inst->GetRecordString(title);
inst->GetRecordString(title, duration);
title += duration;
}
mutex.unlock();
if(inst == NULL)