mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-19 13:56:06 -04:00
frontend: Move transition preview button to button box
This commit is contained in:
@@ -76,7 +76,11 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||
ui->propertiesLayout->addWidget(view);
|
||||
|
||||
if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
||||
connect(view, &OBSPropertiesView::PropertiesRefreshed, this, &OBSBasicProperties::AddPreviewButton);
|
||||
ui->transitionButton->setVisible(true);
|
||||
connect(ui->transitionButton, &QPushButton::clicked, this,
|
||||
&OBSBasicProperties::previewTransitionClicked);
|
||||
} else {
|
||||
ui->transitionButton->setVisible(false);
|
||||
}
|
||||
|
||||
view->show();
|
||||
@@ -147,6 +151,8 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||
} else {
|
||||
ui->preview->hide();
|
||||
}
|
||||
|
||||
connect(ui->defaultsButton, &QPushButton::clicked, this, &OBSBasicProperties::restoreDefaultsClicked);
|
||||
}
|
||||
|
||||
OBSBasicProperties::~OBSBasicProperties()
|
||||
@@ -159,37 +165,6 @@ OBSBasicProperties::~OBSBasicProperties()
|
||||
main->UpdateContextBarDeferred(true);
|
||||
}
|
||||
|
||||
void OBSBasicProperties::AddPreviewButton()
|
||||
{
|
||||
QPushButton *playButton = new QPushButton(QTStr("PreviewTransition"), this);
|
||||
VScrollArea *area = view;
|
||||
area->widget()->layout()->addWidget(playButton);
|
||||
|
||||
playButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
auto play = [this]() {
|
||||
OBSSource start;
|
||||
OBSSource end;
|
||||
|
||||
if (direction) {
|
||||
start = sourceA;
|
||||
end = sourceB;
|
||||
} else {
|
||||
start = sourceB;
|
||||
end = sourceA;
|
||||
}
|
||||
|
||||
obs_transition_set(sourceClone, start);
|
||||
obs_transition_start(sourceClone, OBS_TRANSITION_MODE_AUTO, main->GetTransitionDuration(), end);
|
||||
direction = !direction;
|
||||
|
||||
start = nullptr;
|
||||
end = nullptr;
|
||||
};
|
||||
|
||||
connect(playButton, &QPushButton::clicked, this, play);
|
||||
}
|
||||
|
||||
static obs_source_t *CreateLabel(const char *name, size_t h)
|
||||
{
|
||||
OBSDataAutoRelease settings = obs_data_create();
|
||||
@@ -251,6 +226,53 @@ static void CreateTransitionScene(OBSSource scene, const char *text, uint32_t co
|
||||
obs_sceneitem_set_bounds_type(item, OBS_BOUNDS_SCALE_INNER);
|
||||
}
|
||||
|
||||
static bool ConfirmReset(QWidget *parent)
|
||||
{
|
||||
QMessageBox::StandardButton button;
|
||||
|
||||
button = OBSMessageBox::question(parent, QTStr("ConfirmReset.Title"), QTStr("ConfirmReset.Text"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
return button == QMessageBox::Yes;
|
||||
}
|
||||
|
||||
void OBSBasicProperties::restoreDefaultsClicked()
|
||||
{
|
||||
if (!ConfirmReset(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
OBSDataAutoRelease settings = obs_source_get_settings(source);
|
||||
obs_data_clear(settings);
|
||||
|
||||
if (!view->DeferUpdate()) {
|
||||
obs_source_update(source, nullptr);
|
||||
}
|
||||
|
||||
view->ReloadProperties();
|
||||
}
|
||||
|
||||
void OBSBasicProperties::previewTransitionClicked()
|
||||
{
|
||||
OBSSource start;
|
||||
OBSSource end;
|
||||
|
||||
if (direction) {
|
||||
start = sourceA;
|
||||
end = sourceB;
|
||||
} else {
|
||||
start = sourceB;
|
||||
end = sourceA;
|
||||
}
|
||||
|
||||
obs_transition_set(sourceClone, start);
|
||||
obs_transition_start(sourceClone, OBS_TRANSITION_MODE_AUTO, main->GetTransitionDuration(), end);
|
||||
direction = !direction;
|
||||
|
||||
start = nullptr;
|
||||
end = nullptr;
|
||||
}
|
||||
|
||||
void OBSBasicProperties::SourceRemoved(void *data, calldata_t *)
|
||||
{
|
||||
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data), "close");
|
||||
@@ -269,16 +291,6 @@ void OBSBasicProperties::UpdateProperties(void *data, calldata_t *)
|
||||
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data)->view, "ReloadProperties");
|
||||
}
|
||||
|
||||
static bool ConfirmReset(QWidget *parent)
|
||||
{
|
||||
QMessageBox::StandardButton button;
|
||||
|
||||
button = OBSMessageBox::question(parent, QTStr("ConfirmReset.Title"), QTStr("ConfirmReset.Text"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
return button == QMessageBox::Yes;
|
||||
}
|
||||
|
||||
void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
QDialogButtonBox::ButtonRole val = ui->buttonBox->buttonRole(button);
|
||||
@@ -329,18 +341,6 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
|
||||
obs_source_update(source, oldSettings);
|
||||
|
||||
close();
|
||||
|
||||
} else if (val == QDialogButtonBox::ResetRole) {
|
||||
if (!ConfirmReset(this))
|
||||
return;
|
||||
|
||||
OBSDataAutoRelease settings = obs_source_get_settings(source);
|
||||
obs_data_clear(settings);
|
||||
|
||||
if (!view->DeferUpdate())
|
||||
obs_source_update(source, nullptr);
|
||||
|
||||
view->ReloadProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ private:
|
||||
OBSSignal updatePropertiesSignal;
|
||||
OBSData oldSettings;
|
||||
OBSPropertiesView *view;
|
||||
QDialogButtonBox *buttonBox;
|
||||
QSplitter *windowSplitter;
|
||||
|
||||
OBSSourceAutoRelease sourceA;
|
||||
@@ -59,7 +58,8 @@ private:
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
void AddPreviewButton();
|
||||
void restoreDefaultsClicked();
|
||||
void previewTransitionClicked();
|
||||
|
||||
public:
|
||||
OBSBasicProperties(QWidget *parent, OBSSource source_);
|
||||
|
||||
@@ -108,11 +108,58 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignBottom">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="defaultsButton">
|
||||
<property name="text">
|
||||
<string>RestoreDefaults</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="transitionButton">
|
||||
<property name="text">
|
||||
<string>PreviewTransition</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user