diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index fdacf6eee..c6d69e416 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -8,6 +8,7 @@ Homepage: http://www.neutrino-images.de/ Copyright (C) 2016-2019 'TangoCash' + Copyright (C) 2021, Thilo Graf 'dbt' License: GPL @@ -153,6 +154,7 @@ void CLCD4l::InitLCD4l() void CLCD4l::StartLCD4l() { + OnBeforeStart(); if (!thrLCD4l) { dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] starting thread with mode %d \033[0m\n", __func__, __LINE__, g_settings.lcd4l_support); @@ -161,12 +163,17 @@ void CLCD4l::StartLCD4l() thrLCD4l = new std::thread(LCD4lProc, this); dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] thread [%p] is running\033[0m\n", __func__, __LINE__, thrLCD4l); } + if (g_settings.lcd4l_support) - exec_initscript("lcd4linux", "start"); + { + if (exec_initscript("lcd4linux", "start")) + OnAfterStart(); + } } void CLCD4l::StopLCD4l() { + OnBeforeStop(); if (thrLCD4l) { dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] stopping thread [%p]\033[0m\n", __func__, __LINE__, thrLCD4l); @@ -179,7 +186,9 @@ void CLCD4l::StopLCD4l() thrLCD4l = NULL; dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] thread [%p] terminated\033[0m\n", __func__, __LINE__, thrLCD4l); } - exec_initscript("lcd4linux", "stop"); + + if (exec_initscript("lcd4linux", "stop")) + OnAfterStop(); } void CLCD4l::SwitchLCD4l() @@ -843,7 +852,11 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) m_Layout = Layout; if (!firstRun) - exec_initscript("lcd4linux", "reload"); + { + OnBeforeRestart(); + if (exec_initscript("lcd4linux", "restart")) + OnAfterRestart(); + } } } diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index d50fc9b2e..b541384a1 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -8,6 +8,7 @@ Homepage: http://www.neutrino-images.de/ Copyright (C) 2016-2019 'TangoCash' + Copyright (C) 2021, Thilo Graf 'dbt' License: GPL @@ -32,6 +33,7 @@ #include #include +#include class CLCD4l { @@ -63,6 +65,15 @@ class CLCD4l void ResetParseID() { m_ParseID = 0; } + // use signal/slot handlers + // That is helping to keep the GUI code away from code inside ./src/driver. + sigc::signal OnBeforeRestart, + OnAfterRestart, + OnBeforeStart, + OnAfterStart, + OnBeforeStop, + OnAfterStop; + private: std::thread *thrLCD4l; static void *LCD4lProc(void *arg); diff --git a/src/gui/lcd4l_setup.cpp b/src/gui/lcd4l_setup.cpp index e6b514c71..df4f3b0b2 100644 --- a/src/gui/lcd4l_setup.cpp +++ b/src/gui/lcd4l_setup.cpp @@ -4,10 +4,11 @@ Copyright (C) 2012 'defans' Homepage: http://www.bluepeercrew.us/ - Copyright (C) 2012-2018 'vanhofen' + Copyright (C) 2012-2021 'vanhofen' Homepage: http://www.neutrino-images.de/ Copyright (C) 2016-2018 'TangoCash' + (C) 2021, Thilo Graf 'dbt' License: GPL @@ -22,9 +23,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - + along with this program. If not, see . */ #ifdef HAVE_CONFIG_H @@ -89,15 +88,24 @@ const CMenuOptionChooser::keyval LCD4L_SAMSUNG_SKIN_OPTIONS[] = }; #define LCD4L_SAMSUNG_SKIN_OPTION_COUNT (sizeof(LCD4L_SAMSUNG_SKIN_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) +using namespace sigc; + CLCD4lSetup::CLCD4lSetup() { width = 40; - + hint = NULL; lcd4l_display_type_changed = false; + + sl_start = bind(mem_fun(*this, &CLCD4lSetup::showHint), "Starting lcd service..."); + sl_stop = bind(mem_fun(*this, &CLCD4lSetup::showHint), "Stopping lcd service..."); + sl_restart = bind(mem_fun(*this, &CLCD4lSetup::showHint), "Restarting lcd service..."); + sl_remove = mem_fun(*this, &CLCD4lSetup::removeHint); + connectSlots(); } CLCD4lSetup::~CLCD4lSetup() { + removeHint(); } CLCD4lSetup* CLCD4lSetup::getInstance() @@ -304,3 +312,32 @@ int CLCD4lSetup::showTypeSetup() return typeSetup->exec(NULL, ""); } + +void CLCD4lSetup::showHint(const std::string &text) +{ + removeHint(); + hint = new CHint(text.c_str()); + hint->paint(); + +} + +void CLCD4lSetup::removeHint() +{ + if (hint) + { + hint->hide(); + delete hint; + hint = NULL; + } +} + +void CLCD4lSetup::connectSlots() +{ + CLCD4l::getInstance()->OnBeforeStart.connect(sl_start); + CLCD4l::getInstance()->OnBeforeStop.connect(sl_stop); + CLCD4l::getInstance()->OnBeforeRestart.connect(sl_restart); + + CLCD4l::getInstance()->OnAfterStart.connect(sl_remove); + CLCD4l::getInstance()->OnAfterStop.connect(sl_remove); + CLCD4l::getInstance()->OnAfterRestart.connect(sl_remove); +} diff --git a/src/gui/lcd4l_setup.h b/src/gui/lcd4l_setup.h index d9665d02d..4dddc677f 100644 --- a/src/gui/lcd4l_setup.h +++ b/src/gui/lcd4l_setup.h @@ -4,10 +4,11 @@ Copyright (C) 2012 'defans' Homepage: http://www.bluepeercrew.us/ - Copyright (C) 2012-2018 'vanhofen' + Copyright (C) 2012-2021 'vanhofen' Homepage: http://www.neutrino-images.de/ Copyright (C) 2016-2018 'TangoCash' + (C) 2021, Thilo Graf 'dbt' License: GPL @@ -22,16 +23,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - + along with this program. If not, see . */ #ifndef __lcd4l_setup__ #define __lcd4l_setup__ -#include +#include "gui/widget/menue.h" +#include "gui/widget/hintbox.h" +#include class CLCD4lSetup : public CMenuTarget, CChangeObserver { @@ -45,12 +46,20 @@ class CLCD4lSetup : public CMenuTarget, CChangeObserver int show(); int showTypeSetup(); + //messages + CHint *hint; + void removeHint(); + void showHint(const std::string &text); + //slots + sigc::slot sl_start, sl_stop, sl_restart, sl_remove; + public: static CLCD4lSetup* getInstance(); CLCD4lSetup(); ~CLCD4lSetup(); int exec(CMenuTarget *parent, const std::string &actionkey); virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/); + void connectSlots(); }; #endif