Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Fixes/Updates #1549

Merged
merged 16 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions assets/webconfig/js/content_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ $(document).ready(function () {
if (getStorage('lastSelectedInstance'))
removeStorage('lastSelectedInstance')

currentHyperionInstance = 0;
currentHyperionInstanceName = getInstanceNameByIndex(0);
window.currentHyperionInstance = 0;
window.currentHyperionInstanceName = getInstanceNameByIndex(0);

requestServerConfig();
setTimeout(requestServerInfo, 100)
setTimeout(requestTokenInfo, 200)
Expand All @@ -293,7 +294,7 @@ $(document).ready(function () {
$('#btn_hypinstanceswitch').toggle(false)

// update listing for button
updateUiOnInstance(currentHyperionInstance);
updateUiOnInstance(window.currentHyperionInstance);
updateHyperionInstanceListing();
});

Expand Down
46 changes: 31 additions & 15 deletions assets/webconfig/js/content_logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,45 @@ $(document).ready(function () {
function infoSummary() {
var info = "";

info += 'Hyperion System Summary Report (' + window.serverConfig.general.name + '), Reported instance: ' + window.currentHyperionInstanceName + '\n';
info += 'Hyperion System Summary Report (' + window.serverConfig.general.name + ')\n';
info += 'Reported instance: [' + window.currentHyperionInstance + '] - ' + window.currentHyperionInstanceName + '\n';

info += "\n< ----- System information -------------------- >\n";
info += getSystemInfo() + '\n';

info += "\n< ----- Configured Instances ------------------ >\n";
var instances = window.serverInfo.instance;
for (var i = 0; i < instances.length; i++) {
info += instances[i].instance + ': ' + instances[i].friendly_name + ' Running: ' + instances[i].running + '\n';
info += instances[i].instance + ': ' + instances[i].friendly_name + ', Running: ' + instances[i].running + '\n';
}

info += "\n< ----- This instance's priorities ------------ >\n";
var prios = window.serverInfo.priorities;
for (var i = 0; i < prios.length; i++) {
info += prios[i].priority + ': ';
if (prios[i].visible) {
info += ' VISIBLE!';
}
else {
info += ' ';

if (prios.length > 0) {

for (var i = 0; i < prios.length; i++) {

var prio = prios[i].priority.toString().padStart(3, '0');

info += prio + ': ';
if (prios[i].visible) {
info += ' VISIBLE -';
}
else {
info += ' INVISIBLE -';
}
info += ' (' + prios[i].componentId + ')';
if (prios[i].owner) {
info += ' (Owner: ' + prios[i].owner + ')';
}
info += '\n';

}
info += ' (' + prios[i].componentId + ') Owner: ' + prios[i].owner + '\n';
} else {
info += 'The current priority list is empty!\n';
}
info += 'priorities_autoselect: ' + window.serverInfo.priorities_autoselect + '\n';
info += 'Autoselect: ' + window.serverInfo.priorities_autoselect + '\n';

info += "\n< ----- This instance components' status ------->\n";
var comps = window.serverInfo.components;
Expand All @@ -67,7 +82,7 @@ $(document).ready(function () {
}

info += "\n< ----- This instance's configuration --------- >\n";
info += JSON.stringify(window.serverConfig) + '\n';
info += JSON.stringify(window.serverConfig, null, 2) + '\n';

info += "\n< ----- Current Log --------------------------- >\n";
var logMsgs = document.getElementById("logmessages").textContent;
Expand Down Expand Up @@ -193,18 +208,19 @@ $(document).ready(function () {
});

// toggle fullscreen button in log output
$(".fullscreen-btn").mousedown(function(e) {
$(".fullscreen-btn").mousedown(function (e) {
e.preventDefault();
});

$(".fullscreen-btn").click(function(e) {
$(".fullscreen-btn").click(function (e) {
e.preventDefault();
$(this).children('i')
.toggleClass('fa-expand')
.toggleClass('fa-compress');
$('#conf_cont').toggle();
$('#logmessages').css('max-height', $('#logmessages').css('max-height') !== 'none' ? 'none' : '400px' );
$('#logmessages').css('max-height', $('#logmessages').css('max-height') !== 'none' ? 'none' : '400px');
});

removeOverlay();
});

4 changes: 4 additions & 0 deletions assets/webconfig/js/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function initLanguageSelection() {
}

function updateUiOnInstance(inst) {

window.currentHyperionInstance = inst;
window.currentHyperionInstanceName = getInstanceNameByIndex(inst);

$("#active_instance_friendly_name").text(getInstanceNameByIndex(inst));
if (window.serverInfo.instance.filter(entry => entry.running).length > 1) {
$('#btn_hypinstanceswitch').toggle(true);
Expand Down
22 changes: 17 additions & 5 deletions assets/webconfig/js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,17 @@ function checkUserResult(reply, usr) {

function useGroupId(id) {
$('#groupId').val(id);
groupLights = hueGroups[id].lights;

//Ensure ligthIDs are strings
groupLights = hueGroups[id].lights.map(num => {
return String(num);
});

groupLightsLocations = hueGroups[id].locations;
get_hue_lights();
}


async function discover_hue_bridges() {
$('#wiz_hue_ipstate').html($.i18n('edt_dev_spec_devices_discovery_inprogress'));
$('#wiz_hue_discovered').html("")
Expand Down Expand Up @@ -1016,11 +1022,11 @@ function beginWizardHue() {
$('#host').val(host);

var port = eV("port");
if (port > 0) {
$('#port').val(port);
if (port == 0) {
$('#port').val(80);
}
else {
$('#port').val('');
$('#port').val(port);
}
hueIPs.unshift({ host: host, port: port });

Expand All @@ -1037,7 +1043,13 @@ function beginWizardHue() {

hueIPs = [];
hueIPsinc = 0;
hueIPs.push({ host: $('#host').val(), port: $('#port').val() });

var port = $('#port').val();
if (isNaN(port) || port < 1 || port > 65535) {
port = 80;
$('#port').val(80);
}
hueIPs.push({ host: $('#host').val(), port: port });
}
else {
discover_hue_bridges();
Expand Down
8 changes: 6 additions & 2 deletions cmake/FindWindowsSDK.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# - Find the Windows SDK aka Platform SDK
# - Find the Windows SDK aka Platform SDK (from https://github.com/rpavlik/cmake-modules)
#
# Relevant Wikipedia article: http://en.wikipedia.org/wiki/Microsoft_Windows_SDK
#
Expand Down Expand Up @@ -49,10 +49,11 @@
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2012.
# Copyright 2012, Iowa State University
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# SPDX-License-Identifier: BSL-1.0

set(_preferred_sdk_dirs) # pre-output
set(_win_sdk_dirs) # pre-output
Expand All @@ -76,6 +77,9 @@ endmacro()
# although version numbers listed on that page don't necessarily match the directory
# used by the installer.
set(_winsdk_win10vers
10.0.22000.0
10.0.20348.0
10.0.19041.0
10.0.18362.0 # Win10 1903 "19H1"
10.0.17763.0 # Win10 1809 "October 2018 Update"
10.0.17134.0 # Redstone 4 aka Win10 1803 "April 2018 Update"
Expand Down
2 changes: 1 addition & 1 deletion cmake/packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ endif()
# .deb files for apt
# https://cmake.org/cmake/help/latest/cpack_gen/deb.html
SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" )
SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4" )
SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4 | libcec (>= 4.0)" )
SET ( CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" )

# .rpm for rpm
Expand Down
19 changes: 1 addition & 18 deletions include/mdns/MdnsBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

// Utility includes
#include <utils/Logger.h>
#include <utils/WeakConnect.h>

namespace {
constexpr std::chrono::milliseconds DEFAULT_DISCOVER_TIMEOUT{ 500 };
Expand Down Expand Up @@ -103,24 +104,6 @@ private slots:
void onServiceRemoved(const QMdnsEngine::Service& service);

private:

template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

/// The logger instance for mDNS-Service
Logger* _log;

Expand Down
2 changes: 1 addition & 1 deletion include/utils/NetUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace NetUtils {
{
if ((port <= 0 || port > MAX_PORT) && port != -1)
{
Error(log, "Invalid port [%d] for host: (%s)! - Port must be in range [0 - %d]", port, QSTRING_CSTR(host), MAX_PORT);
Error(log, "Invalid port [%d] for host: (%s)! - Port must be in range [1 - %d]", port, QSTRING_CSTR(host), MAX_PORT);
return false;
}
return true;
Expand Down
63 changes: 63 additions & 0 deletions include/utils/WeakConnect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef WEAKCONNECT_H
#define WEAKCONNECT_H

#include <type_traits>

// Qt includes
#include <QObject>

template <typename Func1, typename Func2, typename std::enable_if_t<std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
typename QtPrivate::FunctionPointer<Func2>::Object* receiver,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, receiver, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
typename QtPrivate::FunctionPointer<Func2>::Object* receiver,
Func2 slot)
{
Q_UNUSED(receiver);
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

#endif // WEAKCONNECT_H
18 changes: 9 additions & 9 deletions include/utils/hyperion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
///
namespace hyperion {

void handleInitialEffect(Hyperion* hyperion, const QJsonObject& FGEffectConfig)
static void handleInitialEffect(Hyperion* hyperion, const QJsonObject& FGEffectConfig)
{
#define FGCONFIG_ARRAY fgColorConfig.toArray()

Expand Down Expand Up @@ -63,12 +63,12 @@ namespace hyperion {
#undef FGCONFIG_ARRAY
}

ColorOrder createColorOrder(const QJsonObject &deviceConfig)
static ColorOrder createColorOrder(const QJsonObject &deviceConfig)
{
return stringToColorOrder(deviceConfig["colorOrder"].toString("rgb"));
}

RgbTransform createRgbTransform(const QJsonObject& colorConfig)
static RgbTransform createRgbTransform(const QJsonObject& colorConfig)
{
const double backlightThreshold = colorConfig["backlightThreshold"].toDouble(0.0);
const bool backlightColored = colorConfig["backlightColored"].toBool(false);
Expand All @@ -81,15 +81,15 @@ namespace hyperion {
return RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, static_cast<uint8_t>(brightness), static_cast<uint8_t>(brightnessComp));
}

OkhsvTransform createOkhsvTransform(const QJsonObject& colorConfig)
static OkhsvTransform createOkhsvTransform(const QJsonObject& colorConfig)
{
const double saturationGain = colorConfig["saturationGain"].toDouble(1.0);
const double brightnessGain = colorConfig["brightnessGain"].toDouble(1.0);

return OkhsvTransform(saturationGain, brightnessGain);
}

RgbChannelAdjustment createRgbChannelAdjustment(const QJsonObject& colorConfig, const QString& channelName, int defaultR, int defaultG, int defaultB)
static RgbChannelAdjustment createRgbChannelAdjustment(const QJsonObject& colorConfig, const QString& channelName, int defaultR, int defaultG, int defaultB)
{
const QJsonArray& channelConfig = colorConfig[channelName].toArray();
return RgbChannelAdjustment(
Expand All @@ -100,7 +100,7 @@ namespace hyperion {
);
}

ColorAdjustment* createColorAdjustment(const QJsonObject & adjustmentConfig)
static ColorAdjustment* createColorAdjustment(const QJsonObject & adjustmentConfig)
{
const QString id = adjustmentConfig["id"].toString("default");

Expand All @@ -120,7 +120,7 @@ namespace hyperion {
return adjustment;
}

MultiColorAdjustment * createLedColorsAdjustment(int ledCnt, const QJsonObject & colorConfig)
static MultiColorAdjustment * createLedColorsAdjustment(int ledCnt, const QJsonObject & colorConfig)
{
// Create the result, the transforms are added to this
MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt);
Expand Down Expand Up @@ -184,7 +184,7 @@ namespace hyperion {
* @param deviceOrder The default RGB channel ordering
* @return The constructed ledstring
*/
LedString createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder)
static LedString createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder)
{
LedString ledString;
const QString deviceOrderStr = colorOrderToString(deviceOrder);
Expand Down Expand Up @@ -215,7 +215,7 @@ namespace hyperion {
return ledString;
}

QSize getLedLayoutGridSize(const QJsonArray& ledConfigArray)
static QSize getLedLayoutGridSize(const QJsonArray& ledConfigArray)
{
std::vector<int> midPointsX;
std::vector<int> midPointsY;
Expand Down
Loading