mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +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
This commit is contained in:
@@ -72,7 +72,8 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, const int& y_pos, c
|
|||||||
cl_thread = 0;
|
cl_thread = 0;
|
||||||
cl_interval = 1;
|
cl_interval = 1;
|
||||||
|
|
||||||
cl_blink_str = "";
|
activeClock = true;
|
||||||
|
cl_blink_str = format_str;
|
||||||
paintClock = false;
|
paintClock = false;
|
||||||
|
|
||||||
activeClock = activ;
|
activeClock = activ;
|
||||||
@@ -89,12 +90,13 @@ CComponentsFrmClock::~CComponentsFrmClock()
|
|||||||
stopThread();
|
stopThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CComponentsFrmClock::initTimeString()
|
void CComponentsFrmClock::initTimeString()
|
||||||
{
|
{
|
||||||
struct tm t;
|
struct tm t;
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
ltime=time(<ime);
|
ltime=time(NULL);
|
||||||
strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format_str.c_str(), localtime_r(<ime, &t));
|
strftime((char*) &cl_timestr, sizeof(cl_timestr), getTimeFormat(ltime), localtime_r(<ime, &t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// How does it works?
|
// How does it works?
|
||||||
@@ -261,20 +263,9 @@ void* CComponentsFrmClock::initClockThread(void *arg)
|
|||||||
#if 0
|
#if 0
|
||||||
time_t count = time(0);
|
time_t count = time(0);
|
||||||
#endif
|
#endif
|
||||||
std::string format_str_save = clock->cl_format_str; // FIXME. This will cause setClockFormat() to be ignored. --martii
|
|
||||||
//start loop for paint
|
//start loop for paint
|
||||||
while(clock != NULL) {
|
while(clock != NULL) {
|
||||||
if (clock->paintClock) {
|
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);
|
clock->paint(CC_SAVE_SCREEN_NO);
|
||||||
#if 0
|
#if 0
|
||||||
count = time(0);
|
count = time(0);
|
||||||
|
@@ -71,10 +71,10 @@ class CComponentsFrmClock : public CComponentsForm
|
|||||||
///text color
|
///text color
|
||||||
int cl_col_text;
|
int cl_col_text;
|
||||||
///time format
|
///time format
|
||||||
std::string cl_format_str;
|
const char *cl_format_str;
|
||||||
///time format for blink
|
///time format for blink
|
||||||
std::string cl_blink_str;
|
const char *cl_blink_str;
|
||||||
///time string align, default allign is ver and hor centered
|
///time string align, default align is ver and hor centered
|
||||||
int cl_align;
|
int cl_align;
|
||||||
|
|
||||||
///initialize clock contents
|
///initialize clock contents
|
||||||
@@ -83,6 +83,8 @@ class CComponentsFrmClock : public CComponentsForm
|
|||||||
virtual void initTimeString();
|
virtual void initTimeString();
|
||||||
///initialize of general alignment of timestring segments within form area
|
///initialize of general alignment of timestring segments within form area
|
||||||
void initSegmentAlign(int* segment_width, int* segment_height);
|
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
|
///return pointer of font object
|
||||||
inline Font** getClockFont();
|
inline Font** getClockFont();
|
||||||
|
@@ -87,11 +87,11 @@ void CTimeOSD::initTimeString()
|
|||||||
struct tm t;
|
struct tm t;
|
||||||
if (m_mode == MODE_DESC) {
|
if (m_mode == MODE_DESC) {
|
||||||
char tt[20];
|
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);
|
snprintf(cl_timestr, sizeof(cl_timestr), "-%s", tt);
|
||||||
}
|
}
|
||||||
else
|
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)
|
void CTimeOSD::show(time_t time_show, bool force)
|
||||||
|
Reference in New Issue
Block a user