Skip to content

Commit

Permalink
Address #31 and #33
Browse files Browse the repository at this point in the history
  • Loading branch information
nhielost committed Nov 1, 2022
1 parent 31d970a commit 7c3af85
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 113 deletions.
11 changes: 6 additions & 5 deletions src/forms/echo/mmg-echo-window.cpp
Expand Up @@ -47,6 +47,9 @@ MMGEchoWindow::MMGEchoWindow(QWidget *parent)
void MMGEchoWindow::show_window()
{
global()->load_new_devices();

QString current_device_name = global()->get_active_device_name();

ui->editor_transfer_source->clear();
ui->editor_transfer_dest->clear();
ui->editor_transfer_mode->setCurrentIndex(0);
Expand All @@ -58,10 +61,13 @@ void MMGEchoWindow::show_window()
ui->editor_transfer_dest->addItem(name);
}

ui->editor_devices->setCurrentText(current_device_name);

ui->editor_structure->clearSelection();
switch_structure_pane(MMGModes::MMGMODE_BINDING);
ui->button_preferences->setChecked(false);
ui->pages->setCurrentIndex(0);

setVisible(!isVisible());
}

Expand Down Expand Up @@ -180,11 +186,6 @@ void MMGEchoWindow::configure_lcd_widgets()
lcd_double4.set_step(0.1, 1.0);
}

void MMGEchoWindow::set_device_view()
{
ui->editor_devices->setCurrentText(current_device->get_name());
}

