fix qlayout error

This commit is contained in:
Malte Jürgens 2023-02-15 02:21:41 +01:00
parent c52daab420
commit 36c8cfedb7
No known key found for this signature in database
GPG Key ID: D29FBD5F93C0CFC3
4 changed files with 13 additions and 16 deletions

View File

@ -9,7 +9,7 @@
#include <QSizePolicy> #include <QSizePolicy>
#include <QVBoxLayout> #include <QVBoxLayout>
StreamDialog::StreamDialog() : QWidget() { StreamDialog::StreamDialog(QWidget *parent) : QDialog(parent) {
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
{ {
@ -22,8 +22,7 @@ StreamDialog::StreamDialog() : QWidget() {
layout->addWidget(m_videoGroupBox); layout->addWidget(m_videoGroupBox);
{ {
auto videoLayout = new QVBoxLayout(this); auto videoLayout = new QVBoxLayout(m_videoGroupBox);
m_videoGroupBox->setLayout(videoLayout);
auto resolutionLabel = new QLabel(this); auto resolutionLabel = new QLabel(this);
resolutionLabel->setText("Resolution"); resolutionLabel->setText("Resolution");
@ -60,15 +59,14 @@ StreamDialog::StreamDialog() : QWidget() {
layout->addWidget(m_audioGroupBox); layout->addWidget(m_audioGroupBox);
{ {
auto audioLayout = new QVBoxLayout(this); auto audioLayout = new QVBoxLayout(m_audioGroupBox);
m_audioGroupBox->setLayout(audioLayout);
auto targetLabel = new QLabel(this); auto targetLabel = new QLabel(this);
targetLabel->setText("Audio Source"); targetLabel->setText("Audio Source");
audioLayout->addWidget(targetLabel); audioLayout->addWidget(targetLabel);
{ {
auto targetLayout = new QHBoxLayout(this); auto targetLayout = new QHBoxLayout();
audioLayout->addLayout(targetLayout); audioLayout->addLayout(targetLayout);
m_targetComboBox = new QComboBox(this); m_targetComboBox = new QComboBox(this);
@ -88,8 +86,6 @@ StreamDialog::StreamDialog() : QWidget() {
button->setText("Start Stream"); button->setText("Start Stream");
connect(button, &QPushButton::clicked, this, &StreamDialog::startStream); connect(button, &QPushButton::clicked, this, &StreamDialog::startStream);
layout->addWidget(button, Qt::AlignRight | Qt::AlignBottom); layout->addWidget(button, Qt::AlignRight | Qt::AlignBottom);
setLayout(layout);
} }
setWindowTitle("discord-screenaudio Stream Dialog"); setWindowTitle("discord-screenaudio Stream Dialog");

View File

@ -5,11 +5,11 @@
#include <QGroupBox> #include <QGroupBox>
#include <QWidget> #include <QWidget>
class StreamDialog : public QWidget { class StreamDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit StreamDialog(); explicit StreamDialog(QWidget *parent = nullptr);
private: private:
QComboBox *m_targetComboBox; QComboBox *m_targetComboBox;

View File

@ -74,7 +74,8 @@ void UserScript::setupShortcutsDialog() {
} }
void UserScript::setupStreamDialog() { void UserScript::setupStreamDialog() {
connect(&m_streamDialog, &StreamDialog::requestedStreamStart, this, m_streamDialog = new StreamDialog(MainWindow::instance());
connect(m_streamDialog, &StreamDialog::requestedStreamStart, this,
&UserScript::startStream); &UserScript::startStream);
} }
@ -156,9 +157,9 @@ void UserScript::startStream(bool video, bool audio, int width, int height,
} }
void UserScript::showStreamDialog() { void UserScript::showStreamDialog() {
if (m_streamDialog.isHidden()) if (m_streamDialog->isHidden())
m_streamDialog.setHidden(false); m_streamDialog->setHidden(false);
else else
m_streamDialog.activateWindow(); m_streamDialog->activateWindow();
m_streamDialog.updateTargets(); m_streamDialog->updateTargets();
} }

View File

@ -30,7 +30,7 @@ public:
private: private:
QProcess m_virtmicProcess; QProcess m_virtmicProcess;
StreamDialog m_streamDialog; StreamDialog *m_streamDialog;
bool m_kxmlgui = false; bool m_kxmlgui = false;
bool m_kglobalaccel = false; bool m_kglobalaccel = false;
#ifdef KXMLGUI #ifdef KXMLGUI