Add dependencies (Resource manager header)

This commit is contained in:
silas 2020-12-12 17:59:34 -06:00
parent 37cf8bcf23
commit 0d862f4ff8
13 changed files with 26328 additions and 14 deletions

102
Dependencies/NetworkClient.h vendored Normal file
View file

@ -0,0 +1,102 @@
/*-----------------------------------------*\
| NetworkClient.h |
| |
| Client header for OpenRGB SDK |
| |
| Adam Honse (CalcProgrammer1) 5/9/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "NetworkProtocol.h"
#include "net_port.h"
#include <mutex>
#include <thread>
#pragma once
typedef void (*NetClientCallback)(void *);
class NetworkClient
{
public:
NetworkClient(std::vector<RGBController *>& control);
~NetworkClient();
void ClientInfoChanged();
bool GetConnected();
const char * GetIP();
unsigned short GetPort();
unsigned int GetProtocolVersion();
bool GetOnline();
void RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg);
void SetIP(const char *new_ip);
void SetName(const char *new_name);
void SetPort(unsigned short new_port);
void StartClient();
void StopClient();
void ConnectionThreadFunction();
void ListenThreadFunction();
void WaitOnControllerData();
void ProcessReply_ControllerCount(unsigned int data_size, char * data);
void ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx);
void ProcessReply_ProtocolVersion(unsigned int data_size, char * data);
void ProcessRequest_DeviceListChanged();
void SendData_ClientString();
void SendRequest_ControllerCount();
void SendRequest_ControllerData(unsigned int dev_idx);
void SendRequest_ProtocolVersion();
void SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size);
void SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size);
void SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size);
void SendRequest_RGBController_UpdateSingleLED(unsigned int dev_idx, unsigned char * data, unsigned int size);
void SendRequest_RGBController_SetCustomMode(unsigned int dev_idx);
void SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size);
std::vector<RGBController *> server_controllers;
std::mutex ControllerListMutex;
protected:
std::vector<RGBController *>& controllers;
private:
SOCKET client_sock;
std::string client_name;
net_port port;
char port_ip[20];
unsigned short port_num;
bool client_active;
bool controller_data_received;
bool server_connected;
bool server_initialized;
unsigned int server_controller_count;
bool server_controller_count_received;
unsigned int server_protocol_version;
bool server_protocol_version_received;
bool change_in_progress;
std::thread * ConnectionThread;
std::thread * ListenThread;
std::mutex ClientInfoChangeMutex;
std::vector<NetClientCallback> ClientInfoChangeCallbacks;
std::vector<void *> ClientInfoChangeCallbackArgs;
int recv_select(SOCKET s, char *buf, int len, int flags);
};

57
Dependencies/NetworkProtocol.h vendored Normal file
View file

@ -0,0 +1,57 @@
/*-----------------------------------------*\
| NetworkProtocol.h |
| |
| Protocol header for OpenRGB SDK |
| |
| Adam Honse (CalcProgrammer1) 5/9/2020 |
\*-----------------------------------------*/
#pragma once
/*-----------------------------------------------------*\
| OpenRGB SDK protocol version |
| |
| 0: Initial (unversioned) protocol |
| 1: Add versioning, vendor string (Release 0.5) |
\*-----------------------------------------------------*/
#define OPENRGB_SDK_PROTOCOL_VERSION 1
/*-----------------------------------------------------*\
| Default OpenRGB SDK port is 6742 |
| This is "ORGB" on a phone keypad |
\*-----------------------------------------------------*/
#define OPENRGB_SDK_PORT 6742
typedef struct NetPacketHeader
{
char pkt_magic[4]; /* Magic value "ORGB" identifies beginning of packet */
unsigned int pkt_dev_idx; /* Device index */
unsigned int pkt_id; /* Packet ID */
unsigned int pkt_size; /* Packet size */
} NetPacketHeader;
enum
{
/*----------------------------------------------------------------------------------------------------------*\
| Network requests |
\*----------------------------------------------------------------------------------------------------------*/
NET_PACKET_ID_REQUEST_CONTROLLER_COUNT = 0, /* Request RGBController device count from server */
NET_PACKET_ID_REQUEST_CONTROLLER_DATA = 1, /* Request RGBController data block */
NET_PACKET_ID_REQUEST_PROTOCOL_VERSION = 40, /* Request OpenRGB SDK protocol version from server */
NET_PACKET_ID_SET_CLIENT_NAME = 50, /* Send client name string to server */
NET_PACKET_ID_DEVICE_LIST_UPDATED = 100, /* Indicate to clients that device list has updated */
/*----------------------------------------------------------------------------------------------------------*\
| RGBController class functions |
\*----------------------------------------------------------------------------------------------------------*/
NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE = 1000, /* RGBController::ResizeZone() */
NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS = 1050, /* RGBController::UpdateLEDs() */
NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS = 1051, /* RGBController::UpdateZoneLEDs() */
NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED = 1052, /* RGBController::UpdateSingleLED() */
NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE = 1100, /* RGBController::SetCustomMode() */
NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE = 1101, /* RGBController::UpdateMode() */
};

