2022-07-09 20:07:14 +00:00
|
|
|
#include "streamdialog.h"
|
|
|
|
#include "virtmic.h"
|
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSizePolicy>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
StreamDialog::StreamDialog() : QWidget() {
|
2022-07-13 15:56:07 +00:00
|
|
|
setAttribute(Qt::WA_QuitOnClose, false);
|
|
|
|
|
2022-11-22 15:35:47 +00:00
|
|
|
{
|
|
|
|
auto layout = new QVBoxLayout(this);
|
|
|
|
layout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
|
|
|
m_videoGroupBox = new QGroupBox(this);
|
|
|
|
m_videoGroupBox->setTitle("Video");
|
|
|
|
m_videoGroupBox->setCheckable(true);
|
|
|
|
layout->addWidget(m_videoGroupBox);
|
|
|
|
|
|
|
|
{
|
|
|
|
auto videoLayout = new QVBoxLayout(this);
|
|
|
|
m_videoGroupBox->setLayout(videoLayout);
|
|
|
|
|
|
|
|
auto resolutionLabel = new QLabel(this);
|
2022-11-22 15:39:58 +00:00
|
|
|
resolutionLabel->setText("Resolution");
|
2022-11-22 15:35:47 +00:00
|
|
|
videoLayout->addWidget(resolutionLabel);
|
|
|
|
|
|
|
|
m_resolutionComboBox = new QComboBox(this);
|
|
|
|
m_resolutionComboBox->addItem("2160p", "3840x2160");
|
|
|
|
m_resolutionComboBox->addItem("1440p", "2560x1440");
|
|
|
|
m_resolutionComboBox->addItem("1080p", "1920x1080");
|
|
|
|
m_resolutionComboBox->addItem("720p", "1280x720");
|
|
|
|
m_resolutionComboBox->addItem("480p", "854x480");
|
|
|
|
m_resolutionComboBox->addItem("360p", "640x360");
|
|
|
|
m_resolutionComboBox->addItem("240p", "426x240");
|
|
|
|
m_resolutionComboBox->setCurrentText("720p");
|
|
|
|
videoLayout->addWidget(m_resolutionComboBox);
|
|
|
|
|
|
|
|
auto framerateLabel = new QLabel(this);
|
2022-11-22 15:39:58 +00:00
|
|
|
framerateLabel->setText("Framerate");
|
2022-11-22 15:35:47 +00:00
|
|
|
videoLayout->addWidget(framerateLabel);
|
|
|
|
|
|
|
|
m_framerateComboBox = new QComboBox(this);
|
|
|
|
m_framerateComboBox->addItem("144 FPS", 144);
|
|
|
|
m_framerateComboBox->addItem("60 FPS", 60);
|
|
|
|
m_framerateComboBox->addItem("30 FPS", 30);
|
|
|
|
m_framerateComboBox->addItem("15 FPS", 15);
|
|
|
|
m_framerateComboBox->addItem("5 FPS", 5);
|
|
|
|
m_framerateComboBox->setCurrentText("30 FPS");
|
|
|
|
videoLayout->addWidget(m_framerateComboBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_audioGroupBox = new QGroupBox(this);
|
|
|
|
m_audioGroupBox->setCheckable(true);
|
|
|
|
m_audioGroupBox->setTitle("Audio");
|
|
|
|
layout->addWidget(m_audioGroupBox);
|
|
|
|
|
|
|
|
{
|
|
|
|
auto audioLayout = new QVBoxLayout(this);
|
|
|
|
m_audioGroupBox->setLayout(audioLayout);
|
|
|
|
|
|
|
|
auto targetLabel = new QLabel(this);
|
|
|
|
targetLabel->setText("Audio Source");
|
|
|
|
audioLayout->addWidget(targetLabel);
|
|
|
|
|
|
|
|
{
|
|
|
|
auto targetLayout = new QHBoxLayout(this);
|
|
|
|
audioLayout->addLayout(targetLayout);
|
|
|
|
|
|
|
|
m_targetComboBox = new QComboBox(this);
|
|
|
|
updateTargets();
|
|
|
|
targetLayout->addWidget(m_targetComboBox);
|
|
|
|
|
|
|
|
auto refreshTargetsButton = new QPushButton(this);
|
|
|
|
refreshTargetsButton->setFixedSize(30, 30);
|
|
|
|
refreshTargetsButton->setIcon(QIcon::fromTheme("view-refresh"));
|
|
|
|
connect(refreshTargetsButton, &QPushButton::clicked, this,
|
|
|
|
&StreamDialog::updateTargets);
|
|
|
|
targetLayout->addWidget(refreshTargetsButton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto button = new QPushButton(this);
|
|
|
|
button->setText("Start Stream");
|
|
|
|
connect(button, &QPushButton::clicked, this, &StreamDialog::startStream);
|
|
|
|
layout->addWidget(button, Qt::AlignRight | Qt::AlignBottom);
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
}
|
2022-07-09 20:07:14 +00:00
|
|
|
|
|
|
|
setWindowTitle("discord-screenaudio Stream Dialog");
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamDialog::startStream() {
|
2022-11-22 15:35:47 +00:00
|
|
|
auto resolution = m_resolutionComboBox->currentData().toString().split('x');
|
|
|
|
emit requestedStreamStart(m_videoGroupBox->isChecked(),
|
2023-02-12 16:20:33 +00:00
|
|
|
m_audioGroupBox->isChecked(), resolution[0].toInt(),
|
|
|
|
resolution[1].toInt(),
|
|
|
|
m_framerateComboBox->currentData().toInt(),
|
2022-11-22 15:35:47 +00:00
|
|
|
m_targetComboBox->currentText());
|
2022-07-09 20:07:14 +00:00
|
|
|
setHidden(true);
|
|
|
|
}
|
2022-07-14 09:57:44 +00:00
|
|
|
|
|
|
|
void StreamDialog::updateTargets() {
|
2022-08-04 13:51:03 +00:00
|
|
|
auto lastTarget = m_targetComboBox->currentText();
|
|
|
|
|
2022-07-14 09:57:44 +00:00
|
|
|
m_targetComboBox->clear();
|
2022-08-04 13:27:39 +00:00
|
|
|
m_targetComboBox->addItem("[All Desktop Audio]");
|
2022-07-14 09:57:44 +00:00
|
|
|
for (auto target : Virtmic::getTargets()) {
|
|
|
|
m_targetComboBox->addItem(target);
|
|
|
|
}
|
2022-08-04 13:51:03 +00:00
|
|
|
|
|
|
|
if (m_targetComboBox->findText(lastTarget) != -1)
|
|
|
|
m_targetComboBox->setCurrentText(lastTarget);
|
|
|
|
else
|
|
|
|
m_targetComboBox->setCurrentText("[All Desktop Audio]");
|
2022-07-14 09:57:44 +00:00
|
|
|
}
|