Various Cleanups (#1075)

* LedDevice - Address clang findings

* Fix Windows Warnings

* Ensure newInput is initialised

* Clean-up unused elements for Plaform Capture

* Fix initialization problem and spellings

* Address clang findings and spelling corrections

* LedDevice clean-ups

* Cleanups

* Align that getLedCount is int

* Have "display" as default for Grabbers

* Fix config during start-up for missing elements

* Framegrabber Clean-up - Remove non supported grabbers from selection, filter valid options

* Typo

* Framegrabber.json - Fix property numbering

* Preselect active Grabbertype

* Sort Grabbernames

* Align options with selected element

* Fix deletion of pointer to incomplete type 'BonjourBrowserWrapper'

* Address macOS compile warnings

* Have default layout = 1 LED only to avoid errors as in #673

* Address lgtm findings

* Address finding that params passed to LedDevice discovery were not considered

* Cleanups after merging with latest master

* Update Changelog

* Address lgtm findings

* Fix comment

* Test Fix

* Fix Python Warning

* Handle Dummy Device assignment correctly

* Address delete called on non-final 'commandline::Option' that has virtual functions but non-virtual destructor

* Correct that QTimer.start accepts only int

* Have Release Python GIL & reset threat state chnage downward compatible

* Correct format specifier

* LedDevice - add assertions

* Readonly DB - Fix merge issue

* Smoothing - Fix wrong defaults

* LedDevice - correct assertion

* Show smoothing config set# in debug and related values.

* Suppress error on windows, if default file is "/dev/null"

* CMAKE - Allow to define QT_BASE_DIR dynamically via environment-variable

* Ignore Visual Studio specific files

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
LordGrey
2020-11-14 17:58:56 +01:00
committed by GitHub
parent d28540a7fe
commit efc2046ab5
93 changed files with 1140 additions and 1172 deletions

View File

@@ -11,7 +11,7 @@ namespace hyperion
///
struct BlackBorder
{
/// Falg indicating if the border is unknown
/// Flag indicating if the border is unknown
bool unknown;
/// The size of the detected horizontal border
@@ -48,7 +48,7 @@ namespace hyperion
public:
///
/// Constructs a black-border detector
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
/// @param[in] threshold The threshold which the black-border detector should use
///
BlackBorderDetector(double threshold);
@@ -67,9 +67,9 @@ namespace hyperion
template <typename Pixel_T>
BlackBorder process(const Image<Pixel_T> & image) const
{
// test center and 33%, 66% of width/heigth
// test centre and 33%, 66% of width/height
// 33 and 66 will check left and top
// center will check right and bottom sids
// centre will check right and bottom sides
int width = image.width();
int height = image.height();
int width33percent = width / 3;
@@ -281,7 +281,7 @@ namespace hyperion
private:
///
/// Checks if a given color is considered black and therefor could be part of the border.
/// Checks if a given color is considered black and therefore could be part of the border.
///
/// @param[in] color The color to check
///
@@ -295,7 +295,7 @@ namespace hyperion
}
private:
/// Threshold for the blackborder detector [0 .. 255]
/// Threshold for the black-border detector [0 .. 255]
const uint8_t _blackborderThreshold;
};

View File

@@ -44,14 +44,14 @@ namespace hyperion
void setEnabled(bool enable);
///
/// Sets the _hardDisabled state, if True prevents the enable from COMP_BLACKBORDER state emit (mimiks wrong state to external!)
/// It's not possible to enable bb from this method, if the user requsted a disable!
/// Sets the _hardDisabled state, if True prevents the enable from COMP_BLACKBORDER state emit (mimics wrong state to external!)
/// It's not possible to enable black-border detection from this method, if the user requested a disable!
/// @param disable The new state
///
void setHardDisable(bool disable);
///
/// Processes the image. This performs detecion of black-border on the given image and
/// Processes the image. This performs detection of black-border on the given image and
/// updates the current border accordingly. If the current border is updated the method call
/// will return true else false
///
@@ -64,10 +64,11 @@ namespace hyperion
{
// get the border for the single image
BlackBorder imageBorder;
imageBorder.horizontalSize = 0;
imageBorder.verticalSize = 0;
if (!enabled())
{
imageBorder.horizontalSize = 0;
imageBorder.verticalSize = 0;
imageBorder.unknown=true;
_currentBorder = imageBorder;
return true;
@@ -98,7 +99,7 @@ namespace hyperion
private slots:
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
/// @param type settingyType from enum
/// @param type settingType from enum
/// @param config configuration object
///
void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
@@ -121,7 +122,7 @@ namespace hyperion
///
bool updateBorder(const BlackBorder & newDetectedBorder);
/// flag for blackborder detector usage
/// flag for black-border detector usage
bool _enabled;
/// The number of unknown-borders detected before it becomes the current border
@@ -133,13 +134,13 @@ namespace hyperion
// The number of frames that are "ignored" before a new border gets set as _previousDetectedBorder
unsigned _maxInconsistentCnt;
/// The number of pixels to increase a detected border for removing blury pixels
/// The number of pixels to increase a detected border for removing blurry pixels
unsigned _blurRemoveCnt;
/// The border detection mode
QString _detectionMode;
/// The blackborder detector
/// The black-border detector
BlackBorderDetector* _detector;
/// The current detected border
@@ -148,9 +149,9 @@ namespace hyperion
/// The border detected in the previous frame
BlackBorder _previousDetectedBorder;
/// The number of frame the previous detected border matched the incomming border
/// The number of frame the previous detected border matched the incoming border
unsigned _consistentCnt;
/// The number of frame the previous detected border NOT matched the incomming border
/// The number of frame the previous detected border NOT matched the incoming border
unsigned _inconsistentCnt;
/// old threshold
double _oldThreshold;

View File

@@ -19,7 +19,7 @@ private:
/// @brief Browse for hyperion services in bonjour, constructed from HyperionDaemon
/// Searching for hyperion http service by default
///
BonjourBrowserWrapper(QObject * parent = 0);
BonjourBrowserWrapper(QObject * parent = nullptr);
public:
@@ -30,36 +30,36 @@ public:
///
/// @brief Get all available sessions
///
QMap<QString,BonjourRecord> getAllServices() { return _hyperionSessions; };
QMap<QString, BonjourRecord> getAllServices() { return _hyperionSessions; }
static BonjourBrowserWrapper* instance;
static BonjourBrowserWrapper* getInstance(){ return instance; };
static BonjourBrowserWrapper *getInstance() { return instance; }
signals:
///
/// @brief Emits whenever a change happend
///
void browserChange(const QMap<QString,BonjourRecord>& bRegisters);
void browserChange( const QMap<QString, BonjourRecord> &bRegisters );
private:
/// map of service names and browsers
QMap< QString, BonjourServiceBrowser* > _browsedServices;
QMap<QString, BonjourServiceBrowser *> _browsedServices;
/// Resolver
BonjourServiceResolver* _bonjourResolver;
BonjourServiceResolver *_bonjourResolver;
// contains all current active service sessions
QMap<QString,BonjourRecord> _hyperionSessions;
QMap<QString, BonjourRecord> _hyperionSessions;
QString _bonjourCurrentServiceToResolve;
QString _bonjourCurrentServiceToResolve;
/// timer to resolve changes
QTimer* _timerBonjourResolver;
QTimer *_timerBonjourResolver;
private slots:
///
/// @brief is called whenever a BonjourServiceBrowser emits change
void currentBonjourRecordsChanged(const QList<BonjourRecord> &list);
void currentBonjourRecordsChanged( const QList<BonjourRecord> &list );
/// @brief new record resolved
void bonjourRecordResolved(const QHostInfo &hostInfo, int port);
void bonjourRecordResolved( const QHostInfo &hostInfo, int port );
///
/// @brief timer slot which updates regularly entries

View File

@@ -33,6 +33,8 @@ public:
QString value(Parser &parser) const;
const char* getCString(Parser &parser) const;
virtual ~Option();
protected:
QString _error;
};

View File

@@ -1,7 +1,6 @@
#pragma once
#include <QtCore>
#include <QtGui>
#include "ColorOption.h"
#include "ColorsOption.h"
#include "DoubleOption.h"
@@ -24,8 +23,8 @@ protected:
/* No public inheritance because we need to modify a few methods */
QCommandLineParser _parser;
QStringList _getNames(const char shortOption, const QString longOption);
QString _getDescription(const QString description, const QString default_=QString());
QStringList _getNames(const char shortOption, const QString& longOption);
QString _getDescription(const QString& description, const QString& default_=QString());
public:
~Parser() override;
@@ -97,24 +96,24 @@ public:
{
if(description.size())
setApplicationDescription(description);
};
}
QCommandLineOption addHelpOption()
{
return _parser.addHelpOption();
};
}
bool addOption(Option &option);
bool addOption(Option *option);
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
{
_parser.addPositionalArgument(name, description, syntax);
};
}
QCommandLineOption addVersionOption()
{
return _parser.addVersionOption();
};
}
QString applicationDescription() const
{
@@ -166,7 +165,7 @@ public:
_parser.setSingleDashWordOptionMode(singleDashWordOptionMode);
}
void showHelp(int exitCode = 0)
[[ noreturn ]] void showHelp(int exitCode = 0)
{
_parser.showHelp(exitCode);
}

