CustomQuickInterface.cc 2.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/****************************************************************************
 *
 * (c) 2009-2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 * @file
 *   @brief Custom QtQuick Interface
 *   @author Gus Grubba <gus@auterion.com>
 */

#include "QGCApplication.h"
#include "AppSettings.h"
#include "SettingsManager.h"
#include "MAVLinkLogManager.h"
#include "QGCMapEngine.h"
#include "QGCApplication.h"
#include "PositionManager.h"

#include "CustomPlugin.h"
#include "CustomQuickInterface.h"

Gus Grubba's avatar
Gus Grubba committed
24 25 26 27
#include <QSettings>

static const char* kGroupName       = "CustomSettings";
static const char* kShowGimbalCtl   = "ShowGimbalCtl";
28
static const char* kShowAttitudeWidget = "ShowAttitudeWidget";
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

//-----------------------------------------------------------------------------
CustomQuickInterface::CustomQuickInterface(QObject* parent)
    : QObject(parent)
{
    qCDebug(CustomLog) << "CustomQuickInterface Created";
}

//-----------------------------------------------------------------------------
CustomQuickInterface::~CustomQuickInterface()
{
    qCDebug(CustomLog) << "CustomQuickInterface Destroyed";
}

//-----------------------------------------------------------------------------
void
CustomQuickInterface::init()
{
Gus Grubba's avatar
Gus Grubba committed
47 48
    QSettings settings;
    settings.beginGroup(kGroupName);
49 50
    _showGimbalControl = settings.value(kShowGimbalCtl, false).toBool();
    _showAttitudeWidget = settings.value(kShowAttitudeWidget, false).toBool();
Gus Grubba's avatar
Gus Grubba committed
51 52 53 54 55 56 57 58 59 60 61 62 63
}

//-----------------------------------------------------------------------------
void
CustomQuickInterface::setShowGimbalControl(bool set)
{
    if(_showGimbalControl != set) {
        _showGimbalControl = set;
        QSettings settings;
        settings.beginGroup(kGroupName);
        settings.setValue(kShowGimbalCtl,set);
        emit showGimbalControlChanged();
    }
64
}
65 66 67 68 69 70 71 72 73 74 75 76 77

//-----------------------------------------------------------------------------
void
CustomQuickInterface::setShowAttitudeWidget(bool set)
{
    if(_showAttitudeWidget != set) {
        _showAttitudeWidget = set;
        QSettings settings;
        settings.beginGroup(kGroupName);
        settings.setValue(kShowAttitudeWidget,set);
        emit showAttitudeWidgetChanged();
    }
}