| 3379 | } |
| 3380 | |
| 3381 | void MainWindow::showQuickAddMemoryDialog(const QString& preferredPanId) |
| 3382 | { |
| 3383 | auto* slice = preferredMemorySlice(preferredPanId); |
| 3384 | if (!slice) { |
| 3385 | statusBar()->showMessage( |
| 3386 | preferredPanId.isEmpty() |
| 3387 | ? "Open a slice before saving a memory." |
| 3388 | : "Open a slice on this pan before saving a memory.", |
| 3389 | 3000); |
| 3390 | return; |
| 3391 | } |
| 3392 | |
| 3393 | const int sliceId = slice->sliceId(); |
| 3394 | const QString frequencyText = QString::number(slice->frequency(), 'f', 6); |
| 3395 | const QString summaryText = QString("%1 | Filter %2 to %3 Hz") |
| 3396 | .arg(slice->mode()) |
| 3397 | .arg(slice->filterLow()) |
| 3398 | .arg(slice->filterHigh()); |
| 3399 | |
| 3400 | QDialog dialog(this); |
| 3401 | dialog.setWindowTitle("Save Memory"); |
| 3402 | dialog.setModal(true); |
| 3403 | dialog.setMinimumWidth(360); |
| 3404 | |
| 3405 | auto* root = new QVBoxLayout(&dialog); |
| 3406 | root->setContentsMargins(14, 14, 14, 14); |
| 3407 | root->setSpacing(10); |
| 3408 | |
| 3409 | auto* nameLabel = new QLabel("Name:", &dialog); |
| 3410 | root->addWidget(nameLabel); |
| 3411 | |
| 3412 | auto* nameEdit = new QLineEdit(&dialog); |
| 3413 | nameEdit->setPlaceholderText("Enter a memory name"); |
| 3414 | root->addWidget(nameEdit); |
| 3415 | |
| 3416 | auto* freqLabel = new QLabel(QString("Current Frequency: %1 MHz").arg(frequencyText), &dialog); |
| 3417 | AetherSDR::ThemeManager::instance().applyStyleSheet(freqLabel, "QLabel { color: {{color.text.primary}}; font-size: 12px; }"); |
| 3418 | root->addWidget(freqLabel); |
| 3419 | |
| 3420 | auto* summaryLabel = new QLabel(summaryText, &dialog); |
| 3421 | summaryLabel->setStyleSheet("QLabel { color: #70879b; font-size: 11px; }"); |
| 3422 | root->addWidget(summaryLabel); |
| 3423 | |
| 3424 | auto* buttonRow = new QHBoxLayout; |
| 3425 | buttonRow->addStretch(1); |
| 3426 | |
| 3427 | auto* cancelButton = new QPushButton("Cancel", &dialog); |
| 3428 | cancelButton->setAutoDefault(false); |
| 3429 | buttonRow->addWidget(cancelButton); |
| 3430 | |
| 3431 | auto* saveButton = new QPushButton("Save", &dialog); |
| 3432 | saveButton->setDefault(true); |
| 3433 | saveButton->setEnabled(false); |
| 3434 | buttonRow->addWidget(saveButton); |
| 3435 | root->addLayout(buttonRow); |
| 3436 | |
| 3437 | connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject); |
| 3438 | connect(nameEdit, &QLineEdit::textChanged, &dialog, [saveButton](const QString& text) { |
nothing calls this directly
no test coverage detected