QGCSettingsWidget.cc 2.44 KB
Newer Older
1 2
#include <QSettings>

lm's avatar
lm committed
3
#include "QGCSettingsWidget.h"
4
#include "MainWindow.h"
lm's avatar
lm committed
5 6
#include "ui_QGCSettingsWidget.h"

7 8 9
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
#include "MAVLinkSettingsWidget.h"
10
#include "GAudioOutput.h"
11 12 13 14 15

//, Qt::WindowFlags flags

QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
    QDialog(parent, flags),
lm's avatar
lm committed
16 17 18
    ui(new Ui::QGCSettingsWidget)
{
    ui->setupUi(this);
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

    // 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"));

34 35 36 37 38
    // 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)));

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    // Reconnect
    ui->reconnectCheckBox->setChecked(MainWindow::instance()->autoReconnectEnabled());
    connect(ui->reconnectCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableAutoReconnect(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()));

61 62
    // Close / destroy
    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(deleteLater()));
63 64 65

    // Set layout options
    ui->generalPaneGridLayout->setAlignment(Qt::AlignTop);
lm's avatar
lm committed
66 67 68 69 70 71
}

QGCSettingsWidget::~QGCSettingsWidget()
{
    delete ui;
}