View File

@@ -1,11 +1,5 @@
#pragma once
// Python includes
// collide of qt slots macro
#undef slots
#include "Python.h"
#define slots
// Qt includes
#include <QThread>
#include <QJsonObject>
@@ -44,13 +38,13 @@ public:
int getPriority() const { return _priority; }
///
/// @brief Set manual interuption to true,
/// Note: DO NOT USE QThread::interuption!
/// @brief Set manual interruption to true,
/// Note: DO NOT USE QThread::interruption!
///
void requestInterruption() { _interupt = true; }
///
/// @brief Check if the interuption flag has been set
/// @brief Check if the interruption flag has been set
/// @return The flag state
///
bool isInterruptionRequested() { return _interupt; }
@@ -88,7 +82,7 @@ private:
QVector<ColorRgb> _colors;
Logger *_log;
// Reflects whenever this effects should interupt (timeout or external request)
// Reflects whenever this effects should interrupt (timeout or external request)
std::atomic<bool> _interupt {};
QSize _imageSize;

View File

@@ -15,7 +15,7 @@ private:
public:
static EffectFileHandler* efhInstance;
static EffectFileHandler* getInstance() { return efhInstance; };
static EffectFileHandler* getInstance() { return efhInstance; }
///
/// @brief Get all available effects