87
Dependencies/NetworkServer.h vendored Normal file
View file

@ -0,0 +1,87 @@
/*-----------------------------------------*\
| NetworkServer.h |
| |
| Server header for OpenRGB SDK |
| |
| Adam Honse (CalcProgrammer1) 5/9/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "NetworkProtocol.h"
#include "net_port.h"
#include <mutex>
#include <thread>
#include <chrono>
#pragma once
typedef void (*NetServerCallback)(void *);
struct NetworkClientInfo
{
SOCKET client_sock;
std::thread * client_listen_thread;
std::string client_string;
unsigned int client_protocol_version;
char client_ip[INET_ADDRSTRLEN];
};
class NetworkServer
{
public:
NetworkServer(std::vector<RGBController *>& control);
~NetworkServer();
unsigned short GetPort();
bool GetOnline();
unsigned int GetNumClients();
const char * GetClientString(unsigned int client_num);
const char * GetClientIP(unsigned int client_num);
unsigned int GetClientProtocolVersion(unsigned int client_num);
void ClientInfoChanged();
void DeviceListChanged();
void RegisterClientInfoChangeCallback(NetServerCallback, void * new_callback_arg);
void SetPort(unsigned short new_port);
void StartServer();
void StopServer();
void ConnectionThreadFunction();
void ListenThreadFunction(NetworkClientInfo * client_sock);
void ProcessRequest_ClientProtocolVersion(SOCKET client_sock, unsigned int data_size, char * data);
void ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data);
void SendReply_ControllerCount(SOCKET client_sock);
void SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx, unsigned int protocol_version);
void SendReply_ProtocolVersion(SOCKET client_sock);
void SendRequest_DeviceListChanged(SOCKET client_sock);
protected:
unsigned short port_num;
bool server_online;
std::vector<RGBController *>& controllers;
std::mutex ServerClientsMutex;
std::vector<NetworkClientInfo *> ServerClients;
std::thread * ConnectionThread;
std::mutex ClientInfoChangeMutex;
std::vector<NetServerCallback> ClientInfoChangeCallbacks;
std::vector<void *> ClientInfoChangeCallbackArgs;
private:
#ifdef WIN32
WSADATA wsa;
#endif
SOCKET server_sock;
int accept_select(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int recv_select(SOCKET s, char *buf, int len, int flags);
};

236
Dependencies/RGBController.h vendored Normal file
View file

@ -0,0 +1,236 @@
/*-----------------------------------------*\
| RGBController.h |
| |
| Definitions and types for generic RGB |
| lighting controller interface |
| |
| Adam Honse (CalcProgrammer1) 6/2/2019 |
\*-----------------------------------------*/
#pragma once
#include <atomic>
#include <vector>
#include <string>
#include <thread>
#include <chrono>
#include <mutex>
typedef unsigned int RGBColor;
#define RGBGetRValue(rgb) (rgb & 0x000000FF)
#define RGBGetGValue(rgb) ((rgb >> 8) & 0x000000FF)
#define RGBGetBValue(rgb) ((rgb >> 16) & 0x000000FF)
#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r))
/*------------------------------------------------------------------*\
| Mode Flags |
\*------------------------------------------------------------------*/
enum
{
MODE_FLAG_HAS_SPEED = (1 << 0), /* Mode has speed parameter */
MODE_FLAG_HAS_DIRECTION_LR = (1 << 1), /* Mode has left/right parameter */
MODE_FLAG_HAS_DIRECTION_UD = (1 << 2), /* Mode has up/down parameter */
MODE_FLAG_HAS_DIRECTION_HV = (1 << 3), /* Mode has horiz/vert parameter */
MODE_FLAG_HAS_BRIGHTNESS = (1 << 4), /* Mode has brightness parameter */
MODE_FLAG_HAS_PER_LED_COLOR = (1 << 5), /* Mode has per-LED colors */
MODE_FLAG_HAS_MODE_SPECIFIC_COLOR = (1 << 6), /* Mode has mode specific colors */
MODE_FLAG_HAS_RANDOM_COLOR = (1 << 7), /* Mode has random color option */
};
/*------------------------------------------------------------------*\
| Mode Directions |
\*------------------------------------------------------------------*/
enum
{
MODE_DIRECTION_LEFT = 0, /* Mode direction left */
MODE_DIRECTION_RIGHT = 1, /* Mode direction right */
MODE_DIRECTION_UP = 2, /* Mode direction up */
MODE_DIRECTION_DOWN = 3, /* Mode direction down */
MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */
MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */
};
enum
{
MODE_COLORS_NONE = 0, /* Mode has no colors */
MODE_COLORS_PER_LED = 1, /* Mode has per LED colors selected */
MODE_COLORS_MODE_SPECIFIC = 2, /* Mode specific colors selected */
MODE_COLORS_RANDOM = 3, /* Mode has random colors selected */
};
/*------------------------------------------------------------------*\
| Mode Type |
\*------------------------------------------------------------------*/
typedef struct
{
/*--------------------------------------------------------------*\
| Mode Information |
\*--------------------------------------------------------------*/
std::string name; /* Mode name */
int value; /* Device-specific mode value */
unsigned int flags; /* Mode flags bitfield */
unsigned int speed_min; /* speed minimum value */
unsigned int speed_max; /* speed maximum value */
unsigned int colors_min; /* minimum number of mode colors*/
unsigned int colors_max; /* maximum numver of mode colors*/
/*--------------------------------------------------------------*\
| Mode Settings |
\*--------------------------------------------------------------*/
unsigned int speed; /* Mode speed parameter value */
unsigned int direction; /* Mode direction value */
unsigned int color_mode; /* Mode color selection */
std::vector<RGBColor>
colors; /* mode-specific colors */
} mode;
typedef struct
{
std::string name; /* LED name */
unsigned int value; /* Device-specific LED value */
} led;
typedef int zone_type;
enum
{
ZONE_TYPE_SINGLE,
ZONE_TYPE_LINEAR,
ZONE_TYPE_MATRIX
};
typedef int device_type;
enum
{
DEVICE_TYPE_MOTHERBOARD,
DEVICE_TYPE_DRAM,
DEVICE_TYPE_GPU,
DEVICE_TYPE_COOLER,
DEVICE_TYPE_LEDSTRIP,
DEVICE_TYPE_KEYBOARD,
DEVICE_TYPE_MOUSE,
DEVICE_TYPE_MOUSEMAT,
DEVICE_TYPE_HEADSET,
DEVICE_TYPE_HEADSET_STAND,
DEVICE_TYPE_GAMEPAD,
DEVICE_TYPE_LIGHT,
DEVICE_TYPE_UNKNOWN
};
std::string device_type_to_str(device_type type);
typedef struct
{
unsigned int height;
unsigned int width;
unsigned int * map;
} matrix_map_type;
typedef struct
{
std::string name; /* Zone name */
zone_type type; /* Zone type */
led * leds; /* List of LEDs in zone */
RGBColor * colors; /* Colors of LEDs in zone */
unsigned int start_idx; /* Start index of led/color */
unsigned int leds_count; /* Number of LEDs in zone */
unsigned int leds_min; /* Minimum number of LEDs */
unsigned int leds_max; /* Maximum number of LEDs */
matrix_map_type * matrix_map; /* Matrix map pointer */
} zone;
typedef void (*RGBControllerCallback)(void *);
class RGBController
{
public:
std::string name; /* controller name */
std::string vendor; /* controller vendor */
std::string description; /* controller description */
std::string version; /* controller version */
std::string serial; /* controller serial number */
std::string location; /* controller location */
std::vector<led> leds; /* LEDs */
std::vector<zone> zones; /* Zones */
std::vector<mode> modes; /* Modes */
std::vector<RGBColor> colors; /* Color buffer */
device_type type; /* device type */
int active_mode = 0;/* active mode */
/*---------------------------------------------------------*\
| RGBController base class constructor |
\*---------------------------------------------------------*/
RGBController();
virtual ~RGBController();
/*---------------------------------------------------------*\
| Generic functions implemented in RGBController.cpp |
\*---------------------------------------------------------*/
void SetupColors();
RGBColor GetLED(unsigned int led);
void SetLED(unsigned int led, RGBColor color);
void SetAllLEDs(RGBColor color);
void SetAllZoneLEDs(int zone, RGBColor color);
int GetMode();
void SetMode(int mode);
unsigned char * GetDeviceDescription(unsigned int protocol_version);
void ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version);
unsigned char * GetModeDescription(int mode);
void SetModeDescription(unsigned char* data_buf);
unsigned char * GetColorDescription();
void SetColorDescription(unsigned char* data_buf);
unsigned char * GetZoneColorDescription(int zone);
void SetZoneColorDescription(unsigned char* data_buf);
unsigned char * GetSingleLEDColorDescription(int led);
void SetSingleLEDColorDescription(unsigned char* data_buf);
void RegisterUpdateCallback(RGBControllerCallback new_callback, void * new_callback_arg);
void UnregisterUpdateCallback(void * callback_arg);
void SignalUpdate();
void UpdateLEDs();
//void UpdateZoneLEDs(int zone);
//void UpdateSingleLED(int led);
void UpdateMode();
void DeviceCallThreadFunction();
/*---------------------------------------------------------*\
| Functions to be implemented in device implementation |
\*---------------------------------------------------------*/
virtual void SetupZones() = 0;
virtual void ResizeZone(int zone, int new_size) = 0;
virtual void DeviceUpdateLEDs() = 0;
virtual void UpdateZoneLEDs(int zone) = 0;
virtual void UpdateSingleLED(int led) = 0;
virtual void DeviceUpdateMode() = 0;
virtual void SetCustomMode() = 0;
private:
std::thread* DeviceCallThread;
std::atomic<bool> CallFlag_UpdateLEDs;
std::atomic<bool> CallFlag_UpdateMode;
std::atomic<bool> DeviceThreadRunning;
//bool CallFlag_UpdateZoneLEDs = false;
//bool CallFlag_UpdateSingleLED = false;
//bool CallFlag_UpdateMode = false;
std::mutex UpdateMutex;
std::vector<RGBControllerCallback> UpdateCallbacks;
std::vector<void *> UpdateCallbackArgs;
};

