UI: Create Properties window XML file, migrate code
window-basic-properties was written in the earliest days of OBS. To make it easier to navigate & adjust, this moves all the structural code into a new .ui file and out of the C++ code. This also modifies the ButtonBox in Filters to use matching buttons.master
parent
af67ef8e57
commit
dbb063eae6
|
@ -78,6 +78,7 @@ RemuxRecordings="Remux Recordings"
|
||||||
Next="Next"
|
Next="Next"
|
||||||
Back="Back"
|
Back="Back"
|
||||||
Defaults="Defaults"
|
Defaults="Defaults"
|
||||||
|
RestoreDefaults="Defaults"
|
||||||
HideMixer="Hide in Mixer"
|
HideMixer="Hide in Mixer"
|
||||||
TransitionOverride="Transition Override"
|
TransitionOverride="Transition Override"
|
||||||
ShowTransition="Show Transition"
|
ShowTransition="Show Transition"
|
||||||
|
|
|
@ -578,7 +578,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
|
<set>QDialogButtonBox::Close|QDialogButtonBox::RestoreDefaults</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>OBSBasicProperties</class>
|
||||||
|
<widget class="QDialog" name="OBSBasicProperties">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>720</width>
|
||||||
|
<height>580</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Properties</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="windowSplitter">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>400</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="childrenCollapsible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QFrame" name="previewFrame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>3</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</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="OBSQTDisplay" name="preview" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>150</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" name="propertiesFrame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="propertiesLayout">
|
||||||
|
<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>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignBottom">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>OBSQTDisplay</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>qt-display.hpp</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources>
|
||||||
|
<include location="obs.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -105,10 +105,7 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_)
|
||||||
connect(close, SIGNAL(clicked()), this, SLOT(close()));
|
connect(close, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
close->setDefault(true);
|
close->setDefault(true);
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Reset)
|
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults),
|
||||||
->setText(QTStr("Defaults"));
|
|
||||||
|
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset),
|
|
||||||
SIGNAL(clicked()), this, SLOT(ResetFilters()));
|
SIGNAL(clicked()), this, SLOT(ResetFilters()));
|
||||||
|
|
||||||
uint32_t caps = obs_source_get_output_flags(source);
|
uint32_t caps = obs_source_get_output_flags(source);
|
||||||
|
|
|
@ -43,7 +43,7 @@ static void CreateTransitionScene(OBSSource scene, const char *text,
|
||||||
|
|
||||||
OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
preview(new OBSQTDisplay(this)),
|
ui(new Ui::OBSBasicProperties),
|
||||||
main(qobject_cast<OBSBasic *>(parent)),
|
main(qobject_cast<OBSBasic *>(parent)),
|
||||||
acceptClicked(false),
|
acceptClicked(false),
|
||||||
source(source_),
|
source(source_),
|
||||||
|
@ -51,8 +51,7 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
OBSBasicProperties::SourceRemoved, this),
|
OBSBasicProperties::SourceRemoved, this),
|
||||||
renamedSignal(obs_source_get_signal_handler(source), "rename",
|
renamedSignal(obs_source_get_signal_handler(source), "rename",
|
||||||
OBSBasicProperties::SourceRenamed, this),
|
OBSBasicProperties::SourceRenamed, this),
|
||||||
oldSettings(obs_data_create()),
|
oldSettings(obs_data_create())
|
||||||
buttonBox(new QDialogButtonBox(this))
|
|
||||||
{
|
{
|
||||||
int cx = (int)config_get_int(App()->GlobalConfig(), "PropertiesWindow",
|
int cx = (int)config_get_int(App()->GlobalConfig(), "PropertiesWindow",
|
||||||
"cx");
|
"cx");
|
||||||
|
@ -61,24 +60,12 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
|
|
||||||
enum obs_source_type type = obs_source_get_type(source);
|
enum obs_source_type type = obs_source_get_type(source);
|
||||||
|
|
||||||
buttonBox->setObjectName(QStringLiteral("buttonBox"));
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
buttonBox->setStandardButtons(QDialogButtonBox::Ok |
|
|
||||||
QDialogButtonBox::Cancel |
|
|
||||||
QDialogButtonBox::RestoreDefaults);
|
|
||||||
|
|
||||||
buttonBox->button(QDialogButtonBox::Ok)->setText(QTStr("OK"));
|
ui->setupUi(this);
|
||||||
buttonBox->button(QDialogButtonBox::Cancel)->setText(QTStr("Cancel"));
|
|
||||||
buttonBox->button(QDialogButtonBox::RestoreDefaults)
|
|
||||||
->setText(QTStr("Defaults"));
|
|
||||||
|
|
||||||
if (cx > 400 && cy > 400)
|
if (cx > 400 && cy > 400)
|
||||||
resize(cx, cy);
|
resize(cx, cy);
|
||||||
else
|
|
||||||
resize(720, 580);
|
|
||||||
|
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
||||||
|
|
||||||
QMetaObject::connectSlotsByName(this);
|
|
||||||
|
|
||||||
/* The OBSData constructor increments the reference once */
|
/* The OBSData constructor increments the reference once */
|
||||||
obs_data_release(oldSettings);
|
obs_data_release(oldSettings);
|
||||||
|
@ -93,30 +80,13 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
(PropertiesVisualUpdateCb)obs_source_update);
|
(PropertiesVisualUpdateCb)obs_source_update);
|
||||||
view->setMinimumHeight(150);
|
view->setMinimumHeight(150);
|
||||||
|
|
||||||
preview->setMinimumSize(20, 150);
|
ui->propertiesLayout->addWidget(view);
|
||||||
preview->setSizePolicy(
|
|
||||||
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
|
||||||
|
|
||||||
// Create a QSplitter to keep a unified workflow here.
|
|
||||||
windowSplitter = new QSplitter(Qt::Orientation::Vertical, this);
|
|
||||||
windowSplitter->addWidget(preview);
|
|
||||||
windowSplitter->addWidget(view);
|
|
||||||
windowSplitter->setChildrenCollapsible(false);
|
|
||||||
//windowSplitter->setSizes(QList<int>({ 16777216, 150 }));
|
|
||||||
windowSplitter->setStretchFactor(0, 3);
|
|
||||||
windowSplitter->setStretchFactor(1, 1);
|
|
||||||
|
|
||||||
setLayout(new QVBoxLayout(this));
|
|
||||||
layout()->addWidget(windowSplitter);
|
|
||||||
|
|
||||||
if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
||||||
connect(view, SIGNAL(PropertiesRefreshed()), this,
|
connect(view, SIGNAL(PropertiesRefreshed()), this,
|
||||||
SLOT(AddPreviewButton()));
|
SLOT(AddPreviewButton()));
|
||||||
}
|
}
|
||||||
|
|
||||||
layout()->addWidget(buttonBox);
|
|
||||||
layout()->setAlignment(buttonBox, Qt::AlignBottom);
|
|
||||||
|
|
||||||
view->show();
|
view->show();
|
||||||
installEventFilter(CreateShortcutFilter());
|
installEventFilter(CreateShortcutFilter());
|
||||||
|
|
||||||
|
@ -131,13 +101,13 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
this);
|
this);
|
||||||
|
|
||||||
auto addDrawCallback = [this]() {
|
auto addDrawCallback = [this]() {
|
||||||
obs_display_add_draw_callback(preview->GetDisplay(),
|
obs_display_add_draw_callback(ui->preview->GetDisplay(),
|
||||||
OBSBasicProperties::DrawPreview,
|
OBSBasicProperties::DrawPreview,
|
||||||
this);
|
this);
|
||||||
};
|
};
|
||||||
auto addTransitionDrawCallback = [this]() {
|
auto addTransitionDrawCallback = [this]() {
|
||||||
obs_display_add_draw_callback(
|
obs_display_add_draw_callback(
|
||||||
preview->GetDisplay(),
|
ui->preview->GetDisplay(),
|
||||||
OBSBasicProperties::DrawTransitionPreview, this);
|
OBSBasicProperties::DrawTransitionPreview, this);
|
||||||
};
|
};
|
||||||
uint32_t caps = obs_source_get_output_flags(source);
|
uint32_t caps = obs_source_get_output_flags(source);
|
||||||
|
@ -146,8 +116,8 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
bool drawable_preview = (caps & OBS_SOURCE_VIDEO) != 0;
|
bool drawable_preview = (caps & OBS_SOURCE_VIDEO) != 0;
|
||||||
|
|
||||||
if (drawable_preview && drawable_type) {
|
if (drawable_preview && drawable_type) {
|
||||||
preview->show();
|
ui->preview->show();
|
||||||
connect(preview.data(), &OBSQTDisplay::DisplayCreated,
|
connect(ui->preview, &OBSQTDisplay::DisplayCreated,
|
||||||
addDrawCallback);
|
addDrawCallback);
|
||||||
|
|
||||||
} else if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
} else if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
||||||
|
@ -190,12 +160,12 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||||
|
|
||||||
connect(view, &OBSPropertiesView::Changed, updateCallback);
|
connect(view, &OBSPropertiesView::Changed, updateCallback);
|
||||||
|
|
||||||
preview->show();
|
ui->preview->show();
|
||||||
connect(preview.data(), &OBSQTDisplay::DisplayCreated,
|
connect(ui->preview, &OBSQTDisplay::DisplayCreated,
|
||||||
addTransitionDrawCallback);
|
addTransitionDrawCallback);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
preview->hide();
|
ui->preview->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +303,7 @@ void OBSBasicProperties::UpdateProperties(void *data, calldata_t *)
|
||||||
|
|
||||||
void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
|
void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
QDialogButtonBox::ButtonRole val = buttonBox->buttonRole(button);
|
QDialogButtonBox::ButtonRole val = ui->buttonBox->buttonRole(button);
|
||||||
|
|
||||||
if (val == QDialogButtonBox::AcceptRole) {
|
if (val == QDialogButtonBox::AcceptRole) {
|
||||||
|
|
||||||
|
@ -472,10 +442,10 @@ void OBSBasicProperties::Cleanup()
|
||||||
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy",
|
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy",
|
||||||
height());
|
height());
|
||||||
|
|
||||||
obs_display_remove_draw_callback(preview->GetDisplay(),
|
obs_display_remove_draw_callback(ui->preview->GetDisplay(),
|
||||||
OBSBasicProperties::DrawPreview, this);
|
OBSBasicProperties::DrawPreview, this);
|
||||||
obs_display_remove_draw_callback(
|
obs_display_remove_draw_callback(
|
||||||
preview->GetDisplay(),
|
ui->preview->GetDisplay(),
|
||||||
OBSBasicProperties::DrawTransitionPreview, this);
|
OBSBasicProperties::DrawTransitionPreview, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,15 @@
|
||||||
class OBSPropertiesView;
|
class OBSPropertiesView;
|
||||||
class OBSBasic;
|
class OBSBasic;
|
||||||
|
|
||||||
|
#include "ui_OBSBasicProperties.h"
|
||||||
|
|
||||||
class OBSBasicProperties : public QDialog {
|
class OBSBasicProperties : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<OBSQTDisplay> preview;
|
|
||||||
|
|
||||||
OBSBasic *main;
|
OBSBasic *main;
|
||||||
|
|
||||||
|
std::unique_ptr<Ui::OBSBasicProperties> ui;
|
||||||
bool acceptClicked;
|
bool acceptClicked;
|
||||||
|
|
||||||
OBSSource source;
|
OBSSource source;
|
||||||
|
|
Loading…
Reference in New Issue