mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
lcd4linux: add slots for more user involvement
Keeps gui stuff away from parts of /src/driver and callbacks with messages should inform the user about possible operations during activation or deactivation of service. Reason: long breaks are mediating freeze or unknown status that leave the user in the dark.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
Homepage: http://www.neutrino-images.de/
|
Homepage: http://www.neutrino-images.de/
|
||||||
|
|
||||||
Copyright (C) 2016-2019 'TangoCash'
|
Copyright (C) 2016-2019 'TangoCash'
|
||||||
|
Copyright (C) 2021, Thilo Graf 'dbt'
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -153,6 +154,7 @@ void CLCD4l::InitLCD4l()
|
|||||||
|
|
||||||
void CLCD4l::StartLCD4l()
|
void CLCD4l::StartLCD4l()
|
||||||
{
|
{
|
||||||
|
OnBeforeStart();
|
||||||
if (!thrLCD4l)
|
if (!thrLCD4l)
|
||||||
{
|
{
|
||||||
dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] starting thread with mode %d \033[0m\n", __func__, __LINE__, g_settings.lcd4l_support);
|
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);
|
dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] thread [%p] is running\033[0m\n", __func__, __LINE__, thrLCD4l);
|
||||||
}
|
}
|
||||||
if (g_settings.lcd4l_support)
|
if (g_settings.lcd4l_support)
|
||||||
exec_initscript("lcd4linux", "start", "systemctl");
|
{
|
||||||
|
if (exec_initscript("lcd4linux", "start", "systemctl"))
|
||||||
|
OnAfterStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLCD4l::StopLCD4l()
|
void CLCD4l::StopLCD4l()
|
||||||
{
|
{
|
||||||
|
OnBeforeStop();
|
||||||
if (thrLCD4l)
|
if (thrLCD4l)
|
||||||
{
|
{
|
||||||
dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] stopping thread [%p]\033[0m\n", __func__, __LINE__, 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;
|
thrLCD4l = NULL;
|
||||||
dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] thread [%p] terminated\033[0m\n", __func__, __LINE__, thrLCD4l);
|
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()
|
void CLCD4l::SwitchLCD4l()
|
||||||
@@ -869,7 +877,11 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun)
|
|||||||
WriteFile(LAYOUT, Layout);
|
WriteFile(LAYOUT, Layout);
|
||||||
m_Layout = Layout;
|
m_Layout = Layout;
|
||||||
if (!firstRun)
|
if (!firstRun)
|
||||||
exec_initscript("lcd4linux", "restart", "systemctl");
|
{
|
||||||
|
OnBeforeRestart();
|
||||||
|
if (exec_initscript("lcd4linux", "restart", "systemctl"))
|
||||||
|
OnAfterRestart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
Homepage: http://www.neutrino-images.de/
|
Homepage: http://www.neutrino-images.de/
|
||||||
|
|
||||||
Copyright (C) 2016-2019 'TangoCash'
|
Copyright (C) 2016-2019 'TangoCash'
|
||||||
|
Copyright (C) 2021, Thilo Graf 'dbt'
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <sigc++/signal.h>
|
||||||
|
|
||||||
class CLCD4l
|
class CLCD4l
|
||||||
{
|
{
|
||||||
@@ -75,6 +76,16 @@ class CLCD4l
|
|||||||
START_LCD4L = 1,
|
START_LCD4L = 1,
|
||||||
RELOAD_LCD4L = 2
|
RELOAD_LCD4L = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// use signal/slot handlers
|
||||||
|
// That is helping to keep the GUI code away from code inside ./src/driver.
|
||||||
|
sigc::signal<void> OnBeforeRestart,
|
||||||
|
OnAfterRestart,
|
||||||
|
OnBeforeStart,
|
||||||
|
OnAfterStart,
|
||||||
|
OnBeforeStop,
|
||||||
|
OnAfterStop;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::thread *thrLCD4l;
|
std::thread *thrLCD4l;
|
||||||
static void *LCD4lProc(void *arg);
|
static void *LCD4lProc(void *arg);
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
Homepage: http://www.neutrino-images.de/
|
Homepage: http://www.neutrino-images.de/
|
||||||
|
|
||||||
Modded (C) 2016 'TangoCash'
|
Modded (C) 2016 'TangoCash'
|
||||||
|
(C) 2021, Thilo Graf 'dbt'
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -22,9 +23,7 @@
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#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))
|
#define LCD4L_SKIN_OPTION_COUNT (sizeof(LCD4L_SKIN_OPTIONS)/sizeof(CMenuOptionChooser::keyval))
|
||||||
|
|
||||||
|
using namespace sigc;
|
||||||
|
|
||||||
CLCD4lSetup::CLCD4lSetup()
|
CLCD4lSetup::CLCD4lSetup()
|
||||||
{
|
{
|
||||||
width = 40;
|
width = 40;
|
||||||
|
hint = NULL;
|
||||||
lcd4l_display_type_changed = false;
|
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()
|
CLCD4lSetup::~CLCD4lSetup()
|
||||||
{
|
{
|
||||||
|
removeHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLCD4lSetup* CLCD4lSetup::getInstance()
|
CLCD4lSetup* CLCD4lSetup::getInstance()
|
||||||
@@ -292,3 +300,32 @@ int CLCD4lSetup::showTypeSetup()
|
|||||||
|
|
||||||
return typeSetup->exec(NULL, "");
|
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);
|
||||||
|
}
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
Homepage: http://www.neutrino-images.de/
|
Homepage: http://www.neutrino-images.de/
|
||||||
|
|
||||||
Modded (C) 2016 'TangoCash'
|
Modded (C) 2016 'TangoCash'
|
||||||
|
(C) 2021, Thilo Graf 'dbt'
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -22,16 +23,16 @@
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __lcd4l_setup__
|
#ifndef __lcd4l_setup__
|
||||||
#define __lcd4l_setup__
|
#define __lcd4l_setup__
|
||||||
|
|
||||||
#include <gui/widget/menue.h>
|
#include "gui/widget/menue.h"
|
||||||
|
#include "gui/widget/hintbox.h"
|
||||||
|
#include <sigc++/signal.h>
|
||||||
|
|
||||||
class CLCD4lSetup : public CMenuTarget, CChangeObserver
|
class CLCD4lSetup : public CMenuTarget, CChangeObserver
|
||||||
{
|
{
|
||||||
@@ -45,12 +46,20 @@ class CLCD4lSetup : public CMenuTarget, CChangeObserver
|
|||||||
int show();
|
int show();
|
||||||
int showTypeSetup();
|
int showTypeSetup();
|
||||||
|
|
||||||
|
//messages
|
||||||
|
CHint *hint;
|
||||||
|
void removeHint();
|
||||||
|
void showHint(const std::string &text);
|
||||||
|
//slots
|
||||||
|
sigc::slot<void> sl_start, sl_stop, sl_restart, sl_remove;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CLCD4lSetup* getInstance();
|
static CLCD4lSetup* getInstance();
|
||||||
CLCD4lSetup();
|
CLCD4lSetup();
|
||||||
~CLCD4lSetup();
|
~CLCD4lSetup();
|
||||||
int exec(CMenuTarget *parent, const std::string &actionkey);
|
int exec(CMenuTarget *parent, const std::string &actionkey);
|
||||||
virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
|
virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
|
||||||
|
void connectSlots();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user