2021-02-26 15:25:48 -05:00
///////////////////////////////////////////////////////////////////////////////////
2023-11-18 07:12:18 -05:00
// Copyright (C) 2021-2023 Jon Beniston, M7RCE <jon@beniston.com> //
2021-02-26 15:25:48 -05:00
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
2024-04-08 16:40:24 -04:00
# include "util/units.h"
2021-02-26 15:25:48 -05:00
# include "satellitetrackersettingsdialog.h"
# include <QDebug>
2024-06-04 18:08:20 -04:00
# include <QMessageBox>
2021-02-26 15:25:48 -05:00
SatelliteTrackerSettingsDialog : : SatelliteTrackerSettingsDialog ( SatelliteTrackerSettings * settings ,
QWidget * parent ) :
QDialog ( parent ) ,
m_settings ( settings ) ,
ui ( new Ui : : SatelliteTrackerSettingsDialog )
{
ui - > setupUi ( this ) ;
ui - > height - > setValue ( settings - > m_heightAboveSeaLevel ) ;
ui - > predictionPeriod - > setValue ( settings - > m_predictionPeriod ) ;
ui - > passStartTime - > setTime ( settings - > m_passStartTime ) ;
ui - > passFinishTime - > setTime ( settings - > m_passFinishTime ) ;
ui - > minimumAOSElevation - > setValue ( settings - > m_minAOSElevation ) ;
ui - > minimumPassElevation - > setValue ( settings - > m_minPassElevation ) ;
ui - > aosSpeech - > setText ( settings - > m_aosSpeech ) ;
ui - > losSpeech - > setText ( settings - > m_losSpeech ) ;
2021-05-16 04:18:42 -04:00
ui - > rotatorMaximumAzimuth - > setValue ( settings - > m_rotatorMaxAzimuth ) ;
ui - > rotatorMaximumElevation - > setValue ( settings - > m_rotatorMaxElevation ) ;
2023-05-20 02:57:19 -04:00
ui - > azimuthOffset - > setValue ( settings - > m_azimuthOffset ) ;
ui - > elevationOffset - > setValue ( settings - > m_elevationOffset ) ;
2021-02-26 15:25:48 -05:00
ui - > aosCommand - > setText ( settings - > m_aosCommand ) ;
ui - > losCommand - > setText ( settings - > m_losCommand ) ;
ui - > updatePeriod - > setValue ( settings - > m_updatePeriod ) ;
ui - > dopplerPeriod - > setValue ( settings - > m_dopplerPeriod ) ;
ui - > defaultFrequency - > setValue ( settings - > m_defaultFrequency / 1000000.0 ) ;
ui - > azElUnits - > setCurrentIndex ( ( int ) settings - > m_azElUnits ) ;
ui - > groundTrackPoints - > setValue ( settings - > m_groundTrackPoints ) ;
2023-04-03 11:53:51 -04:00
ui - > drawRotators - > setCurrentIndex ( ( int ) settings - > m_drawRotators ) ;
2021-02-26 15:25:48 -05:00
ui - > dateFormat - > setText ( settings - > m_dateFormat ) ;
ui - > utc - > setChecked ( settings - > m_utc ) ;
ui - > drawOnMap - > setChecked ( settings - > m_drawOnMap ) ;
2024-06-04 18:06:19 -04:00
updateTleWidget ( settings - > m_tles ) ;
2022-02-04 12:14:12 -05:00
ui - > replayEnabled - > setChecked ( settings - > m_replayEnabled ) ;
ui - > replayDateTime - > setDateTime ( settings - > m_replayStartDateTime ) ;
ui - > sendTimeToMap - > setChecked ( settings - > m_sendTimeToMap ) ;
2021-02-26 15:25:48 -05:00
}
SatelliteTrackerSettingsDialog : : ~ SatelliteTrackerSettingsDialog ( )
{
delete ui ;
}
2024-06-04 18:06:19 -04:00
void SatelliteTrackerSettingsDialog : : updateTleWidget ( QList < QString > tles )
{
for ( int i = 0 ; i < tles . size ( ) ; i + + )
{
QListWidgetItem * item = new QListWidgetItem ( tles [ i ] ) ;
item - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEditable | Qt : : ItemIsEnabled ) ;
ui - > tles - > addItem ( item ) ;
}
}
2021-02-26 15:25:48 -05:00
void SatelliteTrackerSettingsDialog : : on_addTle_clicked ( )
{
2024-06-04 16:34:36 -04:00
QListWidgetItem * item = new QListWidgetItem ( " https:// " ) ;
2021-02-26 15:25:48 -05:00
item - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEditable | Qt : : ItemIsEnabled ) ;
ui - > tles - > addItem ( item ) ;
}
void SatelliteTrackerSettingsDialog : : on_removeTle_clicked ( )
{
QList < QListWidgetItem * > items = ui - > tles - > selectedItems ( ) ;
for ( int i = 0 ; i < items . size ( ) ; i + + )
delete items [ i ] ;
}
2024-06-04 18:08:20 -04:00
void SatelliteTrackerSettingsDialog : : on_defaultTles_clicked ( )
{
QMessageBox : : StandardButton reply ;
2024-07-10 16:59:13 -04:00
reply = QMessageBox : : question ( this , " Confirm overwrite " , " Replace the current TLE list with the default? " , QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : No ) ;
2024-06-04 18:08:20 -04:00
if ( reply = = QMessageBox : : Yes ) {
ui - > tles - > clear ( ) ;
updateTleWidget ( DEFAULT_TLES ) ;
}
}
2021-02-26 15:25:48 -05:00
void SatelliteTrackerSettingsDialog : : accept ( )
{
m_settings - > m_heightAboveSeaLevel = ui - > height - > value ( ) ;
m_settings - > m_predictionPeriod = ui - > predictionPeriod - > value ( ) ;
m_settings - > m_passStartTime = ui - > passStartTime - > time ( ) ;
m_settings - > m_passFinishTime = ui - > passFinishTime - > time ( ) ;
m_settings - > m_minAOSElevation = ui - > minimumAOSElevation - > value ( ) ;
m_settings - > m_minPassElevation = ui - > minimumPassElevation - > value ( ) ;
2021-05-16 04:18:42 -04:00
m_settings - > m_rotatorMaxAzimuth = ui - > rotatorMaximumAzimuth - > value ( ) ;
m_settings - > m_rotatorMaxElevation = ui - > rotatorMaximumElevation - > value ( ) ;
2023-05-20 02:57:19 -04:00
m_settings - > m_azimuthOffset = ui - > azimuthOffset - > value ( ) ;
m_settings - > m_elevationOffset = ui - > elevationOffset - > value ( ) ;
2021-02-26 15:25:48 -05:00
m_settings - > m_aosSpeech = ui - > aosSpeech - > text ( ) ;
m_settings - > m_losSpeech = ui - > losSpeech - > text ( ) ;
m_settings - > m_aosCommand = ui - > aosCommand - > text ( ) ;
m_settings - > m_losCommand = ui - > losCommand - > text ( ) ;
m_settings - > m_updatePeriod = ( float ) ui - > updatePeriod - > value ( ) ;
m_settings - > m_dopplerPeriod = ( float ) ui - > dopplerPeriod - > value ( ) ;
m_settings - > m_defaultFrequency = ( float ) ( ui - > defaultFrequency - > value ( ) * 1000000.0 ) ;
m_settings - > m_azElUnits = ( SatelliteTrackerSettings : : AzElUnits ) ui - > azElUnits - > currentIndex ( ) ;
m_settings - > m_groundTrackPoints = ui - > groundTrackPoints - > value ( ) ;
2023-04-03 11:53:51 -04:00
m_settings - > m_drawRotators = ( SatelliteTrackerSettings : : Rotators ) ui - > drawRotators - > currentIndex ( ) ;
2021-02-26 15:25:48 -05:00
m_settings - > m_dateFormat = ui - > dateFormat - > text ( ) ;
m_settings - > m_utc = ui - > utc - > isChecked ( ) ;
m_settings - > m_drawOnMap = ui - > drawOnMap - > isChecked ( ) ;
m_settings - > m_tles . clear ( ) ;
2022-02-04 12:14:12 -05:00
for ( int i = 0 ; i < ui - > tles - > count ( ) ; i + + ) {
2021-02-26 15:25:48 -05:00
m_settings - > m_tles . append ( ui - > tles - > item ( i ) - > text ( ) ) ;
2022-02-04 12:14:12 -05:00
}
m_settings - > m_replayEnabled = ui - > replayEnabled - > isChecked ( ) ;
m_settings - > m_replayStartDateTime = ui - > replayDateTime - > dateTime ( ) ;
m_settings - > m_sendTimeToMap = ui - > sendTimeToMap - > isChecked ( ) ;
2021-02-26 15:25:48 -05:00
QDialog : : accept ( ) ;
}