147
Dependencies/ResourceManager.h vendored Normal file
View file

@ -0,0 +1,147 @@
/*-----------------------------------------*\
| ResourceManager.h |
| |
| OpenRGB Resource Manager controls access |
| to application components including |
| RGBControllers, I2C interfaces, and |
| network SDK components |
| |
| Adam Honse (CalcProgrammer1) 9/27/2020 |
\*-----------------------------------------*/
#pragma once
#include <memory>
#include <vector>
#include <functional>
#include <thread>
#include <string>
#include "NetworkClient.h"
#include "NetworkServer.h"
#include "RGBController.h"
#include "SettingsManager.h"
#define HID_INTERFACE_ANY -1
#define HID_USAGE_ANY -1
#define HID_USAGE_PAGE_ANY -1L
#define CONTROLLER_LIST_HID 0
struct hid_device_info;
typedef std::function<void(std::vector<RGBController*>&)> DeviceDetectorFunction;
typedef void (*DeviceListChangeCallback)(void *);
typedef void (*DetectionProgressCallback)(void *);
typedef void (*I2CBusListChangeCallback)(void *);
class ResourceManager
{
public:
static ResourceManager *get();
ResourceManager();
~ResourceManager();
void RegisterRGBController(RGBController *rgb_controller);
std::vector<RGBController*> & GetRGBControllers();
unsigned int GetDetectionPercent();
const char* GetDetectionString();
std::string GetConfigurationDirectory();
std::vector<NetworkClient*>& GetClients();
NetworkServer* GetServer();
SettingsManager* GetSettingsManager();
void SetConfigurationDirectory(std::string directory);
void DeviceListChanged();
void DetectionProgressChanged();
void I2CBusListChanged();
void Cleanup();
void DetectDevices();
void DisableDetection();
void StopDeviceDetection();
void WaitForDeviceDetection();
private:
void DetectDevicesThreadFunction();
static std::unique_ptr<ResourceManager> instance;
/*-------------------------------------------------------------------------------------*\
| Detection enabled flag |
\*-------------------------------------------------------------------------------------*/
bool detection_enabled;
/*-------------------------------------------------------------------------------------*\
| Settings Manager |
\*-------------------------------------------------------------------------------------*/
SettingsManager* settings_manager;
/*-------------------------------------------------------------------------------------*\
| RGBControllers |
\*-------------------------------------------------------------------------------------*/
std::vector<RGBController*> rgb_controllers_sizes;
std::vector<RGBController*> rgb_controllers_hw;
std::vector<RGBController*> rgb_controllers;
/*-------------------------------------------------------------------------------------*\
| Network Server |
\*-------------------------------------------------------------------------------------*/
NetworkServer* server;
/*-------------------------------------------------------------------------------------*\
| Network Clients |
\*-------------------------------------------------------------------------------------*/
std::vector<NetworkClient*> clients;
/*-------------------------------------------------------------------------------------*\
| Detectors |
\*-------------------------------------------------------------------------------------*/
std::vector<DeviceDetectorFunction> device_detectors;
std::vector<std::string> device_detector_strings;
std::vector<std::string> i2c_device_detector_strings;
std::vector<std::string> hid_device_detector_strings;
/*-------------------------------------------------------------------------------------*\
| Detection Thread and Detection State |
\*-------------------------------------------------------------------------------------*/
std::thread * DetectDevicesThread;
std::mutex DetectDeviceMutex;
std::atomic<bool> detection_is_required;
std::atomic<unsigned int> detection_percent;
const char* detection_string;
/*-------------------------------------------------------------------------------------*\
| Device List Changed Callback |
\*-------------------------------------------------------------------------------------*/
std::mutex DeviceListChangeMutex;
std::vector<DeviceListChangeCallback> DeviceListChangeCallbacks;
std::vector<void *> DeviceListChangeCallbackArgs;
/*-------------------------------------------------------------------------------------*\
| Detection Progress Callback |
\*-------------------------------------------------------------------------------------*/
std::mutex DetectionProgressMutex;
std::vector<DetectionProgressCallback> DetectionProgressCallbacks;
std::vector<void *> DetectionProgressCallbackArgs;
/*-------------------------------------------------------------------------------------*\
| I2C/SMBus Adapter List Changed Callback |
\*-------------------------------------------------------------------------------------*/
std::mutex I2CBusListChangeMutex;
std::vector<I2CBusListChangeCallback> I2CBusListChangeCallbacks;
std::vector<void *> I2CBusListChangeCallbackArgs;
};

