frontend: Replace add source dropdown with dialog

Co-Authored-By: Lain <134130700+Lain-B@users.noreply.github.com>
This commit is contained in:
Warchamp7
2026-05-07 15:31:10 -04:00
committed by Ryan Foster
co-authored by Lain
parent b1a15af06e
commit 12597e9484
32 changed files with 3361 additions and 634 deletions
File diff suppressed because it is too large Load Diff
+62 -22
View File
@@ -1,5 +1,6 @@
/******************************************************************************
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
Copyright (C) 2025 by Taylor Giampaolo <warchamp7@obsproject.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,40 +18,79 @@
#pragma once
#include <OBSApp.hpp>
#include "ui_OBSBasicSourceSelect.h"
#include <components/FlowLayout.hpp>
#include <components/SourceSelectButton.hpp>
#include <utility/undo_stack.hpp>
#include <widgets/OBSBasic.hpp>
#include <obs.hpp>
#include <QButtonGroup>
#include <QDialog>
class OBSBasicSourceSelect : public QDialog {
Q_OBJECT
private:
std::unique_ptr<Ui::OBSBasicSourceSelect> ui;
const char *id;
undo_stack &undo_s;
static bool EnumSources(void *data, obs_source_t *source);
static bool EnumGroups(void *data, obs_source_t *source);
static void OBSSourceRemoved(void *data, calldata_t *calldata);
static void OBSSourceAdded(void *data, calldata_t *calldata);
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void SourceAdded(OBSSource source);
void SourceRemoved(OBSSource source);
public:
OBSBasicSourceSelect(OBSBasic *parent, const char *id, undo_stack &undo_s);
OBSBasicSourceSelect(OBSBasic *parent, undo_stack &undo_s);
~OBSBasicSourceSelect();
OBSSource newSource;
static void SourcePaste(SourceCopyInfo &info, bool duplicate);
static void sourcePaste(SourceCopyInfo &info, bool duplicate);
protected:
void showEvent(QShowEvent *event) override;
private:
std::unique_ptr<Ui::OBSBasicSourceSelect> ui;
QString selectedTypeId;
undo_stack &undo_s;
QPointer<QButtonGroup> sourceButtons;
std::vector<OBSSignal> signalHandlers;
static void obsSourceCreated(void *param, calldata_t *calldata);
static void obsSourceRemoved(void *param, calldata_t *calldata);
std::vector<OBSWeakSource> weakSources;
QPointer<FlowLayout> existingFlowLayout = nullptr;
void refreshSources();
void updateExistingSources(int limit = 0);
static bool enumSourcesCallback(void *data, obs_source_t *source);
void rebuildSourceTypeList();
int lastSelectedIndex = -1;
std::vector<std::string> selectedItems;
void addSelectedItem(const std::string &uuid);
void removeSelectedItem(const std::string &uuid);
void clearSelectedItems();
SourceSelectButton *findButtonForUuid(const std::string &uuid);
void createNew();
void addExisting(const std::string &uuid, bool visible);
void updateButtonVisibility();
signals:
void sourcesUpdated();
void selectedItemsChanged();
public slots:
void on_createNewSource_clicked(bool checked);
void addSelectedSources();
void handleSourceCreated();
void handleSourceRemoved(QString uuid);
void sourceTypeSelected(QListWidgetItem *current, QListWidgetItem *previous);
void sourceButtonToggled(QAbstractButton *button, bool checked);
void sourceDropped(QString uuid);
};