discord-screenaudio/src/streamdialog.cpp

72 lines
2.4 KiB
C++
Raw Normal View History

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() {
auto layout = new QVBoxLayout;
auto targetLabel = new QLabel;
targetLabel->setText("Which app do you want to stream sound from?");
layout->addWidget(targetLabel);
m_targetComboBox = new QComboBox;
m_targetComboBox->addItem("None");
for (auto target : Virtmic::getTargets()) {
m_targetComboBox->addItem(target);
}
layout->addWidget(m_targetComboBox);
auto qualityLabel = new QLabel;
qualityLabel->setText("Stream Quality");
layout->addWidget(qualityLabel);
auto qualityHBox = new QHBoxLayout;
layout->addLayout(qualityHBox);
m_qualityResolutionComboBox = new QComboBox;
m_qualityResolutionComboBox->addItem("2160p", "3840x2160");
m_qualityResolutionComboBox->addItem("1440p", "2560x1440");
m_qualityResolutionComboBox->addItem("1080p", "1920x1080");
m_qualityResolutionComboBox->addItem("720p", "1280x720");
m_qualityResolutionComboBox->addItem("480p", "854x480");
m_qualityResolutionComboBox->addItem("360p", "640x360");
m_qualityResolutionComboBox->addItem("240p", "426x240");
m_qualityResolutionComboBox->setCurrentText("720p");
qualityHBox->addWidget(m_qualityResolutionComboBox);
m_qualityFPSComboBox = new QComboBox;
m_qualityFPSComboBox->addItem("144 FPS", 144);
m_qualityFPSComboBox->addItem("60 FPS", 60);
m_qualityFPSComboBox->addItem("30 FPS", 30);
m_qualityFPSComboBox->addItem("15 FPS", 15);
m_qualityFPSComboBox->addItem("5 FPS", 5);
m_qualityFPSComboBox->setCurrentText("30 FPS");
qualityHBox->addWidget(m_qualityFPSComboBox);
auto button = new QPushButton;
button->setText("Start Stream");
connect(button, &QPushButton::clicked, this, &StreamDialog::startStream);
layout->addWidget(button, Qt::AlignRight | Qt::AlignBottom);
setLayout(layout);
setWindowTitle("discord-screenaudio Stream Dialog");
setFixedSize(0, 0);
}
void StreamDialog::startStream() {
auto resolution =
m_qualityResolutionComboBox->currentData().toString().split('x');
emit requestedStreamStart(m_targetComboBox->currentText(),
resolution[0].toUInt(), resolution[1].toUInt(),
m_qualityFPSComboBox->currentData().toUInt());
setHidden(true);
}