35
Dependencies/SettingsManager.h vendored Normal file
View file

@ -0,0 +1,35 @@
/*-----------------------------------------*\
| SettingsManager.h |
| |
| OpenRGB Settings Manager maintains a list|
| of application settings in JSON format. |
| Other components may register settings |
| with this class and store/load values. |
| |
| Adam Honse (CalcProgrammer1) 11/4/2020 |
\*-----------------------------------------*/
#pragma once
#include "json.hpp"
using json = nlohmann::json;
class SettingsManager
{
public:
SettingsManager();
~SettingsManager();
json GetSettings(std::string settings_key);
void SetSettings(std::string settings_key, json new_settings);
void LoadSettings(std::string filename);
void SaveSettings();
private:
json settings_data;
json settings_prototype;
std::string settings_filename;
};

25533
Dependencies/json.hpp vendored Normal file

File diff suppressed because it is too large Load diff

87
Dependencies/net_port.h vendored Normal file
View file

@ -0,0 +1,87 @@
/*---------------------------------------------------------*\
| Cross Platform Network Library for Windows and Linux |
| This library provides access to TCP and UDP ports with |
| a common API for both Windows and Linux systems. It |
| features read and write |
| |
| Adam Honse (calcprogrammer1@gmail.com), 12/15/2016 |
\*---------------------------------------------------------*/
#ifndef NET_PORT_H
#define NET_PORT_H
#include <vector>
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <net/if.h>
#endif
#ifndef WIN32
#define SOCKET int
#define ioctlsocket ioctl
#define closesocket close
#define WSACleanup()
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define SD_RECEIVE SHUT_RD
#endif
//Network Port Class
//The reason for this class is that network ports are treated differently
//on Windows and Linux. By creating a class, those differences can be
//made invisible to the program and make cross-platform usage easy
class net_port
{
public:
net_port();
net_port(const char * client_name, const char * port);
~net_port();
//Function to open the port
bool udp_client(const char* client_name, const char * port);
bool tcp_client(const char* client_name, const char * port);
bool tcp_client_connect();
//Function to open a server
bool tcp_server(const char * port);
std::size_t tcp_server_num_clients();
SOCKET * tcp_server_get_client(std::size_t client_idx);
SOCKET * tcp_server_listen();
int udp_listen(char * recv_data, int length);
int tcp_listen(char * recv_data, int length);
//Function to write data to the serial port
int udp_write(char * buffer, int length);
int tcp_write(char * buffer, int length);
int tcp_client_write(char * buffer, int length);
void tcp_close();
bool connected;
SOCKET sock;
private:
#ifdef WIN32
WSADATA wsa;
#endif
std::vector<SOCKET *> clients;
sockaddr addrDest;
addrinfo* result_list;
};
#endif