View File

@@ -37,7 +37,7 @@ public:
///
/// @brief Apply new width/height values, overwrite Grabber.h implementation as qt doesn't use width/height, just pixelDecimation to calc dimensions
///
bool setWidthHeight(int width, int height) override { return true; };
bool setWidthHeight(int width, int height) override { return true; }
///
/// @brief Apply new pixelDecimation

View File

@@ -45,7 +45,7 @@ public:
///
/// @brief Apply new width/height values, overwrite Grabber.h implementation as X11 doesn't use width/height, just pixelDecimation to calc dimensions
///
bool setWidthHeight(int width, int height) override { return true; };
bool setWidthHeight(int width, int height) override { return true; }
///
/// @brief Apply new pixelDecimation

View File

@@ -15,7 +15,7 @@ public:
~XcbWrapper() override;
public slots:
virtual void action();
void action() override;
private:
XcbGrabber _grabber;

View File

@@ -21,7 +21,7 @@ class AuthManager : public QObject
private:
friend class HyperionDaemon;
/// constructor is private, can be called from HyperionDaemon
AuthManager(QObject *parent = 0, bool readonlyMode = false);
AuthManager(QObject *parent = nullptr, bool readonlyMode = false);
public:
struct AuthDefinition

View File

@@ -19,14 +19,14 @@ public:
// listen for config changes
connect(_hyperion, &Hyperion::settingsChanged, this, &BGEffectHandler::handleSettingsUpdate);
// init
// initialization
handleSettingsUpdate(settings::BGEFFECT, _hyperion->getSetting(settings::BGEFFECT));
};
}
private slots:
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
/// @param type settingyType from enum
/// @param type settingType from enum
/// @param config configuration object
///
void handleSettingsUpdate(settings::type type, const QJsonDocument& config)
@@ -36,7 +36,7 @@ private slots:
const QJsonObject& BGEffectConfig = config.object();
#define BGCONFIG_ARRAY bgColorConfig.toArray()
// clear bg prioritiy
// clear background priority
_hyperion->clear(254);
// initial background effect/color
if (BGEffectConfig["enable"].toBool(true))
@@ -48,24 +48,24 @@ private slots:
{
std::vector<ColorRgb> bg_color = {
ColorRgb {
(uint8_t)BGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
static_cast<uint8_t>(BGCONFIG_ARRAY.at(0).toInt(0)),
static_cast<uint8_t>(BGCONFIG_ARRAY.at(1).toInt(0)),
static_cast<uint8_t>(BGCONFIG_ARRAY.at(2).toInt(0))
}
};
_hyperion->setColor(254, bg_color);
Info(Logger::getInstance("HYPERION"),"Inital background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
Info(Logger::getInstance("HYPERION"),"Initial background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
}
else
{
int result = _hyperion->setEffect(bgEffectConfig, 254);
Info(Logger::getInstance("HYPERION"),"Inital background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed"));
Info(Logger::getInstance("HYPERION"),"Initial background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed"));
}
}
#undef BGCONFIG_ARRAY
}
};
}
private:
/// Hyperion instance pointer

