mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
SettingsDialog: Add UI logic and start session table
This commit is contained in:
parent
105229336e
commit
41731f9d57
@ -6,6 +6,7 @@ OBSWebSocket.Settings.AuthRequired="Enable Authentication"
|
|||||||
OBSWebSocket.Settings.Password="Server Password"
|
OBSWebSocket.Settings.Password="Server Password"
|
||||||
OBSWebSocket.Settings.CopyPassword="Copy Password to Clipboard"
|
OBSWebSocket.Settings.CopyPassword="Copy Password to Clipboard"
|
||||||
OBSWebSocket.Settings.ServerPort="Server Port"
|
OBSWebSocket.Settings.ServerPort="Server Port"
|
||||||
|
OBSWebSocket.Settings.ConnectedSessionsTitle="Connected WebSocket Sessions"
|
||||||
|
|
||||||
OBSWebSocket.NotifyConnect.Title="New WebSocket connection."
|
OBSWebSocket.NotifyConnect.Title="New WebSocket connection."
|
||||||
OBSWebSocket.NotifyConnect.Message="Client %1 connected."
|
OBSWebSocket.NotifyConnect.Message="Client %1 connected."
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
#include <QtWidgets/QMessageBox>
|
#include <QtWidgets/QMessageBox>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
#include "SettingsDialog.h"
|
#include "SettingsDialog.h"
|
||||||
#include "../obs-websocket.h"
|
#include "../obs-websocket.h"
|
||||||
@ -10,12 +11,23 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
|
|||||||
ui(new Ui::SettingsDialog)
|
ui(new Ui::SettingsDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->websocketSessionTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted,
|
connect(ui->buttonBox, &QDialogButtonBox::accepted,
|
||||||
this, &SettingsDialog::FormAccepted);
|
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();
|
auto conf = GetConfig();
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
blog(LOG_INFO, "Unable to retreive config!");
|
blog(LOG_INFO, "Unable to retreive config!");
|
||||||
@ -28,16 +40,45 @@ void SettingsDialog::showEvent(QShowEvent* event) {
|
|||||||
ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired);
|
ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired);
|
||||||
ui->serverPasswordLineEdit->setText(conf->ServerPassword);
|
ui->serverPasswordLineEdit->setText(conf->ServerPassword);
|
||||||
ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired);
|
ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired);
|
||||||
|
|
||||||
|
FillSessionTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::ToggleShowHide() {
|
void SettingsDialog::ToggleShowHide()
|
||||||
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
else
|
else
|
||||||
setVisible(false);
|
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();
|
auto conf = GetConfig();
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
blog(LOG_INFO, "Unable to retreive config!");
|
blog(LOG_INFO, "Unable to retreive config!");
|
||||||
@ -53,6 +94,20 @@ void SettingsDialog::FormAccepted() {
|
|||||||
conf->Save();
|
conf->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog() {
|
void SettingsDialog::EnableAuthenticationCheckBoxChanged()
|
||||||
delete ui;
|
{
|
||||||
|
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();
|
||||||
}
|
}
|
@ -16,7 +16,11 @@ public:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void FormAccepted();
|
void FormAccepted();
|
||||||
|
void EnableAuthenticationCheckBoxChanged();
|
||||||
|
void CopyPasswordButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog* ui;
|
Ui::SettingsDialog* ui;
|
||||||
|
|
||||||
|
void FillSessionTable();
|
||||||
};
|
};
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>453</width>
|
<width>601</width>
|
||||||
<height>235</height>
|
<height>419</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -16,8 +16,8 @@
|
|||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>100</x>
|
<x>250</x>
|
||||||
<y>200</y>
|
<y>380</y>
|
||||||
<width>341</width>
|
<width>341</width>
|
||||||
<height>32</height>
|
<height>32</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>9</x>
|
<x>9</x>
|
||||||
<y>9</y>
|
<y>9</y>
|
||||||
<width>431</width>
|
<width>581</width>
|
||||||
<height>191</height>
|
<height>191</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -126,6 +126,70 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>210</y>
|
||||||
|
<width>581</width>
|
||||||
|
<height>161</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>OBSWebSocket.Settings.ConnectedSessionsTitle</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QTableWidget" name="websocketSessionTable">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>30</y>
|
||||||
|
<width>561</width>
|
||||||
|
<height>121</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="tabKeyNavigation">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="showDropIndicator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||||
|
<number>135</number>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||||
|
<number>135</number>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderMinimumSectionSize">
|
||||||
|
<number>21</number>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Remote Address</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Duration</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>In/Out</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Kick?</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
Loading…
Reference in New Issue
Block a user