- etcp_metrics struct: 12-bucket RTT histogram, 11-bucket loss histogram, 10-min snapshots (>=200 pkts) - Total counters: packets/bytes sent/rcvd, losses (retrans + probe gap detection) - CSV append to <stats_dir>/<peer_id>.dat every 10 min - Ed25519 pubkey exchange in INIT handshake (V3), always present - Signed metrics exchange via ETCP_SECTION_METRICS (0x0A) - Received metrics saved as from_<peer_id>.dat with signature hex - on_metrics_rcvd callback in ETCP_BINDINGS - stats_dir derived from config file path, mkdir'd at instance init - Simplified versioning: ETCP_INIT_REQ_SIZE / ETCP_INIT_RESP_SIZE via sizeof
86 lines
2.9 KiB
C++
86 lines
2.9 KiB
C++
// settingsdialog.cpp — Settings dialog with category list
|
|
#include "settingsdialog.h"
|
|
#include "networksettingspage.h"
|
|
#include <QVBoxLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QPushButton>
|
|
#include <QLabel>
|
|
|
|
SettingsDialog::SettingsDialog(const QString& configPath, QWidget* parent)
|
|
: QDialog(parent)
|
|
, m_configPath(configPath)
|
|
{
|
|
setWindowTitle("Settings");
|
|
setMinimumSize(560, 380);
|
|
setModal(true);
|
|
|
|
auto* mainLayout = new QHBoxLayout(this);
|
|
mainLayout->setSpacing(0);
|
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
// --- Left sidebar: category list ---
|
|
m_categoryList = new QListWidget(this);
|
|
m_categoryList->setFixedWidth(150);
|
|
m_categoryList->setStyleSheet(
|
|
"QListWidget { border: none; border-right: 1px solid palette(mid);"
|
|
" background: palette(window); font-size: 13px; }"
|
|
"QListWidget::item { padding: 10px 14px; }"
|
|
"QListWidget::item:selected { background: #3390EC; color: white; }");
|
|
m_categoryList->addItem("Network");
|
|
mainLayout->addWidget(m_categoryList);
|
|
|
|
// --- Right panel: stacked pages ---
|
|
auto* rightPanel = new QWidget(this);
|
|
auto* rightLayout = new QVBoxLayout(rightPanel);
|
|
rightLayout->setContentsMargins(20, 16, 20, 16);
|
|
rightLayout->setSpacing(0);
|
|
|
|
m_pages = new QStackedWidget(rightPanel);
|
|
m_networkPage = new NetworkSettingsPage(m_pages);
|
|
m_pages->addWidget(m_networkPage);
|
|
rightLayout->addWidget(m_pages, 1);
|
|
|
|
// --- Bottom buttons ---
|
|
auto* btnLayout = new QHBoxLayout();
|
|
btnLayout->setSpacing(8);
|
|
btnLayout->addStretch();
|
|
|
|
auto* cancelBtn = new QPushButton("Cancel", rightPanel);
|
|
cancelBtn->setFixedWidth(90);
|
|
cancelBtn->setStyleSheet(
|
|
"QPushButton { border: 1px solid palette(mid); border-radius: 4px;"
|
|
" padding: 6px 16px; font-size: 13px; background: palette(button); }"
|
|
"QPushButton:hover { background: palette(light); }");
|
|
connect(cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
|
btnLayout->addWidget(cancelBtn);
|
|
|
|
m_saveBtn = new QPushButton("Save", rightPanel);
|
|
m_saveBtn->setFixedWidth(90);
|
|
m_saveBtn->setDefault(true);
|
|
m_saveBtn->setStyleSheet(
|
|
"QPushButton { border: none; border-radius: 4px;"
|
|
" padding: 6px 16px; font-size: 13px; font-weight: bold;"
|
|
" background: #3390EC; color: white; }"
|
|
"QPushButton:hover { background: #2B7ED4; }");
|
|
connect(m_saveBtn, &QPushButton::clicked, this, &SettingsDialog::onSave);
|
|
btnLayout->addWidget(m_saveBtn);
|
|
|
|
rightLayout->addLayout(btnLayout);
|
|
mainLayout->addWidget(rightPanel, 1);
|
|
|
|
connect(m_categoryList, &QListWidget::currentRowChanged,
|
|
this, &SettingsDialog::onCategoryChanged);
|
|
|
|
m_networkPage->loadFromConfig(m_configPath);
|
|
m_categoryList->setCurrentRow(0);
|
|
}
|
|
|
|
void SettingsDialog::onCategoryChanged(int row) {
|
|
m_pages->setCurrentIndex(row);
|
|
}
|
|
|
|
void SettingsDialog::onSave() {
|
|
m_networkPage->saveToConfig(m_configPath);
|
|
accept();
|
|
}
|