From 30c8783af5fd3c004f1c04f8228f4fbdfe5500d7 Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Sun, 17 Sep 2023 10:48:55 +0200 Subject: [PATCH] Online map: Double-Clicking the IBP callsign in the online map tunes the frequency --- Changelog | 1 + res/map/onlinemap.html | 21 ++++++++++++++++++--- ui/MapWebChannelHandler.cpp | 7 +++++++ ui/MapWebChannelHandler.h | 3 +++ ui/OnlineMapWidget.cpp | 11 +++++++++++ ui/OnlineMapWidget.h | 1 + 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index c4c4bde2..182c5d7a 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ TBC - 0.28.0 - [NEW] - Added ON4KST Chat Support - [NEW] - Added Az BeamWidth and Az Offset to Antenna Profile +- [NEW] - Double-Clicking the IBP callsign in the online map tunes the frequency - Fixed Browse button should open an expecting folder (issue #241) - Fixed Reword QSL buttons and Settings in QSO Details and Settings (issue #242) diff --git a/res/map/onlinemap.html b/res/map/onlinemap.html index cf39baed..351dd2a5 100644 --- a/res/map/onlinemap.html +++ b/res/map/onlinemap.html @@ -315,7 +315,13 @@ } // Definition for IBP - const band = ["20m", "17m","15m","12m","10m"]; + const band = [{band_name :"20m", freq : 14.1}, + {band_name :"17m", freq : 18.11}, + {band_name :"15m", freq : 21.15}, + {band_name :"12m", freq : 24.93}, + {band_name :"10m", freq : 28.2}, + ]; + const beacons = [{name: '4U1UN', lat: 40.7501, lon: -73.9682, active: true}, {name: 'VE8AT', lat: 79.9949, lon: -85.8451, active: true}, {name: 'W6WX', lat: 37.1599, lon: -121.9083, active: true}, @@ -334,10 +340,15 @@ {name: 'LU4AA', lat: -34.6439, lon: -58.4138, active: true}, {name: 'OA4B', lat: -12.0940, lon: -77.0165, active: true}, {name: 'YV5B', lat: 9.0964, lon: -67.8239, active: true}] - var currentBand=""; // to control which band is displayed + var currentBand=""; // to control which band is displayed - QLog core sets it. var IBPLayer = L.layerGroup().addTo(map); var prevStationIndex = -1; + function IBPCallsignPressed(e) { + let currentIndex = band.findIndex(object => {return object.band_name === currentBand;}); + foo.IBPCallsignClicked(this.callsign, band[currentIndex].freq); + } + // render IPB Beacon Point function beaconPoint(beacon, color) { let pointColor = color @@ -352,7 +363,11 @@ } let markerMirror = new L.marker([beacon.lat, mirrorLon], {opacity: 0.001 }); marker.bindTooltip(beacon.name, {permanent: true, direction : 'bottom', offset: [-16, 8], className: 'muf-tooltip' }); + marker.on('dblclick', IBPCallsignPressed); + marker.callsign = beacon.name; markerMirror.bindTooltip(beacon.name, {permanent: true, direction : 'bottom', offset: [-16, 8], className: 'muf-tooltip' }); + markerMirror.on('dblclick', IBPCallsignPressed); + markerMirror.callsign = beacon.name; marker.getTooltip().setContent(`
${marker.getTooltip().getContent()}
`); markerMirror.getTooltip().setContent(`
${markerMirror.getTooltip().getContent()}
`); IBPLayer.addLayer(marker); @@ -362,7 +377,7 @@ // Update IPB Beacon Points function updateBeacon() { - currentBandIndex = band.indexOf(currentBand); + currentBandIndex = band.findIndex(object => {return object.band_name === currentBand;}); if ( currentBandIndex == -1 ) { IBPLayer.clearLayers(); diff --git a/ui/MapWebChannelHandler.cpp b/ui/MapWebChannelHandler.cpp index 193cee4f..e5d27d67 100644 --- a/ui/MapWebChannelHandler.cpp +++ b/ui/MapWebChannelHandler.cpp @@ -189,3 +189,10 @@ void MapWebChannelHandler::chatCallsignClicked(const QVariant &data) emit chatCallsignPressed(data.toString()); } + +void MapWebChannelHandler::IBPCallsignClicked(const QVariant &callsign, const QVariant &freq) +{ + FCT_IDENTIFICATION; + + emit IBPPressed(callsign.toString(), freq.toDouble()); +} diff --git a/ui/MapWebChannelHandler.h b/ui/MapWebChannelHandler.h index dfe782a7..7477cb2d 100644 --- a/ui/MapWebChannelHandler.h +++ b/ui/MapWebChannelHandler.h @@ -21,11 +21,14 @@ class MapWebChannelHandler : public QObject signals: void chatCallsignPressed(QString); + void IBPPressed(QString, double); public slots: void handleLayerSelectionChanged(const QVariant &data, const QVariant &state); void chatCallsignClicked(const QVariant &data); + void IBPCallsignClicked(const QVariant &callsign, + const QVariant &freq); private: QString configID; diff --git a/ui/OnlineMapWidget.cpp b/ui/OnlineMapWidget.cpp index b91cd6a0..878fbf49 100644 --- a/ui/OnlineMapWidget.cpp +++ b/ui/OnlineMapWidget.cpp @@ -17,6 +17,7 @@ #include "data/Band.h" #include "data/Data.h" #include "core/Rotator.h" +#include "core/Rig.h" MODULE_IDENTIFICATION("qlog.ui.onlinemapwidget"); @@ -54,6 +55,7 @@ OnlineMapWidget::OnlineMapWidget(QWidget *parent): connect(Rotator::instance(), &Rotator::rotConnected, this, &OnlineMapWidget::rotConnected); connect(Rotator::instance(), &Rotator::rotDisconnected, this, &OnlineMapWidget::rotDisconnected); connect(&webChannelHandler, &MapWebChannelHandler::chatCallsignPressed, this, &OnlineMapWidget::chatCallsignTrigger); + connect(&webChannelHandler, &MapWebChannelHandler::IBPPressed, this, &OnlineMapWidget::IBPCallsignTrigger); } void OnlineMapWidget::setTarget(double lat, double lon) @@ -287,6 +289,15 @@ void OnlineMapWidget::chatCallsignTrigger(QString callsign) emit chatCallsignPressed(callsign); } +void OnlineMapWidget::IBPCallsignTrigger(const QString &callsign, double freq) +{ + FCT_IDENTIFICATION; + + qCDebug(function_parameters) << callsign << freq; + + Rig::instance()->setFrequency(MHz(freq)); +} + void OnlineMapWidget::runJavaScript(QString &js) { FCT_IDENTIFICATION; diff --git a/ui/OnlineMapWidget.h b/ui/OnlineMapWidget.h index 658d5a6f..cdc70cde 100644 --- a/ui/OnlineMapWidget.h +++ b/ui/OnlineMapWidget.h @@ -44,6 +44,7 @@ public slots: protected slots: void finishLoading(bool); void chatCallsignTrigger(QString); + void IBPCallsignTrigger(const QString&, double); private: