diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index b42cb25e..0e12ed28 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -6,6 +6,7 @@ OBSWebSocket.Settings.AuthRequired="Enable Authentication" OBSWebSocket.Settings.Password="Server Password" OBSWebSocket.Settings.CopyPassword="Copy Password to Clipboard" OBSWebSocket.Settings.ServerPort="Server Port" +OBSWebSocket.Settings.ConnectedSessionsTitle="Connected WebSocket Sessions" OBSWebSocket.NotifyConnect.Title="New WebSocket connection." OBSWebSocket.NotifyConnect.Message="Client %1 connected." diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index 516b2978..32c55d7d 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "SettingsDialog.h" #include "../obs-websocket.h" @@ -10,12 +11,23 @@ SettingsDialog::SettingsDialog(QWidget* parent) : ui(new Ui::SettingsDialog) { ui->setupUi(this); + ui->websocketSessionTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::FormAccepted); + connect(ui->enableAuthenticationCheckBox, &QCheckBox::stateChanged, + this, &SettingsDialog::EnableAuthenticationCheckBoxChanged); + connect(ui->copyPasswordButton, &QPushButton::clicked, + this, &SettingsDialog::CopyPasswordButtonClicked); } -void SettingsDialog::showEvent(QShowEvent* event) { +SettingsDialog::~SettingsDialog() +{ + delete ui; +} + +void SettingsDialog::showEvent(QShowEvent* event) +{ auto conf = GetConfig(); if (!conf) { blog(LOG_INFO, "Unable to retreive config!"); @@ -28,16 +40,45 @@ void SettingsDialog::showEvent(QShowEvent* event) { ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired); ui->serverPasswordLineEdit->setText(conf->ServerPassword); ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired); + + FillSessionTable(); } -void SettingsDialog::ToggleShowHide() { +void SettingsDialog::ToggleShowHide() +{ if (!isVisible()) setVisible(true); else setVisible(false); } -void SettingsDialog::FormAccepted() { +void SettingsDialog::FillSessionTable() +{ + int rowCount = 5; + ui->websocketSessionTable->setRowCount(rowCount); + for (int i = 0; i < 5; i++) { + QTableWidgetItem *addressItem = new QTableWidgetItem("test"); + ui->websocketSessionTable->setItem(i, 0, addressItem); + + QTableWidgetItem *durationItem = new QTableWidgetItem("test"); + ui->websocketSessionTable->setItem(i, 1, durationItem); + + QTableWidgetItem *statsItem = new QTableWidgetItem("test"); + ui->websocketSessionTable->setItem(i, 2, statsItem); + + QPushButton *invalidateButton = new QPushButton("Kick", this); + QWidget *invalidateButtonWidget = new QWidget(); + QHBoxLayout *invalidateButtonLayout = new QHBoxLayout(this); + invalidateButtonLayout->addWidget(invalidateButton); + invalidateButtonLayout->setAlignment(Qt::AlignCenter); + invalidateButtonLayout->setContentsMargins(0, 0, 0, 0); + invalidateButtonWidget->setLayout(invalidateButtonLayout); + ui->websocketSessionTable->setCellWidget(i, 3, invalidateButtonWidget); + } +} + +void SettingsDialog::FormAccepted() +{ auto conf = GetConfig(); if (!conf) { blog(LOG_INFO, "Unable to retreive config!"); @@ -53,6 +94,20 @@ void SettingsDialog::FormAccepted() { conf->Save(); } -SettingsDialog::~SettingsDialog() { - delete ui; +void SettingsDialog::EnableAuthenticationCheckBoxChanged() +{ + if (ui->enableAuthenticationCheckBox->isChecked()) { + ui->serverPasswordLineEdit->setEnabled(true); + ui->copyPasswordButton->setEnabled(true); + } else { + ui->serverPasswordLineEdit->setEnabled(false); + ui->copyPasswordButton->setEnabled(false); + } +} + +void SettingsDialog::CopyPasswordButtonClicked() +{ + QClipboard *clipboard = QGuiApplication::clipboard(); + clipboard->setText(ui->serverPasswordLineEdit->text()); + ui->serverPasswordLineEdit->selectAll(); } \ No newline at end of file diff --git a/src/forms/SettingsDialog.h b/src/forms/SettingsDialog.h index 5a580ed2..046eea5b 100644 --- a/src/forms/SettingsDialog.h +++ b/src/forms/SettingsDialog.h @@ -16,7 +16,11 @@ public: private Q_SLOTS: void FormAccepted(); + void EnableAuthenticationCheckBoxChanged(); + void CopyPasswordButtonClicked(); private: Ui::SettingsDialog* ui; + + void FillSessionTable(); }; \ No newline at end of file diff --git a/src/forms/SettingsDialog.ui b/src/forms/SettingsDialog.ui index 7146a07a..5b8eb282 100644 --- a/src/forms/SettingsDialog.ui +++ b/src/forms/SettingsDialog.ui @@ -6,8 +6,8 @@ 0 0 - 453 - 235 + 601 + 419 @@ -16,8 +16,8 @@ - 100 - 200 + 250 + 380 341 32 @@ -34,7 +34,7 @@ 9 9 - 431 + 581 191 @@ -126,6 +126,70 @@ + + + + 10 + 210 + 581 + 161 + + + + OBSWebSocket.Settings.ConnectedSessionsTitle + + + + + 10 + 30 + 561 + 121 + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + 135 + + + 135 + + + false + + + 21 + + + + Remote Address + + + + + Duration + + + + + In/Out + + + + + Kick? + + + +