Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3b2a9f482 | ||
|
|
36d36fab40 | ||
|
|
d330dc0344 | ||
|
|
369e568ce4 | ||
|
|
25c829ac2a |
+1
-1
@@ -310,7 +310,7 @@ void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
* Detect and populate RGB Controllers vector *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#include "RGBController_Dummy.h"
|
||||
void DetectRGBControllers(void)
|
||||
{
|
||||
DetectI2CBusses();
|
||||
|
||||
@@ -52,6 +52,7 @@ SOURCES += \
|
||||
i2c_tools/i2c_tools.cpp \
|
||||
net_port/net_port.cpp \
|
||||
qt/OpenRGBDialog2.cpp \
|
||||
qt/OpenRGBProfileSaveDialog.cpp \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/hsv.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
@@ -138,6 +139,7 @@ HEADERS += \
|
||||
i2c_tools/i2c_tools.h \
|
||||
net_port/net_port.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBProfileSaveDialog.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
serial_port/serial_port.h \
|
||||
@@ -199,6 +201,7 @@ FORMS += \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
qt/OpenRGBDialog2.ui \
|
||||
qt/OpenRGBProfileSaveDialog.ui \
|
||||
qt/OpenRGBSystemInfoPage.ui
|
||||
|
||||
#-----------------------------------------------
|
||||
|
||||
@@ -26,6 +26,7 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||
|
||||
unsigned short *zone_map_rows = new unsigned short[num_zones];
|
||||
|
||||
data_size += sizeof(data_size);
|
||||
data_size += sizeof(device_type);
|
||||
data_size += name_len + sizeof(name_len);
|
||||
data_size += description_len + sizeof(description_len);
|
||||
@@ -94,6 +95,12 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char *data_buf = new unsigned char[data_size];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in data size |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &data_size, sizeof(data_size));
|
||||
data_ptr += sizeof(data_size);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in type |
|
||||
\*---------------------------------------------------------*/
|
||||
@@ -357,6 +364,8 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
|
||||
data_ptr += sizeof(unsigned int);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in type |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
@@ -597,6 +597,7 @@ void Ui::OpenRGBDevicePage::UpdateMode()
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
device->SetMode(current_mode);
|
||||
device->UpdateLEDs();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -613,6 +614,15 @@ void Ui::OpenRGBDevicePage::SetDevice(unsigned char red, unsigned char green, un
|
||||
on_SetDeviceButton_clicked();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::UpdateDevice()
|
||||
{
|
||||
ui->ModeBox->blockSignals(true);
|
||||
ui->ModeBox->setCurrentIndex(device->active_mode);
|
||||
ui->ModeBox->blockSignals(false);
|
||||
UpdateModeUi();
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::SetCustomMode()
|
||||
{
|
||||
device->SetCustomMode();
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
|
||||
void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetCustomMode();
|
||||
void UpdateDevice();
|
||||
void UpdateMode();
|
||||
void UpdateModeUi();
|
||||
|
||||
|
||||
+230
-1
@@ -1,9 +1,17 @@
|
||||
#include <fstream>
|
||||
#include "OpenRGBDialog2.h"
|
||||
#include "OpenRGBDevicePage.h"
|
||||
#include "OpenRGBDeviceInfoPage.h"
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "OpenRGBProfileSaveDialog.h"
|
||||
#include "RGBController_Dummy.h"
|
||||
#include <QLabel>
|
||||
#include <QTabBar>
|
||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||
#include <experimental/filesystem>
|
||||
#include <iostream>
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
@@ -14,6 +22,44 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
||||
QIcon logo(":OpenRGB.png");
|
||||
setWindowIcon(logo);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Load profiles by looking for .orp files in current dir |
|
||||
\*---------------------------------------------------------*/
|
||||
for(const auto & entry : fs::directory_iterator("."))
|
||||
{
|
||||
std::string filename = entry.path().filename().string();
|
||||
|
||||
if(filename.find(".orp"))
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Open input file in binary mode |
|
||||
\*---------------------------------------------------------*/
|
||||
std::ifstream profile_file(filename, std::ios::in | std::ios::binary);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Read and verify file header |
|
||||
\*---------------------------------------------------------*/
|
||||
char header_string[16];
|
||||
unsigned int header_version;
|
||||
|
||||
profile_file.read(header_string, 16);
|
||||
profile_file.read((char *)&header_version, sizeof(unsigned int));
|
||||
|
||||
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
|
||||
{
|
||||
if(header_version == 1)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Add this profile to the list |
|
||||
\*---------------------------------------------------------*/
|
||||
ui->comboBox->addItem(filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
profile_file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up tray icon menu |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -276,4 +322,187 @@ void OpenRGBDialog2::on_ShowHide()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ButtonSaveProfile_clicked()
|
||||
{
|
||||
OpenRGBProfileSaveDialog dialog;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Open Profile Name Dialog |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string profile_name = dialog.show();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If a name was entered, save the profile file |
|
||||
\*---------------------------------------------------------*/
|
||||
if(profile_name != "")
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Extension .orp - OpenRgb Profile |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string filename = profile_name + ".orp";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Open an output file in binary mode |
|
||||
\*---------------------------------------------------------*/
|
||||
std::ofstream controller_file(filename, std::ios::out | std::ios::binary);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Write header |
|
||||
| 16 bytes - "OPENRGB_PROFILE" |
|
||||
| 4 bytes - Version, unsigned int |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int profile_version = 1;
|
||||
controller_file.write("OPENRGB_PROFILE", 16);
|
||||
controller_file.write((char *)&profile_version, sizeof(unsigned int));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Write controller data for each controller |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
|
||||
{
|
||||
unsigned char *controller_data = controllers[controller_index]->GetDeviceDescription();
|
||||
unsigned int controller_size;
|
||||
|
||||
memcpy(&controller_size, controller_data, sizeof(controller_size));
|
||||
|
||||
controller_file.write((const char *)controller_data, controller_size);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Close the file when done |
|
||||
\*---------------------------------------------------------*/
|
||||
controller_file.close();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Add the new file to the profile list |
|
||||
\*---------------------------------------------------------*/
|
||||
ui->comboBox->addItem(filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ButtonLoadProfile_clicked()
|
||||
{
|
||||
std::vector<RGBController*> temp_controllers;
|
||||
unsigned int controller_size;
|
||||
unsigned int controller_offset = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get the profile filename from the profiles list |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string filename = ui->comboBox->currentText().toStdString();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Open input file in binary mode |
|
||||
\*---------------------------------------------------------*/
|
||||
std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Read and verify file header |
|
||||
\*---------------------------------------------------------*/
|
||||
char header_string[16];
|
||||
unsigned int header_version;
|
||||
|
||||
controller_file.read(header_string, 16);
|
||||
controller_file.read((char *)&header_version, sizeof(unsigned int));
|
||||
|
||||
controller_offset += 16 + sizeof(unsigned int);
|
||||
controller_file.seekg(controller_offset);
|
||||
|
||||
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
|
||||
{
|
||||
if(header_version == 1)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Read controller data from file until EOF |
|
||||
\*---------------------------------------------------------*/
|
||||
while(!(controller_file.peek() == EOF))
|
||||
{
|
||||
controller_file.read((char *)&controller_size, sizeof(controller_size));
|
||||
|
||||
unsigned char *controller_data = new unsigned char[controller_size];
|
||||
|
||||
controller_file.seekg(controller_offset);
|
||||
|
||||
controller_file.read((char *)controller_data, controller_size);
|
||||
|
||||
RGBController_Dummy *temp_controller = new RGBController_Dummy();
|
||||
|
||||
temp_controller->ReadDeviceDescription(controller_data);
|
||||
|
||||
temp_controllers.push_back(temp_controller);
|
||||
|
||||
delete[] controller_data;
|
||||
|
||||
controller_offset += controller_size;
|
||||
controller_file.seekg(controller_offset);
|
||||
}
|
||||
|
||||
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
|
||||
{
|
||||
RGBController *temp_controller = temp_controllers[controller_index];
|
||||
RGBController *controller_ptr = controllers[controller_index];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Test if saved controller data matches this controller |
|
||||
\*---------------------------------------------------------*/
|
||||
if((temp_controller->type == controller_ptr->type )
|
||||
&&(temp_controller->name == controller_ptr->name )
|
||||
&&(temp_controller->description == controller_ptr->description)
|
||||
&&(temp_controller->version == controller_ptr->version )
|
||||
&&(temp_controller->serial == controller_ptr->serial )
|
||||
&&(temp_controller->location == controller_ptr->location ))
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Update all modes |
|
||||
\*---------------------------------------------------------*/
|
||||
if(temp_controller->modes.size() == controller_ptr->modes.size())
|
||||
{
|
||||
for(int mode_index = 0; mode_index < temp_controller->modes.size(); mode_index++)
|
||||
{
|
||||
if((temp_controller->modes[mode_index].name == controller_ptr->modes[mode_index].name )
|
||||
&&(temp_controller->modes[mode_index].value == controller_ptr->modes[mode_index].value )
|
||||
&&(temp_controller->modes[mode_index].flags == controller_ptr->modes[mode_index].flags )
|
||||
&&(temp_controller->modes[mode_index].speed_min == controller_ptr->modes[mode_index].speed_min )
|
||||
&&(temp_controller->modes[mode_index].speed_max == controller_ptr->modes[mode_index].speed_max )
|
||||
&&(temp_controller->modes[mode_index].colors_min == controller_ptr->modes[mode_index].colors_min)
|
||||
&&(temp_controller->modes[mode_index].colors_max == controller_ptr->modes[mode_index].colors_max))
|
||||
{
|
||||
controller_ptr->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
|
||||
controller_ptr->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
|
||||
controller_ptr->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
|
||||
|
||||
controller_ptr->modes[mode_index].colors.resize(temp_controller->modes[mode_index].colors.size());
|
||||
|
||||
for(int mode_color_index = 0; mode_color_index < temp_controller->modes[mode_index].colors.size(); mode_color_index++)
|
||||
{
|
||||
controller_ptr->modes[mode_index].colors[mode_color_index] = temp_controller->modes[mode_index].colors[mode_color_index];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
controller_ptr->active_mode = temp_controller->active_mode;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Update all colors |
|
||||
\*---------------------------------------------------------*/
|
||||
if(temp_controller->colors.size() == controller_ptr->colors.size())
|
||||
{
|
||||
for(int color_index = 0; color_index < temp_controller->colors.size(); color_index++)
|
||||
{
|
||||
controller_ptr->colors[color_index] = temp_controller->colors[color_index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
|
||||
{
|
||||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ private slots:
|
||||
void on_QuickWhite();
|
||||
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void on_ShowHide();
|
||||
void on_ButtonSaveProfile_clicked();
|
||||
void on_ButtonLoadProfile_clicked();
|
||||
};
|
||||
|
||||
#endif // OPENRGBDIALOG2_H
|
||||
|
||||
+19
-2
@@ -15,7 +15,24 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="ButtonLoadProfile">
|
||||
<property name="text">
|
||||
<string>Load Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="ButtonSaveProfile">
|
||||
<property name="text">
|
||||
<string>Save Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QTabWidget" name="MainTabBar">
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
@@ -34,7 +51,7 @@
|
||||
<string>Devices</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTabWidget" name="DevicesTabBar">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::West</enum>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "OpenRGBProfileSaveDialog.h"
|
||||
#include "ui_OpenRGBProfileSaveDialog.h"
|
||||
|
||||
Ui::OpenRGBProfileSaveDialog::OpenRGBProfileSaveDialog(QWidget *parent) :
|
||||
QDialog(parent), ui(new Ui::OpenRGBProfileSaveDialogUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
Ui::OpenRGBProfileSaveDialog::~OpenRGBProfileSaveDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
std::string Ui::OpenRGBProfileSaveDialog::show()
|
||||
{
|
||||
std::string return_string;
|
||||
|
||||
int result = this->exec();
|
||||
|
||||
if(result == QDialog::Rejected)
|
||||
{
|
||||
return_string = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return_string = ui->lineEdit->text().toStdString();
|
||||
}
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef OPENRGBPROFILESAVEDIALOG_H
|
||||
#define OPENRGBPROFILESAVEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_OpenRGBProfileSaveDialog.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OpenRGBProfileSaveDialog;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBProfileSaveDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBProfileSaveDialog(QWidget *parent = nullptr);
|
||||
~OpenRGBProfileSaveDialog();
|
||||
|
||||
std::string show();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBProfileSaveDialogUi *ui;
|
||||
};
|
||||
|
||||
#endif // OPENRGBPROFILESAVEDIALOG_H
|
||||
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBProfileSaveDialogUi</class>
|
||||
<widget class="QDialog" name="OpenRGBProfileSaveDialogUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>160</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>120</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>341</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>341</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Profile Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>OpenRGBProfileSaveDialogUi</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>OpenRGBProfileSaveDialogUi</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user