diff --git a/CMakeLists.txt b/CMakeLists.txt index 6db7889..89e6319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,6 +268,7 @@ set(CONTESTPROGRAMM_UI_SOURCES src/ui/MultiplierWindow.cpp src/ui/RotorWidget.h src/ui/RotorWidget.cpp + src/ui/RotorRowWidget.cpp src/ui/CwMacroPanel.h src/ui/CwMacroPanel.cpp src/ui/EdiExportDialog.h diff --git a/TESTLISTE.md b/TESTLISTE.md index 8b0056a..72047ed 100644 --- a/TESTLISTE.md +++ b/TESTLISTE.md @@ -23,6 +23,22 @@ bewusst aufgeschoben. ## Claude (gebaut, aber noch nicht am echten Gerät geprüft) +- [ ] **Panels einzeln in Longpath (2026-11-04, #72 + oe5sos/Longpath#386).** + Longpath › Tools › Contest logbook panels: ein Panel anhaken, es + muss als eigenes Fenster neben dem Longpath-Hauptfenster erscheinen, + OHNE dass das Logbuch-Hauptfenster aufgeht; ✕ am Panel dockt es + zurück (unsichtbar, weil das Logbuch zu ist); danach Tools › + Contest Logbook öffnen: dasselbe Logbuch, das Panel wieder drin. + Zu sehen ist vor allem, was der offscreen-Prüfstand nicht kann: ob + macOS ein Werkzeugfenster zeigt, dessen Elternfenster verborgen + ist, und ob das Panel beim Minimieren von Longpath mit ins Dock geht. + Prüfstände: `test_einbettung::panelsLassenSichVonAussenAbloesen`, + Longpath `tst_contestfenster::einPanelOhneLogbuchFenster`. + Dazu (f432e0a): die Panels dort sind eckig und ohne Systemrahmen, + ↙ in der Kopfzeile dockt zurück, Zug an der Kopfzeile und Anfasser + rechts unten müssen gehen; das Panel „Rotoren" muss sich bis auf + EINEN Rotor Breite ziehen lassen (dann untereinander), und die + Gradzahlen bleiben am kleineren Zifferblatt lesbar. - [ ] **Wasserfall gegen das echte Longpath — Ursache gefunden, am Gerät noch nicht nachgefahren.** Gefahren am 2026-11-02: Longpath protokolliert „Spektrum abonniert rx 0, 718 Punkte" und sendet diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index d6f8675..346d2be 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -66,6 +66,7 @@ #include "ui/SideAreaWidget.h" #include "ui/ProfileRail.h" #include "ui/RateMeterWidget.h" +#include "ui/RotorRowWidget.h" #include "ui/RotorWidget.h" #include "ui/ScoreboardDialog.h" #include "ui/SkedPanel.h" @@ -717,13 +718,12 @@ MainWindow::MainWindow(AppController& appController, QWidget* parent) // below) reads as one instrument *group*, not a doubled header; the // dockable-panel system tolerates the rotor slots appearing/ // disappearing at runtime the same way the old fixed layout did, - // since applyRotorSlot() below still only ever touches m_rotorLayout, + // since applyRotorSlot() below still only ever touches m_rotorRow, // never this panel's own container. - m_rotorRow = new QWidget(this); - m_rotorLayout = new QHBoxLayout(m_rotorRow); - m_rotorLayout->setContentsMargins(0, 0, 0, 0); - m_rotorLayout->setSpacing(10); - m_rotorLayout->addStretch(); + // RotorRowWidget statt QHBoxLayout (2026-11-04): die Zeile kann so + // schmal werden wie EIN Rotor, dann stehen sie untereinander. Siehe + // RotorRowWidget.h fuer den Betreiberwunsch dahinter. + m_rotorRow = new RotorRowWidget(this); // y=632: below the merged Log panel's own bottom edge (64+560=624) // plus an 8px gap. // Height 370 (was 272, originally 236): RotorWidget::minimumSizeHint() @@ -754,7 +754,7 @@ MainWindow::MainWindow(AppController& appController, QWidget* parent) // kReadoutMinWidth -- the three big AKTUELL/ZIEL/ENTFERNUNG numbers // measure ~90px each at kFontDisplay and were overlapping at the old // 220px). With both rotor slots enabled (the default), two widgets - // at 300px plus m_rotorLayout's 10px spacing need >=610px, which the + // at 300px plus the rotor row's 10px spacing need >=610px, which the // old 300px-wide row/708 x-offset could never have fit even before // this pass (a pre-existing mismatch this pass's own live-app // verification screenshot exposed). Moved to x=0 (rather than @@ -1920,19 +1920,10 @@ MainWindow::MainWindow(AppController& appController, QWidget* parent) // why that panel stays on its independent checkbox). windowMenu->addSeparator(); auto* panelsMenu = windowMenu->addMenu(QStringLiteral("&Panels")); - struct PanelMenuEntry { QString id; QString label; }; - static const QVector kPanelMenuEntries = { - {QStringLiteral("unifiedlog"), QStringLiteral("Log")}, - {QStringLiteral("rotorrow"), QStringLiteral("Rotoren")}, - {QStringLiteral("map"), QStringLiteral("Karte / Verbindungen")}, - {QStringLiteral("suggestion"), QStringLiteral("Nächstes Ziel")}, - {QStringLiteral("ratemeter"), QStringLiteral("Rate")}, - {QStringLiteral("checkpartial"), QStringLiteral("Check")}, - {QStringLiteral("bandmap"), QStringLiteral("Bandmap")}, - {QStringLiteral("skeds"), QStringLiteral("Skeds")}, - {QStringLiteral("chat"), QStringLiteral("Chat")}, - {QStringLiteral("wasserfall"), QStringLiteral("Wasserfall")}, - }; + // Die Tabelle liegt seit 2026-11-04 in panelEintraege(): Longpath + // holt sich dort dieselbe Liste (siehe MainWindow.h). + using PanelMenuEntry = MainWindow::PanelEintrag; + static const QList kPanelMenuEntries = MainWindow::panelEintraege(); // Panels als eigene Fenster ablösen -- Martin, 2026-09-28: "schön // wäre es, ein windows zu haben, wo ich alle windows auch aber auch // rausziehen kann um platz zu sparen. das haben wir bei longpath @@ -1941,7 +1932,7 @@ MainWindow::MainWindow(AppController& appController, QWidget* parent) auto* ablösenMenu = windowMenu->addMenu(QStringLiteral("Als eigenes &Fenster")); ablösenMenu->setObjectName(QStringLiteral("floatPanelsMenu")); for (const PanelMenuEntry& entry : kPanelMenuEntries) { - QAction* action = ablösenMenu->addAction(entry.label); + QAction* action = ablösenMenu->addAction(entry.titel); action->setObjectName(QStringLiteral("float_%1").arg(entry.id)); action->setCheckable(true); connect(action, &QAction::toggled, this, [this, id = entry.id](bool floating) { @@ -1978,10 +1969,10 @@ MainWindow::MainWindow(AppController& appController, QWidget* parent) auto* seitenbereichMenu = windowMenu->addMenu(QStringLiteral("In den &Seitenbereich")); seitenbereichMenu->setObjectName(QStringLiteral("sideAreaMenu")); for (const PanelMenuEntry& entry : kPanelMenuEntries) { - QAction* action = seitenbereichMenu->addAction(entry.label); + QAction* action = seitenbereichMenu->addAction(entry.titel); action->setObjectName(QStringLiteral("side_%1").arg(entry.id)); action->setCheckable(true); - connect(action, &QAction::toggled, this, [this, id = entry.id, label = entry.label](bool hinein) { + connect(action, &QAction::toggled, this, [this, id = entry.id, label = entry.titel](bool hinein) { if (hinein) { putPanelIntoSideArea(id, label); } else { @@ -2014,7 +2005,7 @@ MainWindow::MainWindow(AppController& appController, QWidget* parent) auto panelActions = std::make_shared>>(); for (const PanelMenuEntry& entry : versteckbar) { - QAction* action = panelsMenu->addAction(entry.label); + QAction* action = panelsMenu->addAction(entry.titel); action->setObjectName(QStringLiteral("panelAction_%1").arg(entry.id)); action->setCheckable(true); connect(action, &QAction::toggled, this, [this, id = entry.id](bool visible) { @@ -2640,7 +2631,7 @@ void MainWindow::applyFixedAntennaSettings() const ContestSettings settings = m_appController.settings(); if (!settings.fixedAntennaEnabled) { if (m_fixedAntennaWidget) { - m_rotorLayout->removeWidget(m_fixedAntennaWidget); + m_rotorRow->entfernen(m_fixedAntennaWidget); delete m_fixedAntennaWidget; m_fixedAntennaWidget = nullptr; } @@ -2660,7 +2651,7 @@ void MainWindow::applyFixedAntennaSettings() if (m_rotor2Widget) { ++index; } - m_rotorLayout->insertWidget(index, m_fixedAntennaWidget); + m_rotorRow->einfuegen(index, m_fixedAntennaWidget); // Der Anzeigestil gilt fuer alle Instrumente gemeinsam, also // auch hier -- dieselbe Runde wie bei den drehbaren. connect(m_fixedAntennaWidget, &RotorWidget::dialStyleRequested, m_fixedAntennaWidget, @@ -2785,7 +2776,7 @@ void MainWindow::applyRotorSlot(bool enabled, const QString& label, RotctldClien if (enabled) { if (!widget) { widget = new RotorWidget(label, m_rotorRow); - m_rotorLayout->insertWidget(insertIndex, widget); + m_rotorRow->einfuegen(insertIndex, widget); // `widget` as the connect() context means both connections // auto-disconnect the moment the widget is destroyed below // (the disabled-slot path) -- no dangling-pointer risk in @@ -2941,7 +2932,7 @@ void MainWindow::applyRotorSlot(bool enabled, const QString& label, RotctldClien pushRotorHeadingToMap(client, true, widget->azimuthDeg(), label); } } else if (widget) { - m_rotorLayout->removeWidget(widget); + m_rotorRow->entfernen(widget); widget->hide(); widget->deleteLater(); widget = nullptr; @@ -3032,6 +3023,61 @@ QStringList MainWindow::panelIdsForTest() const return m_panelLayoutManager ? m_panelLayoutManager->panelIds() : QStringList(); } +// ── Panels von aussen (2026-11-04, fuer Longpath) ─────────────────── + +QList MainWindow::panelEintraege() +{ + // Dieselbe Reihenfolge wie im Menue "Fenster > Panels" -- der + // Betreiber soll in Longpath dieselbe Liste sehen wie hier. + static const QList eintraege = { + {QStringLiteral("unifiedlog"), QStringLiteral("Log")}, + {QStringLiteral("rotorrow"), QStringLiteral("Rotoren")}, + {QStringLiteral("map"), QStringLiteral("Karte / Verbindungen")}, + {QStringLiteral("suggestion"), QStringLiteral("Nächstes Ziel")}, + {QStringLiteral("ratemeter"), QStringLiteral("Rate")}, + {QStringLiteral("checkpartial"), QStringLiteral("Check")}, + {QStringLiteral("bandmap"), QStringLiteral("Bandmap")}, + {QStringLiteral("skeds"), QStringLiteral("Skeds")}, + {QStringLiteral("chat"), QStringLiteral("Chat")}, + {QStringLiteral("wasserfall"), QStringLiteral("Wasserfall")}, + }; + return eintraege; +} + +bool MainWindow::istPanelSchwebend(const QString& id) const +{ + return m_panelLayoutManager && m_panelLayoutManager->isPanelFloating(id); +} + +void MainWindow::setzePanelSchwebend(const QString& id, bool schwebend) +{ + if (!m_panelLayoutManager) { return; } + PanelContainerWidget* panel = m_panelLayoutManager->panel(id); + if (!panel) { return; } + if (schwebend) { + // Aus dem Seitenbereich holen: dort ist es eine Seite, kein + // Fenster, und setPanelFloating() faende es nicht in der Flaeche. + takePanelOutOfSideArea(id); + m_panelLayoutManager->setPanelFloating(id, true); + // Ein nie gezeigtes Hauptfenster hat keine ausgelegte Flaeche: + // das Panel kaeme mit der Groesse 0x0 daher. Dann die Groesse + // des Entwurfs, mindestens etwas Greifbares. + if (panel->width() < 160 || panel->height() < 120) { + QSize groesse = m_panelLayoutManager->defaultGeometryFor(id).size(); + if (groesse.isEmpty()) { groesse = panel->sizeHint(); } + panel->resize(groesse.expandedTo(QSize(320, 240))); + } + if (!panel->isVisible()) { panel->show(); } + } else { + m_panelLayoutManager->setPanelFloating(id, false); + } +} + +QWidget* MainWindow::panelFenster(const QString& id) const +{ + return m_panelLayoutManager ? m_panelLayoutManager->panel(id) : nullptr; +} + QRect MainWindow::defaultGeometryForTest(const QString& id) const { return m_panelLayoutManager ? m_panelLayoutManager->defaultGeometryFor(id) : QRect(); diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 268b7cf..3944d0a 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -102,6 +102,27 @@ class MainWindow : public QMainWindow { /// Panel dazu. Fuer tests/test_jedes_panel_ausblendbar.cpp. QStringList panelIdsForTest() const; class PanelContainerWidget* panelForTest(const QString& id) const; + + // ── Panels von aussen (2026-11-04, fuer Longpath) ─────────────── + // + // Betreiber: "jedes panel vom contestprogramm sollte in longpath + // eigens hinzuzufuegen sein, das waere die beste version." Longpath + // bettet dieses Fenster ein (siehe README "Als Fenster in Longpath") + // und will jedes Panel EINZELN als eigenes Fenster holen -- auch + // ohne dieses Hauptfenster zu zeigen. Dieselbe Liste und derselbe + // Weg wie das Menue "Fenster > Als eigenes Fenster" hier; nur nach + // aussen gereicht, damit Longpath keine Panel-Kennung raten muss. + struct PanelEintrag { QString id; QString titel; }; + static QList panelEintraege(); + bool istPanelSchwebend(const QString& id) const; + // Loest das Panel als eigenes Fenster (Qt::Tool-Kind dieses + // Fensters) oder holt es zurueck in die Flaeche. Ein Panel im + // Seitenbereich wird vorher herausgeholt. Ist dieses Hauptfenster + // noch nie gezeigt worden, hat das Panel keine Groesse aus der + // Flaeche -- dann bekommt es die des Entwurfs. + void setzePanelSchwebend(const QString& id, bool schwebend); + // Das Panel als Fenster (oder nullptr, wenn es die Kennung nicht gibt). + QWidget* panelFenster(const QString& id) const; class SideAreaWidget* sideAreaForTest() const { return m_sideArea; } void applyWaterfallVisibilityForTest() { applyWaterfallVisibility(); } void putPanelIntoSideAreaForTest(const QString& id); @@ -424,7 +445,7 @@ private slots: // "/CHAT ..." ahead of the LOGIN handshake). void syncOn4kstRoomForCurrentBand(); - // Creates `*widget` (inserted into m_rotorLayout at `insertIndex`, + // Creates `*widget` (inserted into m_rotorRow at `insertIndex`, // wired to `client`'s azimuthChanged/stateChanged) if `enabled` and // it does not exist yet; updates its label in place if it already // exists; tears it down (removed from the layout, hidden, then @@ -623,8 +644,9 @@ private slots: // shown by the Startcheck until the rotor connects. QString m_rotctldError1; QString m_rotctldError2; - QWidget* m_rotorRow = nullptr; - QHBoxLayout* m_rotorLayout = nullptr; + // Seit 2026-11-04 eine RotorRowWidget (nebeneinander oder + // untereinander, je nach Platz) statt QWidget + QHBoxLayout. + class RotorRowWidget* m_rotorRow = nullptr; RotorWidget* m_rotor1Widget = nullptr; RotorWidget* m_rotor2Widget = nullptr; // Die feste Antenne (ContestSettings::fixedAntennaEnabled): dasselbe diff --git a/src/ui/MapWidget.cpp b/src/ui/MapWidget.cpp index e5230a1..60cd1b9 100644 --- a/src/ui/MapWidget.cpp +++ b/src/ui/MapWidget.cpp @@ -1963,12 +1963,20 @@ void MapWidget::drawNumbersColumn(QPainter& painter, const QRectF& column) const // anderes Instrument, er ist dasselbe, blasser. const QColor nadel = live ? QColor(Style::kAmberText()) : QColor(Style::kAmberDim()); + // Mittig in der Spalte, Ueberschrift und Scheibe (Betreiber + // 2026-11-04: "bei karte und verbindungen sollten die rotoren + // eher mittig sein, sonst sieht es eigenartig aus"). Vorher + // sass die Scheibe am linken Rand der Spalte, die Legende + // darunter auch -- und rechts blieb Luft. + const double spaltenMitte = column.left() + column.width() / 2.0; painter.setFont(Style::capsFont(font(), Style::kFontCaption)); painter.setPen(QColor(Style::kTextTertiary())); - painter.drawText(QPointF(x, y + 9.0), QStringLiteral("ROTOR %1").arg(i + 1)); + painter.drawText(QRectF(column.left(), y, column.width(), 16.0), + Qt::AlignHCenter | Qt::AlignVCenter, + QStringLiteral("ROTOR %1").arg(i + 1)); y += 16.0; - const QPointF mitte(x + radius + 4.0, y + radius); + const QPointF mitte(spaltenMitte, y + radius); m_rotorDialRect[i] = QRectF(mitte.x() - radius, mitte.y() - radius, durchmesser, durchmesser); // ── Entwurf A ──────────────────────────────────────── @@ -2090,7 +2098,8 @@ void MapWidget::drawNumbersColumn(QPainter& painter, const QRectF& column) const if (m_rotorDialsBackward) { painter.setFont(Style::monoFont(font(), Style::kFontCaption)); painter.setPen(QColor(Style::kTextTertiary())); - painter.drawText(QPointF(x, y + 11.0), + painter.drawText(QRectF(column.left(), y, column.width(), 16.0), + Qt::AlignHCenter | Qt::AlignVCenter, QStringLiteral("zurück %1°").arg(wrap360(az + 180.0), 0, 'f', 0)); y += 16.0; } diff --git a/src/ui/PanelContainerWidget.cpp b/src/ui/PanelContainerWidget.cpp index 46912fc..6b7f03c 100644 --- a/src/ui/PanelContainerWidget.cpp +++ b/src/ui/PanelContainerWidget.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,7 @@ PanelContainerWidget::PanelContainerWidget(const QString& id, const QString& tit m_headerBar->setLockAffordanceEnabled(true); m_headerBar->installEventFilter(this); connect(m_headerBar, &PanelHeaderBar::lockToggled, this, &PanelContainerWidget::setLocked); + connect(m_headerBar, &PanelHeaderBar::dockRequested, this, [this]() { setFloating(false); }); layout->addWidget(m_headerBar); layout->addWidget(content, 1); } @@ -74,6 +76,37 @@ PanelContainerWidget::PanelContainerWidget(const QString& id, const QString& tit layoutOverlayWidgets(); } +namespace { +bool s_rahmenlosSchwebend = false; +} + +void PanelContainerWidget::setzeRahmenlosSchwebend(bool an) { s_rahmenlosSchwebend = an; } +bool PanelContainerWidget::rahmenlosSchwebend() { return s_rahmenlosSchwebend; } + +void PanelContainerWidget::zeigeRueckwegAffordanz(bool an) +{ + if (m_headerBar) { + m_headerBar->setDockAffordanceEnabled(an); + } + if (m_contentHasOwnChrome) { + if (an && !m_overlayDockButton) { + m_overlayDockButton = new QPushButton(QString::fromUtf8("↙"), this); + m_overlayDockButton->setObjectName(QStringLiteral("panelOverlayDockButton")); + m_overlayDockButton->setFixedSize(24, 18); + m_overlayDockButton->setCursor(Qt::PointingHandCursor); + m_overlayDockButton->setToolTip(QStringLiteral("Zurück ins Logbuch")); + m_overlayDockButton->setStyleSheet(Style::iconButtonStyle()); + connect(m_overlayDockButton, &QPushButton::clicked, this, [this]() { + setFloating(false); + }); + } + if (m_overlayDockButton) { + m_overlayDockButton->setVisible(an); + layoutOverlayWidgets(); + } + } +} + void PanelContainerWidget::buildChromelessOverlay() { m_overlayLockButton = new QPushButton(this); @@ -166,7 +199,20 @@ void PanelContainerWidget::setFloating(bool floating) // haengt es daran -- es folgt beim Minimieren, beim Wechsel // des Schirms und beim Schliessen. QWidget* hauptfenster = m_dockTarget ? m_dockTarget->window() : window(); - setParent(hauptfenster, Qt::Tool); + if (s_rahmenlosSchwebend) { + // Ohne Systemrahmen, eckig, mit eigenem Rueckweg (↙) -- siehe + // setzeRahmenlosSchwebend(). WA_MacAlwaysShowToolWindow: ein + // Werkzeugfenster verschwaende sonst, sobald das Programm + // nicht mehr vorn ist; ein Log-Panel soll stehen bleiben. + setParent(hauptfenster, Qt::Tool | Qt::FramelessWindowHint); + setAttribute(Qt::WA_MacAlwaysShowToolWindow, true); + if (!m_contentHasOwnChrome) { + Style::applyPanelFrameStyle(this, m_id, 0); + } + zeigeRueckwegAffordanz(true); + } else { + setParent(hauptfenster, Qt::Tool); + } setWindowTitle(m_title.isEmpty() ? m_id : m_title); // Dort aufmachen, wo es gerade stand -- nicht irgendwo. move(aufDemSchirm); @@ -176,7 +222,13 @@ void PanelContainerWidget::setFloating(bool floating) activateWindow(); } else { setWindowFlag(Qt::Tool, false); + setWindowFlag(Qt::FramelessWindowHint, false); setWindowFlag(Qt::Window, false); + setAttribute(Qt::WA_MacAlwaysShowToolWindow, false); + zeigeRueckwegAffordanz(false); + if (!m_contentHasOwnChrome) { + Style::applyPanelFrameStyle(this, m_id); + } setParent(m_dockTarget); if (m_dockedGeometry.isValid()) { setGeometry(m_dockedGeometry); @@ -217,6 +269,12 @@ void PanelContainerWidget::layoutOverlayWidgets() m_overlayLockButton->move(width() - m_overlayLockButton->width() - 6, 6); m_overlayLockButton->raise(); } + if (m_overlayDockButton && m_overlayLockButton) { + // Rechts vom Schloss, wie in der Kopfzeile. + m_overlayDockButton->move(width() - m_overlayLockButton->width() - 6 + - m_overlayDockButton->width() - 4, 6); + m_overlayDockButton->raise(); + } } void PanelContainerWidget::beginDrag(const QPoint& globalPos) @@ -241,6 +299,20 @@ void PanelContainerWidget::updateDrag(const QPoint& globalPos) return; } QPoint newPos = globalPos - m_dragStartOffset; + if (m_floating) { + // Als eigenes Fenster: am Schirm halten, nicht am Elternfenster + // -- das waere das Hauptfenster, und ein Panel soll auch neben + // ihm stehen duerfen. Die Kopfzeile muss greifbar bleiben. + if (QScreen* scr = screen()) { + const QRect platz = scr->availableGeometry(); + newPos.setX(std::clamp(newPos.x(), platz.left() - width() + 60, platz.right() - 60)); + newPos.setY(std::clamp(newPos.y(), platz.top(), platz.bottom() - 40)); + } + if (pos() != newPos) { + move(newPos); + } + return; + } // Clamped to the parent canvas -- same overlay-docked behavior as // ContainerWidget::updateDrag()'s non-floating branch. if (parentWidget()) { @@ -291,7 +363,7 @@ void PanelContainerWidget::updateResize(const QPoint& globalPos) const int dy = globalPos.y() - m_resizeStartGlobal.y(); int newW = std::max(kMinWidth, m_resizeStartSize.width() + dx); int newH = std::max(kMinHeight, m_resizeStartSize.height() + dy); - if (parentWidget()) { + if (!m_floating && parentWidget()) { newW = std::min(newW, std::max(kMinWidth, parentWidget()->width() - x())); newH = std::min(newH, std::max(kMinHeight, parentWidget()->height() - y())); } diff --git a/src/ui/PanelContainerWidget.h b/src/ui/PanelContainerWidget.h index a02fca3..bb961ae 100644 --- a/src/ui/PanelContainerWidget.h +++ b/src/ui/PanelContainerWidget.h @@ -111,6 +111,16 @@ class PanelContainerWidget : public QWidget { // das sich wegklicken lässt und dann nirgends mehr steht, wäre eine // Falle). void setFloating(bool floating); + // Schwebende Panels OHNE Systemrahmen (2026-11-04): Qt::Tool | + // FramelessWindowHint, eckig, mit ↙ in der Kopfzeile statt dem ✕ + // des Systems, Zug an der Kopfzeile und Anfasser rechts unten wie + // in der Flaeche -- so sehen Longpaths eigene Fenster aus, und so + // sollen die Panels des Contestprogramms dort aussehen. Betreiber: + // "alle panels haben hier noch runde kanten, dies bitte auf eckig + // umstellen." Gilt fuer alle Panels des Prozesses; Longpath setzt + // es beim Laden, eigenstaendig bleibt der Systemrahmen. + static void setzeRahmenlosSchwebend(bool an); + static bool rahmenlosSchwebend(); bool isFloating() const { return m_floating; } // Die Fläche, in die zurückgedockt wird -- der Elternteil, den das // Panel beim Herauslösen hatte. @@ -172,6 +182,7 @@ class PanelContainerWidget : public QWidget { private: void buildChromelessOverlay(); void updateChromelessLockBadge(); + void zeigeRueckwegAffordanz(bool an); void layoutOverlayWidgets(); void beginDrag(const QPoint& globalPos); @@ -196,6 +207,7 @@ class PanelContainerWidget : public QWidget { // Header mode only. PanelHeaderBar* m_headerBar = nullptr; + QPushButton* m_overlayDockButton = nullptr; // ↙ im rahmenlosen Fenster, chromlos // Chromeless mode only -- a small overlay lock badge raised above // `content`, since there is no PanelHeaderBar to host one. diff --git a/src/ui/PanelHeaderBar.cpp b/src/ui/PanelHeaderBar.cpp index d0af742..c4d9ea8 100644 --- a/src/ui/PanelHeaderBar.cpp +++ b/src/ui/PanelHeaderBar.cpp @@ -26,6 +26,7 @@ PanelHeaderBar::PanelHeaderBar(const QString& title, QWidget* parent) , m_clockWidget(new UtcClockWidget(this)) , m_lockButton(new QPushButton(this)) , m_optionsButton(new QPushButton(QString::fromUtf8("⚙"), this)) + , m_dockButton(new QPushButton(QString::fromUtf8("↙"), this)) { setFixedHeight(kHeaderHeight); @@ -69,6 +70,22 @@ PanelHeaderBar::PanelHeaderBar(const QString& title, QWidget* parent) setLocked(!m_locked); emit lockToggled(m_locked); }); + + // Ganz rechts, wie an Longpaths Fenstern der Rueckweg: siehe + // setDockAffordanceEnabled(). + m_dockButton->setObjectName(QStringLiteral("panelHeaderDockButton")); + m_dockButton->setFixedSize(kOptionsButtonW, kOptionsButtonH); + m_dockButton->setCursor(Qt::PointingHandCursor); + m_dockButton->setToolTip(QStringLiteral("Zurück ins Logbuch")); + m_dockButton->setStyleSheet(Style::iconButtonStyle()); + m_dockButton->setVisible(false); + layout->addWidget(m_dockButton); + connect(m_dockButton, &QPushButton::clicked, this, &PanelHeaderBar::dockRequested); +} + +void PanelHeaderBar::setDockAffordanceEnabled(bool enabled) +{ + m_dockButton->setVisible(enabled); } void PanelHeaderBar::setTitle(const QString& title) diff --git a/src/ui/PanelHeaderBar.h b/src/ui/PanelHeaderBar.h index 3ab5e59..5d8a307 100644 --- a/src/ui/PanelHeaderBar.h +++ b/src/ui/PanelHeaderBar.h @@ -78,6 +78,13 @@ class PanelHeaderBar : public QWidget { // the top bar's countdown. void setClockVisible(bool visible); + // "Zurueck ins Logbuch" (↙), opt-in wie die anderen: nur fuer ein + // Panel, das als RAHMENLOSES eigenes Fenster steht (in Longpath, + // 2026-11-04). Ohne Systemrahmen gibt es kein ✕ mehr, und das ✕ + // war bisher der Rueckweg (PanelContainerWidget::closeEvent). Das + // Zeichen ist dasselbe wie an Longpaths eigenen Fenstern. + void setDockAffordanceEnabled(bool enabled); + signals: // Emitted only when the operator actually clicks the lock button -- // PanelContainerWidget connects this to its own setLocked() (single @@ -91,6 +98,9 @@ class PanelHeaderBar : public QWidget { // state to keep in sync, unlike the lock's on/off badge). void optionsRequested(); + // Klick auf ↙ -- der Besitzer dockt das Panel zurueck. + void dockRequested(); + protected: void paintEvent(QPaintEvent* event) override; @@ -101,6 +111,7 @@ class PanelHeaderBar : public QWidget { UtcClockWidget* m_clockWidget; QPushButton* m_lockButton; QPushButton* m_optionsButton; + QPushButton* m_dockButton; bool m_locked = false; }; diff --git a/src/ui/RotorRowWidget.cpp b/src/ui/RotorRowWidget.cpp new file mode 100644 index 0000000..d3cba4d --- /dev/null +++ b/src/ui/RotorRowWidget.cpp @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// src/ui/RotorRowWidget.cpp (Contestprogramm) -- siehe RotorRowWidget.h +// +// ================================================================= +// Modification history (Contestprogramm): +// 2026-11-04 -- Original von Martin Fischer, KI-gestuetzt ueber +// Anthropic Claude. +// ================================================================= +#include "ui/RotorRowWidget.h" + +#include +#include +#include + +namespace Contestprogramm { + +RotorRowWidget::RotorRowWidget(QWidget* parent) + : QWidget(parent) +{ +} + +void RotorRowWidget::einfuegen(int index, QWidget* w) +{ + if (!w) { return; } + m_felder.removeAll(w); + if (index < 0 || index > m_felder.size()) { index = m_felder.size(); } + m_felder.insert(index, w); + w->setParent(this); + w->show(); + anordnen(); + updateGeometry(); +} + +void RotorRowWidget::entfernen(QWidget* w) +{ + if (m_felder.removeAll(w) > 0) { + anordnen(); + updateGeometry(); + } +} + +QSize RotorRowWidget::einzelMindestgroesse() const +{ + QSize s(0, 0); + for (QWidget* w : m_felder) { + if (w) { s = s.expandedTo(w->minimumSizeHint()); } + } + return s; +} + +QSize RotorRowWidget::minimumSizeHint() const +{ + // EIN Rotor -- ob die anderen daneben oder darunter stehen, + // entscheidet anordnen() nach der Groesse, die man der Zeile gibt. + return einzelMindestgroesse(); +} + +QSize RotorRowWidget::sizeHint() const +{ + // Nebeneinander, mit dem Wunschmass jedes Feldes. + int w = 0; + int h = 0; + for (QWidget* f : m_felder) { + if (!f) { continue; } + const QSize s = f->sizeHint(); + w += s.width(); + h = std::max(h, s.height()); + } + if (m_felder.size() > 1) { w += kAbstand * (m_felder.size() - 1); } + return QSize(w, h); +} + +void RotorRowWidget::anordnen() +{ + const int n = m_felder.size(); + if (n == 0) { return; } + const QSize einzel = einzelMindestgroesse(); + const int breite = width(); + const int hoehe = height(); + + // Nebeneinander, wenn alle in ihrer Mindestbreite nebeneinander + // passen; sonst untereinander -- es sei denn, auch das passt nicht, + // dann bleibt es nebeneinander (irgendwo muss es hin). + const bool passtNebeneinander = breite >= n * einzel.width() + kAbstand * (n - 1); + const bool passtUntereinander = hoehe >= n * einzel.height() + kAbstand * (n - 1); + m_nebeneinander = passtNebeneinander || !passtUntereinander; + + if (m_nebeneinander) { + const int feldBreite = std::max(1, (breite - kAbstand * (n - 1)) / n); + int x = 0; + for (int i = 0; i < n; ++i) { + const int w = (i == n - 1) ? std::max(1, breite - x) : feldBreite; + m_felder[i]->setGeometry(x, 0, w, std::max(1, hoehe)); + x += feldBreite + kAbstand; + } + } else { + const int feldHoehe = std::max(1, (hoehe - kAbstand * (n - 1)) / n); + int y = 0; + for (int i = 0; i < n; ++i) { + const int h = (i == n - 1) ? std::max(1, hoehe - y) : feldHoehe; + m_felder[i]->setGeometry(0, y, std::max(1, breite), h); + y += feldHoehe + kAbstand; + } + } +} + +void RotorRowWidget::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + anordnen(); +} + +void RotorRowWidget::childEvent(QChildEvent* event) +{ + QWidget::childEvent(event); + if (event->removed()) { + // Ein geloeschtes Bedienfeld (Rotor-Steckplatz abgeschaltet) + // faellt aus der Liste; der Rest rueckt nach. + auto* w = static_cast(event->child()); + if (m_felder.removeAll(w) > 0) { + anordnen(); + updateGeometry(); + } + } +} + +} // namespace Contestprogramm diff --git a/src/ui/RotorRowWidget.h b/src/ui/RotorRowWidget.h new file mode 100644 index 0000000..dc32d2c --- /dev/null +++ b/src/ui/RotorRowWidget.h @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// src/ui/RotorRowWidget.h (Contestprogramm) +// +// Die Zeile mit den Rotor-Bedienfeldern -- nebeneinander, wenn die +// Breite reicht, sonst untereinander. +// +// Betreiber 2026-11-04, mit dem Panel "Rotoren" als eigenem Fenster in +// Longpath: "das fenster rotoren muss sehr gross gezogen werden, um grad +// eigens zu sehen. bitte um loesungen, um fenster klein ziehen zu +// koennen." Bis dahin war die Zeile ein QHBoxLayout: zwei Rotoren +// nebeneinander, und die Mindestbreite der Zeile war die Summe ihrer +// Mindestbreiten (2 x 186 + 10). Kleiner ging das Fenster nicht, und bei +// der Mindestbreite war jedes Zifferblatt gerade so gross, dass die +// Gradzahlen wegfielen. +// +// Jetzt entscheidet die Breite: passen alle Rotoren nebeneinander, +// stehen sie nebeneinander; sonst untereinander. Die Mindestgroesse der +// Zeile ist die EINES Rotors -- ein schmales, hohes Fenster geht also +// genauso wie ein breites, flaches. Kein Layout-Objekt, weil Qt-Layouts +// ihre Mindestgroesse aus der festen Anordnung ableiten und die Zeile +// damit nie unter die Breite "alle nebeneinander" kaeme. +// +// ================================================================= +// Modification history (Contestprogramm): +// 2026-11-04 -- Original von Martin Fischer, KI-gestuetzt ueber +// Anthropic Claude. +// ================================================================= +#pragma once + +#include +#include + +namespace Contestprogramm { + +class RotorRowWidget : public QWidget { + Q_OBJECT + +public: + explicit RotorRowWidget(QWidget* parent = nullptr); + + // Ein Bedienfeld an der Stelle `index` einhaengen (0 = links/oben). + // Entfernt wird durch Loeschen des Widgets; die Zeile merkt es. + void einfuegen(int index, QWidget* w); + // Aus der Zeile nehmen (das Widget bleibt bestehen; wer es loescht, + // entscheidet der Aufrufer). Ein spaeteres Loeschen ist harmlos. + void entfernen(QWidget* w); + int anzahl() const { return m_felder.size(); } + // Stehen die Felder gerade nebeneinander (true) oder untereinander? + bool nebeneinander() const { return m_nebeneinander; } + + QSize minimumSizeHint() const override; + QSize sizeHint() const override; + +protected: + void resizeEvent(QResizeEvent* event) override; + void childEvent(QChildEvent* event) override; + +private: + void anordnen(); + QSize einzelMindestgroesse() const; + + QList m_felder; + bool m_nebeneinander = true; + static constexpr int kAbstand = 10; +}; + +} // namespace Contestprogramm diff --git a/src/ui/RotorWidget.cpp b/src/ui/RotorWidget.cpp index c715bc5..388b71a 100644 --- a/src/ui/RotorWidget.cpp +++ b/src/ui/RotorWidget.cpp @@ -48,6 +48,17 @@ constexpr int kReadoutLabelHeight = 14; // "Aktuell"/"Ziel"/"Entfernung" caps l // Gegenrichtung nie die bessere, und die Zeile bliebe nur im Weg. constexpr double kLongPathFromKm = 5000.0; constexpr int kReadoutValueHeight = 46; // kFontDisplay (38px) big numbers + leading +// Die Kaestchen des Ablesefelds schrumpfen mit der Breite (Betreiber +// 2026-11-04, Rotoren als eigenes Fenster in Longpath: "die kaestchen +// fuer die gradanzahl bei rotoren koennen kleiner sein, so waere dann +// alles auch gemeinsam kleiner"). Drei Stufen der Wertschrift, je mit +// eigener Hoehe von Wert- und Beschriftungszeile; readoutStufeFontPx() +// nimmt die groesste, bei der "000°" dreimal nebeneinander passt. Die +// Konstanten oben sind die GROSSE Stufe; die kleinen stehen hier. +constexpr int kReadoutValueHeightMittel = 34; // 28 px +constexpr int kReadoutValueHeightKlein = 22; // kFontSub (16 px) +constexpr int kReadoutLabelHeightMittel = 12; +constexpr int kReadoutLabelHeightKlein = 11; constexpr int kReadoutRowGap = 4; constexpr int kReadoutLineHeight = 18; // one generic text line -- caption row and connection-status row both use this constexpr int kReadoutBottomPad = 4; @@ -422,10 +433,47 @@ bool RotorWidget::readoutFitsWidth() const // because textAreaHeight() (which readoutBlockRect() needs) asks // this first. const int cellWidth = (width() - 12) / 3 - 3; - const QFontMetrics small(Style::monoFont(font(), kDigitalValueFontPx)); + const QFontMetrics small(Style::monoFont(font(), Style::kFontSub)); return small.horizontalAdvance(QStringLiteral("000°")) + 10 <= cellWidth; } +int RotorWidget::readoutStufeFontPx() const +{ + // Aus width() gerechnet, NICHT aus readoutBlockRect(): das fragt + // textAreaHeight(), das fragt die Hoehen hier -- ein Kreis. + const int cellWidth = (width() - 12) / 3 - 3; + for (int px : {Style::kFontDisplay, kDigitalValueFontPx, Style::kFontSub}) { + const QFontMetrics fm(Style::monoFont(font(), px)); + if (fm.horizontalAdvance(QStringLiteral("000°")) + 10 <= cellWidth) { + return px; + } + } + return Style::kFontSub; +} + +int RotorWidget::readoutValueHeight() const +{ + const int px = readoutStufeFontPx(); + return px >= Style::kFontDisplay ? kReadoutValueHeight + : px >= kDigitalValueFontPx ? kReadoutValueHeightMittel + : kReadoutValueHeightKlein; +} + +int RotorWidget::readoutLabelHeight() const +{ + const int px = readoutStufeFontPx(); + return px >= Style::kFontDisplay ? kReadoutLabelHeight + : px >= kDigitalValueFontPx ? kReadoutLabelHeightMittel + : kReadoutLabelHeightKlein; +} + +int RotorWidget::readoutTextAreaFull() const +{ + // Dasselbe wie kTextAreaHeight, mit den Hoehen der aktuellen Stufe. + return kReadoutTopPad + readoutLabelHeight() + readoutValueHeight() + kReadoutRowGap + + kReadoutLineHeight + kReadoutRowGap + kReadoutLineHeight + kReadoutBottomPad; +} + QSize RotorWidget::sizeHint() const { // Room for the full readout under a comfortable dial -- the size @@ -444,7 +492,7 @@ int RotorWidget::textAreaHeight() const } const int available = height() - kHeaderHeight - kMinDialAreaHeight; const bool digital = m_dialStyle == RotorDialStyle::Digital; - const int full = digital ? kDigitalTextAreaHeight : kTextAreaHeight; + const int full = digital ? kDigitalTextAreaHeight : readoutTextAreaFull(); const int withoutStatus = full - (digital ? kDigitalRowGap + kDigitalStatusHeight : kReadoutRowGap + kReadoutLineHeight); const int withoutCaption = withoutStatus - (digital ? kDigitalRowGap + kDigitalCaptionHeight : kReadoutRowGap + kReadoutLineHeight); for (int candidate : {full, withoutStatus, withoutCaption}) { @@ -931,12 +979,18 @@ void RotorWidget::drawTicks(QPainter& painter, const QPointF& center, double rad // cardinals, which already carry a letter. Longpath only draws these // once the dial is big enough that they would not collide (r > 84); // below that it skips them entirely rather than crowding the face. - if (radius > 84.0) { + // Betreiber 2026-11-04: "das fenster rotoren muss sehr gross gezogen + // werden, um grad eigens zu sehen. bitte um loesungen, um fenster + // klein ziehen zu koennen." Darum unter r = 84 nicht mehr weg, + // sondern kleiner: bis r = 54 in 8 px, erst darunter faellt die + // Beschriftung -- da stuende sie auf den Strichen. + if (radius > 54.0) { + const int fontPx = radius > 84.0 ? Style::kFontCaption : Style::kFontCaption - 1; for (int deg = 30; deg < 360; deg += 30) { if (deg % 90 == 0) { continue; } - drawDegreeLabel(painter, center, radius * 0.755, deg); + drawDegreeLabel(painter, center, radius * 0.755, deg, fontPx); } } } @@ -955,11 +1009,12 @@ void RotorWidget::drawCompassLabel(QPainter& painter, const QPointF& center, dou painter.drawText(box, Qt::AlignCenter, text); } -void RotorWidget::drawDegreeLabel(QPainter& painter, const QPointF& center, double radius, double angleDeg) const +void RotorWidget::drawDegreeLabel(QPainter& painter, const QPointF& center, double radius, double angleDeg, + int fontPx) const { const QString text = QString::number(static_cast(angleDeg)); const QPointF p = pointOnCircle(center, radius, angleDeg); - const QFont f = Style::monoFont(painter.font(), Style::kFontCaption); + const QFont f = Style::monoFont(painter.font(), fontPx > 0 ? fontPx : Style::kFontCaption); painter.setFont(f); const QFontMetrics fm(f); const QRectF box(p.x() - fm.horizontalAdvance(text), p.y() - fm.height() * 0.5, fm.horizontalAdvance(text) * 2.0, fm.height()); @@ -1184,7 +1239,7 @@ QRect RotorWidget::readoutBlockRect() const const int textHeight = textAreaHeight(); const QRect textArea(0, height() - textHeight, width(), textHeight); return QRect(textArea.left() + 6, textArea.top() + kReadoutTopPad, textArea.width() - 12, - kReadoutLabelHeight + kReadoutValueHeight); + readoutLabelHeight() + readoutValueHeight()); } QRect RotorWidget::readoutValuesRow() const @@ -1192,15 +1247,12 @@ QRect RotorWidget::readoutValuesRow() const // Below the cell's label, ending a little above the glass's bottom // edge. const QRect block = readoutBlockRect(); - return QRect(block.left(), block.top() + 3 + kReadoutLabelHeight, block.width(), kReadoutValueHeight - 6); + return QRect(block.left(), block.top() + 3 + readoutLabelHeight(), block.width(), readoutValueHeight() - 6); } int RotorWidget::readoutValueFontPx() const { - const int cellWidth = columnRect(readoutBlockRect(), 0).width() - 3; - const QFontMetrics big(Style::monoFont(font(), Style::kFontDisplay)); - return big.horizontalAdvance(QStringLiteral("000°")) + 10 <= cellWidth ? Style::kFontDisplay - : kDigitalValueFontPx; + return readoutStufeFontPx(); } void RotorWidget::drawReadoutInset(QPainter& painter, const QRect& box) const @@ -1293,13 +1345,15 @@ void RotorWidget::drawReadout(QPainter& painter, const QRect& area) const // Row 1: caps labels, one per column -- same "small caps label // above a value" convention UnifiedLogWidget::buildFieldCell() and // MapWidget::drawLegend() both already use. - const QRect labelsRow(block.left(), block.top() + 3, block.width(), kReadoutLabelHeight); - painter.setFont(capLabelFont); + const QRect labelsRow(block.left(), block.top() + 3, block.width(), readoutLabelHeight()); + painter.setFont(readoutLabelHeight() < kReadoutLabelHeight + ? Style::capsFont(painter.font(), Style::kFontCaption - 1) + : capLabelFont); painter.setPen(scaleColor); painter.drawText(columnRect(labelsRow, 0), Qt::AlignCenter, QStringLiteral("Aktuell")); painter.drawText(columnRect(labelsRow, 1), Qt::AlignCenter, QStringLiteral("Ziel")); painter.drawText(columnRect(labelsRow, 2), Qt::AlignCenter, QStringLiteral("Entfernung")); - y += kReadoutLabelHeight; + y += readoutLabelHeight(); // Row 2: the big numbers themselves. const QRect valuesRow = readoutValuesRow(); @@ -1341,7 +1395,10 @@ void RotorWidget::drawReadout(QPainter& painter, const QRect& area) const // kReadoutValueHeight the one line used to have alone. const QRect aRow1(col0.left(), col0.top(), col0.width(), col0.height() / 2); const QRect aRow2(col0.left(), col0.top() + col0.height() / 2, col0.width(), col0.height() - col0.height() / 2); - painter.setFont(Style::monoFont(painter.font(), Style::kFontBody, QFont::Bold)); + painter.setFont(Style::monoFont(painter.font(), + readoutValueHeight() < kReadoutValueHeightMittel + ? Style::kFontCaption : Style::kFontBody, + QFont::Bold)); painter.setPen(showAktuell ? aktuellColor : inactiveColor); painter.drawText(aRow1, Qt::AlignCenter, QStringLiteral("1 %1").arg(showAktuell ? formatDeg(m_azimuthDeg) : Style::unknownDash())); @@ -1372,7 +1429,10 @@ void RotorWidget::drawReadout(QPainter& painter, const QRect& area) const const QString secondZiel = m_hasTarget ? formatDeg(BeamHeading::wrap360(m_targetBearingDeg + m_secondAntennaOffsetDeg)) : Style::unknownDash(); - painter.setFont(Style::monoFont(painter.font(), Style::kFontBody, QFont::Bold)); + painter.setFont(Style::monoFont(painter.font(), + readoutValueHeight() < kReadoutValueHeightMittel + ? Style::kFontCaption : Style::kFontBody, + QFont::Bold)); painter.setPen(m_hasTarget ? QColor(Style::kBlueBg()) : inactiveColor); painter.drawText(row2, Qt::AlignCenter, QStringLiteral("2 %1").arg(secondZiel)); } @@ -1397,12 +1457,12 @@ void RotorWidget::drawReadout(QPainter& painter, const QRect& area) const drawCenteredSegments(painter, columnRect(valuesRow, 2), segs); } - y += kReadoutValueHeight + kReadoutRowGap; + y += readoutValueHeight() + kReadoutRowGap; // A reduced block (see textAreaHeight()) ends here, or after the // caption. - const bool hasCaptionRow = area.height() >= kTextAreaHeight - (kReadoutRowGap + kReadoutLineHeight); - const bool hasStatusRow = area.height() >= kTextAreaHeight; + const bool hasCaptionRow = area.height() >= readoutTextAreaFull() - (kReadoutRowGap + kReadoutLineHeight); + const bool hasStatusRow = area.height() >= readoutTextAreaFull(); if (!hasCaptionRow) { return; } diff --git a/src/ui/RotorWidget.h b/src/ui/RotorWidget.h index 991561c..c6d611d 100644 --- a/src/ui/RotorWidget.h +++ b/src/ui/RotorWidget.h @@ -310,7 +310,9 @@ class RotorWidget : public QWidget { void drawGlow(QPainter& painter, const QPointF& center, double radius) const; void drawTicks(QPainter& painter, const QPointF& center, double radius) const; void drawCompassLabel(QPainter& painter, const QPointF& center, double radius, double angleDeg, const QString& text) const; - void drawDegreeLabel(QPainter& painter, const QPointF& center, double radius, double angleDeg) const; + // fontPx < 0 = Style::kFontCaption (die Kopfdatei kennt StyleKit nicht). + void drawDegreeLabel(QPainter& painter, const QPointF& center, double radius, double angleDeg, + int fontPx = -1) const; // `alpha` dims the needle (0..255) -- used to mark a stale/unknown // reading (rotor not connected) without hiding it outright, per // HAUSSTIL rule 7 ("Unbekannt ist ein Strich, keine Null" -- @@ -334,6 +336,13 @@ class RotorWidget : public QWidget { // so the editable ZIEL field sits exactly on its painted cell. QRect readoutBlockRect() const; int textAreaHeight() const; + // Die Stufe des Ablesefelds (2026-11-04): Wertschrift in px, und die + // Hoehen der Wert- und Beschriftungszeile dieser Stufe. Siehe die + // Konstanten kReadoutValueHeight* in RotorWidget.cpp. + int readoutStufeFontPx() const; + int readoutValueHeight() const; + int readoutLabelHeight() const; + int readoutTextAreaFull() const; // False when three readout columns no longer fit the width even in // the smaller value font -- the readout then gives way (see .cpp). bool readoutFitsWidth() const; diff --git a/src/ui/StyleKit.cpp b/src/ui/StyleKit.cpp index ed499c9..7b36a16 100644 --- a/src/ui/StyleKit.cpp +++ b/src/ui/StyleKit.cpp @@ -429,6 +429,11 @@ void applyPanelFrameStyle(QWidget* widget) } void applyPanelFrameStyle(QWidget* widget, const QString& objectName) +{ + applyPanelFrameStyle(widget, objectName, kPanelRadius); +} + +void applyPanelFrameStyle(QWidget* widget, const QString& objectName, int radiusPx) { if (!widget) { return; @@ -449,7 +454,7 @@ void applyPanelFrameStyle(QWidget* widget, const QString& objectName) widget->setStyleSheet(QStringLiteral( "QWidget#%1 { background: %2; border: 1px solid %3; border-radius: %4px; }") .arg(objectName, kPanelBg(), kBorderSubtle()) - .arg(kPanelRadius)); + .arg(radiusPx)); } QString badgeStyle(bool ok) diff --git a/src/ui/StyleKit.h b/src/ui/StyleKit.h index bcac112..6243732 100644 --- a/src/ui/StyleKit.h +++ b/src/ui/StyleKit.h @@ -225,6 +225,12 @@ void applyPanelFrameStyle(QWidget* widget); // order-of-operations trap entirely; the no-arg overload just delegates // here with the historical shared name. void applyPanelFrameStyle(QWidget* widget, const QString& objectName); +// Dieselbe Regel mit waehlbarem Eckenradius. 0 = eckig: fuer ein Panel, +// das als rahmenloses Fenster in Longpath steht (Betreiber 2026-11-04: +// "alle panels haben hier noch runde kanten, dies bitte auf eckig +// umstellen") -- Longpaths eigene Fenster sind eckig, und ein runder +// Rahmen auf einem eckigen Fenster liesse vier helle Ecken stehen. +void applyPanelFrameStyle(QWidget* widget, const QString& objectName, int radiusPx); // Small connect/disconnected badge pill: kBadgeOkBg/kGreenText when // `ok`, kBadgeOffBg/kTextInactive otherwise -- the named pairs from diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 92cd86d..f1d251e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -135,6 +135,7 @@ contestprogramm_add_test(test_transverter) contestprogramm_add_test(test_hamlibinstaller) contestprogramm_add_test(test_beamheading) contestprogramm_add_test(test_rotorwidget) +contestprogramm_add_test(test_rotorzeile) contestprogramm_add_test(test_broadcastpublisher) contestprogramm_add_test(test_qso_audio_recorder) contestprogramm_add_test(test_mitschnitt_sichtbar) diff --git a/tests/test_einbettung.cpp b/tests/test_einbettung.cpp index b64de6e..3c8704d 100644 --- a/tests/test_einbettung.cpp +++ b/tests/test_einbettung.cpp @@ -16,6 +16,7 @@ // eigenstaendigen Weg; main.cpp geht durch dieselben zwei Funktionen. #include +#include #include #include @@ -24,6 +25,7 @@ #include "app/ContestSettings.h" #include "app/Datenverzeichnis.h" #include "ui/MainWindow.h" +#include "ui/PanelContainerWidget.h" using namespace Contestprogramm; @@ -35,6 +37,8 @@ private slots: void dasDatenverzeichnisHaengtNichtAmProzessnamen(); void dieUmgebungGehtVor(); void fensterUndControllerEntstehenImFremdenProzess(); + void panelsLassenSichVonAussenAbloesen(); + void rahmenlosSchwebendIstEckigMitRueckweg(); }; void TestEinbettung::dasDatenverzeichnisHaengtNichtAmProzessnamen() @@ -92,5 +96,134 @@ void TestEinbettung::fensterUndControllerEntstehenImFremdenProzess() fenster.close(); } +// Betreiber 2026-11-04: "jedes panel vom contestprogramm sollte in +// longpath eigens hinzuzufuegen sein". Longpath holt ein Panel als +// eigenes Fenster, OHNE dieses Hauptfenster je zu zeigen -- also darf +// das Panel nicht mit 0x0 daherkommen, und es muss ein Fensterkind +// dieses Hauptfensters sein (Qt::Tool), damit es beim Wirt auf der Ebene +// der Panels liegt. Alte Fassung: die Methoden gibt es nicht. +void TestEinbettung::panelsLassenSichVonAussenAbloesen() +{ + QTemporaryDir ordner; + QVERIFY(ordner.isValid()); + AppController controller; + QString fehler; + QVERIFY2(controller.openDatabase(datenbankPfad(ordner.path()), &fehler), + qPrintable(fehler)); + ContestSettings s = controller.settings(); + s.ownCallsign = QStringLiteral("OE5SOS"); + s.ownGrid = QStringLiteral("JN67UT"); + s.rigctldHost.clear(); + s.rotor1Enabled = false; + s.rotor2Enabled = false; + s.esmEnabled = false; + controller.setSettings(s); + + MainWindow fenster(controller); + // NICHT fenster.show(): genau der Fall "Panel ohne Hauptfenster". + + const QList eintraege = MainWindow::panelEintraege(); + QVERIFY(eintraege.size() >= 8); + for (const MainWindow::PanelEintrag& e : eintraege) { + QVERIFY2(fenster.panelFenster(e.id) != nullptr, + qPrintable(QStringLiteral("Panel '%1' aus der Liste ist nicht angemeldet").arg(e.id))); + QVERIFY(!e.titel.isEmpty()); + } + + QVERIFY(!fenster.istPanelSchwebend(QStringLiteral("chat"))); + fenster.setzePanelSchwebend(QStringLiteral("chat"), true); + QWidget* chat = fenster.panelFenster(QStringLiteral("chat")); + QVERIFY(chat); + QVERIFY(fenster.istPanelSchwebend(QStringLiteral("chat"))); + QVERIFY2(chat->isWindow(), "als eigenes Fenster geloest"); + QCOMPARE(chat->windowFlags() & Qt::WindowType_Mask, Qt::Tool); + QCOMPARE(chat->parentWidget(), &fenster); + QVERIFY(QTest::qWaitForWindowExposed(chat, 10000)); + QVERIFY2(chat->width() >= 160 && chat->height() >= 120, + qPrintable(QStringLiteral("Panel ohne Hauptfenster kam %1x%2 daher") + .arg(chat->width()).arg(chat->height()))); + QVERIFY2(!fenster.isVisible(), "das Hauptfenster bleibt dabei zu"); + + // Auch aus dem Seitenbereich heraus. + fenster.putPanelIntoSideAreaForTest(QStringLiteral("skeds")); + fenster.setzePanelSchwebend(QStringLiteral("skeds"), true); + QVERIFY(fenster.istPanelSchwebend(QStringLiteral("skeds"))); + QVERIFY(fenster.panelFenster(QStringLiteral("skeds"))->isWindow()); + + fenster.setzePanelSchwebend(QStringLiteral("chat"), false); + QVERIFY(!fenster.istPanelSchwebend(QStringLiteral("chat"))); + QVERIFY(!chat->isWindow()); + fenster.setzePanelSchwebend(QStringLiteral("skeds"), false); +} + +// Betreiber 2026-11-04: "alle panels haben hier noch runde kanten, dies +// bitte auf eckig umstellen." In Longpath schweben die Panels ohne +// Systemrahmen (FramelessWindowHint), eckig, und tragen den Rueckweg +// (↙) selbst, weil es das ✕ des Systems nicht mehr gibt. Eigenstaendig +// (Fahne aus) bleibt alles wie gehabt: Systemrahmen, kein ↙. +void TestEinbettung::rahmenlosSchwebendIstEckigMitRueckweg() +{ + QTemporaryDir ordner; + QVERIFY(ordner.isValid()); + AppController controller; + QString fehler; + QVERIFY2(controller.openDatabase(datenbankPfad(ordner.path()), &fehler), + qPrintable(fehler)); + ContestSettings s = controller.settings(); + s.ownCallsign = QStringLiteral("OE5SOS"); + s.ownGrid = QStringLiteral("JN67UT"); + s.rigctldHost.clear(); + s.rotor1Enabled = false; + s.rotor2Enabled = false; + s.esmEnabled = false; + controller.setSettings(s); + MainWindow fenster(controller); + + auto rueckweg = [](QWidget* panel) -> QPushButton* { + for (QPushButton* b : panel->findChildren()) { + if (b->objectName() == QStringLiteral("panelHeaderDockButton") + || b->objectName() == QStringLiteral("panelOverlayDockButton")) { + return b; + } + } + return nullptr; + }; + + // Eigenstaendig: Systemrahmen, kein Rueckweg in der Kopfzeile. + QVERIFY(!PanelContainerWidget::rahmenlosSchwebend()); + fenster.setzePanelSchwebend(QStringLiteral("chat"), true); + QWidget* chat = fenster.panelFenster(QStringLiteral("chat")); + QVERIFY(chat && chat->isWindow()); + QVERIFY(!(chat->windowFlags() & Qt::FramelessWindowHint)); + QPushButton* knopf = rueckweg(chat); + QVERIFY(!knopf || !knopf->isVisible()); + fenster.setzePanelSchwebend(QStringLiteral("chat"), false); + + // In Longpath: rahmenlos, eckig, ↙ sichtbar, und ↙ dockt zurueck. + PanelContainerWidget::setzeRahmenlosSchwebend(true); + fenster.setzePanelSchwebend(QStringLiteral("chat"), true); + QVERIFY(chat->isWindow()); + QVERIFY2(chat->windowFlags() & Qt::FramelessWindowHint, "ohne Systemrahmen"); + QVERIFY(chat->testAttribute(Qt::WA_MacAlwaysShowToolWindow)); + QVERIFY2(chat->styleSheet().contains(QStringLiteral("border-radius: 0px")), + qPrintable(QStringLiteral("eckig erwartet, Stil: %1").arg(chat->styleSheet()))); + knopf = rueckweg(chat); + QVERIFY2(knopf && knopf->isVisible(), "der Rueckweg (↙) muss da sein"); + knopf->click(); + QVERIFY2(!chat->isWindow(), "↙ dockt das Panel zurueck"); + QVERIFY(!(chat->windowFlags() & Qt::FramelessWindowHint)); + QVERIFY(!chat->styleSheet().contains(QStringLiteral("border-radius: 0px"))); + + // Auch das chromlose Panel (Karte) bekommt den Rueckweg. + fenster.setzePanelSchwebend(QStringLiteral("map"), true); + QWidget* karte = fenster.panelFenster(QStringLiteral("map")); + QVERIFY(karte && karte->isWindow()); + QPushButton* kartenKnopf = rueckweg(karte); + QVERIFY2(kartenKnopf && kartenKnopf->isVisible(), "auch die Karte braucht ↙"); + kartenKnopf->click(); + QVERIFY(!karte->isWindow()); + PanelContainerWidget::setzeRahmenlosSchwebend(false); +} + QTEST_MAIN(TestEinbettung) #include "test_einbettung.moc" diff --git a/tests/test_rotorwidget.cpp b/tests/test_rotorwidget.cpp index bb97c43..8d71e3c 100644 --- a/tests/test_rotorwidget.cpp +++ b/tests/test_rotorwidget.cpp @@ -757,16 +757,26 @@ void TestRotorWidgetReadout::minimumSizeHintFitsTheThreeColumnReadoutBlock() // 2026-09-21 ("hier sollten die rotoren auch kleiner werden und nicht // abgeschnitten sein"): the widget's own minimum is the DIAL's, not // the readout's -- two rotors must fit a 540px panel. At that - // minimum the readout gives way entirely (textAreaHeight() 0) rather - // than overlapping or clipping; at a middling width it is there in - // the smaller value font; at sizeHint() in full. + // minimum the readout used to give way entirely (textAreaHeight() 0). + // Seit 2026-11-04 ("die kaestchen fuer die gradanzahl bei rotoren + // koennen kleiner sein, so waere dann alles auch gemeinsam kleiner") + // schrumpfen die Kaestchen in drei Stufen mit der Breite: am + // Mindestmass ist das Ablesefeld DA, aber in der kleinen Stufe, + // niedriger als in voller Groesse; bei mittlerer Breite mittel; bei + // sizeHint() in voller Hoehe. Alte Fassung: 0 am Mindestmass. QVERIFY(widget.minimumSizeHint().width() < widestColumnContent * 3); widget.resize(widget.minimumSizeHint().width(), 400); - QCOMPARE(widget.textAreaHeightForTest(), 0); + const int klein = widget.textAreaHeightForTest(); + QVERIFY2(klein > 0, "am Mindestmass gibt es ein kleines Ablesefeld"); widget.resize(260, 400); - QVERIFY(widget.textAreaHeightForTest() > 0); - widget.resize(widget.sizeHint()); - QVERIFY(widget.textAreaHeightForTest() > 0); + const int mittel = widget.textAreaHeightForTest(); + QVERIFY(mittel > klein); + // Die grosse Stufe (38 px) braucht drei Spalten zu je ~102 px: erst + // ab ~330 px Breite, nicht schon bei sizeHint() (300). + widget.resize(420, 400); + const int gross = widget.textAreaHeightForTest(); + QVERIFY2(gross > mittel, qPrintable(QStringLiteral("klein %1, mittel %2, gross %3") + .arg(klein).arg(mittel).arg(gross))); widget.setConnected(true); widget.setAzimuthDeg(214.0); widget.resize(widget.minimumSizeHint().width(), 400); @@ -814,19 +824,25 @@ void TestRotorWidgetReadout::readoutGivesWayBeforeTheDialInALowPanel() QVERIFY(QTest::qWaitForWindowExposed(&widget)); // The dial shrinks first (down to its 150 px floor), then the - // readout: full at 362 and still at 292, one row less at 285, - // two at 265, none at the minimum. + // readout: one row less, two less, none at the minimum. Die Hoehen + // seit 2026-11-04 aus dem Block der aktuellen Stufe gerechnet (bei + // 320 px Breite die mittlere), nicht mehr feste Zahlen: Sockel = + // Kopf + Mindestflaeche des Zifferblatts = minimumSizeHint(). widget.resize(320, widget.sizeHint().height()); const int full = widget.textAreaHeightForTest(); QVERIFY(full > 0); - widget.resize(320, 292); + const int sockel = widget.minimumSizeHint().height(); + widget.resize(320, sockel + full + 14); QCOMPARE(widget.textAreaHeightForTest(), full); - widget.resize(320, 285); + widget.resize(320, sockel + full - 1); const int withoutStatus = widget.textAreaHeightForTest(); - QVERIFY(withoutStatus > 0 && withoutStatus < full); - widget.resize(320, 265); + QVERIFY2(withoutStatus > 0 && withoutStatus < full, + qPrintable(QStringLiteral("full %1, ohne Status %2").arg(full).arg(withoutStatus))); + widget.resize(320, sockel + withoutStatus - 1); const int withoutCaption = widget.textAreaHeightForTest(); - QVERIFY(withoutCaption > 0 && withoutCaption < withoutStatus); + QVERIFY2(withoutCaption > 0 && withoutCaption < withoutStatus, + qPrintable(QStringLiteral("ohne Status %1, ohne Beschriftung %2") + .arg(withoutStatus).arg(withoutCaption))); widget.resize(320, widget.minimumSizeHint().height()); QCOMPARE(widget.textAreaHeightForTest(), 0); auto* input = widget.findChild(QStringLiteral("rotorWidgetTargetInput")); diff --git a/tests/test_rotorzeile.cpp b/tests/test_rotorzeile.cpp new file mode 100644 index 0000000..5f55a35 --- /dev/null +++ b/tests/test_rotorzeile.cpp @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// tests/test_rotorzeile.cpp (Contestprogramm) +// +// Betreiber 2026-11-04: "das fenster rotoren muss sehr gross gezogen +// werden, um grad eigens zu sehen. bitte um loesungen, um fenster klein +// ziehen zu koennen." +// +// Die Rotorzeile (RotorRowWidget) stellt ihre Bedienfelder nebeneinander, +// wenn die Breite reicht, sonst untereinander; ihre Mindestgroesse ist +// die EINES Rotors. Alte Fassung (QHBoxLayout): Mindestbreite = Summe, +// nie untereinander -- Fall 1 und 2 fallen um. +// +// ================================================================= +// Modification history (Contestprogramm): +// 2026-11-04 -- Original von Martin Fischer, KI-gestuetzt ueber +// Anthropic Claude. +// ================================================================= +#include + +#include "ui/RotorRowWidget.h" +#include "ui/RotorWidget.h" + +using namespace Contestprogramm; + +class TestRotorzeile : public QObject { + Q_OBJECT + +private slots: + void dieMindestbreiteIstDieEinesRotors(); + void schmalUndHochStehenSieUntereinander(); + void breitStehenSieNebeneinander(); + void einEntferntesFeldFaelltHeraus(); +}; + +namespace { +struct Zeile { + RotorRowWidget row; + RotorWidget* r1; + RotorWidget* r2; + Zeile() + : r1(new RotorWidget(QStringLiteral("144"), &row)) + , r2(new RotorWidget(QStringLiteral("432"), &row)) + { + row.einfuegen(0, r1); + row.einfuegen(1, r2); + } +}; +} + +void TestRotorzeile::dieMindestbreiteIstDieEinesRotors() +{ + Zeile z; + const QSize einer = z.r1->minimumSizeHint(); + QVERIFY(einer.width() > 0 && einer.height() > 0); + QCOMPARE(z.row.minimumSizeHint().width(), einer.width()); + QVERIFY2(z.row.minimumSizeHint().width() < 2 * einer.width(), + "die Zeile darf nicht die Summe beider Breiten verlangen"); +} + +void TestRotorzeile::schmalUndHochStehenSieUntereinander() +{ + Zeile z; + const QSize einer = z.r1->minimumSizeHint(); + z.row.resize(einer.width() + 20, 2 * einer.height() + 60); + z.row.show(); + QVERIFY(QTest::qWaitForWindowExposed(&z.row, 10000)); + QVERIFY2(!z.row.nebeneinander(), "zu schmal fuer zwei nebeneinander"); + QVERIFY(z.r1->geometry().bottom() < z.r2->geometry().top()); + QCOMPARE(z.r1->geometry().left(), z.r2->geometry().left()); + QVERIFY(z.r1->width() >= einer.width()); + QVERIFY(z.r1->height() >= einer.height()); + QVERIFY(z.r2->height() >= einer.height()); +} + +void TestRotorzeile::breitStehenSieNebeneinander() +{ + Zeile z; + const QSize einer = z.r1->minimumSizeHint(); + z.row.resize(2 * einer.width() + 80, einer.height() + 40); + z.row.show(); + QVERIFY(QTest::qWaitForWindowExposed(&z.row, 10000)); + QVERIFY(z.row.nebeneinander()); + QVERIFY(z.r1->geometry().right() < z.r2->geometry().left()); + QCOMPARE(z.r1->geometry().top(), z.r2->geometry().top()); + QVERIFY(z.r1->width() >= einer.width() && z.r2->width() >= einer.width()); + + // Schmaler ziehen: sie wechseln untereinander, wenn die Hoehe reicht. + z.row.resize(einer.width() + 20, 2 * einer.height() + 60); + QCoreApplication::processEvents(); + QVERIFY(!z.row.nebeneinander()); +} + +void TestRotorzeile::einEntferntesFeldFaelltHeraus() +{ + Zeile z; + z.row.resize(600, 300); + z.row.show(); + QVERIFY(QTest::qWaitForWindowExposed(&z.row, 10000)); + QCOMPARE(z.row.anzahl(), 2); + z.row.entfernen(z.r2); + QCOMPARE(z.row.anzahl(), 1); + QCoreApplication::processEvents(); + QCOMPARE(z.r1->width(), z.row.width()); // der Rest bekommt die ganze Breite + delete z.r2; + z.r2 = nullptr; + QCOMPARE(z.row.anzahl(), 1); +} + +QTEST_MAIN(TestRotorzeile) +#include "test_rotorzeile.moc"