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
#include <QSettings>
#include "QGCSettingsWidget.h"
#include "MainWindow.h"
#include "ui_QGCSettingsWidget.h"
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
#include "MAVLinkSettingsWidget.h"
#include "GAudioOutput.h"
//, Qt::WindowFlags flags
QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags),
ui(new Ui::QGCSettingsWidget)
{
ui->setupUi(this);
// Add all protocols
QList<ProtocolInterface*> protocols = LinkManager::instance()->getProtocols();
foreach (ProtocolInterface* protocol, protocols) {
MAVLinkProtocol* mavlink = dynamic_cast<MAVLinkProtocol*>(protocol);
if (mavlink) {
MAVLinkSettingsWidget* msettings = new MAVLinkSettingsWidget(mavlink, this);
ui->tabWidget->addTab(msettings, "MAVLink");
}
}
this->window()->setWindowTitle(tr("QGroundControl Settings"));
// Audio preferences
ui->audioMuteCheckBox->setChecked(GAudioOutput::instance()->isMuted());
connect(ui->audioMuteCheckBox, SIGNAL(toggled(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
connect(GAudioOutput::instance(), SIGNAL(mutedChanged(bool)), ui->audioMuteCheckBox, SLOT(setChecked(bool)));
// Reconnect
ui->reconnectCheckBox->setChecked(MainWindow::instance()->autoReconnectEnabled());
connect(ui->reconnectCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableAutoReconnect(bool)));
// Low power mode
ui->lowPowerCheckBox->setChecked(MainWindow::instance()->lowPowerModeEnabled());
connect(ui->lowPowerCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableLowPowerMode(bool)));
// Style
MainWindow::QGC_MAINWINDOW_STYLE style = (MainWindow::QGC_MAINWINDOW_STYLE)MainWindow::instance()->getStyle();
switch (style) {
case MainWindow::QGC_MAINWINDOW_STYLE_NATIVE:
ui->nativeStyle->setChecked(true);
break;
case MainWindow::QGC_MAINWINDOW_STYLE_INDOOR:
ui->indoorStyle->setChecked(true);
break;
case MainWindow::QGC_MAINWINDOW_STYLE_OUTDOOR:
ui->outdoorStyle->setChecked(true);
break;
}
connect(ui->nativeStyle, SIGNAL(clicked()), MainWindow::instance(), SLOT(loadNativeStyle()));
connect(ui->indoorStyle, SIGNAL(clicked()), MainWindow::instance(), SLOT(loadIndoorStyle()));
connect(ui->outdoorStyle, SIGNAL(clicked()), MainWindow::instance(), SLOT(loadOutdoorStyle()));
// Close / destroy
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(deleteLater()));
// Set layout options
ui->generalPaneGridLayout->setAlignment(Qt::AlignTop);
}
QGCSettingsWidget::~QGCSettingsWidget()
{
delete ui;
}