-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogsetup.cpp
130 lines (114 loc) · 5.12 KB
/
dialogsetup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
** This file is part of the CatRotator project.
** Copyright 2022-2024 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
**
** 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, either 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 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/>.
**/
#include "dialogsetup.h"
#include "ui_dialogsetup.h"
#include "rotatordata.h"
#include <QSettings>
#include <QFile>
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
extern catRotatorConfig rotCfg;
DialogSetup::DialogSetup(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogSetup)
{
ui->setupUi(this);
//* Set config
ui->lineEdit_qthLocator->setText(rotCfg.qthLocator);
ui->checkBox_udp->setChecked(rotCfg.udp);
ui->lineEdit_udpAddress->setText(rotCfg.udpAddress);
ui->lineEdit_udpPort->setText(QString::number(rotCfg.udpPort));
ui->lineEdit_WSJTXStatus->setText(rotCfg.pathTrackWSJTXStatus);
ui->lineEdit_WSJTX->setText(rotCfg.pathTrackWSJTX);
ui->lineEdit_AirScout->setText(rotCfg.pathTrackAirScout);
ui->radioButton_themeDark->setChecked(rotCfg.darkTheme);
ui->checkBox_autoConnect->setChecked(rotCfg.autoConnect);
ui->checkBox_debug->setChecked(rotCfg.debugMode);
}
DialogSetup::~DialogSetup()
{
delete ui;
}
void DialogSetup::on_pushButton_udpDefault_clicked() //Set default UDP address and port
{
ui->lineEdit_udpAddress->setText("127.0.0.1");
ui->lineEdit_udpPort->setText("12000");
}
void DialogSetup::on_pushButton_AirScout_clicked()
{
//QString fileTrackAirScout = QFileDialog::getOpenFileName(this, "Set file", rotCfg.pathTrackAirScout);
rotCfg.pathTrackAirScout = QFileDialog::getExistingDirectory(this, "Set path", rotCfg.pathTrackAirScout);
//fileTrackAirScout = fileTrackAirScout + "/azel.dat";
ui->lineEdit_AirScout->setText(rotCfg.pathTrackAirScout);
}
void DialogSetup::on_pushButton_WSJTXStatus_clicked()
{
rotCfg.pathTrackWSJTXStatus = QFileDialog::getExistingDirectory(this, "Set path", rotCfg.pathTrackWSJTXStatus);
ui->lineEdit_WSJTXStatus->setText(rotCfg.pathTrackWSJTXStatus);
}
void DialogSetup::on_pushButton_WSJTX_clicked()
{
rotCfg.pathTrackWSJTX = QFileDialog::getExistingDirectory(this, "Set path", rotCfg.pathTrackWSJTX);
ui->lineEdit_WSJTX->setText(rotCfg.pathTrackWSJTX);
}
void DialogSetup::on_buttonBox_accepted()
{
//MessageBox to restart if UDP config is changed
if ((rotCfg.udp != ui->checkBox_udp->isChecked()) || (rotCfg.udpAddress != ui->lineEdit_udpAddress->text()) || (rotCfg.udpPort != ui->lineEdit_udpPort->text().toUShort()))
{
QMessageBox msgBox;
msgBox.setWindowTitle("UDP");
msgBox.setText("Please, restart CatRotator to make effective the UDP setup changes.");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
if ((rotCfg.darkTheme != ui->radioButton_themeDark->isChecked()))
{
QMessageBox msgBox;
msgBox.setWindowTitle("Theme");
msgBox.setText("Please, restart CatRotator to make effective the theme.");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
//* Load config from dialog
rotCfg.qthLocator = ui->lineEdit_qthLocator->text();
rotCfg.udp = ui->checkBox_udp->isChecked();
rotCfg.udpAddress = ui->lineEdit_udpAddress->text();
rotCfg.udpPort = ui->lineEdit_udpPort->text().toUShort();
rotCfg.pathTrackWSJTXStatus = ui->lineEdit_WSJTXStatus->text();
rotCfg.pathTrackWSJTX = ui->lineEdit_WSJTX->text();
rotCfg.pathTrackAirScout = ui->lineEdit_AirScout->text();
rotCfg.darkTheme = ui->radioButton_themeDark->isChecked();
rotCfg.autoConnect = ui->checkBox_autoConnect->isChecked();
rotCfg.debugMode = ui->checkBox_debug->isChecked();
//* Save settings in catrotator.ini
QSettings configFile(QString("catrotator.ini"), QSettings::IniFormat);
configFile.setValue("qthLocator", rotCfg.qthLocator);
configFile.setValue("udp", rotCfg.udp);
configFile.setValue("udpAddress", rotCfg.udpAddress);
configFile.setValue("udpPort", rotCfg.udpPort);
configFile.setValue("pathTrackWSJTXStatus", rotCfg.pathTrackWSJTXStatus);
configFile.setValue("pathTrackWSJTX", rotCfg.pathTrackWSJTX);
configFile.setValue("pathTrackAirScout", rotCfg.pathTrackAirScout);
configFile.setValue("darkTheme", rotCfg.darkTheme);
configFile.setValue("autoConnect", rotCfg.autoConnect);
configFile.setValue("debugMode", rotCfg.debugMode);
}