SettingsDialog: Add timer to constantly update session table

This commit is contained in:
tt2468 2021-04-28 11:56:41 -07:00
parent aa241ecc9e
commit fb01a28623
2 changed files with 20 additions and 6 deletions

View File

@ -14,7 +14,8 @@
SettingsDialog::SettingsDialog(QWidget* parent) :
QDialog(parent, Qt::Dialog),
ui(new Ui::SettingsDialog)
ui(new Ui::SettingsDialog),
sessionTableTimer(new QTimer)
{
ui->setupUi(this);
ui->websocketSessionTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
@ -25,14 +26,17 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
this, &SettingsDialog::EnableAuthenticationCheckBoxChanged);
connect(ui->copyPasswordButton, &QPushButton::clicked,
this, &SettingsDialog::CopyPasswordButtonClicked);
connect(sessionTableTimer, &QTimer::timeout,
this, &SettingsDialog::FillSessionTable);
}
SettingsDialog::~SettingsDialog()
{
delete ui;
delete sessionTableTimer;
}
void SettingsDialog::showEvent(QShowEvent* event)
void SettingsDialog::showEvent(QShowEvent *event)
{
auto conf = GetConfig();
if (!conf) {
@ -48,6 +52,14 @@ void SettingsDialog::showEvent(QShowEvent* event)
ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired);
FillSessionTable();
sessionTableTimer->start(1000);
}
void SettingsDialog::closeEvent(QCloseEvent *event)
{
if (sessionTableTimer->isActive())
sessionTableTimer->stop();
}
void SettingsDialog::ToggleShowHide()

View File

@ -1,6 +1,7 @@
#pragma once
#include <QtWidgets/QDialog>
#include <QTimer>
#include "ui_SettingsDialog.h"
@ -11,16 +12,17 @@ class SettingsDialog : public QDialog
public:
explicit SettingsDialog(QWidget* parent = 0);
~SettingsDialog();
void showEvent(QShowEvent* event);
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *event);
void ToggleShowHide();
private Q_SLOTS:
void FormAccepted();
void EnableAuthenticationCheckBoxChanged();
void CopyPasswordButtonClicked();
void FillSessionTable();
private:
Ui::SettingsDialog* ui;
void FillSessionTable();
Ui::SettingsDialog *ui;
QTimer *sessionTableTimer;
};