From 7db1ffea7e58131d077d2065bd54dc29c8473c2c Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 21 Jul 2011 22:09:03 +0200 Subject: Attach modifiedSig handlers to the session.screenX.strftimeFormat resource --- src/ClockTool.cc | 15 ++++++--------- src/ClockTool.hh | 3 +-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 126e0dd..6252248 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -102,13 +102,13 @@ public: void click(int button, int time, unsigned int mods) { + std::string newformat = *m_tool.timeFormatResource(); // does the current format string contain something with 24/12h? size_t found; size_t pos = FbTk::StringUtil::findCharFromAlphabetAfterTrigger( - m_tool.timeFormat(), '%', SWITCHES_24_12H, sizeof(SWITCHES_24_12H), &found); + newformat, '%', SWITCHES_24_12H, sizeof(SWITCHES_24_12H), &found); if (pos != std::string::npos) { // if so, exchange it with 12/24h - std::string newformat = m_tool.timeFormat(); newformat[pos+1] = SWITCHES_12_24H[found]; if (found < 3) { // 24h? erase %P/%p (AM|PM / am|pm) @@ -119,7 +119,7 @@ public: } } - m_tool.setTimeFormat(newformat); + *m_tool.timeFormatResource() = newformat; setClockModeLabel(); } // else some other strange format...so we don't do anything @@ -130,7 +130,7 @@ private: void setClockModeLabel() { _FB_USES_NLS; if (FbTk::StringUtil::findCharFromAlphabetAfterTrigger( - m_tool.timeFormat(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) { + *m_tool.timeFormatResource(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) { setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); } else { setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); @@ -170,6 +170,8 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, m_stringconvertor(FbTk::StringConvertor::ToFbString) { // attach signals m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &ClockTool::themeReconfigured)); + m_tracker.join(m_timeformat.modifiedSig(), + FbTk::MemFunIgnoreArgs(*this, &ClockTool::themeReconfigured)); std::string time_locale = setlocale(LC_TIME, NULL); size_t pos = time_locale.find('.'); @@ -232,11 +234,6 @@ void ClockTool::hide() { m_button.hide(); } -void ClockTool::setTimeFormat(const std::string &format) { - *m_timeformat = format; - themeReconfigured(); -} - void ClockTool::themeReconfigured() { updateTime(); diff --git a/src/ClockTool.hh b/src/ClockTool.hh index 80dde97..8fb6f7f 100644 --- a/src/ClockTool.hh +++ b/src/ClockTool.hh @@ -54,12 +54,11 @@ public: void show(); void hide(); - void setTimeFormat(const std::string &format); // accessors unsigned int width() const; unsigned int height() const; unsigned int borderWidth() const; - const std::string &timeFormat() const { return *m_timeformat; } + FbTk::StringResource &timeFormatResource() { return m_timeformat; } void setOrientation(FbTk::Orientation orient); -- cgit v0.11.2