Skip to content

Commit

Permalink
Fix #1671 (#1672)
Browse files Browse the repository at this point in the history
* Refactor to fix #1671

* Add GUI/NonGUI mode to info page

* Do not show lock config, if in non-UI mode

* Updae Changelog

* Correct includes

* Remove unused variable

* use ninja generator under macos

---------

Co-authored-by: Paulchen-Panther <[email protected]>
  • Loading branch information
Lord-Grey and Paulchen-Panther authored Jan 3, 2024
1 parent 3f2375d commit cdd59ff
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 120 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Note: The wizard will configure an APIv2 capable bridge always with Entertainmen
- Fixed that the Matrix effect finds its image - Thanks @lsellens
- MDNSBrower - Fixed, if timeout while resolving host occurs
- Non image updates ignored blacklisted LEDs (#1634)
- Fixed that Windows OsEvents failed in non-GUI mode (#1671)

##### LED-Devices

Expand Down
7 changes: 7 additions & 0 deletions assets/webconfig/js/content_events.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$(document).ready(function () {
performTranslation();

let isGuiMode = window.sysInfo.hyperion.isGuiMode;
const CEC_ENABLED = (jQuery.inArray("cec", window.serverInfo.services) !== -1);

let conf_editor_osEvents = null;
Expand Down Expand Up @@ -76,6 +77,12 @@ $(document).ready(function () {
osEvents: window.schema.osEvents
}, true, true);

conf_editor_osEvents.on('ready', function () {
if (!isGuiMode) {
showInputOptionsForKey(conf_editor_osEvents, "osEvents", "suspendEnable", false);
}
});

conf_editor_osEvents.on('change', function () {
conf_editor_osEvents.validate().length || window.readOnlyMode ? $('#btn_submit_os_events').prop('disabled', true) : $('#btn_submit_os_events').prop('disabled', false);
});
Expand Down
1 change: 1 addition & 0 deletions assets/webconfig/js/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ function getSystemInfo() {
info += '- Avail Services: ' + window.serverInfo.services + '\n';
info += '- Config path: ' + shy.rootPath + '\n';
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
info += '- Mode: ' + (shy.isGuiMode ? "GUI" : "Non-GUI") + '\n';

info += '\n';

Expand Down
29 changes: 19 additions & 10 deletions include/events/OsEventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QAbstractEventDispatcher>
#include <QWidget>
#include <windows.h>
#include <powrprof.h>
#endif

#include <utils/settings.h>
Expand All @@ -21,8 +22,9 @@ class OsEventHandlerBase : public QObject
Q_OBJECT

public:

OsEventHandlerBase();
~OsEventHandlerBase() override;
virtual ~OsEventHandlerBase();

public slots:
void suspend(bool sleep);
Expand All @@ -46,17 +48,20 @@ public slots:
bool _isSuspendRegistered;
bool _isLockRegistered;

Logger * _log {};
bool _isService;

Logger* _log{};
};

#if defined(_WIN32)

class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeEventFilter
{

public:
OsEventHandlerWindows();
~OsEventHandlerWindows() override;
~OsEventHandlerWindows();

void handleSuspendResumeEvent(bool sleep);

protected:
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
Expand All @@ -65,13 +70,17 @@ class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeE
bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) override;
#endif

private:
bool registerOsEventHandler() override;
void unregisterOsEventHandler() override;
bool registerLockHandler() override;
void unregisterLockHandler() override;

QWidget _widget;
private:
static OsEventHandlerWindows* getInstance();

static DEVICE_NOTIFY_CALLBACK_ROUTINE handlePowerNotifications;

QWidget* _widget;
HPOWERNOTIFY _notifyHandle;
};

Expand All @@ -82,15 +91,15 @@ class OsEventHandlerLinux : public OsEventHandlerBase
{
Q_OBJECT

static void static_signaleHandler(int signum)
static void static_signaleHandler(int signum)
{
OsEventHandlerLinux::getInstance()->handleSignal(signum);
}

public:
OsEventHandlerLinux();

void handleSignal (int signum);
void handleSignal(int signum);

private:
static OsEventHandlerLinux* getInstance();
Expand Down Expand Up @@ -119,8 +128,8 @@ class OsEventHandlerMacOS : public OsEventHandlerBase
bool registerLockHandler() override;
void unregisterLockHandler() override;

void *_sleepEventHandler;
void *_lockEventHandler;
void* _sleepEventHandler;
void* _lockEventHandler;
};

using OsEventHandler = OsEventHandlerMacOS;
Expand Down
5 changes: 5 additions & 0 deletions libsrc/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <QTimer>
#include <QHostInfo>
#include <QMultiMap>
#include <QCoreApplication>
#include <QApplication>

// hyperion includes
#include <leddevice/LedDeviceWrapper.h>
Expand Down Expand Up @@ -389,6 +391,9 @@ void JsonAPI::handleSysInfoCommand(const QJsonObject &, const QString &command,
hyperion["rootPath"] = _instanceManager->getRootPath();
hyperion["readOnlyMode"] = _hyperion->getReadOnlyMode();

QCoreApplication* app = QCoreApplication::instance();
hyperion["isGuiMode"] = qobject_cast<QApplication*>(app) ? true : false;

info["hyperion"] = hyperion;

// send the result
Expand Down
Loading

0 comments on commit cdd59ff

Please sign in to comment.