diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d7e326e --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: InheritParentConfig +ColumnLimit: 132 \ No newline at end of file diff --git a/transition-table.cpp b/transition-table.cpp index 17d558e..fa5a4f9 100644 --- a/transition-table.cpp +++ b/transition-table.cpp @@ -53,12 +53,8 @@ static void load_transition_matrix(obs_data_t *obj) obs_data_t *transition2 = obs_data_array_item(data, j); string toScene = obs_data_get_string(transition2, "to"); if (!fromScene.empty() && !toScene.empty()) { - transition_table[fromScene][toScene].transition = - obs_data_get_string(transition2, - "transition"); - transition_table[fromScene][toScene].duration = - obs_data_get_int(transition2, - "duration"); + transition_table[fromScene][toScene].transition = obs_data_get_string(transition2, "transition"); + transition_table[fromScene][toScene].duration = obs_data_get_int(transition2, "duration"); } obs_data_release(transition2); } @@ -76,15 +72,11 @@ static void load_transitions(obs_data_t *obj) const size_t count = obs_data_array_count(transitions); for (size_t i = 0; i < count; i++) { obs_data_t *transition = obs_data_array_item(transitions, i); - string fromScene = - obs_data_get_string(transition, "from_scene"); + string fromScene = obs_data_get_string(transition, "from_scene"); string toScene = obs_data_get_string(transition, "to_scene"); - string transitionName = - obs_data_get_string(transition, "transition"); - const uint32_t duration = - obs_data_get_int(transition, "duration"); - transition_table[fromScene][toScene].transition = - transitionName; + string transitionName = obs_data_get_string(transition, "transition"); + const uint32_t duration = obs_data_get_int(transition, "duration"); + transition_table[fromScene][toScene].transition = transitionName; transition_table[fromScene][toScene].duration = duration; obs_data_release(transition); } @@ -100,27 +92,18 @@ static void frontend_save_load(obs_data_t *save_data, bool saving, void *) for (const auto &it : transition_table) { for (const auto &it2 : it.second) { obs_data_t *transition = obs_data_create(); - obs_data_set_string(transition, "from_scene", - it.first.c_str()); - obs_data_set_string(transition, "to_scene", - it2.first.c_str()); - obs_data_set_string( - transition, "transition", - it2.second.transition.c_str()); - obs_data_set_int(transition, "duration", - it2.second.duration); - obs_data_array_push_back(transitions, - transition); + obs_data_set_string(transition, "from_scene", it.first.c_str()); + obs_data_set_string(transition, "to_scene", it2.first.c_str()); + obs_data_set_string(transition, "transition", it2.second.transition.c_str()); + obs_data_set_int(transition, "duration", it2.second.duration); + obs_data_array_push_back(transitions, transition); obs_data_release(transition); } } obs_data_set_array(obj, "transitions", transitions); - if (transition_table_width > 500 && - transition_table_height > 300) { - obs_data_set_int(obj, "dialog_width", - transition_table_width); - obs_data_set_int(obj, "dialog_height", - transition_table_height); + if (transition_table_width > 500 && transition_table_height > 300) { + obs_data_set_int(obj, "dialog_width", transition_table_width); + obs_data_set_int(obj, "dialog_height", transition_table_height); } obs_data_array_t *data0 = nullptr; obs_data_array_t *data1 = nullptr; @@ -138,25 +121,19 @@ static void frontend_save_load(obs_data_t *save_data, bool saving, void *) obs_data_release(obj); } else { transition_table.clear(); - obs_data_t *obj = - obs_data_get_obj(save_data, "transition-table"); + obs_data_t *obj = obs_data_get_obj(save_data, "transition-table"); if (obj) { - transition_table_width = - obs_data_get_int(obj, "dialog_width"); - transition_table_height = - obs_data_get_int(obj, "dialog_height"); - obs_data_array_t *eh = - obs_data_get_array(obj, "enable_hotkey"); - obs_data_array_t *dh = - obs_data_get_array(obj, "disable_hotkey"); + transition_table_width = obs_data_get_int(obj, "dialog_width"); + transition_table_height = obs_data_get_int(obj, "dialog_height"); + obs_data_array_t *eh = obs_data_get_array(obj, "enable_hotkey"); + obs_data_array_t *dh = obs_data_get_array(obj, "disable_hotkey"); obs_hotkey_pair_load(transition_table_hotkey, eh, dh); obs_data_array_release(eh); obs_data_array_release(dh); load_transitions(obj); obs_data_release(obj); } else { - obj = obs_data_get_obj(save_data, - "obs-transition-matrix"); + obj = obs_data_get_obj(save_data, "obs-transition-matrix"); if (obj) { load_transition_matrix(obj); obs_data_release(obj); @@ -165,19 +142,12 @@ static void frontend_save_load(obs_data_t *save_data, bool saving, void *) obs_frontend_source_list scenes = {}; obs_frontend_get_scenes(&scenes); for (size_t i = 0; i < scenes.sources.num; i++) { - obs_data_t *data = - obs_source_get_private_settings( - scenes.sources.array[i]); - string transitionName = - obs_data_get_string(data, "transition"); - string sceneName = obs_source_get_name( - scenes.sources.array[i]); + obs_data_t *data = obs_source_get_private_settings(scenes.sources.array[i]); + string transitionName = obs_data_get_string(data, "transition"); + string sceneName = obs_source_get_name(scenes.sources.array[i]); if (!transitionName.empty()) { - transition_table["Any"][sceneName] - .transition = transitionName; - transition_table["Any"][sceneName] - .duration = obs_data_get_int( - data, "transition_duration"); + transition_table["Any"][sceneName].transition = transitionName; + transition_table["Any"][sceneName].duration = obs_data_get_int(data, "transition_duration"); } obs_data_release(data); } @@ -191,8 +161,7 @@ static void clear_transition_overrides() obs_frontend_source_list scenes = {}; obs_frontend_get_scenes(&scenes); for (size_t i = 0; i < scenes.sources.num; i++) { - obs_data_t *data = obs_source_get_private_settings( - scenes.sources.array[i]); + obs_data_t *data = obs_source_get_private_settings(scenes.sources.array[i]); obs_data_erase(data, "transition"); obs_data_release(data); } @@ -208,8 +177,7 @@ static void set_transition_overrides() obs_source_release(scene); } - auto fs_it = fromScene.empty() ? transition_table.end() - : transition_table.find(fromScene); + auto fs_it = fromScene.empty() ? transition_table.end() : transition_table.find(fromScene); auto as_it = transition_table.find("Any"); obs_frontend_source_list scenes = {}; @@ -238,13 +206,11 @@ static void set_transition_overrides() duration = to_it->second.duration; } } - obs_data_t *data = obs_source_get_private_settings( - scenes.sources.array[i]); + obs_data_t *data = obs_source_get_private_settings(scenes.sources.array[i]); if (transition.empty()) { obs_data_erase(data, "transition"); } else { - obs_data_set_string(data, "transition", - transition.c_str()); + obs_data_set_string(data, "transition", transition.c_str()); obs_data_set_int(data, "transition_duration", duration); } obs_data_release(data); @@ -259,8 +225,7 @@ static void frontend_event(enum obs_frontend_event event, void *) if (event == OBS_FRONTEND_EVENT_SCENE_CHANGED) { if (transition_table_enabled) set_transition_overrides(); - } else if (event == OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP || - event == OBS_FRONTEND_EVENT_EXIT) { + } else if (event == OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP || event == OBS_FRONTEND_EVENT_EXIT) { transition_table.clear(); } } @@ -284,8 +249,7 @@ static void source_rename(void *data, calldata_t *call_data) } } -bool enable_hotkey(void *data, obs_hotkey_pair_id id, obs_hotkey_t *hotkey, - bool pressed) +bool enable_hotkey(void *data, obs_hotkey_pair_id id, obs_hotkey_t *hotkey, bool pressed) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(id); @@ -298,8 +262,7 @@ bool enable_hotkey(void *data, obs_hotkey_pair_id id, obs_hotkey_t *hotkey, return false; } -bool disable_hotkey(void *data, obs_hotkey_pair_id id, obs_hotkey_t *hotkey, - bool pressed) +bool disable_hotkey(void *data, obs_hotkey_pair_id id, obs_hotkey_t *hotkey, bool pressed) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(id); @@ -312,8 +275,7 @@ bool disable_hotkey(void *data, obs_hotkey_pair_id id, obs_hotkey_t *hotkey, return false; } -static void get_transition(std::string from_scene, std::string to_scene, - std::string &transition, int &duration) +static void get_transition(std::string from_scene, std::string to_scene, std::string &transition, int &duration) { auto fs_it = transition_table.find(from_scene); auto as_it = transition_table.find("Any"); @@ -362,14 +324,12 @@ static void proc_get_transition(void *data, calldata_t *cd) bool obs_module_load(void) { blog(LOG_INFO, "[Transition Table] loaded version %s", PROJECT_VERSION); - auto *action = (QAction *)obs_frontend_add_tools_menu_qaction( - obs_module_text("TransitionTable")); + auto *action = (QAction *)obs_frontend_add_tools_menu_qaction(obs_module_text("TransitionTable")); auto cb = [] { obs_frontend_push_ui_translation(obs_module_get_string); - auto ttd = new TransitionTableDialog( - (QMainWindow *)obs_frontend_get_main_window()); + auto ttd = new TransitionTableDialog((QMainWindow *)obs_frontend_get_main_window()); ttd->setAttribute(Qt::WA_DeleteOnClose); ttd->show(); obs_frontend_pop_ui_translation(); @@ -379,15 +339,11 @@ bool obs_module_load(void) obs_frontend_add_save_callback(frontend_save_load, nullptr); obs_frontend_add_event_callback(frontend_event, nullptr); - signal_handler_connect(obs_get_signal_handler(), "source_rename", - source_rename, nullptr); + signal_handler_connect(obs_get_signal_handler(), "source_rename", source_rename, nullptr); transition_table_hotkey = obs_hotkey_pair_register_frontend( - "transition-table.enable", - obs_module_text("TransitionTable.Enable"), - "transition-table.disable", - obs_module_text("TransitionTable.Disable"), enable_hotkey, - disable_hotkey, nullptr, nullptr); + "transition-table.enable", obs_module_text("TransitionTable.Enable"), "transition-table.disable", + obs_module_text("TransitionTable.Disable"), enable_hotkey, disable_hotkey, nullptr, nullptr); auto ph = obs_get_proc_handler(); proc_handler_add( ph, @@ -398,12 +354,10 @@ bool obs_module_load(void) static obs_websocket_vendor vendor = nullptr; -static void vendor_get_transition(obs_data_t *request_data, - obs_data_t *response_data, void *param) +static void vendor_get_transition(obs_data_t *request_data, obs_data_t *response_data, void *param) { UNUSED_PARAMETER(param); - std::string from_scene = - obs_data_get_string(request_data, "from_scene"); + std::string from_scene = obs_data_get_string(request_data, "from_scene"); std::string to_scene = obs_data_get_string(request_data, "to_scene"); string transition; auto duration = 0; @@ -413,40 +367,32 @@ static void vendor_get_transition(obs_data_t *request_data, obs_data_set_bool(response_data, "success", true); } -static void vendor_set_transition(obs_data_t *request_data, - obs_data_t *response_data, void *param) +static void vendor_set_transition(obs_data_t *request_data, obs_data_t *response_data, void *param) { UNUSED_PARAMETER(param); - std::string from_scene = - obs_data_get_string(request_data, "from_scene"); + std::string from_scene = obs_data_get_string(request_data, "from_scene"); if (from_scene.empty()) { - obs_data_set_string(response_data, "error", - "'from_scene' not set"); + obs_data_set_string(response_data, "error", "'from_scene' not set"); obs_data_set_bool(response_data, "success", false); return; } std::string to_scene = obs_data_get_string(request_data, "to_scene"); if (to_scene.empty()) { - obs_data_set_string(response_data, "error", - "'to_scene' not set"); + obs_data_set_string(response_data, "error", "'to_scene' not set"); obs_data_set_bool(response_data, "success", false); return; } - std::string transition = - obs_data_get_string(request_data, "transition"); + std::string transition = obs_data_get_string(request_data, "transition"); if (transition.empty()) { auto fs_it = transition_table.find(from_scene); if (fs_it == transition_table.end()) { - obs_data_set_string(response_data, "error", - "'from_scene' not found in table"); + obs_data_set_string(response_data, "error", "'from_scene' not found in table"); obs_data_set_bool(response_data, "success", false); return; } auto ts_it = fs_it->second.find(to_scene); if (ts_it == fs_it->second.end()) { - obs_data_set_string( - response_data, "error", - "'to_scene' not found for this 'from_scene'"); + obs_data_set_string(response_data, "error", "'to_scene' not found for this 'from_scene'"); obs_data_set_bool(response_data, "success", false); return; } @@ -460,8 +406,7 @@ static void vendor_set_transition(obs_data_t *request_data, obs_data_set_bool(response_data, "success", true); } -static void vendor_get_table(obs_data_t *request_data, - obs_data_t *response_data, void *param) +static void vendor_get_table(obs_data_t *request_data, obs_data_t *response_data, void *param) { UNUSED_PARAMETER(request_data); UNUSED_PARAMETER(param); @@ -469,14 +414,10 @@ static void vendor_get_table(obs_data_t *request_data, for (const auto &it : transition_table) { for (const auto &it2 : it.second) { obs_data_t *transition = obs_data_create(); - obs_data_set_string(transition, "from_scene", - it.first.c_str()); - obs_data_set_string(transition, "to_scene", - it2.first.c_str()); - obs_data_set_string(transition, "transition", - it2.second.transition.c_str()); - obs_data_set_int(transition, "duration", - it2.second.duration); + obs_data_set_string(transition, "from_scene", it.first.c_str()); + obs_data_set_string(transition, "to_scene", it2.first.c_str()); + obs_data_set_string(transition, "transition", it2.second.transition.c_str()); + obs_data_set_int(transition, "duration", it2.second.duration); obs_data_array_push_back(transitions_array, transition); obs_data_release(transition); } @@ -491,12 +432,9 @@ void obs_module_post_load(void) vendor = obs_websocket_register_vendor("transition-table"); if (!vendor) return; - obs_websocket_vendor_register_request(vendor, "get_transition", - vendor_get_transition, nullptr); - obs_websocket_vendor_register_request(vendor, "set_transition", - vendor_set_transition, nullptr); - obs_websocket_vendor_register_request(vendor, "get_table", - vendor_get_table, nullptr); + obs_websocket_vendor_register_request(vendor, "get_transition", vendor_get_transition, nullptr); + obs_websocket_vendor_register_request(vendor, "set_transition", vendor_set_transition, nullptr); + obs_websocket_vendor_register_request(vendor, "get_table", vendor_get_table, nullptr); } void obs_module_unload(void) @@ -504,8 +442,7 @@ void obs_module_unload(void) obs_hotkey_pair_unregister(transition_table_hotkey); obs_frontend_remove_save_callback(frontend_save_load, nullptr); obs_frontend_remove_event_callback(frontend_event, nullptr); - signal_handler_disconnect(obs_get_signal_handler(), "source_rename", - source_rename, nullptr); + signal_handler_disconnect(obs_get_signal_handler(), "source_rename", source_rename, nullptr); transition_table.clear(); } @@ -519,8 +456,7 @@ MODULE_EXPORT const char *obs_module_name(void) return obs_module_text("TransitionTable"); } -TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) - : QDialog(parent) +TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) : QDialog(parent) { obs_frontend_get_scenes(&scenes); obs_frontend_get_transitions(&transitions); @@ -546,8 +482,7 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) mainLayout->setColumnStretch(1, 1); mainLayout->setColumnStretch(2, 1); - connect(checkbox, &QCheckBox::stateChanged, - [this]() { SelectAllChanged(); }); + connect(checkbox, &QCheckBox::stateChanged, [this]() { SelectAllChanged(); }); idx = 0; fromCombo = new QComboBox(); @@ -571,23 +506,17 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) for (size_t i = 0; i < scenes.sources.num; i++) { string sceneName = obs_source_get_name(scenes.sources.array[i]); - fromCombo->addItem(QString::fromUtf8(sceneName.c_str()), - QByteArray(sceneName.c_str())); - toCombo->addItem(QString::fromUtf8(sceneName.c_str()), - QByteArray(sceneName.c_str())); + fromCombo->addItem(QString::fromUtf8(sceneName.c_str()), QByteArray(sceneName.c_str())); + toCombo->addItem(QString::fromUtf8(sceneName.c_str()), QByteArray(sceneName.c_str())); } - connect(fromCombo, SIGNAL(editTextChanged(const QString &)), - SLOT(RefreshTable())); - connect(toCombo, SIGNAL(editTextChanged(const QString &)), - SLOT(RefreshTable())); + connect(fromCombo, SIGNAL(editTextChanged(const QString &)), SLOT(RefreshTable())); + connect(toCombo, SIGNAL(editTextChanged(const QString &)), SLOT(RefreshTable())); transitionCombo = new QComboBox(); for (size_t i = 0; i < transitions.sources.num; i++) { - string trName = - obs_source_get_name(transitions.sources.array[i]); - transitionCombo->addItem(QString::fromUtf8(trName.c_str()), - QByteArray(trName.c_str())); + string trName = obs_source_get_name(transitions.sources.array[i]); + transitionCombo->addItem(QString::fromUtf8(trName.c_str()), QByteArray(trName.c_str())); } mainLayout->addWidget(transitionCombo, 1, idx++); durationSpin = new QSpinBox; @@ -605,8 +534,7 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) QWidget *controlArea = new QWidget; controlArea->setLayout(mainLayout); - controlArea->setSizePolicy(QSizePolicy::Preferred, - QSizePolicy::Preferred); + controlArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addWidget(controlArea); @@ -619,16 +547,11 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) scrollArea->setWidget(widget); scrollArea->setWidgetResizable(true); - QPushButton *closeButton = - new QPushButton(QString::fromUtf8(obs_module_text("Close"))); - QPushButton *exportButton = - new QPushButton(QString::fromUtf8(obs_module_text("Export"))); - QPushButton *matrixButton = - new QPushButton(QString::fromUtf8(obs_module_text("Matrix"))); - QPushButton *importButton = - new QPushButton(QString::fromUtf8(obs_module_text("Import"))); - QPushButton *deleteButton = - new QPushButton(QString::fromUtf8(obs_module_text("Delete"))); + QPushButton *closeButton = new QPushButton(QString::fromUtf8(obs_module_text("Close"))); + QPushButton *exportButton = new QPushButton(QString::fromUtf8(obs_module_text("Export"))); + QPushButton *matrixButton = new QPushButton(QString::fromUtf8(obs_module_text("Matrix"))); + QPushButton *importButton = new QPushButton(QString::fromUtf8(obs_module_text("Import"))); + QPushButton *deleteButton = new QPushButton(QString::fromUtf8(obs_module_text("Delete"))); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addWidget( @@ -642,15 +565,11 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) bottomLayout->addWidget(deleteButton, 0, Qt::AlignRight); bottomLayout->addWidget(closeButton, 0, Qt::AlignRight); bottomLayout->setStretch(0, 1); - connect(deleteButton, &QPushButton::clicked, - [this]() { DeleteClicked(); }); + connect(deleteButton, &QPushButton::clicked, [this]() { DeleteClicked(); }); connect(closeButton, &QPushButton::clicked, [this]() { close(); }); connect(exportButton, &QPushButton::clicked, [this]() { const QString fileName = QFileDialog::getSaveFileName( - nullptr, - QString::fromUtf8( - obs_module_text("SaveTransitionTable")), - QString(), "JSON File (*.json)"); + nullptr, QString::fromUtf8(obs_module_text("SaveTransitionTable")), QString(), "JSON File (*.json)"); if (fileName.isEmpty()) return; const auto fu = fileName.toUtf8(); @@ -661,8 +580,7 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) auto *item = mainLayout->itemAtPosition(row, 4); if (!item) continue; - auto *checkBox = - dynamic_cast(item->widget()); + auto *checkBox = dynamic_cast(item->widget()); if (!checkBox || !checkBox->isChecked()) continue; @@ -688,35 +606,22 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) continue; selection = true; obs_data_t *transition = obs_data_create(); - obs_data_set_string(transition, "from_scene", - fromScene.c_str()); - obs_data_set_string(transition, "to_scene", - toScene.c_str()); - obs_data_set_string(transition, "transition", - ts_it->second.transition.c_str()); - obs_data_set_int(transition, "duration", - ts_it->second.duration); + obs_data_set_string(transition, "from_scene", fromScene.c_str()); + obs_data_set_string(transition, "to_scene", toScene.c_str()); + obs_data_set_string(transition, "transition", ts_it->second.transition.c_str()); + obs_data_set_int(transition, "duration", ts_it->second.duration); obs_data_array_push_back(transitions_array, transition); obs_data_release(transition); } if (!selection) { for (const auto &it : transition_table) { for (const auto &it2 : it.second) { - obs_data_t *transition = - obs_data_create(); - obs_data_set_string(transition, - "from_scene", - it.first.c_str()); - obs_data_set_string(transition, - "to_scene", - it2.first.c_str()); - obs_data_set_string( - transition, "transition", - it2.second.transition.c_str()); - obs_data_set_int(transition, "duration", - it2.second.duration); - obs_data_array_push_back( - transitions_array, transition); + obs_data_t *transition = obs_data_create(); + obs_data_set_string(transition, "from_scene", it.first.c_str()); + obs_data_set_string(transition, "to_scene", it2.first.c_str()); + obs_data_set_string(transition, "transition", it2.second.transition.c_str()); + obs_data_set_int(transition, "duration", it2.second.duration); + obs_data_array_push_back(transitions_array, transition); obs_data_release(transition); } } @@ -729,23 +634,18 @@ TransitionTableDialog::TransitionTableDialog(QMainWindow *parent) }); connect(importButton, &QPushButton::clicked, [this]() { const QString fileName = QFileDialog::getOpenFileName( - nullptr, - QString::fromUtf8( - obs_module_text("LoadTransitionTable")), - QString(), "JSON File (*.json)"); + nullptr, QString::fromUtf8(obs_module_text("LoadTransitionTable")), QString(), "JSON File (*.json)"); if (fileName.isEmpty()) return; const auto fu = fileName.toUtf8(); - obs_data_t *data = - obs_data_create_from_json_file(fu.constData()); + obs_data_t *data = obs_data_create_from_json_file(fu.constData()); load_transitions(data); obs_data_release(data); RefreshTable(); if (transition_table_enabled) set_transition_overrides(); }); - connect(matrixButton, &QPushButton::clicked, this, - &TransitionTableDialog::ShowMatrix); + connect(matrixButton, &QPushButton::clicked, this, &TransitionTableDialog::ShowMatrix); vlayout = new QVBoxLayout; vlayout->setContentsMargins(11, 11, 11, 11); @@ -783,8 +683,7 @@ void TransitionTableDialog::AddClicked() if (toScene == QString::fromUtf8(obs_module_text("Any"))) toScene = "Any"; - auto &t = transition_table[fromScene.toUtf8().constData()] - [toScene.toUtf8().constData()]; + auto &t = transition_table[fromScene.toUtf8().constData()][toScene.toUtf8().constData()]; t.transition = transition.toUtf8().constData(); t.duration = durationSpin->value(); RefreshTable(); @@ -854,8 +753,7 @@ void TransitionTableDialog::RefreshTable() if (toScene == QString::fromUtf8(obs_module_text("Any"))) toScene = "Any"; for (auto row = mainLayout->rowCount() - 1; row >= 2; row--) { - for (auto col = mainLayout->columnCount() - 1; col >= 0; - col--) { + for (auto col = mainLayout->columnCount() - 1; col >= 0; col--) { auto *item = mainLayout->itemAtPosition(row, col); if (item) { mainLayout->removeItem(item); @@ -868,25 +766,18 @@ void TransitionTableDialog::RefreshTable() string transition; auto row = 2; for (const auto &it : transition_table) { - if (!fromScene.isEmpty() && - !QString::fromUtf8(it.first.c_str()) - .contains(fromScene, Qt::CaseInsensitive)) + if (!fromScene.isEmpty() && !QString::fromUtf8(it.first.c_str()).contains(fromScene, Qt::CaseInsensitive)) continue; for (const auto &it2 : it.second) { - if (!toScene.isEmpty() && - !QString::fromUtf8(it2.first.c_str()) - .contains(toScene, Qt::CaseInsensitive)) + if (!toScene.isEmpty() && !QString::fromUtf8(it2.first.c_str()).contains(toScene, Qt::CaseInsensitive)) continue; auto col = 0; - auto *label = - new QLabel(QString::fromUtf8(it.first.c_str())); + auto *label = new QLabel(QString::fromUtf8(it.first.c_str())); if (it.first == "Any") { label->setProperty("themeID", "good"); - label->setText(QString::fromUtf8( - obs_module_text("Any"))); + label->setText(QString::fromUtf8(obs_module_text("Any"))); } else { - auto scene = obs_get_source_by_name( - it.first.c_str()); + auto scene = obs_get_source_by_name(it.first.c_str()); if (scene) { obs_source_release(scene); } else { @@ -894,15 +785,12 @@ void TransitionTableDialog::RefreshTable() } } mainLayout->addWidget(label, row, col++); - label = new QLabel( - QString::fromUtf8(it2.first.c_str())); + label = new QLabel(QString::fromUtf8(it2.first.c_str())); if (it2.first == "Any") { label->setProperty("themeID", "good"); - label->setText(QString::fromUtf8( - obs_module_text("Any"))); + label->setText(QString::fromUtf8(obs_module_text("Any"))); } else { - auto scene = obs_get_source_by_name( - it2.first.c_str()); + auto scene = obs_get_source_by_name(it2.first.c_str()); if (scene) { obs_source_release(scene); } else { @@ -910,17 +798,12 @@ void TransitionTableDialog::RefreshTable() } } mainLayout->addWidget(label, row, col++); - label = new QLabel(QString::fromUtf8( - it2.second.transition.c_str())); + label = new QLabel(QString::fromUtf8(it2.second.transition.c_str())); mainLayout->addWidget(label, row, col++); - label = new QLabel(QString::fromUtf8( - (to_string(it2.second.duration) + "ms") - .c_str())); - mainLayout->addWidget(label, row, col++, - Qt::AlignRight); + label = new QLabel(QString::fromUtf8((to_string(it2.second.duration) + "ms").c_str())); + mainLayout->addWidget(label, row, col++, Qt::AlignRight); auto *checkBox = new QCheckBox; - mainLayout->addWidget(checkBox, row, col++, - Qt::AlignCenter); + mainLayout->addWidget(checkBox, row, col++, Qt::AlignCenter); duration = it2.second.duration; transition = it2.second.transition; row++; @@ -972,8 +855,7 @@ void TransitionTableDialog::mouseDoubleClickEvent(QMouseEvent *event) void TransitionTableDialog::ShowMatrix() { const auto md = new QDialog(this); - md->setWindowTitle( - QString::fromUtf8(obs_module_text("TransitionMatrix"))); + md->setWindowTitle(QString::fromUtf8(obs_module_text("TransitionMatrix"))); md->setAttribute(Qt::WA_DeleteOnClose); md->setSizeGripEnabled(true); @@ -994,17 +876,11 @@ void TransitionTableDialog::ShowMatrix() int i = 0; for (const auto &it : scenes) { w->setHorizontalHeaderItem( - i, new QTableWidgetItem( - QString::fromUtf8( - it == "Any" ? obs_module_text("Any") - : it.c_str()), - QTableWidgetItem::ItemType::Type)); - w->setVerticalHeaderItem( - i, new QTableWidgetItem( - QString::fromUtf8( - it == "Any" ? obs_module_text("Any") - : it.c_str()), - QTableWidgetItem::ItemType::Type)); + i, new QTableWidgetItem(QString::fromUtf8(it == "Any" ? obs_module_text("Any") : it.c_str()), + QTableWidgetItem::ItemType::Type)); + w->setVerticalHeaderItem(i, + new QTableWidgetItem(QString::fromUtf8(it == "Any" ? obs_module_text("Any") : it.c_str()), + QTableWidgetItem::ItemType::Type)); i++; } int row = 0; @@ -1019,9 +895,7 @@ void TransitionTableDialog::ShowMatrix() t = f2->second.transition; } } - w->setCellWidget( - row, column, - new QLabel(QString::fromUtf8(t.c_str()))); + w->setCellWidget(row, column, new QLabel(QString::fromUtf8(t.c_str()))); column++; } row++; @@ -1029,8 +903,7 @@ void TransitionTableDialog::ShowMatrix() const auto m = new QVBoxLayout; m->addWidget(w); - QPushButton *closeButton = - new QPushButton(QString::fromUtf8(obs_module_text("Close"))); + QPushButton *closeButton = new QPushButton(QString::fromUtf8(obs_module_text("Close"))); connect(closeButton, &QPushButton::clicked, [md]() { md->close(); }); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addWidget(