View file

@ -1,6 +1,5 @@
#include "ORGBExamplePlugin.h"
#include <QDebug>
#include "Dependencies/ResourceManager.h"
std::string ORGBPlugin::PluginName() const
{
@ -17,10 +16,24 @@ std::string ORGBPlugin::PluginLocal() const
return "InfoTab";
}
QWidget* ORGBPlugin::CreateGUI(QWidget *Parent) const
QWidget* ORGBPlugin::CreateGUI(QWidget *Parent, ResourceManager *RM) const
{
QWidget *ORGBExamplePage = new QWidget(Parent);
QLabel *ORGBExampleLabel = new QLabel(ORGBExamplePage);
QPushButton *ORGBExamplePushButton = new QPushButton(ORGBExamplePage);
qDebug() << ORGBExamplePushButton->objectName();
connect(ORGBExamplePushButton,SIGNAL(clicked()) ,this , SLOT(on_ExampleButton_clicked()));
ORGBExampleLabel->setText("This is an example page added by plugins");
return ORGBExamplePage;
}
void ORGBPlugin::on_ExampleButton_clicked()
{
QDialog *ButtonDialog = new QDialog();
ButtonDialog->setModal(true);
QLabel *DialogText = new QLabel(ButtonDialog);
DialogText->setText("This is the result of the button being clicked");
ButtonDialog->show();
}

