From 5129612b6cc1479bdc6b13e98c13aa75a5cfd9a2 Mon Sep 17 00:00:00 2001 From: gxalpha Date: Sun, 19 Jan 2025 01:32:42 +0100 Subject: [PATCH] frontend,shared: Replace and disable contextless connect calls # Conflicts: # frontend/OBSApp.cpp --- frontend/OBSApp.cpp | 2 +- frontend/OBSStudioAPI.cpp | 2 +- frontend/components/OBSAdvAudioCtrl.cpp | 3 ++- frontend/components/SourceTreeItem.cpp | 4 ++-- frontend/components/VisibilityItemWidget.cpp | 2 +- frontend/dialogs/OBSBasicFilters.cpp | 8 ++++---- frontend/dialogs/OBSBasicInteraction.cpp | 2 +- frontend/dialogs/OBSBasicProperties.cpp | 8 ++++---- frontend/dialogs/OBSBasicSourceSelect.cpp | 6 +++--- .../ImporterEntryPathItemDelegate.cpp | 4 ++-- .../plugins/aja-output-ui/aja-ui-main.cpp | 2 +- .../decklink-captions/decklink-captions.cpp | 2 +- .../decklink-output-ui/decklink-ui-main.cpp | 2 +- .../frontend-tools/auto-scene-switcher.cpp | 2 +- .../plugins/frontend-tools/output-timer.cpp | 2 +- frontend/plugins/frontend-tools/scripts.cpp | 2 +- frontend/settings/OBSBasicSettings.cpp | 6 +++--- frontend/settings/OBSHotkeyEdit.cpp | 2 +- frontend/settings/OBSHotkeyWidget.cpp | 11 +++++----- .../utility/MissingFilesPathItemDelegate.cpp | 4 ++-- .../utility/RemuxEntryPathItemDelegate.cpp | 4 ++-- frontend/widgets/OBSBasic.cpp | 12 ++++++----- frontend/widgets/OBSBasicStats.cpp | 4 ++-- frontend/widgets/OBSBasic_Docks.cpp | 4 ++-- frontend/widgets/OBSBasic_Preview.cpp | 8 ++++---- frontend/widgets/OBSBasic_SceneItems.cpp | 6 +++--- frontend/widgets/OBSBasic_Scenes.cpp | 2 +- frontend/widgets/OBSBasic_StudioMode.cpp | 20 +++++++++---------- frontend/widgets/OBSBasic_Transitions.cpp | 20 +++++++++---------- frontend/widgets/OBSProjector.cpp | 2 +- frontend/widgets/OBSQTDisplay.cpp | 4 ++-- frontend/wizards/AutoConfigStreamPage.cpp | 2 +- shared/properties-view/double-slider.cpp | 2 +- shared/properties-view/properties-view.cpp | 16 +++++++-------- 34 files changed, 93 insertions(+), 89 deletions(-) diff --git a/frontend/OBSApp.cpp b/frontend/OBSApp.cpp index 1403eb816..b14aa2f56 100644 --- a/frontend/OBSApp.cpp +++ b/frontend/OBSApp.cpp @@ -1254,7 +1254,7 @@ bool OBSApp::OBSInit() connect(OBSBasic::Get(), &OBSBasic::mainWindowClosed, crashHandler_.get(), &OBS::CrashHandler::applicationShutdownHandler); - connect(this, &QGuiApplication::applicationStateChanged, + connect(this, &QGuiApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) { ResetHotkeyState(state == Qt::ApplicationActive); }); ResetHotkeyState(applicationState() == Qt::ApplicationActive); diff --git a/frontend/OBSStudioAPI.cpp b/frontend/OBSStudioAPI.cpp index 7e8ab72bb..ad0da34dc 100644 --- a/frontend/OBSStudioAPI.cpp +++ b/frontend/OBSStudioAPI.cpp @@ -326,7 +326,7 @@ void OBSStudioAPI::obs_frontend_add_tools_menu_item(const char *name, obs_fronte QAction *action = main->ui->menuTools->addAction(QT_UTF8(name)); action->setMenuRole(QAction::NoRole); - QObject::connect(action, &QAction::triggered, func); + QObject::connect(action, &QAction::triggered, action, func); } bool OBSStudioAPI::obs_frontend_add_dock_by_id(const char *id, const char *title, void *widget) diff --git a/frontend/components/OBSAdvAudioCtrl.cpp b/frontend/components/OBSAdvAudioCtrl.cpp index 33a6385ae..068c57ed7 100644 --- a/frontend/components/OBSAdvAudioCtrl.cpp +++ b/frontend/components/OBSAdvAudioCtrl.cpp @@ -207,7 +207,8 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_) : source( connect(monitoringType, &QComboBox::currentIndexChanged, this, &OBSAdvAudioCtrl::monitoringTypeChanged); auto connectMixer = [this](QCheckBox *mixer, int num) { - connect(mixer, &QCheckBox::clicked, [this, num](bool checked) { setMixer(source, num, checked); }); + connect(mixer, &QCheckBox::clicked, this, + [this, num](bool checked) { setMixer(source, num, checked); }); }; connectMixer(mixer1, 0); connectMixer(mixer2, 1); diff --git a/frontend/components/SourceTreeItem.cpp b/frontend/components/SourceTreeItem.cpp index 66b19f1e0..97236a2a4 100644 --- a/frontend/components/SourceTreeItem.cpp +++ b/frontend/components/SourceTreeItem.cpp @@ -156,8 +156,8 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_) : tre obs_sceneitem_set_locked(sceneitem, checked); }; - connect(vis, &QAbstractButton::clicked, setItemVisible); - connect(lock, &QAbstractButton::clicked, setItemLocked); + connect(vis, &QAbstractButton::clicked, this, setItemVisible); + connect(lock, &QAbstractButton::clicked, this, setItemLocked); } void SourceTreeItem::paintEvent(QPaintEvent *event) diff --git a/frontend/components/VisibilityItemWidget.cpp b/frontend/components/VisibilityItemWidget.cpp index bc1fda2e3..42af71813 100644 --- a/frontend/components/VisibilityItemWidget.cpp +++ b/frontend/components/VisibilityItemWidget.cpp @@ -28,7 +28,7 @@ VisibilityItemWidget::VisibilityItemWidget(obs_source_t *source_) setLayout(itemLayout); - connect(vis, &QCheckBox::clicked, [this](bool visible) { obs_source_set_enabled(source, visible); }); + connect(vis, &QCheckBox::clicked, this, [this](bool visible) { obs_source_set_enabled(source, visible); }); } void VisibilityItemWidget::OBSSourceEnabled(void *param, calldata_t *data) diff --git a/frontend/dialogs/OBSBasicFilters.cpp b/frontend/dialogs/OBSBasicFilters.cpp index a7c42d7f6..cbc2f7654 100644 --- a/frontend/dialogs/OBSBasicFilters.cpp +++ b/frontend/dialogs/OBSBasicFilters.cpp @@ -76,10 +76,10 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_) installEventFilter(CreateShortcutFilter()); - connect(ui->asyncFilters->itemDelegate(), &QAbstractItemDelegate::closeEditor, + connect(ui->asyncFilters->itemDelegate(), &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) { FilterNameEdited(editor, ui->asyncFilters); }); - connect(ui->effectFilters->itemDelegate(), &QAbstractItemDelegate::closeEditor, + connect(ui->effectFilters->itemDelegate(), &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) { FilterNameEdited(editor, ui->effectFilters); }); QPushButton *close = ui->buttonBox->button(QDialogButtonBox::Close); @@ -133,7 +133,7 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_) ui->rightLayout->setContentsMargins(0, 0, 0, 0); ui->preview->show(); if (drawable_type) - connect(ui->preview, &OBSQTDisplay::DisplayCreated, addDrawCallback); + connect(ui->preview, &OBSQTDisplay::DisplayCreated, this, addDrawCallback); } else { ui->rightLayout->setContentsMargins(0, noPreviewMargin, 0, 0); ui->preview->hide(); @@ -486,7 +486,7 @@ QMenu *OBSBasicFilters::CreateAddFilterPopupMenu(bool async) QAction *popupItem = new QAction(QT_UTF8(type.name.c_str()), this); popupItem->setData(QT_UTF8(type.type.c_str())); - connect(popupItem, &QAction::triggered, [this, type]() { AddNewFilter(type.type.c_str()); }); + connect(popupItem, &QAction::triggered, this, [this, type]() { AddNewFilter(type.type.c_str()); }); popup->addAction(popupItem); foundValues = true; diff --git a/frontend/dialogs/OBSBasicInteraction.cpp b/frontend/dialogs/OBSBasicInteraction.cpp index 67880c75d..0deeb6525 100644 --- a/frontend/dialogs/OBSBasicInteraction.cpp +++ b/frontend/dialogs/OBSBasicInteraction.cpp @@ -69,7 +69,7 @@ OBSBasicInteraction::OBSBasicInteraction(QWidget *parent, OBSSource source_) obs_display_add_draw_callback(ui->preview->GetDisplay(), OBSBasicInteraction::DrawPreview, this); }; - connect(ui->preview, &OBSQTDisplay::DisplayCreated, addDrawCallback); + connect(ui->preview, &OBSQTDisplay::DisplayCreated, this, addDrawCallback); } OBSBasicInteraction::~OBSBasicInteraction() diff --git a/frontend/dialogs/OBSBasicProperties.cpp b/frontend/dialogs/OBSBasicProperties.cpp index 881ed5e0d..ecf1653dd 100644 --- a/frontend/dialogs/OBSBasicProperties.cpp +++ b/frontend/dialogs/OBSBasicProperties.cpp @@ -103,7 +103,7 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_) if (drawable_preview && drawable_type) { ui->preview->show(); - connect(ui->preview, &OBSQTDisplay::DisplayCreated, addDrawCallback); + connect(ui->preview, &OBSQTDisplay::DisplayCreated, this, addDrawCallback); } else if (type == OBS_SOURCE_TYPE_TRANSITION) { sourceA = obs_source_create_private("scene", "sourceA", nullptr); @@ -139,10 +139,10 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_) direction = true; }; - connect(view, &OBSPropertiesView::Changed, updateCallback); + connect(view, &OBSPropertiesView::Changed, this, updateCallback); ui->preview->show(); - connect(ui->preview, &OBSQTDisplay::DisplayCreated, addTransitionDrawCallback); + connect(ui->preview, &OBSQTDisplay::DisplayCreated, this, addTransitionDrawCallback); } else { ui->preview->hide(); @@ -187,7 +187,7 @@ void OBSBasicProperties::AddPreviewButton() end = nullptr; }; - connect(playButton, &QPushButton::clicked, play); + connect(playButton, &QPushButton::clicked, this, play); } static obs_source_t *CreateLabel(const char *name, size_t h) diff --git a/frontend/dialogs/OBSBasicSourceSelect.cpp b/frontend/dialogs/OBSBasicSourceSelect.cpp index 76db07802..3e5056180 100644 --- a/frontend/dialogs/OBSBasicSourceSelect.cpp +++ b/frontend/dialogs/OBSBasicSourceSelect.cpp @@ -359,18 +359,18 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *id_, un installEventFilter(CreateShortcutFilter()); - connect(ui->createNew, &QRadioButton::pressed, [&]() { + connect(ui->createNew, &QRadioButton::pressed, this, [&]() { QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Ok); if (!button->isEnabled()) button->setEnabled(true); }); - connect(ui->selectExisting, &QRadioButton::pressed, [&]() { + connect(ui->selectExisting, &QRadioButton::pressed, this, [&]() { QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Ok); bool enabled = ui->sourceList->selectedItems().size() != 0; if (button->isEnabled() != enabled) button->setEnabled(enabled); }); - connect(ui->sourceList, &QListWidget::itemSelectionChanged, [&]() { + connect(ui->sourceList, &QListWidget::itemSelectionChanged, this, [&]() { QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Ok); if (!button->isEnabled()) button->setEnabled(true); diff --git a/frontend/importer/ImporterEntryPathItemDelegate.cpp b/frontend/importer/ImporterEntryPathItemDelegate.cpp index d6b3b8f7c..520dc5ef9 100644 --- a/frontend/importer/ImporterEntryPathItemDelegate.cpp +++ b/frontend/importer/ImporterEntryPathItemDelegate.cpp @@ -68,7 +68,7 @@ QWidget *ImporterEntryPathItemDelegate::createEditor(QWidget *parent, const QSty browseButton->setSizePolicy(buttonSizePolicy); layout->addWidget(browseButton); - container->connect(browseButton, &QToolButton::clicked, browseCallback); + connect(browseButton, &QToolButton::clicked, this, browseCallback); // The "clear" button is not shown in output cells // or the insertion point's input cell. @@ -78,7 +78,7 @@ QWidget *ImporterEntryPathItemDelegate::createEditor(QWidget *parent, const QSty clearButton->setSizePolicy(buttonSizePolicy); layout->addWidget(clearButton); - container->connect(clearButton, &QToolButton::clicked, clearCallback); + connect(clearButton, &QToolButton::clicked, this, clearCallback); } container->setLayout(layout); diff --git a/frontend/plugins/aja-output-ui/aja-ui-main.cpp b/frontend/plugins/aja-output-ui/aja-ui-main.cpp index a1eb58e10..587ab879d 100644 --- a/frontend/plugins/aja-output-ui/aja-ui-main.cpp +++ b/frontend/plugins/aja-output-ui/aja-ui-main.cpp @@ -374,7 +374,7 @@ void addOutputUI(void) ajaOutputUI->ShowHideDialog(); }; - action->connect(action, &QAction::triggered, cb); + QObject::connect(action, &QAction::triggered, action, cb); } static void OBSEvent(enum obs_frontend_event event, void *) diff --git a/frontend/plugins/decklink-captions/decklink-captions.cpp b/frontend/plugins/decklink-captions/decklink-captions.cpp index f853c3518..f3d02cdb1 100644 --- a/frontend/plugins/decklink-captions/decklink-captions.cpp +++ b/frontend/plugins/decklink-captions/decklink-captions.cpp @@ -133,7 +133,7 @@ void addOutputUI(void) obs_frontend_add_save_callback(save_decklink_caption_data, nullptr); - action->connect(action, &QAction::triggered, cb); + QObject::connect(action, &QAction::triggered, action, cb); } bool obs_module_load(void) diff --git a/frontend/plugins/decklink-output-ui/decklink-ui-main.cpp b/frontend/plugins/decklink-output-ui/decklink-ui-main.cpp index 9c6bd23d8..325cfe1e8 100644 --- a/frontend/plugins/decklink-output-ui/decklink-ui-main.cpp +++ b/frontend/plugins/decklink-output-ui/decklink-ui-main.cpp @@ -427,7 +427,7 @@ void addOutputUI(void) doUI->ShowHideDialog(); }; - action->connect(action, &QAction::triggered, cb); + QObject::connect(action, &QAction::triggered, action, cb); } static void OBSEvent(enum obs_frontend_event event, void *) diff --git a/frontend/plugins/frontend-tools/auto-scene-switcher.cpp b/frontend/plugins/frontend-tools/auto-scene-switcher.cpp index f008a6884..5ba03433a 100644 --- a/frontend/plugins/frontend-tools/auto-scene-switcher.cpp +++ b/frontend/plugins/frontend-tools/auto-scene-switcher.cpp @@ -503,5 +503,5 @@ extern "C" void InitSceneSwitcher() obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr); obs_frontend_add_event_callback(OBSEvent, nullptr); - action->connect(action, &QAction::triggered, cb); + QObject::connect(action, &QAction::triggered, action, cb); } diff --git a/frontend/plugins/frontend-tools/output-timer.cpp b/frontend/plugins/frontend-tools/output-timer.cpp index 388f449b4..6c3f31004 100644 --- a/frontend/plugins/frontend-tools/output-timer.cpp +++ b/frontend/plugins/frontend-tools/output-timer.cpp @@ -315,5 +315,5 @@ extern "C" void InitOutputTimer() obs_frontend_add_save_callback(SaveOutputTimer, nullptr); obs_frontend_add_event_callback(OBSEvent, nullptr); - action->connect(action, &QAction::triggered, cb); + QObject::connect(action, &QAction::triggered, action, cb); } diff --git a/frontend/plugins/frontend-tools/scripts.cpp b/frontend/plugins/frontend-tools/scripts.cpp index 08e5bdd35..2e170f35a 100644 --- a/frontend/plugins/frontend-tools/scripts.cpp +++ b/frontend/plugins/frontend-tools/scripts.cpp @@ -677,5 +677,5 @@ extern "C" void InitScripts() obs_frontend_add_preload_callback(load_script_data, nullptr); obs_frontend_add_event_callback(obs_event, nullptr); - action->connect(action, &QAction::triggered, cb); + QObject::connect(action, &QAction::triggered, action, cb); } diff --git a/frontend/settings/OBSBasicSettings.cpp b/frontend/settings/OBSBasicSettings.cpp index f36c72b71..8eff83dce 100644 --- a/frontend/settings/OBSBasicSettings.cpp +++ b/frontend/settings/OBSBasicSettings.cpp @@ -2404,9 +2404,9 @@ void OBSBasicSettings::LoadAudioSources() TruncateLabel(label, label->text()); label->setMinimumSize(QSize(170, 0)); label->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); - connect(label, &OBSSourceLabel::Removed, + connect(label, &OBSSourceLabel::Removed, this, [=]() { QMetaObject::invokeMethod(this, "ReloadAudioSources"); }); - connect(label, &OBSSourceLabel::Destroyed, + connect(label, &OBSSourceLabel::Destroyed, this, [=]() { QMetaObject::invokeMethod(this, "ReloadAudioSources"); }); layout->addRow(label, form); @@ -2839,7 +2839,7 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) HotkeysChanged(); ScanDuplicateHotkeys(hotkeysLayout); }); - connect(hw, &OBSHotkeyWidget::SearchKey, [=](obs_key_combination_t combo) { + connect(hw, &OBSHotkeyWidget::SearchKey, this, [=](obs_key_combination_t combo) { ui->hotkeyFilterSearch->setText(""); ui->hotkeyFilterInput->HandleNewKey(combo); ui->hotkeyFilterInput->KeyChanged(combo); diff --git a/frontend/settings/OBSHotkeyEdit.cpp b/frontend/settings/OBSHotkeyEdit.cpp index 336f416c8..863dbb411 100644 --- a/frontend/settings/OBSHotkeyEdit.cpp +++ b/frontend/settings/OBSHotkeyEdit.cpp @@ -207,7 +207,7 @@ void OBSHotkeyEdit::CreateDupeIcon() { dupeIcon = addAction(settings->GetHotkeyConflictIcon(), ActionPosition::TrailingPosition); dupeIcon->setToolTip(QTStr("Basic.Settings.Hotkeys.DuplicateWarning")); - QObject::connect(dupeIcon, &QAction::triggered, [=] { emit SearchKey(key); }); + QObject::connect(dupeIcon, &QAction::triggered, this, [=] { emit SearchKey(key); }); dupeIcon->setVisible(false); } diff --git a/frontend/settings/OBSHotkeyWidget.cpp b/frontend/settings/OBSHotkeyWidget.cpp index b5a0b9670..8a6feb7f3 100644 --- a/frontend/settings/OBSHotkeyWidget.cpp +++ b/frontend/settings/OBSHotkeyWidget.cpp @@ -98,7 +98,7 @@ void OBSHotkeyWidget::AddEdit(obs_key_combination combo, int idx) clear->setToolTip(QTStr("Clear")); clear->setEnabled(!obs_key_combination_is_empty(combo)); - QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, [=](obs_key_combination_t new_combo) { + QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, this, [=](obs_key_combination_t new_combo) { clear->setEnabled(!obs_key_combination_is_empty(new_combo)); revert->setEnabled(edit->original != new_combo); }); @@ -117,10 +117,10 @@ void OBSHotkeyWidget::AddEdit(obs_key_combination combo, int idx) return std::distance(begin(removeButtons), res); }; - QObject::connect(add, &QPushButton::clicked, + QObject::connect(add, &QPushButton::clicked, this, [&, CurrentIndex] { AddEdit({0, OBS_KEY_NONE}, CurrentIndex() + 1); }); - QObject::connect(remove, &QPushButton::clicked, [&, CurrentIndex] { RemoveEdit(CurrentIndex()); }); + QObject::connect(remove, &QPushButton::clicked, this, [&, CurrentIndex] { RemoveEdit(CurrentIndex()); }); QHBoxLayout *subLayout = new QHBoxLayout; subLayout->setContentsMargins(0, 2, 0, 2); @@ -148,8 +148,9 @@ void OBSHotkeyWidget::AddEdit(obs_key_combination combo, int idx) QObject::connect(revert, &QPushButton::clicked, edit, &OBSHotkeyEdit::ResetKey); QObject::connect(clear, &QPushButton::clicked, edit, &OBSHotkeyEdit::ClearKey); - QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, [&](obs_key_combination) { emit KeyChanged(); }); - QObject::connect(edit, &OBSHotkeyEdit::SearchKey, [=](obs_key_combination combo) { emit SearchKey(combo); }); + QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, this, [&](obs_key_combination) { emit KeyChanged(); }); + QObject::connect(edit, &OBSHotkeyEdit::SearchKey, this, + [=](obs_key_combination combo) { emit SearchKey(combo); }); } void OBSHotkeyWidget::RemoveEdit(size_t idx, bool signal) diff --git a/frontend/utility/MissingFilesPathItemDelegate.cpp b/frontend/utility/MissingFilesPathItemDelegate.cpp index 298557628..d7601b8d1 100644 --- a/frontend/utility/MissingFilesPathItemDelegate.cpp +++ b/frontend/utility/MissingFilesPathItemDelegate.cpp @@ -61,7 +61,7 @@ QWidget *MissingFilesPathItemDelegate::createEditor(QWidget *parent, const QStyl browseButton->setSizePolicy(buttonSizePolicy); layout->addWidget(browseButton); - container->connect(browseButton, &QToolButton::clicked, browseCallback); + connect(browseButton, &QToolButton::clicked, this, browseCallback); QToolButton *clearButton = new QToolButton(); QIcon icon; @@ -71,7 +71,7 @@ QWidget *MissingFilesPathItemDelegate::createEditor(QWidget *parent, const QStyl clearButton->setSizePolicy(buttonSizePolicy); layout->addWidget(clearButton); - container->connect(clearButton, &QToolButton::clicked, clearCallback); + connect(clearButton, &QToolButton::clicked, this, clearCallback); container->setLayout(layout); container->setFocusProxy(text); diff --git a/frontend/utility/RemuxEntryPathItemDelegate.cpp b/frontend/utility/RemuxEntryPathItemDelegate.cpp index 0349d1fab..bcaa43f83 100644 --- a/frontend/utility/RemuxEntryPathItemDelegate.cpp +++ b/frontend/utility/RemuxEntryPathItemDelegate.cpp @@ -85,7 +85,7 @@ QWidget *RemuxEntryPathItemDelegate::createEditor(QWidget *parent, const QStyleO browseButton->setSizePolicy(buttonSizePolicy); layout->addWidget(browseButton); - container->connect(browseButton, &QToolButton::clicked, browseCallback); + connect(browseButton, &QToolButton::clicked, this, browseCallback); // The "clear" button is not shown in output cells // or the insertion point's input cell. @@ -95,7 +95,7 @@ QWidget *RemuxEntryPathItemDelegate::createEditor(QWidget *parent, const QStyleO clearButton->setSizePolicy(buttonSizePolicy); layout->addWidget(clearButton); - container->connect(clearButton, &QToolButton::clicked, clearCallback); + connect(clearButton, &QToolButton::clicked, this, clearCallback); } container->setLayout(layout); diff --git a/frontend/widgets/OBSBasic.cpp b/frontend/widgets/OBSBasic.cpp index 4e25e91e6..cad4f752e 100644 --- a/frontend/widgets/OBSBasic.cpp +++ b/frontend/widgets/OBSBasic.cpp @@ -389,8 +389,8 @@ OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new }; dpi = devicePixelRatioF(); - connect(windowHandle(), &QWindow::screenChanged, displayResize); - connect(ui->preview, &OBSQTDisplay::DisplayResized, displayResize); + connect(windowHandle(), &QWindow::screenChanged, this, displayResize); + connect(ui->preview, &OBSQTDisplay::DisplayResized, this, displayResize); /* TODO: Move these into window-basic-preview */ /* Preview Scaling label */ @@ -486,7 +486,8 @@ OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new nudge->setShortcut(seq); nudge->setShortcutContext(Qt::WidgetShortcut); ui->preview->addAction(nudge); - connect(nudge, &QAction::triggered, [this, distance, direction]() { Nudge(distance, direction); }); + connect(nudge, &QAction::triggered, this, + [this, distance, direction]() { Nudge(distance, direction); }); }; addNudge(Qt::Key_Up, MoveDir::Up, 1); @@ -555,7 +556,8 @@ OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new ui->previewDisabledWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->enablePreviewButton, &QPushButton::clicked, this, &OBSBasic::TogglePreview); - connect(ui->scenes, &SceneTree::scenesReordered, []() { OBSProjector::UpdateMultiviewProjectors(); }); + connect(ui->scenes, &SceneTree::scenesReordered, ui->scenes, + []() { OBSProjector::UpdateMultiviewProjectors(); }); connect(App(), &OBSApp::StyleChanged, this, [this]() { OnEvent(OBS_FRONTEND_EVENT_THEME_CHANGED); }); connect(App(), &OBSApp::aboutToQuit, this, &OBSBasic::closeWindow); @@ -1135,7 +1137,7 @@ void OBSBasic::OBSInit() ResizePreview(ovi.base_width, ovi.base_height); }; - connect(ui->preview, &OBSQTDisplay::DisplayCreated, addDisplay); + connect(ui->preview, &OBSQTDisplay::DisplayCreated, this, addDisplay); /* Show the main window, unless the tray icon isn't available * or neither the setting nor flag for starting minimized is set. */ diff --git a/frontend/widgets/OBSBasicStats.cpp b/frontend/widgets/OBSBasicStats.cpp index f1ae10a1e..c8d91e048 100644 --- a/frontend/widgets/OBSBasicStats.cpp +++ b/frontend/widgets/OBSBasicStats.cpp @@ -159,8 +159,8 @@ OBSBasicStats::OBSBasicStats(QWidget *parent, bool closable) /* --------------------------------------------- */ if (closable) - connect(closeButton, &QPushButton::clicked, [this]() { close(); }); - connect(resetButton, &QPushButton::clicked, [this]() { Reset(); }); + connect(closeButton, &QPushButton::clicked, this, [this]() { close(); }); + connect(resetButton, &QPushButton::clicked, this, [this]() { Reset(); }); delete shortcutFilter; shortcutFilter = CreateShortcutFilter(); diff --git a/frontend/widgets/OBSBasic_Docks.cpp b/frontend/widgets/OBSBasic_Docks.cpp index 670ed5a25..876a1e1f0 100644 --- a/frontend/widgets/OBSBasic_Docks.cpp +++ b/frontend/widgets/OBSBasic_Docks.cpp @@ -37,10 +37,10 @@ void setupDockAction(QDockWidget *dock) // Replace the slot connected by default QObject::disconnect(action, &QAction::triggered, nullptr, 0); - dock->connect(action, &QAction::triggered, newToggleView); + QObject::connect(action, &QAction::triggered, dock, newToggleView); // Make the action unable to be disabled - action->connect(action, &QAction::enabledChanged, neverDisable); + QObject::connect(action, &QAction::enabledChanged, action, neverDisable); } void OBSBasic::on_resetDocks_triggered(bool force) diff --git a/frontend/widgets/OBSBasic_Preview.cpp b/frontend/widgets/OBSBasic_Preview.cpp index 8af68d2cf..491d88fb6 100644 --- a/frontend/widgets/OBSBasic_Preview.cpp +++ b/frontend/widgets/OBSBasic_Preview.cpp @@ -350,7 +350,7 @@ void OBSBasic::Nudge(int dist, MoveDir dir) std::string undo_data(obs_data_get_json(wrapper)); nudge_timer = new QTimer; - QObject::connect(nudge_timer, &QTimer::timeout, [this, &recent_nudge = recent_nudge, undo_data]() { + QObject::connect(nudge_timer, &QTimer::timeout, this, [this, &recent_nudge = recent_nudge, undo_data]() { OBSDataAutoRelease rwrapper = obs_scene_save_transform_states(GetCurrentScene(), true); std::string redo_data(obs_data_get_json(rwrapper)); @@ -527,9 +527,9 @@ void OBSBasic::ColorChange() QColorDialog *colorDialog = new QColorDialog(this); colorDialog->setOptions(options); colorDialog->setCurrentColor(QColor(customColor)); - connect(colorDialog, &QColorDialog::currentColorChanged, liveChangeColor); - connect(colorDialog, &QColorDialog::colorSelected, changedColor); - connect(colorDialog, &QColorDialog::rejected, rejected); + connect(colorDialog, &QColorDialog::currentColorChanged, this, liveChangeColor); + connect(colorDialog, &QColorDialog::colorSelected, this, changedColor); + connect(colorDialog, &QColorDialog::rejected, this, rejected); colorDialog->open(); } else { for (int x = 0; x < selectedItems.count(); x++) { diff --git a/frontend/widgets/OBSBasic_SceneItems.cpp b/frontend/widgets/OBSBasic_SceneItems.cpp index ce60b71ec..e39e34feb 100644 --- a/frontend/widgets/OBSBasic_SceneItems.cpp +++ b/frontend/widgets/OBSBasic_SceneItems.cpp @@ -552,7 +552,7 @@ QMenu *OBSBasic::AddBackgroundColorMenu(QMenu *menu, QWidgetAction *widgetAction colorButton->setStyleSheet("border: 2px solid black"); colorButton->setProperty("bgColor", i); - select->connect(colorButton, &QPushButton::released, this, &OBSBasic::ColorChange); + connect(colorButton, &QPushButton::released, this, &OBSBasic::ColorChange); } menu->addAction(widgetAction); @@ -803,7 +803,7 @@ QMenu *OBSBasic::CreateAddSourcePopupMenu() auto addSource = [this, getActionAfter](QMenu *popup, const char *type, const char *name) { QString qname = QT_UTF8(name); QAction *popupItem = new QAction(qname, this); - connect(popupItem, &QAction::triggered, [this, type]() { AddSource(type); }); + connect(popupItem, &QAction::triggered, this, [this, type]() { AddSource(type); }); QIcon icon; @@ -839,7 +839,7 @@ QMenu *OBSBasic::CreateAddSourcePopupMenu() popup->addSeparator(); QAction *addGroup = new QAction(QTStr("Group"), this); addGroup->setIcon(GetGroupIcon()); - connect(addGroup, &QAction::triggered, [this]() { AddSource("group"); }); + connect(addGroup, &QAction::triggered, this, [this]() { AddSource("group"); }); popup->addAction(addGroup); if (!foundDeprecated) { diff --git a/frontend/widgets/OBSBasic_Scenes.cpp b/frontend/widgets/OBSBasic_Scenes.cpp index 1797112ff..30f15eadb 100644 --- a/frontend/widgets/OBSBasic_Scenes.cpp +++ b/frontend/widgets/OBSBasic_Scenes.cpp @@ -601,7 +601,7 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos) OBSProjector::UpdateMultiviewProjectors(); }; - connect(multiviewAction, &QAction::triggered, std::bind(showInMultiview, data.Get())); + connect(multiviewAction, &QAction::triggered, multiviewAction, std::bind(showInMultiview, data.Get())); copyFilters->setEnabled(obs_source_filter_count(source) > 0); } diff --git a/frontend/widgets/OBSBasic_StudioMode.cpp b/frontend/widgets/OBSBasic_StudioMode.cpp index d492f8f29..200c12a9f 100644 --- a/frontend/widgets/OBSBasic_StudioMode.cpp +++ b/frontend/widgets/OBSBasic_StudioMode.cpp @@ -42,7 +42,7 @@ void OBSBasic::CreateProgramDisplay() ResizeProgram(ovi.base_width, ovi.base_height); }; - connect(program.data(), &OBSQTDisplay::DisplayResized, displayResize); + connect(program.data(), &OBSQTDisplay::DisplayResized, this, displayResize); auto addDisplay = [this](OBSQTDisplay *window) { obs_display_add_draw_callback(window->GetDisplay(), OBSBasic::RenderProgram, this); @@ -52,7 +52,7 @@ void OBSBasic::CreateProgramDisplay() ResizeProgram(ovi.base_width, ovi.base_height); }; - connect(program.data(), &OBSQTDisplay::DisplayCreated, addDisplay); + connect(program.data(), &OBSQTDisplay::DisplayCreated, this, addDisplay); program->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } @@ -146,30 +146,30 @@ void OBSBasic::CreateProgramOptions() action->setToolTip(QTStr("QuickTransitions.DuplicateSceneTT")); action->setCheckable(true); action->setChecked(sceneDuplicationMode); - connect(action, &QAction::triggered, toggleSceneDuplication); - connect(action, &QAction::hovered, showToolTip); + connect(action, &QAction::triggered, this, toggleSceneDuplication); + connect(action, &QAction::hovered, action, showToolTip); action = menu.addAction(QTStr("QuickTransitions.EditProperties")); action->setToolTip(QTStr("QuickTransitions.EditPropertiesTT")); action->setCheckable(true); action->setChecked(editPropertiesMode); action->setEnabled(sceneDuplicationMode); - connect(action, &QAction::triggered, toggleEditProperties); - connect(action, &QAction::hovered, showToolTip); + connect(action, &QAction::triggered, this, toggleEditProperties); + connect(action, &QAction::hovered, action, showToolTip); action = menu.addAction(QTStr("QuickTransitions.SwapScenes")); action->setToolTip(QTStr("QuickTransitions.SwapScenesTT")); action->setCheckable(true); action->setChecked(swapScenesMode); - connect(action, &QAction::triggered, toggleSwapScenesMode); - connect(action, &QAction::hovered, showToolTip); + connect(action, &QAction::triggered, this, toggleSwapScenesMode); + connect(action, &QAction::hovered, action, showToolTip); menu.exec(QCursor::pos()); }; connect(transitionButton.data(), &QAbstractButton::clicked, this, &OBSBasic::TransitionClicked); - connect(addQuickTransition, &QAbstractButton::clicked, onAdd); - connect(configTransitions, &QAbstractButton::clicked, onConfig); + connect(addQuickTransition, &QAbstractButton::clicked, this, onAdd); + connect(configTransitions, &QAbstractButton::clicked, this, onConfig); } void OBSBasic::TogglePreviewProgramMode() diff --git a/frontend/widgets/OBSBasic_Transitions.cpp b/frontend/widgets/OBSBasic_Transitions.cpp index b76f43376..dedd01456 100644 --- a/frontend/widgets/OBSBasic_Transitions.cpp +++ b/frontend/widgets/OBSBasic_Transitions.cpp @@ -485,7 +485,7 @@ void OBSBasic::on_transitionAdd_clicked() const char *name = obs_source_get_display_name(id); QAction *action = new QAction(name, this); - connect(action, &QAction::triggered, [this, id]() { AddTransition(id); }); + connect(action, &QAction::triggered, this, [this, id]() { AddTransition(id); }); menu.addAction(action); foundConfigurableTransitions = true; @@ -593,11 +593,11 @@ void OBSBasic::on_transitionProps_clicked() QMenu menu(this); QAction *action = new QAction(QTStr("Rename"), &menu); - connect(action, &QAction::triggered, [this, source]() { RenameTransition(source); }); + connect(action, &QAction::triggered, this, [this, source]() { RenameTransition(source); }); menu.addAction(action); action = new QAction(QTStr("Properties"), &menu); - connect(action, &QAction::triggered, properties); + connect(action, &QAction::triggered, this, properties); menu.addAction(action); menu.exec(QCursor::pos()); @@ -821,7 +821,7 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() obs_data_set_int(data, "transition_duration", duration); }; - connect(duration, (void(QSpinBox::*)(int)) & QSpinBox::valueChanged, setDuration); + connect(duration, &QSpinBox::valueChanged, this, setDuration); auto addAction = [&](const std::string &uuid = "") { const char *name = ""; @@ -845,7 +845,7 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() action->setCheckable(true); action->setChecked(match); - connect(action, &QAction::triggered, std::bind(setTransition, action)); + connect(action, &QAction::triggered, this, std::bind(setTransition, action)); }; addAction(); @@ -987,13 +987,13 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible) OBSSceneItem item = main->GetCurrentSceneItem(); obs_sceneitem_set_transition_duration(item, visible, duration); }; - connect(duration, (void(QSpinBox::*)(int)) & QSpinBox::valueChanged, setDuration); + connect(duration, &QSpinBox::valueChanged, duration, setDuration); action = menu->addAction(QT_UTF8(Str("None"))); action->setProperty("transition_id", QT_UTF8("")); action->setCheckable(true); action->setChecked(!curId); - connect(action, &QAction::triggered, std::bind(setTransition, action, visible)); + connect(action, &QAction::triggered, this, std::bind(setTransition, action, visible)); size_t idx = 0; const char *id; while (obs_enum_transition_types(idx++, &id)) { @@ -1003,7 +1003,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible) action->setProperty("transition_id", QT_UTF8(id)); action->setCheckable(true); action->setChecked(match); - connect(action, &QAction::triggered, std::bind(setTransition, action, visible)); + connect(action, &QAction::triggered, this, std::bind(setTransition, action, visible)); } QWidgetAction *durationAction = new QWidgetAction(menu); @@ -1028,7 +1028,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible) menu->addSeparator(); action = menu->addAction(QT_UTF8(Str("Copy"))); action->setEnabled(curId != nullptr); - connect(action, &QAction::triggered, std::bind(copyTransition, action, visible)); + connect(action, &QAction::triggered, this, std::bind(copyTransition, action, visible)); auto pasteTransition = [this](QAction *, bool show) { OBSBasic *main = OBSBasic::Get(); @@ -1048,7 +1048,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible) action = menu->addAction(QT_UTF8(Str("Paste"))); action->setEnabled(!!OBSGetStrongRef(copySourceTransition)); - connect(action, &QAction::triggered, std::bind(pasteTransition, action, visible)); + connect(action, &QAction::triggered, this, std::bind(pasteTransition, action, visible)); return menu; } diff --git a/frontend/widgets/OBSProjector.cpp b/frontend/widgets/OBSProjector.cpp index cc214ea1c..16e7fc5e5 100644 --- a/frontend/widgets/OBSProjector.cpp +++ b/frontend/widgets/OBSProjector.cpp @@ -74,7 +74,7 @@ OBSProjector::OBSProjector(QWidget *widget, obs_source_t *source_, int monitor, obs_display_set_background_color(GetDisplay(), 0x000000); }; - connect(this, &OBSQTDisplay::DisplayCreated, addDrawCallback); + connect(this, &OBSQTDisplay::DisplayCreated, this, addDrawCallback); connect(App(), &QGuiApplication::screenRemoved, this, &OBSProjector::ScreenRemoved); if (type == ProjectorType::Multiview) { diff --git a/frontend/widgets/OBSQTDisplay.cpp b/frontend/widgets/OBSQTDisplay.cpp index 8342c908f..ea341bc2a 100644 --- a/frontend/widgets/OBSQTDisplay.cpp +++ b/frontend/widgets/OBSQTDisplay.cpp @@ -102,8 +102,8 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags) : QWidget(par obs_display_resize(display, size.width(), size.height()); }; - connect(windowHandle(), &QWindow::visibleChanged, windowVisible); - connect(windowHandle(), &QWindow::screenChanged, screenChanged); + connect(windowHandle(), &QWindow::visibleChanged, this, windowVisible); + connect(windowHandle(), &QWindow::screenChanged, this, screenChanged); windowHandle()->installEventFilter(new SurfaceEventFilter(this)); } diff --git a/frontend/wizards/AutoConfigStreamPage.cpp b/frontend/wizards/AutoConfigStreamPage.cpp index 3086185df..1e5c47536 100644 --- a/frontend/wizards/AutoConfigStreamPage.cpp +++ b/frontend/wizards/AutoConfigStreamPage.cpp @@ -67,7 +67,7 @@ AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent) : QWizardPage(parent connect(ui->service, &QComboBox::currentIndexChanged, this, &AutoConfigStreamPage::UpdateKeyLink); connect(ui->service, &QComboBox::currentIndexChanged, this, &AutoConfigStreamPage::UpdateMoreInfoLink); - connect(ui->useStreamKeyAdv, &QPushButton::clicked, [&]() { + connect(ui->useStreamKeyAdv, &QPushButton::clicked, this, [&]() { ui->streamKeyWidget->setVisible(true); ui->streamKeyLabel->setVisible(true); ui->useStreamKeyAdv->setVisible(false); diff --git a/shared/properties-view/double-slider.cpp b/shared/properties-view/double-slider.cpp index bd287e50b..8a1e91b80 100644 --- a/shared/properties-view/double-slider.cpp +++ b/shared/properties-view/double-slider.cpp @@ -4,7 +4,7 @@ DoubleSlider::DoubleSlider(QWidget *parent) : SliderIgnoreScroll(parent) { - connect(this, &DoubleSlider::valueChanged, + connect(this, &DoubleSlider::valueChanged, this, [this](int val) { emit doubleValChanged((minVal / minStep + val) * minStep); }); } diff --git a/shared/properties-view/properties-view.cpp b/shared/properties-view/properties-view.cpp index 60796a351..071e6dc65 100644 --- a/shared/properties-view/properties-view.cpp +++ b/shared/properties-view/properties-view.cpp @@ -333,7 +333,7 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, Q WidgetInfo *info = new WidgetInfo(this, prop, edit); connect(show, &QAbstractButton::toggled, info, &WidgetInfo::TogglePasswordText); - connect(show, &QAbstractButton::toggled, + connect(show, &QAbstractButton::toggled, show, [=](bool hide) { show->setText(hide ? tr("Hide") : tr("Show")); }); children.emplace_back(info); @@ -741,7 +741,7 @@ void OBSPropertiesView::AddEditableList(obs_property_t *prop, QFormLayout *layou WidgetInfo *info = new WidgetInfo(this, prop, list); list->setDragDropMode(QAbstractItemView::InternalMove); - connect(list->model(), &QAbstractItemModel::rowsMoved, [info]() { info->EditableListChanged(); }); + connect(list->model(), &QAbstractItemModel::rowsMoved, info, [info]() { info->EditableListChanged(); }); QVBoxLayout *sideLayout = new QVBoxLayout(); NewButton(sideLayout, info, "icon-plus", &WidgetInfo::EditListAdd); @@ -1408,14 +1408,14 @@ void OBSPropertiesView::AddFrameRate(obs_property_t *prop, bool &warning, QFormL emit info->ControlChanged(); }); - connect(widget->simpleFPS, comboIndexChanged, [=](int) { + connect(widget->simpleFPS, comboIndexChanged, info, [=](int) { if (widget->updating) return; emit info->ControlChanged(); }); - connect(widget->fpsRange, comboIndexChanged, [=](int) { + connect(widget->fpsRange, comboIndexChanged, info, [=](int) { if (widget->updating) return; @@ -1423,14 +1423,14 @@ void OBSPropertiesView::AddFrameRate(obs_property_t *prop, bool &warning, QFormL }); auto sbValueChanged = static_cast(&QSpinBox::valueChanged); - connect(widget->numEdit, sbValueChanged, [=](int) { + connect(widget->numEdit, sbValueChanged, info, [=](int) { if (widget->updating) return; emit info->ControlChanged(); }); - connect(widget->denEdit, sbValueChanged, [=](int) { + connect(widget->denEdit, sbValueChanged, info, [=](int) { if (widget->updating) return; @@ -2021,7 +2021,7 @@ void WidgetInfo::ControlChanged() if (!recently_updated) { recently_updated = true; update_timer = new QTimer; - connect(update_timer, &QTimer::timeout, [this, &ru = recently_updated]() { + connect(update_timer, &QTimer::timeout, this, [this, &ru = recently_updated]() { OBSObject strongObj = view->GetObject(); void *obj = strongObj ? strongObj.Get() : view->rawObj; if (obj && view->callback && !view->deferUpdate) { @@ -2030,7 +2030,7 @@ void WidgetInfo::ControlChanged() ru = false; }); - connect(update_timer, &QTimer::timeout, &QTimer::deleteLater); + connect(update_timer, &QTimer::timeout, update_timer, &QTimer::deleteLater); update_timer->setSingleShot(true); }