Files
OpenRGB/qt/DeviceView.h
Adam Honse c0826fbe83 Settings Rework
* Add JSON string configuration field to RGBController to store device-specific configurations
    * This JSON string holds both configuration and schema
    * Add settings schema tracking to SettingsManager
    * Implement dynamic settings widget that generates a settings UI based on a JSON schema
    * Implement SettingsManager callback for notifying of settings changes and settings schema updates
    * Always enable Entire Device zone option and use it to enable Edit Device
    * Rename SaveSizes to SaveConfiguration in ProfileManager and Sizes.json to Configuration.json
    * Add zone flag for indicating that a zone's geometry may change, informing profile manager to ignore this check
    * Remove Theme setting and Theme Manager, as this didn't work on most setups anyways and Qt6 has proper Windows dark theming
2026-05-04 22:50:47 -05:00

123 lines
5.3 KiB
C++

/*---------------------------------------------------------*\
| DeviceView.h |
| |
| OpenRGB Device view widget for Qt |
| |
| Adam Honse (calcprogrammer1@gmail.com) |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QWidget>
#include "RGBController.h"
typedef struct
{
float matrix_x;
float matrix_y;
float matrix_w;
float matrix_h;
} matrix_pos_size_type;
class DeviceView : public QWidget
{
Q_OBJECT
public:
explicit DeviceView(QWidget *parent = 0);
~DeviceView();
/*-----------------------------------------------------*\
| Qt size hints |
\*-----------------------------------------------------*/
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
/*-----------------------------------------------------*\
| Selection functions |
\*-----------------------------------------------------*/
bool SelectLED(std::size_t led_idx);
bool SelectLEDs(std::vector<std::size_t> leds);
bool SelectSegment(std::size_t zone_idx, std::size_t segment_idx, bool add = false);
bool SelectZone(std::size_t zone_idx, bool add = false);
/*-----------------------------------------------------*\
| Setter functions |
\*-----------------------------------------------------*/
void ClearSelection();
void SetChanged();
void SetController(RGBController * controller_ptr);
void SetDisableKeyExpansion(bool disable_key_expansion);
void SetNumericalLabels(bool enable);
void SetPerLED(bool per_led_mode);
void SetSelectionColor(RGBColor);
protected:
/*-----------------------------------------------------*\
| Qt events |
\*-----------------------------------------------------*/
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *);
private:
/*-----------------------------------------------------*\
| State tracking variables |
\*-----------------------------------------------------*/
bool changed;
bool ctrl_down;
bool disable_expansion;
QPoint last_mouse_point;
bool mouse_down;
bool mouse_moved;
bool numerical_labels;
bool per_led;
/*-----------------------------------------------------*\
| Size tracking variables |
\*-----------------------------------------------------*/
QSize init_size;
float matrix_h;
int offset_x;
int size;
/*-----------------------------------------------------*\
| Selection tracking variables |
\*-----------------------------------------------------*/
std::vector<std::size_t> previous_selection;
std::vector<std::size_t> selected_leds;
QRect selection_rect;
std::vector<bool> selection_flags;
std::vector<bool> previous_flags;
/*-----------------------------------------------------*\
| UI element tracking variables |
\*-----------------------------------------------------*/
std::vector<QString> led_labels;
std::vector<matrix_pos_size_type> led_pos;
std::vector<matrix_pos_size_type> segment_pos;
std::vector<matrix_pos_size_type> zone_pos;
/*-----------------------------------------------------*\
| Pointer to attached RGBController |
\*-----------------------------------------------------*/
RGBController* controller;
/*-----------------------------------------------------*\
| Private functions |
\*-----------------------------------------------------*/
void InitDeviceView();
void UpdateSelection();
signals:
/*-----------------------------------------------------*\
| Signals |
\*-----------------------------------------------------*/
void selectionChanged(int selected_zone, int selected_segment, std::vector<std::size_t>);
};