mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 22:40:18 +00:00
GUI: codec options tab
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <QMetaType>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include <functional>
|
||||
#include "settings_ui.hpp"
|
||||
#include "video_opts.hpp"
|
||||
@@ -176,4 +180,101 @@ void SettingsUi::initSettingsWin(Ui::Settings *ui){
|
||||
addControl(new CheckboxUi(ui->decodeAccelCheck, settings, "decode.hwaccel"));
|
||||
addControl(new CheckboxUi(ui->errorsFatalBox, settings, "errors_fatal"));
|
||||
addControl(new LineEditUi(ui->encryptionLineEdit, settings, "encryption"));
|
||||
|
||||
buildSettingsCodecList();
|
||||
connect(settingsWin->codecList, &QListWidget::currentItemChanged,
|
||||
this, &SettingsUi::settingsCodecSelected);
|
||||
}
|
||||
|
||||
void SettingsUi::buildSettingsCodecList(){
|
||||
QListWidget *list = settingsWin->codecList;
|
||||
list->clear();
|
||||
|
||||
auto codecs = getVideoCompress(availableSettings);
|
||||
|
||||
for(const auto& codec : codecs){
|
||||
QListWidgetItem *item = new QListWidgetItem(list);
|
||||
item->setText(QString::fromStdString(codec.name));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(codec));
|
||||
|
||||
list->addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsUi::settingsCodecSelected(QListWidgetItem *curr, QListWidgetItem *){
|
||||
const SettingItem &settingItem = curr->data(Qt::UserRole).value<SettingItem>();
|
||||
|
||||
auto modIt = std::find_if(settingItem.opts.begin(), settingItem.opts.end(),
|
||||
[](const SettingValue& si){ return si.opt == "video.compress"; });
|
||||
|
||||
if(modIt == settingItem.opts.end())
|
||||
return;
|
||||
|
||||
const std::string& modName = modIt->val;
|
||||
|
||||
auto codecIt = std::find_if(settingItem.opts.begin(), settingItem.opts.end(),
|
||||
[modName](const SettingValue& si){
|
||||
return si.opt == "video.compress." + modName + ".codec"; });
|
||||
|
||||
if(codecIt == settingItem.opts.end())
|
||||
return;
|
||||
|
||||
buildCodecOptControls(modName, codecIt->val);
|
||||
}
|
||||
|
||||
void SettingsUi::buildCodecOptControls(const std::string& mod, const std::string& codec){
|
||||
codecControls.clear();
|
||||
|
||||
QWidget *container = new QWidget();
|
||||
QFormLayout *formLayout = new QFormLayout(container);
|
||||
|
||||
QComboBox *encoderCombo = new QComboBox();
|
||||
formLayout->addRow("Encoder", encoderCombo);
|
||||
|
||||
WidgetUi *encoderComboUi = new ComboBoxUi(encoderCombo,
|
||||
settings,
|
||||
"video.compress." + mod + ".codec." + codec + ".encoder",
|
||||
std::bind(getCodecEncoders, availableSettings, mod, codec));
|
||||
|
||||
codecControls.emplace_back(encoderComboUi);
|
||||
connect(encoderComboUi, &WidgetUi::changed, this, &SettingsUi::changed);
|
||||
|
||||
for(const auto& compMod : availableSettings->getVideoCompressModules()){
|
||||
if(compMod.name == mod){
|
||||
for(const auto& modOpt : compMod.opts){
|
||||
QLabel *label = new QLabel(QString::fromStdString(modOpt.displayName));
|
||||
QWidget *field = nullptr;
|
||||
WidgetUi *widgetUi = nullptr;
|
||||
std::string optKey = "video.compress." + mod + "." + modOpt.key;
|
||||
if(modOpt.booleanOpt){
|
||||
QCheckBox *checkBox = new QCheckBox();
|
||||
field = checkBox;
|
||||
|
||||
widgetUi = new CheckboxUi(checkBox,
|
||||
settings,
|
||||
optKey);
|
||||
} else {
|
||||
QLineEdit *lineEdit = new QLineEdit();
|
||||
field = lineEdit;
|
||||
|
||||
widgetUi = new LineEditUi(lineEdit,
|
||||
settings,
|
||||
optKey);
|
||||
}
|
||||
label->setToolTip(QString::fromStdString(modOpt.displayDesc));
|
||||
field->setToolTip(QString::fromStdString(modOpt.displayDesc));
|
||||
|
||||
formLayout->addRow(label, field);
|
||||
|
||||
codecControls.emplace_back(widgetUi);
|
||||
connect(widgetUi, &WidgetUi::changed, this, &SettingsUi::changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
container->setLayout(formLayout);
|
||||
|
||||
delete settingsWin->scrollContents;
|
||||
settingsWin->scrollContents = container;
|
||||
settingsWin->codecOptScroll->setWidget(container);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
AvailableSettings *availableSettings = nullptr;
|
||||
|
||||
std::vector<std::unique_ptr<WidgetUi>> uiControls;
|
||||
std::vector<std::unique_ptr<WidgetUi>> codecControls;
|
||||
|
||||
static void refreshAllCallback(Option&, bool, void *);
|
||||
|
||||
@@ -47,6 +48,11 @@ private slots:
|
||||
|
||||
void test();
|
||||
|
||||
void buildSettingsCodecList();
|
||||
void settingsCodecSelected(QListWidgetItem *curr, QListWidgetItem *prev);
|
||||
void buildCodecOptControls(const std::string& mod, const std::string& codec);
|
||||
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
};
|
||||
|
||||
@@ -105,6 +105,32 @@ std::vector<SettingItem> getVideoDisplay(AvailableSettings *availSettings){
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<SettingItem> getCodecEncoders(AvailableSettings *availSettings,
|
||||
const std::string& mod, const std::string& codec)
|
||||
{
|
||||
std::vector<SettingItem> res;
|
||||
|
||||
for(const auto& compMod : availSettings->getVideoCompressModules()){
|
||||
if(compMod.name != mod)
|
||||
continue;
|
||||
|
||||
for(const auto& modCodec : compMod.codecs){
|
||||
if(modCodec.name != codec)
|
||||
continue;
|
||||
|
||||
for(const auto& encoder: modCodec.encoders){
|
||||
SettingItem item;
|
||||
item.name = encoder.name;
|
||||
item.opts.push_back({"video.compress." + mod + ".codec." + codec + ".encoder", encoder.optStr});
|
||||
|
||||
res.emplace_back(std::move(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct VideoCompressItem{
|
||||
const char * displayName;
|
||||
const char * value;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define VIDEO_OPTS_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "available_settings.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "extra_callback_data.hpp"
|
||||
@@ -22,6 +23,9 @@ std::vector<SettingItem> getVideoDisplay(AvailableSettings *availSettings);
|
||||
std::vector<SettingItem> getVideoModes(AvailableSettings *availSettings);
|
||||
std::vector<SettingItem> getVideoCompress(AvailableSettings *availSettings);
|
||||
|
||||
std::vector<SettingItem> getCodecEncoders(AvailableSettings *availSettings,
|
||||
const std::string& mod, const std::string& codec);
|
||||
|
||||
void populateVideoCompressSettings(AvailableSettings *availSettings,
|
||||
Settings* settings);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>452</width>
|
||||
<width>480</width>
|
||||
<height>460</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -481,6 +481,46 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="vidCompTab">
|
||||
<attribute name="title">
|
||||
<string>Video compress</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="codecList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="codecOptScroll">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="accelTab">
|
||||
<attribute name="title">
|
||||
<string>Acceleration</string>
|
||||
|
||||
Reference in New Issue
Block a user