Skip to content

Commit cdd59ff

Browse files
Fix #1671 (#1672)
* 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 <16664240+Paulchen-Panther@users.noreply.github.com>
1 parent 3f2375d commit cdd59ff

File tree

6 files changed

+184
-120
lines changed

6 files changed

+184
-120
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Note: The wizard will configure an APIv2 capable bridge always with Entertainmen
5252
- Fixed that the Matrix effect finds its image - Thanks @lsellens
5353
- MDNSBrower - Fixed, if timeout while resolving host occurs
5454
- Non image updates ignored blacklisted LEDs (#1634)
55+
- Fixed that Windows OsEvents failed in non-GUI mode (#1671)
5556

5657
##### LED-Devices
5758

assets/webconfig/js/content_events.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
$(document).ready(function () {
22
performTranslation();
33

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

67
let conf_editor_osEvents = null;
@@ -76,6 +77,12 @@ $(document).ready(function () {
7677
osEvents: window.schema.osEvents
7778
}, true, true);
7879

80+
conf_editor_osEvents.on('ready', function () {
81+
if (!isGuiMode) {
82+
showInputOptionsForKey(conf_editor_osEvents, "osEvents", "suspendEnable", false);
83+
}
84+
});
85+
7986
conf_editor_osEvents.on('change', function () {
8087
conf_editor_osEvents.validate().length || window.readOnlyMode ? $('#btn_submit_os_events').prop('disabled', true) : $('#btn_submit_os_events').prop('disabled', false);
8188
});

assets/webconfig/js/ui_utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ function getSystemInfo() {
12241224
info += '- Avail Services: ' + window.serverInfo.services + '\n';
12251225
info += '- Config path: ' + shy.rootPath + '\n';
12261226
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
1227+
info += '- Mode: ' + (shy.isGuiMode ? "GUI" : "Non-GUI") + '\n';
12271228

12281229
info += '\n';
12291230

include/events/OsEventHandler.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QAbstractEventDispatcher>
1111
#include <QWidget>
1212
#include <windows.h>
13+
#include <powrprof.h>
1314
#endif
1415

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

2324
public:
25+
2426
OsEventHandlerBase();
25-
~OsEventHandlerBase() override;
27+
virtual ~OsEventHandlerBase();
2628

2729
public slots:
2830
void suspend(bool sleep);
@@ -46,17 +48,20 @@ public slots:
4648
bool _isSuspendRegistered;
4749
bool _isLockRegistered;
4850

49-
Logger * _log {};
51+
bool _isService;
52+
53+
Logger* _log{};
5054
};
5155

5256
#if defined(_WIN32)
5357

5458
class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeEventFilter
5559
{
56-
5760
public:
5861
OsEventHandlerWindows();
59-
~OsEventHandlerWindows() override;
62+
~OsEventHandlerWindows();
63+
64+
void handleSuspendResumeEvent(bool sleep);
6065

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

68-
private:
6973
bool registerOsEventHandler() override;
7074
void unregisterOsEventHandler() override;
7175
bool registerLockHandler() override;
7276
void unregisterLockHandler() override;
7377

74-
QWidget _widget;
78+
private:
79+
static OsEventHandlerWindows* getInstance();
80+
81+
static DEVICE_NOTIFY_CALLBACK_ROUTINE handlePowerNotifications;
82+
83+
QWidget* _widget;
7584
HPOWERNOTIFY _notifyHandle;
7685
};
7786

@@ -82,15 +91,15 @@ class OsEventHandlerLinux : public OsEventHandlerBase
8291
{
8392
Q_OBJECT
8493

85-
static void static_signaleHandler(int signum)
94+
static void static_signaleHandler(int signum)
8695
{
8796
OsEventHandlerLinux::getInstance()->handleSignal(signum);
8897
}
8998

9099
public:
91100
OsEventHandlerLinux();
92101

93-
void handleSignal (int signum);
102+
void handleSignal(int signum);
94103

95104
private:
96105
static OsEventHandlerLinux* getInstance();
@@ -119,8 +128,8 @@ class OsEventHandlerMacOS : public OsEventHandlerBase
119128
bool registerLockHandler() override;
120129
void unregisterLockHandler() override;
121130

122-
void *_sleepEventHandler;
123-
void *_lockEventHandler;
131+
void* _sleepEventHandler;
132+
void* _lockEventHandler;
124133
};
125134

126135
using OsEventHandler = OsEventHandlerMacOS;

libsrc/api/JsonAPI.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <QTimer>
1111
#include <QHostInfo>
1212
#include <QMultiMap>
13+
#include <QCoreApplication>
14+
#include <QApplication>
1315

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

394+
QCoreApplication* app = QCoreApplication::instance();
395+
hyperion["isGuiMode"] = qobject_cast<QApplication*>(app) ? true : false;
396+
392397
info["hyperion"] = hyperion;
393398

394399
// send the result

0 commit comments

Comments
 (0)