void MMGEchoWindow::set_message_view()
{
// Because current_message is modified in these function calls (LCDData::reset),
Expand Down
2 changes: 0 additions & 2 deletions src/forms/echo/mmg-echo-window.h
Expand Up @@ -43,9 +43,7 @@ class MMGEchoWindow : public QDialog {
void reject() override;
void connect_ui_signals();
void configure_lcd_widgets();

void switch_structure_pane(enum MMGModes mode);
void set_device_view();
void set_message_view();
void set_action_view();
void set_preferences_view();
Expand Down
209 changes: 106 additions & 103 deletions src/forms/macros/mmg-window-macros.h
Expand Up @@ -146,113 +146,114 @@ with this program. If not, see <https://www.gnu.org/licenses/>
break; \
}

#define INSERT_FIRST_OPTION() \
current_action->set_sub(index); \
ui->editor_str1->clear(); \
ui->editor_str2->clear(); \
ui->editor_str3->clear(); \
ui->lcd_double1->display(0); \
ui->lcd_double2->display(0); \
ui->lcd_double3->display(0); \
ui->lcd_double4->display(0); \
set_strs_visible(); \
set_doubles_visible(); \
switch (current_action->get_category()) { \
case MMGAction::Category::MMGACTION_NONE: \
case MMGAction::Category::MMGACTION_STREAM: \
case MMGAction::Category::MMGACTION_RECORD: \
case MMGAction::Category::MMGACTION_VIRCAM: \
case MMGAction::Category::MMGACTION_REPBUF: \
break; \
case MMGAction::Category::MMGACTION_STUDIOMODE: \
if (index == 3) { \
set_strs_visible(true); \
ui->label_str1->setText("Scene"); \
MMGAction::do_obs_scene_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
} \
break; \
case MMGAction::Category::MMGACTION_SCENE: \
set_strs_visible(true); \
ui->label_str1->setText("Scene"); \
MMGAction::do_obs_scene_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
break; \
case MMGAction::Category::MMGACTION_SOURCE_VIDEO: \
set_strs_visible(true); \
ui->label_str1->setText("Scene"); \
MMGAction::do_obs_scene_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_SOURCE_AUDIO: \
set_strs_visible(true); \
ui->label_str1->setText("Source"); \
MMGAction::do_obs_source_enum( \
ui->editor_str1, \
MMGAction::Category::MMGACTION_SOURCE_AUDIO); \
break; \
case MMGAction::Category::MMGACTION_SOURCE_MEDIA: \
set_strs_visible(true); \
ui->label_str1->setText("Source"); \
MMGAction::do_obs_media_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_TRANSITION: \
set_strs_visible(true); \
ui->label_str1->setText("Transition"); \
MMGAction::do_obs_transition_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_FILTER: \
set_strs_visible(true); \
ui->label_str1->setText("Source"); \
MMGAction::do_obs_source_enum( \
ui->editor_str1, \
MMGAction::Category::MMGACTION_FILTER); \
break; \
case MMGAction::Category::MMGACTION_HOTKEY: \
set_strs_visible(true); \
ui->label_str1->setText("Hotkey"); \
MMGAction::do_obs_hotkey_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_PROFILE: \
set_strs_visible(true); \
ui->label_str1->setText("Profile"); \
MMGAction::do_obs_profile_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
break; \
case MMGAction::Category::MMGACTION_COLLECTION: \
set_strs_visible(true); \
ui->label_str1->setText("Collection"); \
MMGAction::do_obs_collection_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
break; \
case MMGAction::Category::MMGACTION_MIDI: \
set_strs_visible(true); \
ui->label_str1->setText("Device"); \
ui->editor_str1->addItems( \
MMGDevice::get_output_device_names()); \
break; \
case MMGAction::Category::MMGACTION_INTERNAL: \
set_strs_visible(true); \
ui->label_str1->setText("Action 1"); \
MMGAction::do_mmg_binding_enum(ui->editor_str1, \
current_binding->get_name()); \
break; \
case MMGAction::Category::MMGACTION_TIMEOUT: \
set_doubles_visible(true); \
ui->label_double1->setText("Time"); \
lcd_double1.set_range(0.0, 1000.0); \
lcd_double1.set_step(1.0, 10.0); \
lcd_double1.reset(); \
break; \
default: \
break; \
#define INSERT_FIRST_OPTION() \
current_action->set_sub(index); \
ui->editor_str1->clear(); \
ui->editor_str2->clear(); \
ui->editor_str3->clear(); \
ui->lcd_double1->display(0); \
ui->lcd_double2->display(0); \
ui->lcd_double3->display(0); \
ui->lcd_double4->display(0); \
set_strs_visible(); \
set_doubles_visible(); \
switch (current_action->get_category()) { \
case MMGAction::Category::MMGACTION_NONE: \
case MMGAction::Category::MMGACTION_STREAM: \
case MMGAction::Category::MMGACTION_RECORD: \
case MMGAction::Category::MMGACTION_VIRCAM: \
case MMGAction::Category::MMGACTION_REPBUF: \
break; \
case MMGAction::Category::MMGACTION_STUDIOMODE: \
if (index == 3) { \
set_strs_visible(true); \
ui->label_str1->setText("Scene"); \
MMGAction::do_obs_scene_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
} \
break; \
case MMGAction::Category::MMGACTION_SCENE: \
set_strs_visible(true); \
ui->label_str1->setText("Scene"); \
MMGAction::do_obs_scene_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
break; \
case MMGAction::Category::MMGACTION_SOURCE_VIDEO: \
set_strs_visible(true); \
ui->label_str1->setText("Scene"); \
MMGAction::do_obs_scene_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_SOURCE_AUDIO: \
set_strs_visible(true); \
ui->label_str1->setText("Source"); \
MMGAction::do_obs_source_enum( \
ui->editor_str1, \
MMGAction::Category::MMGACTION_SOURCE_AUDIO); \
break; \
case MMGAction::Category::MMGACTION_SOURCE_MEDIA: \
set_strs_visible(true); \
ui->label_str1->setText("Source"); \
MMGAction::do_obs_media_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_TRANSITION: \
set_strs_visible(true); \
ui->label_str1->setText("Transition"); \
MMGAction::do_obs_transition_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_FILTER: \
set_strs_visible(true); \
ui->label_str1->setText("Source"); \
MMGAction::do_obs_source_enum( \
ui->editor_str1, \
MMGAction::Category::MMGACTION_FILTER); \
break; \
case MMGAction::Category::MMGACTION_HOTKEY: \
set_strs_visible(true); \
ui->label_str1->setText("Hotkey"); \
MMGAction::do_obs_hotkey_enum(ui->editor_str1); \
break; \
case MMGAction::Category::MMGACTION_PROFILE: \
set_strs_visible(true); \
ui->label_str1->setText("Profile"); \
MMGAction::do_obs_profile_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
break; \
case MMGAction::Category::MMGACTION_COLLECTION: \
set_strs_visible(true); \
ui->label_str1->setText("Collection"); \
MMGAction::do_obs_collection_enum(ui->editor_str1); \
ui->editor_str1->addItem("Use Message Value"); \
break; \
case MMGAction::Category::MMGACTION_MIDI: \
set_strs_visible(true); \
ui->label_str1->setText("Device"); \
ui->editor_str1->addItems( \
MMGDevice::get_output_device_names()); \
break; \
case MMGAction::Category::MMGACTION_INTERNAL: \
set_strs_visible(true); \
ui->label_str1->setText("Action 1"); \
MMGAction::do_mmg_binding_enum(ui->editor_str1, \
current_binding->get_name(), \
current_action->get_str(0)); \
break; \
case MMGAction::Category::MMGACTION_TIMEOUT: \
set_doubles_visible(true); \
ui->label_double1->setText("Time"); \
lcd_double1.set_range(0.0, 1000.0); \
lcd_double1.set_step(1.0, 10.0); \
lcd_double1.reset(); \
break; \
default: \
break; \
}

#define INSERT_SECOND_OPTION() \
current_action->set_str(0, value); \
set_strs_visible(true); \
set_doubles_visible(); \
if (value.isEmpty()) \
return; \
current_action->set_str(0, value); \
ui->editor_str2->clear(); \
lcd_double1.set_use_time(false); \
switch (current_action->get_category()) { \
Expand Down Expand Up @@ -384,17 +385,18 @@ with this program. If not, see <https://www.gnu.org/licenses/>
set_strs_visible(true, true); \
ui->label_str2->setText("Action 2"); \
MMGAction::do_mmg_binding_enum( \
ui->editor_str2, current_binding->get_name()); \
ui->editor_str2, current_binding->get_name(), \
current_action->get_str(1)); \
} \
break; \
default: \
break; \
}

