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

View File

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