Skip to content

Commit

Permalink
Refactor: Settings Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
cpyarger committed Mar 12, 2021
1 parent 9e35b2d commit 2f0237c
Show file tree
Hide file tree
Showing 16 changed files with 473 additions and 463 deletions.
5 changes: 4 additions & 1 deletion src/Midi_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MidiHook::MidiHook(const QString &json_string)
}
MidiMessage *MidiHook::get_message_from_hook()
{
MidiMessage *message = new MidiMessage();
auto *message = new MidiMessage();
message->channel = this->channel;
message->message_type = this->message_type;
message->NORC = this->norc;
Expand Down Expand Up @@ -236,6 +236,9 @@ void MidiHook::setAction()
case ActionsClass::Enable_Preview:
obsControlFunction = EnablePreview;
break;
case ActionsClass::Poke_filter:
obsControlFunction = make_opacity_filter;

default:
blog(LOG_DEBUG, "Action Does not exist");
break;
Expand Down
4 changes: 2 additions & 2 deletions src/Midi_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ typedef struct MidiMessage {
int channel = 0;
int NORC = 0;
int value = 0;
inline bool isNote() { return (message_type == "Note On" || message_type == "Note Off"); };
MidiMessage get() { return (MidiMessage) * this; }
inline bool isNote() const { return (message_type == "Note On" || message_type == "Note Off"); };
MidiMessage get() const { return (MidiMessage) * this; }
static QString get_midi_message_type(const libremidi::message &message);
static QString mtype_to_string(libremidi::message_type);
static int get_midi_note_or_control(const libremidi::message &mess);
Expand Down
8 changes: 4 additions & 4 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void Config::Save()
auto deviceManager = GetDeviceManager();
obs_data_t *newmidi = obs_data_create_from_json(deviceManager->GetData().toStdString().c_str());
obs_data_set_bool(newmidi, "debug_mode", DebugMode);
auto path = obs_module_config_path(get_file_name().toStdString().c_str());
const auto path = obs_module_config_path(get_file_name().toStdString().c_str());
obs_data_save_json_safe(newmidi, path, ".tmp", ".bkp");
bfree(path);

Expand All @@ -73,11 +73,11 @@ QString Config::get_file_name(std::optional<QString> prepend)
}
QString Config::GetConfigStore(std::optional<QString> prepend)
{
auto path = obs_module_config_path(NULL);
const auto path = obs_module_config_path(NULL);
os_mkdirs(path);
bfree(path);
auto filepath = (prepend) ? obs_module_config_path(get_file_name(prepend).toStdString().c_str()) :obs_module_config_path(get_file_name().toStdString().c_str());

const auto filepath = (prepend) ? obs_module_config_path(get_file_name(prepend).toStdString().c_str()) :obs_module_config_path(get_file_name().toStdString().c_str());
obs_data_t *midiConfig = os_file_exists(filepath) ? obs_data_create_from_json_file(filepath) : obs_data_create();
if (!os_file_exists(filepath)) {
obs_data_save_json_safe(midiConfig, filepath, ".tmp", ".bkp");
Expand Down
16 changes: 8 additions & 8 deletions src/device-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ void DeviceManager::Load(QString datastring)
{
obs_data_t *incoming_data = obs_data_create_from_json(datastring.toStdString().c_str());
obs_data_array_t *data = obs_data_get_array(incoming_data, "MidiDevices");
size_t deviceCount = obs_data_array_count(data);
const size_t deviceCount = obs_data_array_count(data);
for (size_t i = 0; i < deviceCount; i++) {
obs_data_t *madata = obs_data_array_item(data, i);
MidiAgent *device = new MidiAgent(obs_data_get_json(madata));
auto *device = new MidiAgent(obs_data_get_json(madata));
obs_data_release(madata);
midiAgents.push_back(device);
}
Expand All @@ -55,7 +55,7 @@ void DeviceManager::Unload()
QStringList DeviceManager::get_input_ports_list()
{
QStringList ports;
unsigned int portCount = libremidi::midi_in().get_port_count();
const unsigned int portCount = libremidi::midi_in().get_port_count();
for (unsigned int i = 0; i < portCount; ++i) {
ports.append(QString::fromStdString(libremidi::midi_in().get_port_name(i)));
}
Expand All @@ -67,7 +67,7 @@ QStringList DeviceManager::get_input_ports_list()
QStringList DeviceManager::get_output_ports_list()
{
QStringList outports;
unsigned int portCount = libremidi::midi_out().get_port_count();
const unsigned int portCount = libremidi::midi_out().get_port_count();
for (unsigned int i = 0; i < portCount; ++i) {
outports.append(QString::fromStdString(libremidi::midi_out().get_port_name(i)));
}
Expand All @@ -79,7 +79,7 @@ QStringList DeviceManager::get_output_ports_list()
*/
int DeviceManager::get_input_port_number(const QString &deviceName)
{
QStringList portsList = get_input_ports_list();
const QStringList portsList = get_input_ports_list();
if (portsList.contains(deviceName)) {
return portsList.indexOf(deviceName);
} else {
Expand All @@ -99,14 +99,14 @@ int DeviceManager::get_input_port_number(const QString &deviceName)
*/
int DeviceManager::get_output_port_number(const QString &deviceName)
{
QStringList portsList = get_output_ports_list();
const QStringList portsList = get_output_ports_list();
if (portsList.contains(deviceName)) {
return portsList.indexOf(deviceName);
} else {
return -1;
}
}
QVector<MidiAgent *> DeviceManager::get_active_midi_devices()
QVector<MidiAgent *> DeviceManager::get_active_midi_devices() const
{
return midiAgents;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ QVector<MidiHook *> DeviceManager::get_midi_hooks(const QString &deviceName)
*/
MidiAgent *DeviceManager::register_midi_device(const int &port, std::optional<int> outport)
{
MidiAgent *midiA = new MidiAgent(port, outport);
auto *midiA = new MidiAgent(port, outport);
midiA->set_enabled(true);
midiAgents.push_back(midiA);
return midiA;
Expand Down
2 changes: 1 addition & 1 deletion src/device-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DeviceManager : public QObject {
QStringList get_output_ports_list();
int get_output_port_number(const QString &deviceName);

QVector<MidiAgent *> get_active_midi_devices();
QVector<MidiAgent *> get_active_midi_devices() const;
MidiAgent *get_midi_device(const QString &deviceName);
QVector<MidiHook *> get_midi_hooks(const QString &deviceName);
MidiAgent *register_midi_device(const int &port, std::optional<int> outport = std::nullopt);
Expand Down
Loading

0 comments on commit 2f0237c

Please sign in to comment.