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

@@ -1578,6 +1578,9 @@ rclock.unlockmsg Fernbedienung reaktiviert...
recording.is_running Folgende Aufnahme läuft bereits! Neue Aufnahme starten? recording.is_running Folgende Aufnahme läuft bereits! Neue Aufnahme starten?
recording.start Starte Aufnahme, bitte warten...! recording.start Starte Aufnahme, bitte warten...!
recording.stop Beende Aufnahme, bitte warten...! recording.stop Beende Aufnahme, bitte warten...!
recording.time_hour Stunde
recording.time_hours Stunden
recording.time_min Min
recordingmenu.apids Tonspuren recordingmenu.apids Tonspuren
recordingmenu.apids_ac3 AC3 Tonspuren aufnehmen recordingmenu.apids_ac3 AC3 Tonspuren aufnehmen
recordingmenu.apids_alt Alternative Tonspuren aufn. recordingmenu.apids_alt Alternative Tonspuren aufn.

View File

@@ -1578,6 +1578,9 @@ rclock.unlockmsg Remote control reactivated.
recording.is_running This channel already recording. Start new record? recording.is_running This channel already recording. Start new record?
recording.start Start recording, please wait...! recording.start Start recording, please wait...!
recording.stop Stop recording, please wait...! recording.stop Stop recording, please wait...!
recording.time_hour hour
recording.time_hours hours
recording.time_min min
recordingmenu.apids Audio streams recordingmenu.apids Audio streams
recordingmenu.apids_ac3 record AC3 streams recordingmenu.apids_ac3 record AC3 streams
recordingmenu.apids_alt record alternative streams recordingmenu.apids_alt record alternative streams

View File

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

View File

@@ -120,7 +120,7 @@ class CRecordInstance
t_channel_id GetChannelId(void) { return channel_id; }; t_channel_id GetChannelId(void) { return channel_id; };
std::string GetEpgTitle(void) { return epgTitle; }; std::string GetEpgTitle(void) { return epgTitle; };
MI_MOVIE_INFO * GetMovieInfo(void) { return recMovieInfo; }; MI_MOVIE_INFO * GetMovieInfo(void) { return recMovieInfo; };
void GetRecordString(std::string& str); void GetRecordString(std::string& str, std::string &dur);
const char * GetFileName() { return filename; }; const char * GetFileName() { return filename; };
bool Timeshift() { return autoshift; }; bool Timeshift() { return autoshift; };
int tshift_mode; int tshift_mode;

View File

@@ -1605,6 +1605,9 @@ typedef enum
LOCALE_RECORDING_IS_RUNNING, LOCALE_RECORDING_IS_RUNNING,
LOCALE_RECORDING_START, LOCALE_RECORDING_START,
LOCALE_RECORDING_STOP, LOCALE_RECORDING_STOP,
LOCALE_RECORDING_TIME_HOUR,
LOCALE_RECORDING_TIME_HOURS,
LOCALE_RECORDING_TIME_MIN,
LOCALE_RECORDINGMENU_APIDS, LOCALE_RECORDINGMENU_APIDS,
LOCALE_RECORDINGMENU_APIDS_AC3, LOCALE_RECORDINGMENU_APIDS_AC3,
LOCALE_RECORDINGMENU_APIDS_ALT, LOCALE_RECORDINGMENU_APIDS_ALT,

View File

@@ -1605,6 +1605,9 @@ const char * locale_real_names[] =
"recording.is_running", "recording.is_running",
"recording.start", "recording.start",
"recording.stop", "recording.stop",
"recording.time_hour",
"recording.time_hours",
"recording.time_min",
"recordingmenu.apids", "recordingmenu.apids",
"recordingmenu.apids_ac3", "recordingmenu.apids_ac3",
"recordingmenu.apids_alt", "recordingmenu.apids_alt",