View File

@@ -111,7 +111,7 @@ public slots:
///
/// Returns the number of attached leds
///
unsigned getLedCount() const;
int getLedCount() const;
///
/// @brief Register a new input by priority, the priority is not active (timeout -100 isn't muxer recognized) until you start to update the data with setInput()
@@ -298,7 +298,7 @@ public slots:
///
/// @return The information of the given, a not found priority will return lowest priority as fallback
///
InputInfo getPriorityInfo(int priority) const;
PriorityMuxer::InputInfo getPriorityInfo(int priority) const;
/// #############
/// SETTINGSMANAGER
@@ -527,7 +527,7 @@ private:
Logger * _log;
/// count of hardware leds
unsigned _hwLedCount;
int _hwLedCount;
QSize _ledGridSize;

View File

@@ -19,9 +19,9 @@
class Hyperion;
///
/// The ImageProcessor translates an RGB-image to RGB-values for the leds. The processing is
/// The ImageProcessor translates an RGB-image to RGB-values for the LEDs. The processing is
/// performed in two steps. First the average color per led-region is computed. Second a
/// color-tranform is applied based on a gamma-correction.
/// color-transform is applied based on a gamma-correction.
///
class ImageProcessor : public QObject
{
@@ -39,7 +39,7 @@ public:
~ImageProcessor() override;
///
/// Specifies the width and height of 'incomming' images. This will resize the buffer-image to
/// Specifies the width and height of 'incoming' images. This will resize the buffer-image to
/// match the given size.
/// NB All earlier obtained references will be invalid.
///
@@ -53,7 +53,7 @@ public:
///
void setLedString(const LedString& ledString);
/// Returns starte of black border detector
/// Returns state of black border detector
bool blackBorderDetectorEnabled() const;
/// Returns the current _userMappingType, this may not be the current applied type!
@@ -66,7 +66,7 @@ public:
static QString mappingTypeToStr(int mappingType);
///
/// @brief Set the Hyperion::update() requestes led mapping type. This type is used in favour of type set with setLedMappingType.
/// @brief Set the Hyperion::update() request LED mapping type. This type is used in favour of type set with setLedMappingType.
/// If you don't want to force a mapType set this to -1 (user choice will be set)
/// @param mapType The new mapping type
///
@@ -85,7 +85,7 @@ public slots:
public:
///
/// Specifies the width and height of 'incomming' images. This will resize the buffer-image to
/// Specifies the width and height of 'incoming' images. This will resize the buffer-image to
/// match the given size.
/// NB All earlier obtained references will be invalid.
///
@@ -117,7 +117,7 @@ public:
// Check black border detection
verifyBorder(image);
// Create a result vector and call the 'in place' functionl
// Create a result vector and call the 'in place' function
switch (_mappingType)
{
case 1: colors = _imageToLeds->getUniLedColor(image); break;
@@ -225,7 +225,7 @@ private:
/// The processor for black border detection
hyperion::BlackBorderProcessor * _borderProcessor;
/// The mapping of image-pixels to leds
/// The mapping of image-pixels to LEDs
hyperion::ImageToLedsMap* _imageToLeds;
/// Type of image 2 led mapping

View File

@@ -175,7 +175,7 @@ namespace hyperion
return ColorRgb::BLACK;
}
// Accumulate the sum of each seperate color channel
// Accumulate the sum of each separate color channel
uint_fast32_t cummRed = 0;
uint_fast32_t cummGreen = 0;
uint_fast32_t cummBlue = 0;
@@ -209,7 +209,7 @@ namespace hyperion
template <typename Pixel_T>
ColorRgb calcMeanColor(const Image<Pixel_T> & image) const
{
// Accumulate the sum of each seperate color channel
// Accumulate the sum of each separate color channel
uint_fast32_t cummRed = 0;
uint_fast32_t cummGreen = 0;
uint_fast32_t cummBlue = 0;

View File

@@ -107,16 +107,6 @@ struct Led
class LedString
{
public:
///
/// Constructs the LedString with no leds
///
LedString();
///
/// Destructor of this LedString
///
~LedString();
///
/// Returns the led specifications
///

View File

@@ -11,22 +11,22 @@
///
/// The LedColorTransform is responsible for performing color transformation from 'raw' colors
/// received as input to colors mapped to match the color-properties of the leds.
/// received as input to colors mapped to match the color-properties of the LEDs.
///
class MultiColorAdjustment
{
public:
MultiColorAdjustment(unsigned ledCnt);
MultiColorAdjustment(int ledCnt);
~MultiColorAdjustment();
/**
* Adds a new ColorAdjustment to this MultiColorTransform
*
* @param adjustment The new ColorAdjustment (ownership is transfered)
* @param adjustment The new ColorAdjustment (ownership is transferred)
*/
void addAdjustment(ColorAdjustment * adjustment);
void setAdjustmentForLed(const QString& id, unsigned startLed, unsigned endLed);
void setAdjustmentForLed(const QString& id, int startLed, int endLed);
bool verifyAdjustments() const;

View File

@@ -58,10 +58,10 @@ public:
const static int LOWEST_PRIORITY;
///
/// Constructs the PriorityMuxer for the given number of leds (used to switch to black when
/// Constructs the PriorityMuxer for the given number of LEDs (used to switch to black when
/// there are no priority channels
///
/// @param ledCount The number of leds
/// @param ledCount The number of LEDs
///
PriorityMuxer(int ledCount, QObject * parent);
@@ -87,18 +87,18 @@ public:
/// @brief Get the state of source auto selection
/// @return True if enabled, else false
///
bool isSourceAutoSelectEnabled() const { return _sourceAutoSelectEnabled; };
bool isSourceAutoSelectEnabled() const { return _sourceAutoSelectEnabled; }
///
/// @brief Overwrite current lowest piority with manual selection; On success disables aito selection
/// @brief Overwrite current lowest priority with manual selection; On success disables auto selection
/// @param priority The
/// @return True on success, false if priority not found
///
bool setPriority(uint8_t priority);
bool setPriority(int priority);
///
/// @brief Update all ledColos with min length of >= 1 to fit the new led length
/// @param[in] ledCount The count of leds
/// @brief Update all LED-Colors with min length of >= 1 to fit the new led length
/// @param[in] ledCount The count of LEDs
///
void updateLedColorsLength(int ledCount);
@@ -146,13 +146,13 @@ public:
/// @param[in] priority The priority of the channel
/// @param[in] component The component of the channel
/// @param[in] origin Who set the channel (CustomString@IP)
/// @param[in] owner Speicifc owner string, might be empty
/// @param[in] owner Specific owner string, might be empty
/// @param[in] smooth_cfg The smooth id to use
///
void registerInput(int priority, hyperion::Components component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = SMOOTHING_MODE_DEFAULT);
///
/// @brief Update the current color of a priority (prev registered with registerInput())
/// @brief Update the current color of a priority (previous registered with registerInput())
/// @param priority The priority to update
/// @param ledColors The colors
/// @param timeout_ms The new timeout (defaults to -1 endless)
@@ -174,7 +174,7 @@ public:
/// @param priority The priority
/// @return True on success false if not found
///
bool setInputInactive(quint8 priority);
bool setInputInactive(int priority);
///
/// Clears the specified priority channel and update _currentPriority on success
@@ -182,7 +182,7 @@ public:
/// @param[in] priority The priority of the channel to clear
/// @return True if priority has been cleared else false (not found)
///
bool clearInput(uint8_t priority);
bool clearInput(int priority);
///
/// Clears all priority channels
@@ -190,7 +190,7 @@ public:
void clearAll(bool forceClearAll=false);
///
/// @brief Queue a manual push where muxer doesn't recognize them (e.g. continous single color pushes)
/// @brief Queue a manual push where muxer doesn't recognize them (e.g. continuous single color pushes)
///
void queuePush() { emit timeRunner(); }

View File

@@ -3,14 +3,14 @@
#include <utils/Logger.h>
#include <utils/settings.h>
// qt incl
// qt includes
#include <QJsonObject>
class Hyperion;
class SettingsTable;
///
/// @brief Manage the settings read write from/to config file, on settings changed will emit a signal to update components accordingly
/// @brief Manage the settings read write from/to configuration file, on settings changed will emit a signal to update components accordingly
///
class SettingsManager : public QObject
{
@@ -24,7 +24,7 @@ public:
SettingsManager(quint8 instance, QObject* parent = nullptr, bool readonlyMode = false);
///
/// @brief Save a complete json config
/// @brief Save a complete json configuration
/// @param config The entire config object
/// @param correct If true will correct json against schema before save
/// @return True on success else false
@@ -32,7 +32,7 @@ public:
bool saveSettings(QJsonObject config, bool correct = false);
///
/// @brief get a single setting json from config
/// @brief get a single setting json from configuration
/// @param type The settings::type from enum
/// @return The requested json data as QJsonDocument
///
@@ -42,11 +42,11 @@ public:
/// @brief get the full settings object of this instance (with global settings)
/// @return The requested json
///
const QJsonObject & getSettings() const { return _qconfig; };
const QJsonObject & getSettings() const { return _qconfig; }
signals:
///
/// @brief Emits whenever a config part changed.
/// @brief Emits whenever a configuration part changed.
/// @param type The settings type from enum
/// @param data The data as QJsonDocument
///
@@ -54,7 +54,7 @@ signals:
private:
///
/// @brief Add possile migrations steps for config here
/// @brief Add possible migrations steps for configuration here
/// @param config The configuration object
/// @return True when a migration has been triggered
///
@@ -73,7 +73,7 @@ private:
/// the schema
static QJsonObject schemaJson;
/// the current config of this instance
/// the current configuration of this instance
QJsonObject _qconfig;
bool _readonlyMode;

View File

@@ -62,7 +62,7 @@ public:
///
/// @param[in] ledCount Number of device LEDs, 0 = unknown number
///
void setLedCount(unsigned int ledCount);
void setLedCount(int ledCount);
///
/// @brief Set a device's latch time.
@@ -87,9 +87,11 @@ public:
/// @brief Discover devices of this type available (for configuration).
/// @note Mainly used for network devices. Allows to find devices, e.g. via ssdp, mDNS or cloud ways.
///
/// @param[in] params Parameters used to overwrite discovery default behaviour
///
/// @return A JSON structure holding a list of devices found
///
virtual QJsonObject discover();
virtual QJsonObject discover(const QJsonObject& params);
///
/// @brief Discover first device of this type available (for configuration).
@@ -116,7 +118,7 @@ public:
///
/// @param[in] params Parameters to address device
///
virtual void identify(const QJsonObject& params) {}
virtual void identify(const QJsonObject& /*params*/) {}
///
/// @brief Check, if device is properly initialised
@@ -193,7 +195,7 @@ public slots:
///
/// @return Number of device's LEDs, 0 = unknown number
///
unsigned int getLedCount() const { return _ledCount; }
int getLedCount() const { return _ledCount; }
///
/// @brief Get the current active LED-device type.
@@ -348,7 +350,7 @@ protected:
/// @param size of the array
/// @param number Number of array items to be converted.
/// @return array as string of hex values
QString uint8_t_to_hex_string(const uint8_t * data, const qint64 size, qint64 number = -1) const;
QString uint8_t_to_hex_string(const uint8_t * data, const int size, int number = -1) const;
///
/// @brief Converts a ByteArray to hex string.

View File

@@ -66,65 +66,62 @@ public:
/// @brief Overwrite description address
/// @param addr new address
///
void setDescriptionAddress(const QString& addr) { _descAddress = addr; };
void setDescriptionAddress( const QString &addr ) { _descAddress = addr; }
///
/// @brief Set uuid
/// @param uuid The uuid
///
void setUuid(const QString& uuid) { _uuid = uuid; };
void setUuid( const QString &uuid ) { _uuid = uuid; }
///
/// @brief set new flatbuffer server port
///
void setFlatBufPort(quint16 port) { _fbsPort = QString::number(port); };
void setFlatBufPort( quint16 port ){_fbsPort = QString::number( port ); }
///
/// @brief Get current flatbuffer server port
///
quint16 getFlatBufPort() const { return _fbsPort.toInt(); };
quint16 getFlatBufPort() const
{
return _fbsPort.toInt();
}
///
/// @brief set new protobuf server port
///
void setProtoBufPort(quint16 port) { _pbsPort = QString::number(port); };
void setProtoBufPort( quint16 port ) { _pbsPort = QString::number( port ); }
///
/// @brief Get current protobuf server port
///
quint16 getProtoBufPort() const { return _pbsPort.toInt(); };
quint16 getProtoBufPort() const { return _pbsPort.toInt(); }
///
/// @brief set new json server port
///
void setJsonServerPort(quint16 port) { _jssPort = QString::number(port); };
void setJsonServerPort( quint16 port ) { _jssPort = QString::number( port ); }
///
/// @brief get new json server port
///
quint16 getJsonServerPort() const { return _jssPort.toInt(); };
quint16 getJsonServerPort() const { return _jssPort.toInt(); }
///
/// @brief set new ssl server port
///
void setSSLServerPort(quint16 port) { _sslPort = QString::number(port); };
void setSSLServerPort( quint16 port ) { _sslPort = QString::number( port ); }
///
/// @brief get new ssl server port
///
quint16 getSSLServerPort() const { return _sslPort.toInt(); };
quint16 getSSLServerPort() const { return _sslPort.toInt(); }
///
/// @brief set new hyperion name
///
void setHyperionName(const QString &name) { _name = name; };
void setHyperionName( const QString &name ) { _name = name; }
///
/// @brief get hyperion name
///
QString getHyperionName() const { return _name; };
QString getHyperionName() const { return _name; }
signals:
///
/// @brief Emits whenever a new SSDP search "man : ssdp:discover" is received along with the service type
@@ -133,23 +130,18 @@ signals:
/// @param address The ip of the caller
/// @param port The port of the caller
///
void msearchRequestReceived(const QString& target, const QString& mx, const QString address, quint16 port);
void msearchRequestReceived( const QString &target,
const QString &mx,
const QString address,
quint16 port );
private:
Logger* _log;
QUdpSocket* _udpSocket;
Logger *_log;
QUdpSocket *_udpSocket;
QString _serverHeader,
_uuid,
_fbsPort,
_pbsPort,
_jssPort,
_sslPort,
_name,
_descAddress;
bool _running;
QString _serverHeader, _uuid, _fbsPort, _pbsPort, _jssPort, _sslPort, _name, _descAddress;
bool _running;
private slots:
void readPendingDatagrams();
};

View File

@@ -38,7 +38,7 @@ public:
_height(other._height),
_pixels(new Pixel_T[other._width * other._height + 1])
{
memcpy(_pixels, other._pixels, (long) other._width * other._height * sizeof(Pixel_T));
memcpy(_pixels, other._pixels, static_cast<ulong>(other._width) * static_cast<ulong>(other._height) * sizeof(Pixel_T));
}
ImageData& operator=(ImageData rhs)
@@ -150,7 +150,7 @@ public:
ssize_t size() const
{
return (ssize_t) _width * _height * sizeof(Pixel_T);
return static_cast<ssize_t>(_width) * static_cast<ssize_t>(_height) * sizeof(Pixel_T);
}
void clear()
@@ -163,7 +163,7 @@ public:
_pixels = new Pixel_T[2];
}
memset(_pixels, 0, (unsigned long) _width * _height * sizeof(Pixel_T));
memset(_pixels, 0, static_cast<unsigned long>(_width) * static_cast<unsigned long>(_height) * sizeof(Pixel_T));
}
private:

View File

@@ -16,7 +16,7 @@ class NetOrigin : public QObject
Q_OBJECT
private:
friend class HyperionDaemon;
NetOrigin(QObject* parent = 0, Logger* log = Logger::getInstance("NETWORK"));
NetOrigin(QObject* parent = nullptr, Logger* log = Logger::getInstance("NETWORK"));
public:
///
@@ -33,8 +33,8 @@ public:
///
bool isLocalAddress(const QHostAddress& address, const QHostAddress& local) const;
static NetOrigin* getInstance(){ return instance; };
static NetOrigin* instance;
static NetOrigin *getInstance() { return instance; }
static NetOrigin *instance;
private slots:
///

View File

@@ -19,9 +19,6 @@ public:
/// @param adjustB
RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB, QString channelName="");
/// Destructor
~RgbChannelAdjustment();
///
/// Transform the given array value
///

View File

@@ -36,9 +36,9 @@ namespace hyperion {
{
std::vector<ColorRgb> fg_color = {
ColorRgb {
(uint8_t)FGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)FGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
static_cast<uint8_t>(FGCONFIG_ARRAY.at(0).toInt(0)),
static_cast<uint8_t>(FGCONFIG_ARRAY.at(1).toInt(0)),
static_cast<uint8_t>(FGCONFIG_ARRAY.at(2).toInt(0))
}
};
hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms);
@@ -62,22 +62,22 @@ namespace hyperion {
{
const double backlightThreshold = colorConfig["backlightThreshold"].toDouble(0.0);
const bool backlightColored = colorConfig["backlightColored"].toBool(false);
const double brightness = colorConfig["brightness"].toInt(100);
const double brightnessComp = colorConfig["brightnessCompensation"].toInt(100);
const int brightness = colorConfig["brightness"].toInt(100);
const int brightnessComp = colorConfig["brightnessCompensation"].toInt(100);
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
const double gammaB = colorConfig["gammaBlue"].toDouble(1.0);
return RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, brightness, brightnessComp);
return RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, static_cast<uint8_t>(brightness), static_cast<uint8_t>(brightnessComp));
}
RgbChannelAdjustment createRgbChannelAdjustment(const QJsonObject& colorConfig, const QString& channelName, int defaultR, int defaultG, int defaultB)
{
const QJsonArray& channelConfig = colorConfig[channelName].toArray();
return RgbChannelAdjustment(
channelConfig[0].toInt(defaultR),
channelConfig[1].toInt(defaultG),
channelConfig[2].toInt(defaultB),
static_cast<uint8_t>(channelConfig[0].toInt(defaultR)),
static_cast<uint8_t>(channelConfig[1].toInt(defaultG)),
static_cast<uint8_t>(channelConfig[2].toInt(defaultB)),
"ChannelAdjust_" + channelName.toUpper()
);
}
@@ -101,7 +101,7 @@ namespace hyperion {
return adjustment;
}
MultiColorAdjustment * createLedColorsAdjustment(unsigned ledCnt, const QJsonObject & colorConfig)
MultiColorAdjustment * createLedColorsAdjustment(int ledCnt, const QJsonObject & colorConfig)
{
// Create the result, the transforms are added to this
MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt);
@@ -233,7 +233,7 @@ namespace hyperion {
std::sort(midPointsY.begin(), midPointsY.end());
midPointsY.erase(std::unique(midPointsY.begin(), midPointsY.end()), midPointsY.end());
QSize gridSize( midPointsX.size(), midPointsY.size() );
QSize gridSize( static_cast<int>(midPointsX.size()), static_cast<int>(midPointsY.size()) );
// Correct the grid in case it is malformed in width vs height
// Expected is at least 50% of width <-> height

View File

@@ -48,7 +48,7 @@ public:
{
case QJsonValue::Array:
{
for (const QJsonValue &v : value.toArray())
for (const QJsonValueRef v : value.toArray())
{
ret = getDefaultValue(v);
if (!ret.isEmpty())

View File

@@ -33,7 +33,7 @@ class WebServer : public QObject
Q_OBJECT
public:
WebServer (const QJsonDocument& config, bool useSsl, QObject * parent = 0);
WebServer (const QJsonDocument& config, bool useSsl, QObject * parent = nullptr);
~WebServer () override;