mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Support Quit event
This commit is contained in:
parent
c14fc0651d
commit
6535cdd899
@ -13,7 +13,8 @@ enum class Event
|
||||
ResumeIdle,
|
||||
ToggleIdle,
|
||||
Reload,
|
||||
Restart
|
||||
Restart,
|
||||
Quit
|
||||
};
|
||||
|
||||
inline const char* eventToString(Event event)
|
||||
@ -24,6 +25,7 @@ inline const char* eventToString(Event event)
|
||||
case Event::Resume: return "Resume";
|
||||
case Event::ToggleSuspend: return "ToggleSuspend";
|
||||
case Event::Idle: return "Idle";
|
||||
case Event::Quit: return "Quit";
|
||||
case Event::ResumeIdle: return "ResumeIdle";
|
||||
case Event::ToggleIdle: return "ToggleIdle";
|
||||
case Event::Reload: return "Reload";
|
||||
@ -39,6 +41,7 @@ inline Event stringToEvent(const QString& event)
|
||||
if (event.compare("Resume")==0) return Event::Resume;
|
||||
if (event.compare("ToggleSuspend")==0) return Event::ToggleSuspend;
|
||||
if (event.compare("Idle")==0) return Event::Idle;
|
||||
if (event.compare("Quit")==0) return Event::Quit;
|
||||
if (event.compare("ResumeIdle")==0) return Event::ResumeIdle;
|
||||
if (event.compare("ToggleIdle")==0) return Event::ToggleIdle;
|
||||
if (event.compare("Reload")==0) return Event::Reload;
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
public slots:
|
||||
void suspend(bool sleep);
|
||||
void lock(bool isLocked);
|
||||
void quit();
|
||||
|
||||
virtual void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
|
||||
|
||||
@ -101,6 +102,7 @@ public:
|
||||
|
||||
void handleSignal(int signum);
|
||||
|
||||
|
||||
private:
|
||||
static OsEventHandlerLinux* getInstance();
|
||||
|
||||
|
@ -144,7 +144,7 @@ void EventHandler::handleEvent(Event event)
|
||||
{
|
||||
QObject *senderObj = QObject::sender();
|
||||
QString senderObjectClass;
|
||||
if (senderObj)
|
||||
if (senderObj != nullptr)
|
||||
{
|
||||
senderObjectClass = senderObj->metaObject()->className();
|
||||
} else
|
||||
@ -188,6 +188,10 @@ void EventHandler::handleEvent(Event event)
|
||||
Process::restartHyperion(11);
|
||||
break;
|
||||
|
||||
case Event::Quit:
|
||||
emit signalEvent(Event::Quit);
|
||||
break;
|
||||
|
||||
default:
|
||||
Error(_log,"Unkonwn Event '%d' received", event);
|
||||
break;
|
||||
|
@ -35,7 +35,7 @@ OsEventHandlerBase::OsEventHandlerBase()
|
||||
_log = Logger::getInstance("EVENTS-OS");
|
||||
|
||||
QCoreApplication* app = QCoreApplication::instance();
|
||||
if (!qobject_cast<QApplication*>(app))
|
||||
if (qobject_cast<QApplication*>(app) == nullptr)
|
||||
{
|
||||
_isService = true;
|
||||
}
|
||||
@ -46,6 +46,7 @@ OsEventHandlerBase::OsEventHandlerBase()
|
||||
|
||||
OsEventHandlerBase::~OsEventHandlerBase()
|
||||
{
|
||||
quit();
|
||||
QObject::disconnect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
|
||||
|
||||
OsEventHandlerBase::unregisterLockHandler();
|
||||
@ -130,6 +131,11 @@ void OsEventHandlerBase::lock(bool isLocked)
|
||||
}
|
||||
}
|
||||
|
||||
void OsEventHandlerBase::quit()
|
||||
{
|
||||
emit signalEvent(Event::Quit);
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
OsEventHandlerWindows* OsEventHandlerWindows::getInstance()
|
||||
|
@ -84,10 +84,8 @@ void SysTray::createTrayIcon()
|
||||
|
||||
restartAction = new QAction(tr("&Restart"), this);
|
||||
restartAction->setIcon(QPixmap(":/restart.svg"));
|
||||
connect(restartAction, &QAction::triggered, this , [=](){ Process::restartHyperion(12); });
|
||||
connect(restartAction, &QAction::triggered, this , [=](){ emit signalEvent(Event::Restart); });
|
||||
|
||||
|
||||
// TODO: Check if can be done with SystemEvents
|
||||
suspendAction = new QAction(tr("&Suspend"), this);
|
||||
suspendAction->setIcon(QPixmap(":/suspend.svg"));
|
||||
connect(suspendAction, &QAction::triggered, this, [this]() { emit signalEvent(Event::Suspend); });
|
||||
@ -129,7 +127,9 @@ void SysTray::createTrayIcon()
|
||||
|
||||
// add seperator if custom effects exists
|
||||
if (!_trayIconEfxMenu->isEmpty())
|
||||
{
|
||||
_trayIconEfxMenu->addSeparator();
|
||||
}
|
||||
|
||||
// build in effects
|
||||
for (const auto &efx : efxs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user