#define INSERT_THIRD_OPTION() \
current_action->set_str(1, value); \
if (value.isEmpty()) \
return; \
current_action->set_str(1, value); \
ui->editor_str3->clear(); \
switch (current_action->get_category()) { \
case MMGAction::Category::MMGACTION_SOURCE_VIDEO: \
Expand Down Expand Up @@ -610,7 +612,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
set_strs_visible(true, true, true); \
ui->label_str3->setText("Action 3"); \
MMGAction::do_mmg_binding_enum( \
ui->editor_str3, current_binding->get_name()); \
ui->editor_str3, current_binding->get_name(), \
current_action->get_str(2)); \
} \
break; \
default: \
Expand Down
8 changes: 6 additions & 2 deletions src/mmg-action.cpp
Expand Up @@ -294,13 +294,17 @@ void MMGAction::do_obs_collection_enum(QComboBox *list)
bfree(collection_names);
}

void MMGAction::do_mmg_binding_enum(QComboBox *list, const QString &current)
void MMGAction::do_mmg_binding_enum(QComboBox *list,
const QString &current_binding,
const QString current_select)
{
for (MMGBinding *const binding :
global()->find_current_device()->get_bindings()) {
if (binding->get_name() != current)
if (binding->get_name() != current_binding)
list->addItem(binding->get_name());
}
if (list->findText(current_select) != -1)
list->setCurrentText(current_select);
}

template<>
Expand Down
3 changes: 2 additions & 1 deletion src/mmg-action.h
Expand Up @@ -189,7 +189,8 @@ class MMGAction {
static void do_obs_profile_enum(QComboBox *list);
static void do_obs_collection_enum(QComboBox *list);
static void do_mmg_binding_enum(QComboBox *list,
const QString &current);
const QString &current_binding,
const QString current_select);

private:
int category;
Expand Down

0 comments on commit 7c3af85

Please sign in to comment.