View file

@ -1,12 +1,16 @@
#pragma once
#include "ORGBExamplePluginInterface.h"
#include "Dependencies/ResourceManager.h"
#include <QObject>
#include <QString>
#include <QtPlugin>
#include "QWidget"
#include "QLabel"
#include "QPushButton"
#include "QDialog"
#include "QAction"
class ORGBPlugin : public QObject, public ORGBPluginInterface
{
@ -21,5 +25,8 @@ public:
std::string PluginDesc() const override;
std::string PluginLocal() const override;
QWidget* CreateGUI(QWidget *Parent) const override;
QWidget* CreateGUI(QWidget *Parent, ResourceManager *RM = nullptr) const override;
private slots:
void on_ExampleButton_clicked();
};

View file

@ -1,6 +1,7 @@
QT += gui
QT += widgets
QT += core
QT += \
gui \
widgets \
core \
TEMPLATE = lib
DEFINES += ORGBEXAMPLEPLUGIN_LIBRARY
@ -15,8 +16,16 @@ SOURCES += \
ORGBExamplePlugin.cpp
HEADERS += \
ORGBExamplePluginInterface.h \
ORGBExamplePlugin.h
ORGBExamplePluginInterface.h \
ORGBExamplePlugin.h \
Dependencies/ResourceManager.h \
Dependencies/RGBController.h \
Dependencies/NetworkClient.h \
Dependencies/NetworkServer.h \
Dependencies/SettingsManager.h \
Dependencies/NetworkProtocol.h \
Dependencies/net_port.h \
Dependencies/json.hpp \
# Default rules for deployment.
unix {

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.13.3, 2020-12-12T10:11:53. -->
<!-- Written by QtCreator 4.13.3, 2020-12-12T17:58:36. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View file

@ -1,6 +1,7 @@
#pragma once
#include <QtPlugin>
#include "Dependencies/ResourceManager.h"
class QString;
#define ORGBPluginInterface_IID "com.ORGBPluginInterface"
@ -10,11 +11,11 @@ class ORGBPluginInterface
public:
virtual ~ORGBPluginInterface() {}
virtual std::string PluginName() const = 0;
virtual std::string PluginDesc() const = 0;
virtual std::string PluginLocal() const = 0;
virtual std::string PluginName() const = 0;
virtual std::string PluginDesc() const = 0;
virtual std::string PluginLocal() const = 0;
virtual QWidget* CreateGUI(QWidget *Parent) const = 0;
virtual QWidget* CreateGUI(QWidget *Parent, ResourceManager *RM = nullptr) const = 0;
};
Q_DECLARE_INTERFACE(ORGBPluginInterface, ORGBPluginInterface_IID)