mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 08:21:07 +02:00
gui/components/cc_frm_clock: simplify; setClockFormat/setClockBlink has now impact on running thread
Conflicts:
src/gui/components/cc_frm_clock.cpp
src/gui/timeosd.cpp
Origin commit data
------------------
Commit: 13118c1148
Author: martii <m4rtii@gmx.de>
Date: 2014-01-10 (Fri, 10 Jan 2014)
This commit is contained in:
@@ -72,7 +72,8 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, const int& y_pos, c
|
||||
cl_thread = 0;
|
||||
cl_interval = 1;
|
||||
|
||||
cl_blink_str = "";
|
||||
activeClock = true;
|
||||
cl_blink_str = format_str;
|
||||
paintClock = false;
|
||||
|
||||
activeClock = activ;
|
||||
@@ -89,12 +90,13 @@ CComponentsFrmClock::~CComponentsFrmClock()
|
||||
stopThread();
|
||||
}
|
||||
|
||||
|
||||
void CComponentsFrmClock::initTimeString()
|
||||
{
|
||||
struct tm t;
|
||||
time_t ltime;
|
||||
ltime=time(<ime);
|
||||
strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format_str.c_str(), localtime_r(<ime, &t));
|
||||
ltime=time(NULL);
|
||||
strftime((char*) &cl_timestr, sizeof(cl_timestr), getTimeFormat(ltime), localtime_r(<ime, &t));
|
||||
}
|
||||
|
||||
// How does it works?
|
||||
@@ -261,20 +263,9 @@ void* CComponentsFrmClock::initClockThread(void *arg)
|
||||
#if 0
|
||||
time_t count = time(0);
|
||||
#endif
|
||||
std::string format_str_save = clock->cl_format_str; // FIXME. This will cause setClockFormat() to be ignored. --martii
|
||||
//start loop for paint
|
||||
while(clock != NULL) {
|
||||
if (clock->paintClock) {
|
||||
// Blinking depending on the blink format string
|
||||
if (!clock->cl_blink_str.empty() && (clock->cl_format_str.length() == clock->cl_blink_str.length())) {
|
||||
if (clock->cl_format_str == clock->cl_blink_str.c_str())
|
||||
clock->cl_format_str = format_str_save;
|
||||
else {
|
||||
format_str_save = clock->cl_format_str;
|
||||
clock->cl_format_str = clock->cl_blink_str;
|
||||
}
|
||||
}
|
||||
//paint segements, but wihtout saved backgrounds
|
||||
clock->paint(CC_SAVE_SCREEN_NO);
|
||||
#if 0
|
||||
count = time(0);
|
||||
|
@@ -71,10 +71,10 @@ class CComponentsFrmClock : public CComponentsForm
|
||||
///text color
|
||||
int cl_col_text;
|
||||
///time format
|
||||
std::string cl_format_str;
|
||||
const char *cl_format_str;
|
||||
///time format for blink
|
||||
std::string cl_blink_str;
|
||||
///time string align, default allign is ver and hor centered
|
||||
const char *cl_blink_str;
|
||||
///time string align, default align is ver and hor centered
|
||||
int cl_align;
|
||||
|
||||
///initialize clock contents
|
||||
@@ -83,6 +83,8 @@ class CComponentsFrmClock : public CComponentsForm
|
||||
virtual void initTimeString();
|
||||
///initialize of general alignment of timestring segments within form area
|
||||
void initSegmentAlign(int* segment_width, int* segment_height);
|
||||
//return current time string format
|
||||
const char *getTimeFormat(time_t when) { return (when & 1) ? cl_format_str : cl_blink_str; }
|
||||
|
||||
///return pointer of font object
|
||||
inline Font** getClockFont();
|
||||
|
@@ -87,11 +87,11 @@ void CTimeOSD::initTimeString()
|
||||
struct tm t;
|
||||
if (m_mode == MODE_DESC) {
|
||||
char tt[20];
|
||||
strftime(tt, sizeof(tt), cl_format_str.c_str(), gmtime_r(&m_time_show, &t));
|
||||
strftime(tt, sizeof(tt), cl_format_str, gmtime_r(&m_time_show, &t));
|
||||
snprintf(cl_timestr, sizeof(cl_timestr), "-%s", tt);
|
||||
}
|
||||
else
|
||||
strftime(cl_timestr, sizeof(cl_timestr), cl_format_str.c_str(), gmtime_r(&m_time_show, &t));
|
||||
strftime(cl_timestr, sizeof(cl_timestr), cl_format_str, gmtime_r(&m_time_show, &t));
|
||||
}
|
||||
|
||||
void CTimeOSD::show(time_t time_show, bool force)
|
||||
|
Reference in New Issue
Block a user