| 307 | } |
| 308 | |
| 309 | void CatControlApplet::buildTableRows() |
| 310 | { |
| 311 | // Clear any existing rows |
| 312 | while (QLayoutItem* item = m_grid->takeAt(0)) { |
| 313 | if (item->widget()) item->widget()->setParent(nullptr); |
| 314 | delete item; |
| 315 | } |
| 316 | m_rows.clear(); |
| 317 | |
| 318 | // Header labels as grid row 0 — same layout as data rows, so columns always align. |
| 319 | // w=0 means no fixed width (used for the stretching PTY column). |
| 320 | auto addHdr = [&](const QString& text, int w, int col, |
| 321 | Qt::Alignment align = Qt::AlignLeft | Qt::AlignVCenter) { |
| 322 | auto* lbl = new QLabel(text); |
| 323 | ThemeManager::instance().applyStyleSheet(lbl, kHeaderStyle); |
| 324 | if (w > 0) lbl->setFixedWidth(w); |
| 325 | lbl->setAlignment(align); |
| 326 | m_grid->addWidget(lbl, 0, col); |
| 327 | }; |
| 328 | int hcol = 0; |
| 329 | addHdr("Enabled", 54, hcol++, Qt::AlignHCenter | Qt::AlignVCenter); |
| 330 | addHdr("Port", 50, hcol++, Qt::AlignHCenter | Qt::AlignVCenter); |
| 331 | addHdr("Dialect", 84, hcol++); |
| 332 | addHdr("VFO A", 42, hcol++, Qt::AlignHCenter | Qt::AlignVCenter); |
| 333 | addHdr("VFO B", 42, hcol++, Qt::AlignHCenter | Qt::AlignVCenter); |
| 334 | #ifndef Q_OS_WIN |
| 335 | addHdr("PTY", 0, hcol++); // no fixed width — column stretches |
| 336 | #endif |
| 337 | addHdr("Clients", 48, hcol++); |
| 338 | |
| 339 | auto& settings = AppSettings::instance(); |
| 340 | |
| 341 | for (int i = 0; i < m_portCount; ++i) { |
| 342 | PortRow row; |
| 343 | const QString prefix = QString("CatPort_%1_").arg(i); |
| 344 | |
| 345 | // Enable checkbox |
| 346 | row.enableCheck = new QCheckBox; |
| 347 | ThemeManager::instance().applyStyleSheet(row.enableCheck, kEnableCheck); |
| 348 | row.enableCheck->setToolTip("Enable this CAT port"); |
| 349 | { |
| 350 | bool en = settings.value(prefix + "Enabled", "False").toString() == "True"; |
| 351 | QSignalBlocker b(row.enableCheck); |
| 352 | row.enableCheck->setChecked(en); |
| 353 | } |
| 354 | |
| 355 | // Port edit |
| 356 | row.portEdit = new QLineEdit; |
| 357 | ThemeManager::instance().applyStyleSheet(row.portEdit, kPortEdit); |
| 358 | row.portEdit->setFixedWidth(50); |
| 359 | row.portEdit->setAlignment(Qt::AlignCenter); |
| 360 | row.portEdit->setValidator(new QIntValidator(kMinPort, kMaxPort, row.portEdit)); |
| 361 | row.portEdit->setPlaceholderText("port"); |
| 362 | { |
| 363 | QString portStr = settings.value(prefix + "Port", "").toString(); |
| 364 | QSignalBlocker b(row.portEdit); |
| 365 | row.portEdit->setText(portStr); |
| 366 | } |
nothing calls this directly
no test coverage detected