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"
|
||||
Back="Back"
|
||||
Defaults="Defaults"
|
||||
RestoreDefaults="Defaults"
|
||||
HideMixer="Hide in Mixer"
|
||||
TransitionOverride="Transition Override"
|
||||
ShowTransition="Show Transition"
|
||||
|
|
|
@ -578,7 +578,7 @@
|
|||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
</widget>
|
||||
</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()));
|
||||
close->setDefault(true);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Reset)
|
||||
->setText(QTStr("Defaults"));
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset),
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults),
|
||||
SIGNAL(clicked()), this, SLOT(ResetFilters()));
|
||||
|
||||
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_)
|
||||
: QDialog(parent),
|
||||
preview(new OBSQTDisplay(this)),
|
||||
ui(new Ui::OBSBasicProperties),
|
||||
main(qobject_cast<OBSBasic *>(parent)),
|
||||
acceptClicked(false),
|
||||
source(source_),
|
||||
|
@ -51,8 +51,7 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
|||
OBSBasicProperties::SourceRemoved, this),
|
||||
renamedSignal(obs_source_get_signal_handler(source), "rename",
|
||||
OBSBasicProperties::SourceRenamed, this),
|
||||
oldSettings(obs_data_create()),
|
||||
buttonBox(new QDialogButtonBox(this))
|
||||
oldSettings(obs_data_create())
|
||||
{
|
||||
int cx = (int)config_get_int(App()->GlobalConfig(), "PropertiesWindow",
|
||||
"cx");
|
||||
|
@ -61,24 +60,12 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
|||
|
||||
enum obs_source_type type = obs_source_get_type(source);
|
||||
|
||||
buttonBox->setObjectName(QStringLiteral("buttonBox"));
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Ok |
|
||||
QDialogButtonBox::Cancel |
|
||||
QDialogButtonBox::RestoreDefaults);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setText(QTStr("OK"));
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setText(QTStr("Cancel"));
|
||||
buttonBox->button(QDialogButtonBox::RestoreDefaults)
|
||||
->setText(QTStr("Defaults"));
|
||||
ui->setupUi(this);
|
||||
|
||||
if (cx > 400 && cy > 400)
|
||||
resize(cx, cy);
|
||||
else
|
||||
resize(720, 580);
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
/* The OBSData constructor increments the reference once */
|
||||
obs_data_release(oldSettings);
|
||||
|
@ -93,30 +80,13 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
|||
(PropertiesVisualUpdateCb)obs_source_update);
|
||||
view->setMinimumHeight(150);
|
||||
|
||||
preview->setMinimumSize(20, 150);
|
||||
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);
|
||||
ui->propertiesLayout->addWidget(view);
|
||||
|
||||
if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
||||
connect(view, SIGNAL(PropertiesRefreshed()), this,
|
||||
SLOT(AddPreviewButton()));
|
||||
}
|
||||
|
||||
layout()->addWidget(buttonBox);
|
||||
layout()->setAlignment(buttonBox, Qt::AlignBottom);
|
||||
|
||||
view->show();
|
||||
installEventFilter(CreateShortcutFilter());
|
||||
|
||||
|
@ -131,13 +101,13 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
|||
this);
|
||||
|
||||
auto addDrawCallback = [this]() {
|
||||
obs_display_add_draw_callback(preview->GetDisplay(),
|
||||
obs_display_add_draw_callback(ui->preview->GetDisplay(),
|
||||
OBSBasicProperties::DrawPreview,
|
||||
this);
|
||||
};
|
||||
auto addTransitionDrawCallback = [this]() {
|
||||
obs_display_add_draw_callback(
|
||||
preview->GetDisplay(),
|
||||
ui->preview->GetDisplay(),
|
||||
OBSBasicProperties::DrawTransitionPreview, this);
|
||||
};
|
||||
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;
|
||||
|
||||
if (drawable_preview && drawable_type) {
|
||||
preview->show();
|
||||
connect(preview.data(), &OBSQTDisplay::DisplayCreated,
|
||||
ui->preview->show();
|
||||
connect(ui->preview, &OBSQTDisplay::DisplayCreated,
|
||||
addDrawCallback);
|
||||
|
||||
} else if (type == OBS_SOURCE_TYPE_TRANSITION) {
|
||||
|
@ -190,12 +160,12 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
|||
|
||||
connect(view, &OBSPropertiesView::Changed, updateCallback);
|
||||
|
||||
preview->show();
|
||||
connect(preview.data(), &OBSQTDisplay::DisplayCreated,
|
||||
ui->preview->show();
|
||||
connect(ui->preview, &OBSQTDisplay::DisplayCreated,
|
||||
addTransitionDrawCallback);
|
||||
|
||||
} else {
|
||||
preview->hide();
|
||||
ui->preview->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,7 +303,7 @@ void OBSBasicProperties::UpdateProperties(void *data, calldata_t *)
|
|||
|
||||
void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
QDialogButtonBox::ButtonRole val = buttonBox->buttonRole(button);
|
||||
QDialogButtonBox::ButtonRole val = ui->buttonBox->buttonRole(button);
|
||||
|
||||
if (val == QDialogButtonBox::AcceptRole) {
|
||||
|
||||
|
@ -472,10 +442,10 @@ void OBSBasicProperties::Cleanup()
|
|||
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy",
|
||||
height());
|
||||
|
||||
obs_display_remove_draw_callback(preview->GetDisplay(),
|
||||
obs_display_remove_draw_callback(ui->preview->GetDisplay(),
|
||||
OBSBasicProperties::DrawPreview, this);
|
||||
obs_display_remove_draw_callback(
|
||||
preview->GetDisplay(),
|
||||
ui->preview->GetDisplay(),
|
||||
OBSBasicProperties::DrawTransitionPreview, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,13 +27,15 @@
|
|||
class OBSPropertiesView;
|
||||
class OBSBasic;
|
||||
|
||||
#include "ui_OBSBasicProperties.h"
|
||||
|
||||
class OBSBasicProperties : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QPointer<OBSQTDisplay> preview;
|
||||
|
||||
OBSBasic *main;
|
||||
|
||||
std::unique_ptr<Ui::OBSBasicProperties> ui;
|
||||
bool acceptClicked;
|
||||
|
||||
OBSSource source;
|
||||
|
|
Loading…
Reference in New Issue