-
Notifications
You must be signed in to change notification settings - Fork 15
/
mainwindow_actions.cpp
215 lines (185 loc) · 6.87 KB
/
mainwindow_actions.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#include "mainwindow.h"
#include "querier.h"
#include "ui_mainwindow.h"
#include "fmtx.h"
#include "logging.h"
/******************************************************************
* Various Mainwindow actions
******************************************************************/
void MainWindow::retranslateUi()
{
int backup1, backup2, backup3, backup4, backup5, backup6, backup7, backup8, backup9, backup10, backup11;
//Worakaround for: QTBUG-3863
backup1 = ui->comboBox_audioCompressorReleasetime->currentIndex();
backup2 = ui->comboBox_audioPreset->currentIndex();
backup3 = ui->comboBox_rds_ps_percentage->currentIndex();
backup4 = ui->comboBox_rds_pty->currentIndex();
backup5 = ui->comboBox_rds_content1_type->currentIndex();
backup6 = ui->comboBox_rds_content2_type->currentIndex();
backup7 = ui->comboBox_rds_content3_type->currentIndex();
backup8 = ui->comboBox_rds_content4_type->currentIndex();
backup9 = ui->comboBox_transmitter_preemph->currentIndex();
backup10 = ui->comboBox_audio_input_level->currentIndex();
backup11 = ui->comboBox_audio_input_mute->currentIndex();
ui->retranslateUi(this);
ui->comboBox_audioCompressorReleasetime->setCurrentIndex(backup1);
ui->comboBox_audioCompressorReleasetime->setCurrentIndex(backup1);
ui->comboBox_audioPreset->setCurrentIndex(backup2);
ui->comboBox_rds_ps_percentage->setCurrentIndex(backup3);
ui->comboBox_rds_pty->setCurrentIndex(backup4);
ui->comboBox_rds_content1_type->setCurrentIndex(backup5);
ui->comboBox_rds_content2_type->setCurrentIndex(backup6);
ui->comboBox_rds_content3_type->setCurrentIndex(backup7);
ui->comboBox_rds_content4_type->setCurrentIndex(backup8);
ui->comboBox_transmitter_preemph->setCurrentIndex(backup9);
ui->comboBox_audio_input_level->setCurrentIndex(backup10);
ui->comboBox_audio_input_mute->setCurrentIndex(backup11);
//menu->setTitle(tr("File"));
//fileAction->setText(tr("First action"));
}
void MainWindow::toggleLiveEditing(bool bVal)
{
if(deviceStatus)
liveEditingEnabled = bVal;
}
void MainWindow::toggleConnection(bool bVal, bool toggleQuerier)
{
qDebug() << __FUNCTION__ << ": " << bVal;
/* actions */
ui->actionRead_from_Device->setEnabled(bVal);
ui->actionRead_from_EEPROM->setEnabled(bVal);
ui->actionWrite_to_Device->setEnabled(bVal);
ui->actionWrite_to_EEPROM->setEnabled(bVal);
ui->actionToggle_transmission->setEnabled(bVal);
/* hardware buttons */
ui->checkBox_hw_run_txAtPowerUp->setEnabled(bVal);
ui->pushButton_fe_powerdown->setEnabled(bVal);
ui->pushButton_fe_powerup->setEnabled(bVal);
ui->pushButton_fe_reset->setEnabled(bVal);
ui->pushButton_open_firmware->setEnabled(bVal);
if(bVal) {
if(ui->checkBox_rds_fifo->isChecked()) {
ui->groupBox_rds_sendmsg->setEnabled(bVal);
}
if(toggleQuerier)
querier->timer.start();
SetTransmitIcon(ICON_WARN);
ui->actionConnect_to_device->setText("Disconnect?");
ui->actionConnect_to_device->setIcon(QIcon(":/fmstick/images/connect_32.png"));
} else {
ui->groupBox_rds_sendmsg->setEnabled(bVal);
if(toggleQuerier) {
querier->timer.stop();
}
SetTransmitIcon(ICON_NODEV);
ui->actionConnect_to_device->setIcon(QIcon(":/fmstick/images/disconnect_32.png"));
ui->actionConnect_to_device->setText("Connect?");
}
deviceStatus = bVal;
}
void MainWindow::SetFrontendPowerDown() {
qDebug() << __FUNCTION__;
if(fmtxIoAppFeDown() != FMTX_MODE_POWER_DOWN) {
qDebug() << "error while powering down";
}
SetTransmitIcon(ICON_WARN);
querier->is_ready=false;
liveEditingEnabled=false;
ui->actionRead_from_Device->setEnabled(false);
ui->actionWrite_to_Device->setEnabled(false);
fmtxCmdStatus=FMTX_MODE_NONE;
}
int MainWindow::SetFrontendPowerUp() {
int ret;
qDebug() << __FUNCTION__;
querier->HidAccessMutex.lock();
ret = fmtxIoAppFeUp();
querier->HidAccessMutex.unlock();
switch(ret){
case FMTX_MODE_POWER_UP:
qDebug() << "Frontend powered up!";
SetTransmitIcon(ICON_NOTX);
fmtxCmdStatus=FMTX_MODE_OK;
break;
case FMTX_MODE_TRANSMITTING:
qDebug() << "Frontend already powered up!";
SetTransmitIcon(ICON_TX);
fmtxCmdStatus=FMTX_MODE_OK;
break;
default:
qDebug() << "Error while powering up";
fmtxCmdStatus=FMTX_MODE_NONE;
break;
}
if(ret == FMTX_MODE_POWER_UP || ret == FMTX_MODE_TRANSMITTING) {
querier->is_ready=true;
liveEditingEnabled=ui->checkBox_sw_live_edit->isChecked();
ui->actionRead_from_Device->setEnabled(true);
ui->actionWrite_to_Device->setEnabled(true);
}
return ret;
}
void MainWindow::SetFrontendReset() {
qDebug() << __FUNCTION__;
if(fmtxIoAppFeReset() != FMTX_MODE_POWER_DOWN)
qDebug() << "Error while resetting frontend";
querier->is_ready=false;
liveEditingEnabled=false;
SetTransmitIcon(ICON_WARN);
ui->actionRead_from_Device->setEnabled(false);
ui->actionWrite_to_Device->setEnabled(false);
fmtxCmdStatus=FMTX_MODE_NONE;
}
void MainWindow::StationButtonClicked()
{
qDebug() << __FUNCTION__;
bool is_checked = ui->checkBox_transmitter_enabled->isChecked();
ui->checkBox_transmitter_enabled->setChecked(!is_checked);
}
int MainWindow::GetFrontendParams()
{
qDebug() << __FUNCTION__;
liveEditingEnabled=false;
DisplayAudioEditor();
if(fmtxCmdStatus!=FMTX_MODE_OK)
goto frontend_params_err;
DisplayTransmitterEditor();
if(fmtxCmdStatus!=FMTX_MODE_OK)
goto frontend_params_err;
DisplayRDSEditor();
if(fmtxCmdStatus!=FMTX_MODE_OK)
goto frontend_params_err;
liveEditingEnabled=ui->checkBox_sw_live_edit->isChecked();
/* run querier, so we can read interrupts and send rds timestamps */
return fmtxCmdStatus;
frontend_params_err:
liveEditingEnabled=false;
qDebug() << "Can't get frontend parameters";
SetTransmitIcon(ICON_ERR);
return fmtxCmdStatus;
}
int MainWindow::SetFrontendParams()
{
qDebug() << __FUNCTION__;
liveEditingEnabled=true;
ConfigureAudioEditor();
if(fmtxCmdStatus!=FMTX_MODE_OK)
goto frontend_params_err;
ConfigureTransmitterEditor();
if(fmtxCmdStatus!=FMTX_MODE_OK)
goto frontend_params_err;
ConfigureRDSEditor();
if(fmtxCmdStatus!=FMTX_MODE_OK)
goto frontend_params_err;
if(!SetDigitalAudioHack())
goto frontend_params_err;
/* run querier, so we can read interrupts and send rds timestamps */
qDebug() << "Frontend parameters setted correctly.";
liveEditingEnabled=ui->checkBox_sw_live_edit->isChecked();
return fmtxCmdStatus;
frontend_params_err:
liveEditingEnabled=false;
qDebug() << "Can't set frontend parameters";
SetTransmitIcon(ICON_ERR);
return fmtxCmdStatus;
}