diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index ac3ab8e89..dccac69ec 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); @@ -162,11 +164,15 @@ void CLCD4l::StartLCD4l() 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", "systemctl"); + { + if (exec_initscript("lcd4linux", "start", "systemctl")) + 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 +185,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", "systemctl"); + + if (exec_initscript("lcd4linux", "stop", "systemctl")) + OnAfterStop(); } void CLCD4l::SwitchLCD4l() @@ -869,7 +877,11 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) WriteFile(LAYOUT, Layout); m_Layout = Layout; if (!firstRun) - exec_initscript("lcd4linux", "restart", "systemctl"); + { + OnBeforeRestart(); + if (exec_initscript("lcd4linux", "restart", "systemctl")) + OnAfterRestart(); + } } } diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index 4a9b2da16..64c6cc12f 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,7 +33,7 @@ #include #include - +#include class CLCD4l { @@ -75,6 +76,16 @@ class CLCD4l START_LCD4L = 1, RELOAD_LCD4L = 2 }; + + // 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 660849966..2a1968a64 100644 --- a/src/gui/lcd4l_setup.cpp +++ b/src/gui/lcd4l_setup.cpp @@ -7,7 +7,8 @@ Copyright (C) 2012-2018 'vanhofen' Homepage: http://www.neutrino-images.de/ - Modded (C) 2016 'TangoCash' + Modded (C) 2016 '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 @@ -87,15 +86,24 @@ const CMenuOptionChooser::keyval LCD4L_SKIN_OPTIONS[] = }; #define LCD4L_SKIN_OPTION_COUNT (sizeof(LCD4L_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() @@ -292,3 +300,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 062aadaac..6dc1feb55 100644 --- a/src/gui/lcd4l_setup.h +++ b/src/gui/lcd4l_setup.h @@ -7,7 +7,8 @@ Copyright (C) 2012-2018 'vanhofen' Homepage: http://www.neutrino-images.de/ - Modded (C) 2016 'TangoCash' + Modded (C) 2016 '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