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.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."
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QClipboard>
|
||||
|
||||
#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();
|
||||
}
|
@ -16,7 +16,11 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void FormAccepted();
|
||||
void EnableAuthenticationCheckBoxChanged();
|
||||
void CopyPasswordButtonClicked();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog* ui;
|
||||
|
||||
void FillSessionTable();
|
||||
};
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>453</width>
|
||||
<height>235</height>
|
||||
<width>601</width>
|
||||
<height>419</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -16,8 +16,8 @@
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>200</y>
|
||||
<x>250</x>
|
||||
<y>380</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
@ -34,7 +34,7 @@
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>431</width>
|
||||
<width>581</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -126,6 +126,70 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
Loading…
Reference in New Issue
Block a user