Twitter Service

This commit is contained in:
David Marsh 2024-07-18 17:02:40 +01:00
parent dcaafc45f7
commit 00b3bc5cfb
2 changed files with 126 additions and 3 deletions

View File

@ -78,3 +78,11 @@ TrovoServer="Trovo Server"
TrovoServerInfo="The stream server URL is preset for Trovo, you do not need to change it."
TrovoStreamKey="Trovo Stream Key"
TrovoStreamKeyInfo="Please enter your stream key, you can find this in your <a href='https://studio.trovo.live/mychannel/stream'>Trovo Studio page</a>."
# Twitter Output Dialog
TwitterOutput="X (Twitter) Output"
TwitterServiceInfo="Please complete the following fields to add a new X (Twitter) output."
TwitterServer="X (Twitter) Server"
TwitterServerInfo="Pick your closest X (Twitter) ingest server."
TwitterStreamKey="X (Twitter) Stream Key"
TwitterStreamKeyInfo="Please enter your stream key, you can find this in your <a href='https://studio.twitter.com/producer/sources'>X (Twitter) Producer page</a>."

View File

@ -342,14 +342,129 @@ QWidget *OutputDialog::WizardInfoYouTube() {
QWidget *OutputDialog::WizardInfoTwitter() {
auto page = new QWidget(this);
auto pageLayout = new QVBoxLayout;
page->setStyleSheet("padding: 0px; margin: 0px;");
auto title = new QLabel(QString("Twitter Service page"));
// Layout
auto pageLayout = new QVBoxLayout;
pageLayout->setSpacing(12);
// Heading
auto title = new QLabel(QString::fromUtf8(obs_module_text("TwitterServiceInfo")));
pageLayout->addWidget(title);
// Content
auto contentLayout = new QVBoxLayout;
// Confirm button - initialised here so we can set state in form input connects
auto confirmButton = generateButton(QString("Create Output"));
// Form
auto formLayout = new QFormLayout;
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout->setLabelAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
formLayout->setSpacing(12);
// Output name
auto outputNameField = new QLineEdit;
outputNameField->setText(QString::fromUtf8(obs_module_text("TwitterOutput")));
outputNameField->setStyleSheet("padding: 4px 8px;");
connect(outputNameField, &QLineEdit::textEdited, [this, outputNameField, confirmButton] {
outputName = outputNameField->text();
validateOutputs(confirmButton);
});
formLayout->addRow(generateFormLabel("OutputName"), outputNameField);
// Server selection
auto serverSelection = new QComboBox;
serverSelection->setMinimumHeight(30);
serverSelection->setStyleSheet("padding: 4px 8px;");
connect(serverSelection, &QComboBox::currentIndexChanged, [this, serverSelection, confirmButton] {
outputServer = serverSelection->currentData().toString();
validateOutputs(confirmButton);
});
auto rawOptions = getService("Twitter");
// turn raw options into actual selectable options
if (rawOptions != nullptr) {
auto servers = obs_data_get_array(rawOptions, "servers");
auto totalServers = obs_data_array_count(servers);
for (size_t idx = 0; idx < totalServers; idx++) {
auto item = obs_data_array_item(servers, idx);
serverSelection->addItem(obs_data_get_string(item, "name"), obs_data_get_string(item, "url"));
}
}
// Set default value for server
outputServer = serverSelection->currentData().toString();
formLayout->addRow(generateFormLabel("TwitterServer"), serverSelection);
// Server info
formLayout->addWidget(generateInfoLabel("TwitterServerInfo"));
// Server key
auto outputKeyField = new QLineEdit;
outputKeyField->setStyleSheet("padding: 4px 8px;");
connect(outputKeyField, &QLineEdit::textEdited, [this, outputKeyField, confirmButton] {
outputKey = outputKeyField->text();
validateOutputs(confirmButton);
});
formLayout->addRow(generateFormLabel("TwitterStreamKey"), outputKeyField);
// Server key info
formLayout->addWidget(generateInfoLabel("TwitterStreamKeyInfo"));
contentLayout->addLayout(formLayout);
// spacing
auto spacer = new QSpacerItem(1, 20, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
contentLayout->addSpacerItem(spacer);
pageLayout->addLayout(contentLayout);
// Controls
auto controlsLayout = new QHBoxLayout;
controlsLayout->setSpacing(12);
// back button
auto serviceButton = generateButton(QString("< Back"));
connect(serviceButton, &QPushButton::clicked, [this] {
stackedWidget->setCurrentIndex(0);
resetOutputs();
});
controlsLayout->addWidget(serviceButton, 0);
controlsLayout->addStretch(1);
// confirm button (initialised above so we can set state)
connect(confirmButton, &QPushButton::clicked, [this] {
acceptOutputs();
});
controlsLayout->addWidget(confirmButton, 0);
// Hook it all together
pageLayout->addLayout(controlsLayout);
page->setLayout(pageLayout);
// Defaults for when we're changed to
connect(stackedWidget, &QStackedWidget::currentChanged, [this, outputNameField, serverSelection, outputKeyField, confirmButton] {
if (stackedWidget->currentIndex() == 3) {
outputName = outputNameField->text();
outputServer = serverSelection->currentData().toString();
outputKey = outputKeyField->text();
validateOutputs(confirmButton);
}
});
return page;
}