mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
CC-33 Now the config panel only shows the relevant panel once the board is connected.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3105 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
06826840aa
commit
b125e51251
@ -13,58 +13,138 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>281</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="zeroBias">
|
||||
<property name="text">
|
||||
<string>Zero Accel Bias</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="zeroBiasProgress">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>281</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Place aircraft flat before computing</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="saveButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>80</y>
|
||||
<width>114</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save to SD</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CopterControl Attitude Calibration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Place aircraft flat before computing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="zeroBias">
|
||||
<property name="toolTip">
|
||||
<string>Launch horizontal calibration.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zero Accel Bias</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="zeroBiasProgress">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="status">
|
||||
<property name="text">
|
||||
<string>Click "Zero Accel Bias" to start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="saveButton">
|
||||
<property name="toolTip">
|
||||
<string>Click to permanently save the accel bias in the CopterControl Flash.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save to SD</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -32,7 +32,8 @@ HEADERS += configplugin.h \
|
||||
configccpmwidget.h \
|
||||
configstabilizationwidget.h \
|
||||
assertions.h \
|
||||
calibration.h
|
||||
calibration.h \
|
||||
defaultattitudewidget.h
|
||||
|
||||
SOURCES += configplugin.cpp \
|
||||
configgadgetconfiguration.cpp \
|
||||
@ -57,6 +58,7 @@ SOURCES += configplugin.cpp \
|
||||
legacy-calibration.cpp \
|
||||
gyro-calibration.cpp \
|
||||
alignment-calibration.cpp \
|
||||
defaultattitudewidget.cpp
|
||||
|
||||
FORMS += \
|
||||
airframe.ui \
|
||||
@ -66,6 +68,7 @@ FORMS += \
|
||||
stabilization.ui \
|
||||
input.ui \
|
||||
output.ui \
|
||||
ccattitude.ui
|
||||
ccattitude.ui \
|
||||
defaultattitude.ui
|
||||
|
||||
RESOURCES += configgadget.qrc
|
||||
|
@ -73,6 +73,8 @@ void ConfigCCAttitudeWidget::attitudeRawUpdated(UAVObject * obj) {
|
||||
field->setDouble(field->getDouble(1) + y_bias,1);
|
||||
field->setDouble(field->getDouble(2) + z_bias,2);
|
||||
settings->updated();
|
||||
ui->status->setText("Calibration done.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,6 +98,8 @@ void ConfigCCAttitudeWidget::startAccelCalibration() {
|
||||
y_accum.clear();
|
||||
z_accum.clear();
|
||||
|
||||
ui->status->setText("Calibrating...");
|
||||
|
||||
// Set up to receive updates
|
||||
UAVDataObject * obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AttitudeRaw")));
|
||||
connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(attitudeRawUpdated(UAVObject*)));
|
||||
|
@ -1,30 +1,30 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGFACTORY_H
|
||||
#define CONFIGFACTORY_H
|
||||
|
||||
#endif // CONFIGFACTORY_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGFACTORY_H
|
||||
#define CONFIGFACTORY_H
|
||||
|
||||
#endif // CONFIGFACTORY_H
|
||||
|
@ -1,57 +1,57 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGET_H
|
||||
#define CONFIGGADGET_H
|
||||
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
#include "configgadgetwidget.h"
|
||||
|
||||
class IUAVGadget;
|
||||
//class QList<int>;
|
||||
class QWidget;
|
||||
class QString;
|
||||
class ConfigGadgetWidget;
|
||||
class Ui_ConfigGadget;
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigGadget(QString classId, ConfigGadgetWidget *widget, QWidget *parent = 0);
|
||||
~ConfigGadget();
|
||||
|
||||
QWidget *widget() { return m_widget; }
|
||||
void loadConfiguration(IUAVGadgetConfiguration* config);
|
||||
|
||||
private:
|
||||
ConfigGadgetWidget *m_widget;
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGGADGET_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGET_H
|
||||
#define CONFIGGADGET_H
|
||||
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
#include "configgadgetwidget.h"
|
||||
|
||||
class IUAVGadget;
|
||||
//class QList<int>;
|
||||
class QWidget;
|
||||
class QString;
|
||||
class ConfigGadgetWidget;
|
||||
class Ui_ConfigGadget;
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigGadget(QString classId, ConfigGadgetWidget *widget, QWidget *parent = 0);
|
||||
~ConfigGadget();
|
||||
|
||||
QWidget *widget() { return m_widget; }
|
||||
void loadConfiguration(IUAVGadgetConfiguration* config);
|
||||
|
||||
private:
|
||||
ConfigGadgetWidget *m_widget;
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGGADGET_H
|
||||
|
@ -1,45 +1,45 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetconfiguration.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configgadgetconfiguration.h"
|
||||
|
||||
ConfigGadgetConfiguration::ConfigGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent)
|
||||
{
|
||||
Q_UNUSED(qSettings);
|
||||
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ConfigGadgetConfiguration::clone()
|
||||
{
|
||||
ConfigGadgetConfiguration *m = new ConfigGadgetConfiguration(this->classId());
|
||||
return m;
|
||||
}
|
||||
|
||||
void ConfigGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetconfiguration.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configgadgetconfiguration.h"
|
||||
|
||||
ConfigGadgetConfiguration::ConfigGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent)
|
||||
{
|
||||
Q_UNUSED(qSettings);
|
||||
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ConfigGadgetConfiguration::clone()
|
||||
{
|
||||
ConfigGadgetConfiguration *m = new ConfigGadgetConfiguration(this->classId());
|
||||
return m;
|
||||
}
|
||||
|
||||
void ConfigGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
|
@ -1,45 +1,45 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGETCONFIGURATION_H
|
||||
#define CONFIGGADGETCONFIGURATION_H
|
||||
|
||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETCONFIGURATION_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGETCONFIGURATION_H
|
||||
#define CONFIGGADGETCONFIGURATION_H
|
||||
|
||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETCONFIGURATION_H
|
||||
|
@ -1,57 +1,57 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configgadgetfactory.h"
|
||||
#include "configgadgetwidget.h"
|
||||
#include "configgadget.h"
|
||||
#include "configgadgetconfiguration.h"
|
||||
#include "configgadgetoptionspage.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
ConfigGadgetFactory::ConfigGadgetFactory(QObject *parent) :
|
||||
IUAVGadgetFactory(QString("ConfigGadget"), tr("Config Gadget"), parent)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigGadgetFactory::~ConfigGadgetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
Core::IUAVGadget* ConfigGadgetFactory::createGadget(QWidget *parent)
|
||||
{
|
||||
ConfigGadgetWidget* gadgetWidget = new ConfigGadgetWidget(parent);
|
||||
return new ConfigGadget(QString("ConfigGadget"), gadgetWidget, parent);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ConfigGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new ConfigGadgetConfiguration(QString("ConfigGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *ConfigGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new ConfigGadgetOptionsPage(qobject_cast<ConfigGadgetConfiguration*>(config));
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configgadgetfactory.h"
|
||||
#include "configgadgetwidget.h"
|
||||
#include "configgadget.h"
|
||||
#include "configgadgetconfiguration.h"
|
||||
#include "configgadgetoptionspage.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
ConfigGadgetFactory::ConfigGadgetFactory(QObject *parent) :
|
||||
IUAVGadgetFactory(QString("ConfigGadget"), tr("Config Gadget"), parent)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigGadgetFactory::~ConfigGadgetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
Core::IUAVGadget* ConfigGadgetFactory::createGadget(QWidget *parent)
|
||||
{
|
||||
ConfigGadgetWidget* gadgetWidget = new ConfigGadgetWidget(parent);
|
||||
return new ConfigGadget(QString("ConfigGadget"), gadgetWidget, parent);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ConfigGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new ConfigGadgetConfiguration(QString("ConfigGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *ConfigGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new ConfigGadgetOptionsPage(qobject_cast<ConfigGadgetConfiguration*>(config));
|
||||
}
|
||||
|
@ -1,52 +1,52 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGETFACTORY_H
|
||||
#define CONFIGGADGETFACTORY_H
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadgetFactory: public Core::IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
ConfigGadgetFactory(QObject *parent = 0);
|
||||
~ConfigGadgetFactory();
|
||||
|
||||
IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETFACTORY_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGETFACTORY_H
|
||||
#define CONFIGGADGETFACTORY_H
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadgetFactory: public Core::IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
ConfigGadgetFactory(QObject *parent = 0);
|
||||
~ConfigGadgetFactory();
|
||||
|
||||
IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETFACTORY_H
|
||||
|
@ -1,52 +1,52 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetoptionspage.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configgadgetoptionspage.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
ConfigGadgetOptionsPage::ConfigGadgetOptionsPage(ConfigGadgetConfiguration *config, QObject *parent)
|
||||
{
|
||||
//todo:implement
|
||||
Q_UNUSED(config);
|
||||
Q_UNUSED(parent);
|
||||
}
|
||||
|
||||
QWidget *ConfigGadgetOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
//todo:implement
|
||||
Q_UNUSED(parent);
|
||||
return new QWidget;
|
||||
}
|
||||
|
||||
void ConfigGadgetOptionsPage::apply()
|
||||
{
|
||||
//todo:implement
|
||||
}
|
||||
|
||||
void ConfigGadgetOptionsPage::finish(){
|
||||
//todo:implement
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetoptionspage.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configgadgetoptionspage.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
ConfigGadgetOptionsPage::ConfigGadgetOptionsPage(ConfigGadgetConfiguration *config, QObject *parent)
|
||||
{
|
||||
//todo:implement
|
||||
Q_UNUSED(config);
|
||||
Q_UNUSED(parent);
|
||||
}
|
||||
|
||||
QWidget *ConfigGadgetOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
//todo:implement
|
||||
Q_UNUSED(parent);
|
||||
return new QWidget;
|
||||
}
|
||||
|
||||
void ConfigGadgetOptionsPage::apply()
|
||||
{
|
||||
//todo:implement
|
||||
}
|
||||
|
||||
void ConfigGadgetOptionsPage::finish(){
|
||||
//todo:implement
|
||||
}
|
||||
|
@ -1,51 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetoptionspage.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGETOPTIONSPAGE_H
|
||||
#define CONFIGGADGETOPTIONSPAGE_H
|
||||
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadgetConfiguration;
|
||||
}
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadgetConfiguration;
|
||||
|
||||
class ConfigGadgetOptionsPage : public IOptionsPage
|
||||
{
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConfigGadgetOptionsPage(ConfigGadgetConfiguration *config, QObject *parent = 0);
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETOPTIONSPAGE_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetoptionspage.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGGADGETOPTIONSPAGE_H
|
||||
#define CONFIGGADGETOPTIONSPAGE_H
|
||||
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadgetConfiguration;
|
||||
}
|
||||
using namespace Core;
|
||||
|
||||
class ConfigGadgetConfiguration;
|
||||
|
||||
class ConfigGadgetOptionsPage : public IOptionsPage
|
||||
{
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConfigGadgetOptionsPage(ConfigGadgetConfiguration *config, QObject *parent = 0);
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETOPTIONSPAGE_H
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "configoutputwidget.h"
|
||||
#include "configstabilizationwidget.h"
|
||||
#include "configtelemetrywidget.h"
|
||||
#include "defaultattitudewidget.h"
|
||||
|
||||
#include "uavobjectutilmanager.h"
|
||||
|
||||
@ -70,7 +71,7 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
qwd = new ConfigOutputWidget(this);
|
||||
ftw->insertTab(2, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output"));
|
||||
|
||||
qwd = new ConfigAHRSWidget(this);
|
||||
qwd = new DefaultAttitudeWidget(this);
|
||||
ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS"));
|
||||
|
||||
qwd = new ConfigStabilizationWidget(this);
|
||||
|
@ -1,62 +1,62 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configplugin.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configplugin.h"
|
||||
#include "configgadgetfactory.h"
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
ConfigPlugin::ConfigPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
ConfigPlugin::~ConfigPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
cf = new ConfigGadgetFactory(this);
|
||||
addAutoReleasedObject(cf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void ConfigPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
Q_EXPORT_PLUGIN(ConfigPlugin)
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configplugin.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configplugin.h"
|
||||
#include "configgadgetfactory.h"
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
ConfigPlugin::ConfigPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
ConfigPlugin::~ConfigPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
cf = new ConfigGadgetFactory(this);
|
||||
addAutoReleasedObject(cf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void ConfigPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
Q_EXPORT_PLUGIN(ConfigPlugin)
|
||||
|
@ -1,47 +1,47 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetplugin.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGPLUGIN_H
|
||||
#define CONFIGPLUGIN_H
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
class ConfigGadgetFactory;
|
||||
|
||||
class ConfigPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
public:
|
||||
ConfigPlugin();
|
||||
~ConfigPlugin();
|
||||
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList & arguments, QString * errorString);
|
||||
void shutdown();
|
||||
private:
|
||||
ConfigGadgetFactory *cf;
|
||||
};
|
||||
|
||||
#endif // CONFIGPLUGIN_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configgadgetplugin.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGPLUGIN_H
|
||||
#define CONFIGPLUGIN_H
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
class ConfigGadgetFactory;
|
||||
|
||||
class ConfigPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
public:
|
||||
ConfigPlugin();
|
||||
~ConfigPlugin();
|
||||
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList & arguments, QString * errorString);
|
||||
void shutdown();
|
||||
private:
|
||||
ConfigGadgetFactory *cf;
|
||||
};
|
||||
|
||||
#endif // CONFIGPLUGIN_H
|
||||
|
@ -1,112 +1,112 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configtelemetrywidget.h
|
||||
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configtelemetrywidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
|
||||
|
||||
ConfigTelemetryWidget::ConfigTelemetryWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
{
|
||||
m_telemetry = new Ui_TelemetryWidget();
|
||||
m_telemetry->setupUi(this);
|
||||
|
||||
// Now connect the widget to the ManualControlCommand / Channel UAVObject
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
UAVObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||
m_telemetry->telemetrySpeed->addItems(field->getOptions());
|
||||
|
||||
requestTelemetryUpdate();
|
||||
connect(m_telemetry->saveTelemetryToSD, SIGNAL(clicked()), this, SLOT(saveTelemetryUpdate()));
|
||||
connect(m_telemetry->saveTelemetryToRAM, SIGNAL(clicked()), this, SLOT(sendTelemetryUpdate()));
|
||||
connect(m_telemetry->getTelemetryCurrent, SIGNAL(clicked()), this, SLOT(requestTelemetryUpdate()));
|
||||
|
||||
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestTelemetryUpdate()));
|
||||
|
||||
}
|
||||
|
||||
ConfigTelemetryWidget::~ConfigTelemetryWidget()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
/*******************************
|
||||
* Telemetry Settings
|
||||
*****************************/
|
||||
|
||||
/**
|
||||
Request telemetry settings from the board
|
||||
*/
|
||||
void ConfigTelemetryWidget::requestTelemetryUpdate()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
Q_ASSERT(obj);
|
||||
obj->requestUpdate();
|
||||
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||
m_telemetry->telemetrySpeed->setCurrentIndex(m_telemetry->telemetrySpeed->findText(field->getValue().toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
Send telemetry settings to the board
|
||||
*/
|
||||
void ConfigTelemetryWidget::sendTelemetryUpdate()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
Q_ASSERT(obj);
|
||||
UAVObjectField* field = obj->getField(QString("Speed"));
|
||||
field->setValue(m_telemetry->telemetrySpeed->currentText());
|
||||
obj->updated();
|
||||
}
|
||||
|
||||
/**
|
||||
Send telemetry settings to the board and request saving to SD card
|
||||
*/
|
||||
void ConfigTelemetryWidget::saveTelemetryUpdate()
|
||||
{
|
||||
// Send update so that the latest value is saved
|
||||
sendTelemetryUpdate();
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
Q_ASSERT(obj);
|
||||
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configtelemetrywidget.h
|
||||
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief The Configuration Gadget used to update settings in the firmware
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configtelemetrywidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
|
||||
|
||||
ConfigTelemetryWidget::ConfigTelemetryWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
{
|
||||
m_telemetry = new Ui_TelemetryWidget();
|
||||
m_telemetry->setupUi(this);
|
||||
|
||||
// Now connect the widget to the ManualControlCommand / Channel UAVObject
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
UAVObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||
m_telemetry->telemetrySpeed->addItems(field->getOptions());
|
||||
|
||||
requestTelemetryUpdate();
|
||||
connect(m_telemetry->saveTelemetryToSD, SIGNAL(clicked()), this, SLOT(saveTelemetryUpdate()));
|
||||
connect(m_telemetry->saveTelemetryToRAM, SIGNAL(clicked()), this, SLOT(sendTelemetryUpdate()));
|
||||
connect(m_telemetry->getTelemetryCurrent, SIGNAL(clicked()), this, SLOT(requestTelemetryUpdate()));
|
||||
|
||||
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestTelemetryUpdate()));
|
||||
|
||||
}
|
||||
|
||||
ConfigTelemetryWidget::~ConfigTelemetryWidget()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
/*******************************
|
||||
* Telemetry Settings
|
||||
*****************************/
|
||||
|
||||
/**
|
||||
Request telemetry settings from the board
|
||||
*/
|
||||
void ConfigTelemetryWidget::requestTelemetryUpdate()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
Q_ASSERT(obj);
|
||||
obj->requestUpdate();
|
||||
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||
m_telemetry->telemetrySpeed->setCurrentIndex(m_telemetry->telemetrySpeed->findText(field->getValue().toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
Send telemetry settings to the board
|
||||
*/
|
||||
void ConfigTelemetryWidget::sendTelemetryUpdate()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
Q_ASSERT(obj);
|
||||
UAVObjectField* field = obj->getField(QString("Speed"));
|
||||
field->setValue(m_telemetry->telemetrySpeed->currentText());
|
||||
obj->updated();
|
||||
}
|
||||
|
||||
/**
|
||||
Send telemetry settings to the board and request saving to SD card
|
||||
*/
|
||||
void ConfigTelemetryWidget::saveTelemetryUpdate()
|
||||
{
|
||||
// Send update so that the latest value is saved
|
||||
sendTelemetryUpdate();
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("TelemetrySettings")));
|
||||
Q_ASSERT(obj);
|
||||
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,57 +1,57 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configtelemetrytwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief Telemetry configuration panel
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGTELEMETRYWIDGET_H
|
||||
#define CONFIGTELEMETRYWIDGET_H
|
||||
|
||||
#include "ui_telemetry.h"
|
||||
#include "configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class ConfigTelemetryWidget: public ConfigTaskWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigTelemetryWidget(QWidget *parent = 0);
|
||||
~ConfigTelemetryWidget();
|
||||
|
||||
private:
|
||||
Ui_TelemetryWidget *m_telemetry;
|
||||
|
||||
private slots:
|
||||
void requestTelemetryUpdate();
|
||||
void sendTelemetryUpdate();
|
||||
void saveTelemetryUpdate();
|
||||
|
||||
};
|
||||
|
||||
#endif // ConfigTelemetryWidget_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configtelemetrytwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief Telemetry configuration panel
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGTELEMETRYWIDGET_H
|
||||
#define CONFIGTELEMETRYWIDGET_H
|
||||
|
||||
#include "ui_telemetry.h"
|
||||
#include "configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class ConfigTelemetryWidget: public ConfigTaskWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigTelemetryWidget(QWidget *parent = 0);
|
||||
~ConfigTelemetryWidget();
|
||||
|
||||
private:
|
||||
Ui_TelemetryWidget *m_telemetry;
|
||||
|
||||
private slots:
|
||||
void requestTelemetryUpdate();
|
||||
void sendTelemetryUpdate();
|
||||
void saveTelemetryUpdate();
|
||||
|
||||
};
|
||||
|
||||
#endif // ConfigTelemetryWidget_H
|
||||
|
77
ground/openpilotgcs/src/plugins/config/defaultattitude.ui
Normal file
77
ground/openpilotgcs/src/plugins/config/defaultattitude.ui
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>defaultattitude</class>
|
||||
<widget class="QWidget" name="defaultattitude">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Attitude / INS calibration</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This panel will be updated to provide the relevant controls to let you calibrate your OpenPilot INS or your CopterControl unit, depending on the board which is detected once telemetry is connected and running.</p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file defaultattitudewidget.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief Placeholder for attitude panel until board is connected.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "defaultattitudewidget.h"
|
||||
#include "ui_defaultattitude.h"
|
||||
#include <QMutexLocker>
|
||||
#include <QErrorMessage>
|
||||
#include <QDebug>
|
||||
|
||||
DefaultAttitudeWidget::DefaultAttitudeWidget(QWidget *parent) :
|
||||
ConfigTaskWidget(parent),
|
||||
ui(new Ui_defaultattitude)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
DefaultAttitudeWidget::~DefaultAttitudeWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file defaultccattitudewidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief Placeholder for attitude settings widget until board connected.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef DEFAULTATTITUDEWIDGET_H
|
||||
#define DEFAULTATTITUDEWIDGET_H
|
||||
|
||||
#include "ui_defaultattitude.h"
|
||||
#include "configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
|
||||
class Ui_Widget;
|
||||
|
||||
class DefaultAttitudeWidget : public ConfigTaskWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DefaultAttitudeWidget(QWidget *parent = 0);
|
||||
~DefaultAttitudeWidget();
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
Ui_defaultattitude *ui;
|
||||
};
|
||||
|
||||
#endif // DEFAULTATTITUDEWIDGET_H
|
@ -1,479 +1,479 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QtGui/QColorDialog>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QWindowsStyle>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QStackedLayout>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QToolTip>
|
||||
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_textPadding = 4;
|
||||
|
||||
FancyTabBar::FancyTabBar(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
verticalTabs = isVertical;
|
||||
setIconSize(16);
|
||||
m_hoverIndex = -1;
|
||||
m_currentIndex = 0;
|
||||
if (isVertical) {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
} else {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
setStyle(new QWindowsStyle);
|
||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
m_hoverControl.setFrameRange(0, 20);
|
||||
m_hoverControl.setDuration(130);
|
||||
m_hoverControl.setCurveShape(QTimeLine::EaseInCurve);
|
||||
connect(&m_hoverControl, SIGNAL(frameChanged(int)), this, SLOT(updateHover()));
|
||||
setMouseTracking(true); // Needed for hover events
|
||||
}
|
||||
|
||||
FancyTabBar::~FancyTabBar()
|
||||
{
|
||||
delete style();
|
||||
}
|
||||
|
||||
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
||||
{
|
||||
QFont boldFont(font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
QFontMetrics fm(boldFont);
|
||||
int spacing = 6;
|
||||
int width = 90 + spacing + 2;
|
||||
|
||||
int iconHeight = minimum ? 0 : iconSize;
|
||||
return QSize(width, iconHeight + spacing + fm.height());
|
||||
}
|
||||
|
||||
void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (i != currentIndex())
|
||||
paintTab(&p, i);
|
||||
|
||||
// paint active tab last, since it overlaps the neighbors
|
||||
paintTab(&p, currentIndex());
|
||||
}
|
||||
|
||||
// Handle hover events for mouse fade ins
|
||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!m_hoverRect.contains(e->pos())) {
|
||||
int newHover = -1;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect area = tabRect(i);
|
||||
if (area.contains(e->pos())) {
|
||||
newHover = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_hoverControl.stop();
|
||||
m_hoverIndex = newHover;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
|
||||
if (m_hoverIndex >=0) {
|
||||
QRect oldHoverRect = m_hoverRect;
|
||||
m_hoverRect = tabRect(m_hoverIndex);
|
||||
m_hoverControl.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyTabBar::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
if (m_hoverIndex >= 0 && m_hoverIndex < m_tabs.count()) {
|
||||
QString tt = tabToolTip(m_hoverIndex);
|
||||
if (!tt.isEmpty()) {
|
||||
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tt, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void FancyTabBar::updateHover()
|
||||
{
|
||||
update(m_hoverRect);
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::enterEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
m_hoverRect = QRect();
|
||||
m_hoverIndex = -1;
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::leaveEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
if (m_hoverIndex >= 0) {
|
||||
m_hoverIndex = -1;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_tabs[index].icon = icon;
|
||||
m_tabs[index].text = label;
|
||||
}
|
||||
|
||||
QSize FancyTabBar::sizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
if (verticalTabs)
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
}
|
||||
|
||||
QSize FancyTabBar::minimumSizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint(true);
|
||||
if (verticalTabs)
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
}
|
||||
|
||||
QRect FancyTabBar::tabRect(int index) const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
if (verticalTabs) {
|
||||
if (sh.height() * m_tabs.count() > height())
|
||||
sh.setHeight(height() / m_tabs.count());
|
||||
|
||||
return QRect(0, index * sh.height(), sh.width(), sh.height());
|
||||
|
||||
}
|
||||
|
||||
if(sh.width() * m_tabs.count() > width())
|
||||
sh.setWidth(width() / m_tabs.count());
|
||||
|
||||
return QRect(index * sh.width(), 0, sh.width(), sh.height());
|
||||
|
||||
}
|
||||
|
||||
void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
for (int i = 0; i < m_tabs.count(); ++i) {
|
||||
if (tabRect(i).contains(e->pos())) {
|
||||
setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QRect rect = tabRect(tabIndex);
|
||||
|
||||
bool selected = (tabIndex == m_currentIndex);
|
||||
bool hover = (tabIndex == m_hoverIndex);
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
hover = false; // Dont hover on Mac
|
||||
#endif
|
||||
|
||||
QColor background = QColor(0, 0, 0, 10);
|
||||
QColor hoverColor;
|
||||
|
||||
if (hover) {
|
||||
hoverColor = QColor(255, 255, 255, m_hoverControl.currentFrame());
|
||||
}
|
||||
|
||||
QColor light = QColor(255, 255, 255, 40);
|
||||
QColor dark = QColor(0, 0, 0, 60);
|
||||
|
||||
if (selected) {
|
||||
QLinearGradient selectedGradient(rect.bottomRight(), QPoint(rect.center().x(), rect.top()));
|
||||
selectedGradient.setColorAt(0, Qt::white);
|
||||
selectedGradient.setColorAt(0.3, Qt::white);
|
||||
selectedGradient.setColorAt(0.7, QColor(210, 210, 220)); //give a blue-ish color
|
||||
|
||||
painter->fillRect(rect, selectedGradient);
|
||||
painter->setPen(QColor(200, 200, 200));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QColor(150, 160, 200));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
} else {
|
||||
painter->fillRect(rect, background);
|
||||
if (hover)
|
||||
painter->fillRect(rect, hoverColor);
|
||||
painter->setPen(QPen(light, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QPen(dark, 0));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
|
||||
QString tabText(this->tabText(tabIndex));
|
||||
QRect tabTextRect(tabRect(tabIndex));
|
||||
QRect tabIconRect(tabTextRect);
|
||||
QFont boldFont(painter->font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
painter->setFont(boldFont);
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(30, 30, 30, 80));
|
||||
int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::ElideRight | Qt::TextWordWrap;
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||
int iconSize = qMin(tabIconRect.width(), tabIconRect.height());
|
||||
if (iconSize > 4)
|
||||
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
|
||||
tabIcon(tabIndex).pixmap(tabIconRect.size()));
|
||||
painter->translate(0, -1);
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void FancyTabBar::setCurrentIndex(int index) {
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
//////
|
||||
// FancyColorButton
|
||||
//////
|
||||
|
||||
class FancyColorButton : public QWidget
|
||||
{
|
||||
public:
|
||||
FancyColorButton(QWidget *parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (ev->modifiers() & Qt::ShiftModifier)
|
||||
Utils::StyleHelper::setBaseColor(QColorDialog::getColor(Utils::StyleHelper::baseColor(), m_parent));
|
||||
}
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
};
|
||||
|
||||
//////
|
||||
// FancyTabWidget
|
||||
//////
|
||||
|
||||
FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_tabBar = new FancyTabBar(this, isVertical);
|
||||
|
||||
m_selectionWidget = new QWidget(this);
|
||||
QBoxLayout *selectionLayout;
|
||||
if (isVertical) {
|
||||
selectionLayout = new QVBoxLayout;
|
||||
} else {
|
||||
selectionLayout = new QHBoxLayout;
|
||||
}
|
||||
selectionLayout->setSpacing(0);
|
||||
selectionLayout->setMargin(0);
|
||||
|
||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
QBoxLayout *layout;
|
||||
if (isVertical) {
|
||||
layout = new QHBoxLayout(bar);
|
||||
} else {
|
||||
layout = new QVBoxLayout(bar);
|
||||
}
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new FancyColorButton(this));
|
||||
selectionLayout->addWidget(bar);
|
||||
|
||||
selectionLayout->addWidget(m_tabBar, 1);
|
||||
m_selectionWidget->setLayout(selectionLayout);
|
||||
if (isVertical) {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
} else {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
m_cornerWidgetContainer = new QWidget(this);
|
||||
if (isVertical) {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
} else {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
}
|
||||
m_cornerWidgetContainer->setAutoFillBackground(false);
|
||||
|
||||
QBoxLayout *cornerWidgetLayout;
|
||||
if (isVertical) {
|
||||
cornerWidgetLayout = new QVBoxLayout;
|
||||
} else {
|
||||
cornerWidgetLayout = new QHBoxLayout;
|
||||
}
|
||||
cornerWidgetLayout->setSpacing(0);
|
||||
cornerWidgetLayout->setMargin(0);
|
||||
cornerWidgetLayout->addStretch();
|
||||
m_cornerWidgetContainer->setLayout(cornerWidgetLayout);
|
||||
|
||||
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
||||
|
||||
m_modesStack = new QStackedLayout;
|
||||
m_statusBar = new QStatusBar;
|
||||
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(m_modesStack);
|
||||
if (!isVertical)
|
||||
vlayout->addWidget(m_selectionWidget);
|
||||
// vlayout->addWidget(m_statusBar); //status bar is not used for now
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(1);
|
||||
if (isVertical)
|
||||
mainLayout->addWidget(m_selectionWidget);
|
||||
mainLayout->addLayout(vlayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_modesStack->insertWidget(index, tab);
|
||||
m_tabBar->insertTab(index, icon, label);
|
||||
}
|
||||
|
||||
void FancyTabWidget::removeTab(int index)
|
||||
{
|
||||
m_modesStack->removeWidget(m_modesStack->widget(index));
|
||||
m_tabBar->removeTab(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_tabBar->updateTabNameIcon(index, icon, label);
|
||||
m_tabBar->repaint();
|
||||
}
|
||||
|
||||
|
||||
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
||||
{
|
||||
QPalette pal = m_tabBar->palette();
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_tabBar->setPalette(pal);
|
||||
pal = m_cornerWidgetContainer->palette();
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_cornerWidgetContainer->setPalette(pal);
|
||||
}
|
||||
|
||||
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
QRect rect = m_selectionWidget->geometry().adjusted(0, 0, 1, 0);
|
||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||
Utils::StyleHelper::verticalGradient(&p, rect, rect);
|
||||
p.setPen(Utils::StyleHelper::borderColor());
|
||||
p.drawLine(rect.topLeft(), rect.topRight());
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
|
||||
{
|
||||
QHBoxLayout *layout = static_cast<QHBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||
layout->insertWidget(pos, widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::cornerWidgetCount() const
|
||||
{
|
||||
return m_cornerWidgetContainer->layout()->count();
|
||||
}
|
||||
|
||||
void FancyTabWidget::addCornerWidget(QWidget *widget)
|
||||
{
|
||||
m_cornerWidgetContainer->layout()->addWidget(widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::currentIndex() const
|
||||
{
|
||||
return m_tabBar->currentIndex();
|
||||
}
|
||||
|
||||
QStatusBar *FancyTabWidget::statusBar() const
|
||||
{
|
||||
return m_statusBar;
|
||||
}
|
||||
|
||||
void FancyTabWidget::setCurrentIndex(int index)
|
||||
{
|
||||
m_tabBar->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::showWidget(int index)
|
||||
{
|
||||
emit currentAboutToShow(index);
|
||||
m_modesStack->setCurrentIndex(index);
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::setTabToolTip(int index, const QString &toolTip)
|
||||
{
|
||||
m_tabBar->setTabToolTip(index, toolTip);
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QtGui/QColorDialog>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QWindowsStyle>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QStackedLayout>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QToolTip>
|
||||
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_textPadding = 4;
|
||||
|
||||
FancyTabBar::FancyTabBar(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
verticalTabs = isVertical;
|
||||
setIconSize(16);
|
||||
m_hoverIndex = -1;
|
||||
m_currentIndex = 0;
|
||||
if (isVertical) {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
} else {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
setStyle(new QWindowsStyle);
|
||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
m_hoverControl.setFrameRange(0, 20);
|
||||
m_hoverControl.setDuration(130);
|
||||
m_hoverControl.setCurveShape(QTimeLine::EaseInCurve);
|
||||
connect(&m_hoverControl, SIGNAL(frameChanged(int)), this, SLOT(updateHover()));
|
||||
setMouseTracking(true); // Needed for hover events
|
||||
}
|
||||
|
||||
FancyTabBar::~FancyTabBar()
|
||||
{
|
||||
delete style();
|
||||
}
|
||||
|
||||
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
||||
{
|
||||
QFont boldFont(font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
QFontMetrics fm(boldFont);
|
||||
int spacing = 6;
|
||||
int width = 90 + spacing + 2;
|
||||
|
||||
int iconHeight = minimum ? 0 : iconSize;
|
||||
return QSize(width, iconHeight + spacing + fm.height());
|
||||
}
|
||||
|
||||
void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (i != currentIndex())
|
||||
paintTab(&p, i);
|
||||
|
||||
// paint active tab last, since it overlaps the neighbors
|
||||
paintTab(&p, currentIndex());
|
||||
}
|
||||
|
||||
// Handle hover events for mouse fade ins
|
||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!m_hoverRect.contains(e->pos())) {
|
||||
int newHover = -1;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect area = tabRect(i);
|
||||
if (area.contains(e->pos())) {
|
||||
newHover = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_hoverControl.stop();
|
||||
m_hoverIndex = newHover;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
|
||||
if (m_hoverIndex >=0) {
|
||||
QRect oldHoverRect = m_hoverRect;
|
||||
m_hoverRect = tabRect(m_hoverIndex);
|
||||
m_hoverControl.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyTabBar::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
if (m_hoverIndex >= 0 && m_hoverIndex < m_tabs.count()) {
|
||||
QString tt = tabToolTip(m_hoverIndex);
|
||||
if (!tt.isEmpty()) {
|
||||
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tt, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void FancyTabBar::updateHover()
|
||||
{
|
||||
update(m_hoverRect);
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::enterEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
m_hoverRect = QRect();
|
||||
m_hoverIndex = -1;
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::leaveEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
if (m_hoverIndex >= 0) {
|
||||
m_hoverIndex = -1;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_tabs[index].icon = icon;
|
||||
m_tabs[index].text = label;
|
||||
}
|
||||
|
||||
QSize FancyTabBar::sizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
if (verticalTabs)
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
}
|
||||
|
||||
QSize FancyTabBar::minimumSizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint(true);
|
||||
if (verticalTabs)
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
}
|
||||
|
||||
QRect FancyTabBar::tabRect(int index) const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
if (verticalTabs) {
|
||||
if (sh.height() * m_tabs.count() > height())
|
||||
sh.setHeight(height() / m_tabs.count());
|
||||
|
||||
return QRect(0, index * sh.height(), sh.width(), sh.height());
|
||||
|
||||
}
|
||||
|
||||
if(sh.width() * m_tabs.count() > width())
|
||||
sh.setWidth(width() / m_tabs.count());
|
||||
|
||||
return QRect(index * sh.width(), 0, sh.width(), sh.height());
|
||||
|
||||
}
|
||||
|
||||
void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
for (int i = 0; i < m_tabs.count(); ++i) {
|
||||
if (tabRect(i).contains(e->pos())) {
|
||||
setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QRect rect = tabRect(tabIndex);
|
||||
|
||||
bool selected = (tabIndex == m_currentIndex);
|
||||
bool hover = (tabIndex == m_hoverIndex);
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
hover = false; // Dont hover on Mac
|
||||
#endif
|
||||
|
||||
QColor background = QColor(0, 0, 0, 10);
|
||||
QColor hoverColor;
|
||||
|
||||
if (hover) {
|
||||
hoverColor = QColor(255, 255, 255, m_hoverControl.currentFrame());
|
||||
}
|
||||
|
||||
QColor light = QColor(255, 255, 255, 40);
|
||||
QColor dark = QColor(0, 0, 0, 60);
|
||||
|
||||
if (selected) {
|
||||
QLinearGradient selectedGradient(rect.bottomRight(), QPoint(rect.center().x(), rect.top()));
|
||||
selectedGradient.setColorAt(0, Qt::white);
|
||||
selectedGradient.setColorAt(0.3, Qt::white);
|
||||
selectedGradient.setColorAt(0.7, QColor(210, 210, 220)); //give a blue-ish color
|
||||
|
||||
painter->fillRect(rect, selectedGradient);
|
||||
painter->setPen(QColor(200, 200, 200));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QColor(150, 160, 200));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
} else {
|
||||
painter->fillRect(rect, background);
|
||||
if (hover)
|
||||
painter->fillRect(rect, hoverColor);
|
||||
painter->setPen(QPen(light, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QPen(dark, 0));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
|
||||
QString tabText(this->tabText(tabIndex));
|
||||
QRect tabTextRect(tabRect(tabIndex));
|
||||
QRect tabIconRect(tabTextRect);
|
||||
QFont boldFont(painter->font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
painter->setFont(boldFont);
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(30, 30, 30, 80));
|
||||
int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::ElideRight | Qt::TextWordWrap;
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||
int iconSize = qMin(tabIconRect.width(), tabIconRect.height());
|
||||
if (iconSize > 4)
|
||||
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
|
||||
tabIcon(tabIndex).pixmap(tabIconRect.size()));
|
||||
painter->translate(0, -1);
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void FancyTabBar::setCurrentIndex(int index) {
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
//////
|
||||
// FancyColorButton
|
||||
//////
|
||||
|
||||
class FancyColorButton : public QWidget
|
||||
{
|
||||
public:
|
||||
FancyColorButton(QWidget *parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (ev->modifiers() & Qt::ShiftModifier)
|
||||
Utils::StyleHelper::setBaseColor(QColorDialog::getColor(Utils::StyleHelper::baseColor(), m_parent));
|
||||
}
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
};
|
||||
|
||||
//////
|
||||
// FancyTabWidget
|
||||
//////
|
||||
|
||||
FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_tabBar = new FancyTabBar(this, isVertical);
|
||||
|
||||
m_selectionWidget = new QWidget(this);
|
||||
QBoxLayout *selectionLayout;
|
||||
if (isVertical) {
|
||||
selectionLayout = new QVBoxLayout;
|
||||
} else {
|
||||
selectionLayout = new QHBoxLayout;
|
||||
}
|
||||
selectionLayout->setSpacing(0);
|
||||
selectionLayout->setMargin(0);
|
||||
|
||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
QBoxLayout *layout;
|
||||
if (isVertical) {
|
||||
layout = new QHBoxLayout(bar);
|
||||
} else {
|
||||
layout = new QVBoxLayout(bar);
|
||||
}
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new FancyColorButton(this));
|
||||
selectionLayout->addWidget(bar);
|
||||
|
||||
selectionLayout->addWidget(m_tabBar, 1);
|
||||
m_selectionWidget->setLayout(selectionLayout);
|
||||
if (isVertical) {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
} else {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
m_cornerWidgetContainer = new QWidget(this);
|
||||
if (isVertical) {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
} else {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
}
|
||||
m_cornerWidgetContainer->setAutoFillBackground(false);
|
||||
|
||||
QBoxLayout *cornerWidgetLayout;
|
||||
if (isVertical) {
|
||||
cornerWidgetLayout = new QVBoxLayout;
|
||||
} else {
|
||||
cornerWidgetLayout = new QHBoxLayout;
|
||||
}
|
||||
cornerWidgetLayout->setSpacing(0);
|
||||
cornerWidgetLayout->setMargin(0);
|
||||
cornerWidgetLayout->addStretch();
|
||||
m_cornerWidgetContainer->setLayout(cornerWidgetLayout);
|
||||
|
||||
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
||||
|
||||
m_modesStack = new QStackedLayout;
|
||||
m_statusBar = new QStatusBar;
|
||||
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(m_modesStack);
|
||||
if (!isVertical)
|
||||
vlayout->addWidget(m_selectionWidget);
|
||||
// vlayout->addWidget(m_statusBar); //status bar is not used for now
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(1);
|
||||
if (isVertical)
|
||||
mainLayout->addWidget(m_selectionWidget);
|
||||
mainLayout->addLayout(vlayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_modesStack->insertWidget(index, tab);
|
||||
m_tabBar->insertTab(index, icon, label);
|
||||
}
|
||||
|
||||
void FancyTabWidget::removeTab(int index)
|
||||
{
|
||||
m_modesStack->removeWidget(m_modesStack->widget(index));
|
||||
m_tabBar->removeTab(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_tabBar->updateTabNameIcon(index, icon, label);
|
||||
m_tabBar->repaint();
|
||||
}
|
||||
|
||||
|
||||
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
||||
{
|
||||
QPalette pal = m_tabBar->palette();
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_tabBar->setPalette(pal);
|
||||
pal = m_cornerWidgetContainer->palette();
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_cornerWidgetContainer->setPalette(pal);
|
||||
}
|
||||
|
||||
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
QRect rect = m_selectionWidget->geometry().adjusted(0, 0, 1, 0);
|
||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||
Utils::StyleHelper::verticalGradient(&p, rect, rect);
|
||||
p.setPen(Utils::StyleHelper::borderColor());
|
||||
p.drawLine(rect.topLeft(), rect.topRight());
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
|
||||
{
|
||||
QHBoxLayout *layout = static_cast<QHBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||
layout->insertWidget(pos, widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::cornerWidgetCount() const
|
||||
{
|
||||
return m_cornerWidgetContainer->layout()->count();
|
||||
}
|
||||
|
||||
void FancyTabWidget::addCornerWidget(QWidget *widget)
|
||||
{
|
||||
m_cornerWidgetContainer->layout()->addWidget(widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::currentIndex() const
|
||||
{
|
||||
return m_tabBar->currentIndex();
|
||||
}
|
||||
|
||||
QStatusBar *FancyTabWidget::statusBar() const
|
||||
{
|
||||
return m_statusBar;
|
||||
}
|
||||
|
||||
void FancyTabWidget::setCurrentIndex(int index)
|
||||
{
|
||||
m_tabBar->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::showWidget(int index)
|
||||
{
|
||||
emit currentAboutToShow(index);
|
||||
m_modesStack->setCurrentIndex(index);
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::setTabToolTip(int index, const QString &toolTip)
|
||||
{
|
||||
m_tabBar->setTabToolTip(index, toolTip);
|
||||
}
|
||||
|
@ -1,154 +1,154 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYTABWIDGET_H
|
||||
#define FANCYTABWIDGET_H
|
||||
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTabBar>
|
||||
#include <QtGui/QStyleOptionTabV2>
|
||||
#include <QtCore/QTimeLine>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
class QStackedLayout;
|
||||
class QStatusBar;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
struct FancyTab {
|
||||
QIcon icon;
|
||||
QString text;
|
||||
QString toolTip;
|
||||
};
|
||||
|
||||
class FancyTabBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabBar(QWidget *parent = 0, bool isVertical=false);
|
||||
~FancyTabBar();
|
||||
|
||||
bool event(QEvent *event);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintTab(QPainter *painter, int tabIndex) const;
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
void insertTab(int index, const QIcon &icon, const QString &label) {
|
||||
FancyTab tab;
|
||||
tab.icon = icon;
|
||||
tab.text = label;
|
||||
m_tabs.insert(index, tab);
|
||||
}
|
||||
void removeTab(int index) {
|
||||
m_tabs.removeAt(index);
|
||||
}
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setCurrentIndex(int index);
|
||||
int currentIndex() const { return m_currentIndex; }
|
||||
|
||||
void setTabToolTip(int index, QString toolTip) { m_tabs[index].toolTip = toolTip; }
|
||||
QString tabToolTip(int index) const { return m_tabs.at(index).toolTip; }
|
||||
|
||||
void setIconSize(int s) { iconSize = s; }
|
||||
QIcon tabIcon(int index) const {return m_tabs.at(index).icon; }
|
||||
QString tabText(int index) const { return m_tabs.at(index).text; }
|
||||
int count() const {return m_tabs.count(); }
|
||||
QRect tabRect(int index) const;
|
||||
|
||||
|
||||
signals:
|
||||
void currentChanged(int);
|
||||
|
||||
public slots:
|
||||
void updateHover();
|
||||
|
||||
private:
|
||||
static const int m_rounding;
|
||||
static const int m_textPadding;
|
||||
QTimeLine m_hoverControl;
|
||||
QRect m_hoverRect;
|
||||
int m_hoverIndex;
|
||||
int m_currentIndex;
|
||||
int iconSize;
|
||||
QList<FancyTab> m_tabs;
|
||||
bool verticalTabs;
|
||||
|
||||
QSize tabSizeHint(bool minimum = false) const;
|
||||
|
||||
};
|
||||
|
||||
class FancyTabWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabWidget(QWidget *parent = 0, bool isVertical = false);
|
||||
|
||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||
void removeTab(int index);
|
||||
void setBackgroundBrush(const QBrush &brush);
|
||||
void addCornerWidget(QWidget *widget);
|
||||
void insertCornerWidget(int pos, QWidget *widget);
|
||||
int cornerWidgetCount() const;
|
||||
void setTabToolTip(int index, const QString &toolTip);
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setIconSize(int s) { m_tabBar->setIconSize(s); }
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
int currentIndex() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
private slots:
|
||||
void showWidget(int index);
|
||||
|
||||
private:
|
||||
FancyTabBar *m_tabBar;
|
||||
QWidget *m_cornerWidgetContainer;
|
||||
QStackedLayout *m_modesStack;
|
||||
QWidget *m_selectionWidget;
|
||||
QStatusBar *m_statusBar;
|
||||
};
|
||||
|
||||
|
||||
#endif // FANCYTABWIDGET_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYTABWIDGET_H
|
||||
#define FANCYTABWIDGET_H
|
||||
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTabBar>
|
||||
#include <QtGui/QStyleOptionTabV2>
|
||||
#include <QtCore/QTimeLine>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
class QStackedLayout;
|
||||
class QStatusBar;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
struct FancyTab {
|
||||
QIcon icon;
|
||||
QString text;
|
||||
QString toolTip;
|
||||
};
|
||||
|
||||
class FancyTabBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabBar(QWidget *parent = 0, bool isVertical=false);
|
||||
~FancyTabBar();
|
||||
|
||||
bool event(QEvent *event);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintTab(QPainter *painter, int tabIndex) const;
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
void insertTab(int index, const QIcon &icon, const QString &label) {
|
||||
FancyTab tab;
|
||||
tab.icon = icon;
|
||||
tab.text = label;
|
||||
m_tabs.insert(index, tab);
|
||||
}
|
||||
void removeTab(int index) {
|
||||
m_tabs.removeAt(index);
|
||||
}
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setCurrentIndex(int index);
|
||||
int currentIndex() const { return m_currentIndex; }
|
||||
|
||||
void setTabToolTip(int index, QString toolTip) { m_tabs[index].toolTip = toolTip; }
|
||||
QString tabToolTip(int index) const { return m_tabs.at(index).toolTip; }
|
||||
|
||||
void setIconSize(int s) { iconSize = s; }
|
||||
QIcon tabIcon(int index) const {return m_tabs.at(index).icon; }
|
||||
QString tabText(int index) const { return m_tabs.at(index).text; }
|
||||
int count() const {return m_tabs.count(); }
|
||||
QRect tabRect(int index) const;
|
||||
|
||||
|
||||
signals:
|
||||
void currentChanged(int);
|
||||
|
||||
public slots:
|
||||
void updateHover();
|
||||
|
||||
private:
|
||||
static const int m_rounding;
|
||||
static const int m_textPadding;
|
||||
QTimeLine m_hoverControl;
|
||||
QRect m_hoverRect;
|
||||
int m_hoverIndex;
|
||||
int m_currentIndex;
|
||||
int iconSize;
|
||||
QList<FancyTab> m_tabs;
|
||||
bool verticalTabs;
|
||||
|
||||
QSize tabSizeHint(bool minimum = false) const;
|
||||
|
||||
};
|
||||
|
||||
class FancyTabWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabWidget(QWidget *parent = 0, bool isVertical = false);
|
||||
|
||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||
void removeTab(int index);
|
||||
void setBackgroundBrush(const QBrush &brush);
|
||||
void addCornerWidget(QWidget *widget);
|
||||
void insertCornerWidget(int pos, QWidget *widget);
|
||||
int cornerWidgetCount() const;
|
||||
void setTabToolTip(int index, const QString &toolTip);
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setIconSize(int s) { m_tabBar->setIconSize(s); }
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
int currentIndex() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
private slots:
|
||||
void showWidget(int index);
|
||||
|
||||
private:
|
||||
FancyTabBar *m_tabBar;
|
||||
QWidget *m_cornerWidgetContainer;
|
||||
QStackedLayout *m_modesStack;
|
||||
QWidget *m_selectionWidget;
|
||||
QStatusBar *m_statusBar;
|
||||
};
|
||||
|
||||
|
||||
#endif // FANCYTABWIDGET_H
|
||||
|
@ -1,212 +1,212 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mixercurvewidget.cpp
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief A widget which displays an adjustable mixer curve
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "mixercurvewidget.h"
|
||||
#include "mixercurveline.h"
|
||||
#include "mixercurvepoint.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the widget
|
||||
*/
|
||||
MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
{
|
||||
|
||||
// Create a layout, add a QGraphicsView and put the SVG inside.
|
||||
// The Mixer Curve widget looks like this:
|
||||
// |--------------------|
|
||||
// | |
|
||||
// | |
|
||||
// | Graph |
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// |--------------------|
|
||||
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
curveMin=0.0;
|
||||
curveMax=1.0;
|
||||
|
||||
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
plot = new QGraphicsSvgItem();
|
||||
renderer->load(QString(":/configgadget/images/curve-bg.svg"));
|
||||
plot->setSharedRenderer(renderer);
|
||||
//plot->setElementId("map");
|
||||
scene->addItem(plot);
|
||||
plot->setZValue(-1);
|
||||
scene->setSceneRect(plot->boundingRect());
|
||||
setScene(scene);
|
||||
|
||||
}
|
||||
|
||||
MixerCurveWidget::~MixerCurveWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Init curve: create a (flat) curve with a specified number of points.
|
||||
|
||||
If a curve exists already, resets it.
|
||||
Points should be between 0 and 1.
|
||||
*/
|
||||
void MixerCurveWidget::initCurve(QList<double> points)
|
||||
{
|
||||
|
||||
if (points.length() < 2)
|
||||
return; // We need at least 2 points on a curve!
|
||||
|
||||
// First of all, reset the list
|
||||
// TODO: one edge might not get deleted properly, small mem leak maybe...
|
||||
foreach (Node *node, nodeList ) {
|
||||
QList<Edge*> edges = node->edges();
|
||||
foreach(Edge *edge, edges) {
|
||||
if (scene()->items().contains(edge))
|
||||
scene()->removeItem(edge);
|
||||
else
|
||||
delete edge;
|
||||
}
|
||||
scene()->removeItem(node);
|
||||
delete node;
|
||||
}
|
||||
nodeList.clear();
|
||||
|
||||
// Create the nodes
|
||||
qreal w = plot->boundingRect().width()/(points.length()-1);
|
||||
qreal h = plot->boundingRect().height();
|
||||
for (int i=0; i<points.length(); i++) {
|
||||
Node *node = new Node(this);
|
||||
scene()->addItem(node);
|
||||
nodeList.append(node);
|
||||
double val = points.at(i);
|
||||
if (val>curveMax)
|
||||
val=curveMax;
|
||||
if (val<curveMin)
|
||||
val=curveMin;
|
||||
val+=curveMin;
|
||||
val/=(curveMax-curveMin);
|
||||
node->setPos(w*i,h-val*h);
|
||||
node->verticalMove(true);
|
||||
}
|
||||
|
||||
// ... and link them together:
|
||||
for (int i=0; i<(points.length()-1); i++) {
|
||||
scene()->addItem(new Edge(nodeList.at(i),nodeList.at(i+1)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the current curve settings
|
||||
*/
|
||||
QList<double> MixerCurveWidget::getCurve() {
|
||||
QList<double> list;
|
||||
|
||||
qreal h = plot->boundingRect().height();
|
||||
foreach(Node *node, nodeList) {
|
||||
list.append(((curveMax-curveMin)*(h-node->pos().y())/h)+curveMin);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
Setd the current curve settings
|
||||
*/
|
||||
void MixerCurveWidget::setCurve(QList<double> points)
|
||||
{
|
||||
if (nodeList.length()<1)
|
||||
{
|
||||
initCurve(points);
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal w = plot->boundingRect().width()/(points.length()-1);
|
||||
qreal h = plot->boundingRect().height();
|
||||
for (int i=0; i<points.length(); i++) {
|
||||
double val = points.at(i);
|
||||
if (val>curveMax)
|
||||
val=curveMax;
|
||||
if (val<curveMin)
|
||||
val=curveMin;
|
||||
val-=curveMin;
|
||||
val/=(curveMax-curveMin);
|
||||
nodeList.at(i)->setPos(w*i,h-val*h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MixerCurveWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
// Thit fitInView method should only be called now, once the
|
||||
// widget is shown, otherwise it cannot compute its values and
|
||||
// the result is usually a ahrsbargraph that is way too small.
|
||||
fitInView(plot, Qt::KeepAspectRatio);
|
||||
|
||||
}
|
||||
|
||||
void MixerCurveWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
fitInView(plot, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MixerCurveWidget::itemMoved(double itemValue)
|
||||
{
|
||||
QList<double> list = getCurve();
|
||||
emit curveUpdated(list, itemValue);
|
||||
}
|
||||
|
||||
void MixerCurveWidget::setMin(double value)
|
||||
{
|
||||
curveMin = value;
|
||||
}
|
||||
void MixerCurveWidget::setMax(double value)
|
||||
{
|
||||
curveMax = value;
|
||||
}
|
||||
void MixerCurveWidget::setRange(double min, double max)
|
||||
{
|
||||
curveMin = min;
|
||||
curveMax = max;
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mixercurvewidget.cpp
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief A widget which displays an adjustable mixer curve
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "mixercurvewidget.h"
|
||||
#include "mixercurveline.h"
|
||||
#include "mixercurvepoint.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the widget
|
||||
*/
|
||||
MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
{
|
||||
|
||||
// Create a layout, add a QGraphicsView and put the SVG inside.
|
||||
// The Mixer Curve widget looks like this:
|
||||
// |--------------------|
|
||||
// | |
|
||||
// | |
|
||||
// | Graph |
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// |--------------------|
|
||||
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
curveMin=0.0;
|
||||
curveMax=1.0;
|
||||
|
||||
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
plot = new QGraphicsSvgItem();
|
||||
renderer->load(QString(":/configgadget/images/curve-bg.svg"));
|
||||
plot->setSharedRenderer(renderer);
|
||||
//plot->setElementId("map");
|
||||
scene->addItem(plot);
|
||||
plot->setZValue(-1);
|
||||
scene->setSceneRect(plot->boundingRect());
|
||||
setScene(scene);
|
||||
|
||||
}
|
||||
|
||||
MixerCurveWidget::~MixerCurveWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Init curve: create a (flat) curve with a specified number of points.
|
||||
|
||||
If a curve exists already, resets it.
|
||||
Points should be between 0 and 1.
|
||||
*/
|
||||
void MixerCurveWidget::initCurve(QList<double> points)
|
||||
{
|
||||
|
||||
if (points.length() < 2)
|
||||
return; // We need at least 2 points on a curve!
|
||||
|
||||
// First of all, reset the list
|
||||
// TODO: one edge might not get deleted properly, small mem leak maybe...
|
||||
foreach (Node *node, nodeList ) {
|
||||
QList<Edge*> edges = node->edges();
|
||||
foreach(Edge *edge, edges) {
|
||||
if (scene()->items().contains(edge))
|
||||
scene()->removeItem(edge);
|
||||
else
|
||||
delete edge;
|
||||
}
|
||||
scene()->removeItem(node);
|
||||
delete node;
|
||||
}
|
||||
nodeList.clear();
|
||||
|
||||
// Create the nodes
|
||||
qreal w = plot->boundingRect().width()/(points.length()-1);
|
||||
qreal h = plot->boundingRect().height();
|
||||
for (int i=0; i<points.length(); i++) {
|
||||
Node *node = new Node(this);
|
||||
scene()->addItem(node);
|
||||
nodeList.append(node);
|
||||
double val = points.at(i);
|
||||
if (val>curveMax)
|
||||
val=curveMax;
|
||||
if (val<curveMin)
|
||||
val=curveMin;
|
||||
val+=curveMin;
|
||||
val/=(curveMax-curveMin);
|
||||
node->setPos(w*i,h-val*h);
|
||||
node->verticalMove(true);
|
||||
}
|
||||
|
||||
// ... and link them together:
|
||||
for (int i=0; i<(points.length()-1); i++) {
|
||||
scene()->addItem(new Edge(nodeList.at(i),nodeList.at(i+1)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the current curve settings
|
||||
*/
|
||||
QList<double> MixerCurveWidget::getCurve() {
|
||||
QList<double> list;
|
||||
|
||||
qreal h = plot->boundingRect().height();
|
||||
foreach(Node *node, nodeList) {
|
||||
list.append(((curveMax-curveMin)*(h-node->pos().y())/h)+curveMin);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
Setd the current curve settings
|
||||
*/
|
||||
void MixerCurveWidget::setCurve(QList<double> points)
|
||||
{
|
||||
if (nodeList.length()<1)
|
||||
{
|
||||
initCurve(points);
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal w = plot->boundingRect().width()/(points.length()-1);
|
||||
qreal h = plot->boundingRect().height();
|
||||
for (int i=0; i<points.length(); i++) {
|
||||
double val = points.at(i);
|
||||
if (val>curveMax)
|
||||
val=curveMax;
|
||||
if (val<curveMin)
|
||||
val=curveMin;
|
||||
val-=curveMin;
|
||||
val/=(curveMax-curveMin);
|
||||
nodeList.at(i)->setPos(w*i,h-val*h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MixerCurveWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
// Thit fitInView method should only be called now, once the
|
||||
// widget is shown, otherwise it cannot compute its values and
|
||||
// the result is usually a ahrsbargraph that is way too small.
|
||||
fitInView(plot, Qt::KeepAspectRatio);
|
||||
|
||||
}
|
||||
|
||||
void MixerCurveWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
fitInView(plot, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MixerCurveWidget::itemMoved(double itemValue)
|
||||
{
|
||||
QList<double> list = getCurve();
|
||||
emit curveUpdated(list, itemValue);
|
||||
}
|
||||
|
||||
void MixerCurveWidget::setMin(double value)
|
||||
{
|
||||
curveMin = value;
|
||||
}
|
||||
void MixerCurveWidget::setMax(double value)
|
||||
{
|
||||
curveMax = value;
|
||||
}
|
||||
void MixerCurveWidget::setRange(double min, double max)
|
||||
{
|
||||
curveMin = min;
|
||||
curveMax = max;
|
||||
}
|
||||
|
@ -1,70 +1,70 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mixercurvewidget.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Configuration Plugin
|
||||
* @{
|
||||
* @brief A widget which displays a mixer curve
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MIXERCURVEWIDGET_H_
|
||||
#define MIXERCURVEWIDGET_H_
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
#include "mixercurvepoint.h"
|
||||
#include "mixercurveline.h"
|
||||
|
||||
|
||||
class MixerCurveWidget : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MixerCurveWidget(QWidget *parent = 0);
|
||||
~MixerCurveWidget();
|
||||
void itemMoved(double itemValue); // Callback when a point is moved, to be updated
|
||||
void initCurve (QList<double> points);
|
||||
QList<double> getCurve();
|
||||
void setCurve(QList<double>);
|
||||
void setMin(double value);
|
||||
void setMax(double value);
|
||||
void setRange(double min, double max);
|
||||
|
||||
signals:
|
||||
void curveUpdated(QList<double>, double );
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
QGraphicsSvgItem *plot;
|
||||
QList<Node*> nodeList;
|
||||
double curveMin;
|
||||
double curveMax;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
|
||||
};
|
||||
#endif /* MIXERCURVEWIDGET_H_ */
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mixercurvewidget.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Configuration Plugin
|
||||
* @{
|
||||
* @brief A widget which displays a mixer curve
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MIXERCURVEWIDGET_H_
|
||||
#define MIXERCURVEWIDGET_H_
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
#include "mixercurvepoint.h"
|
||||
#include "mixercurveline.h"
|
||||
|
||||
|
||||
class MixerCurveWidget : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MixerCurveWidget(QWidget *parent = 0);
|
||||
~MixerCurveWidget();
|
||||
void itemMoved(double itemValue); // Callback when a point is moved, to be updated
|
||||
void initCurve (QList<double> points);
|
||||
QList<double> getCurve();
|
||||
void setCurve(QList<double>);
|
||||
void setMin(double value);
|
||||
void setMax(double value);
|
||||
void setRange(double min, double max);
|
||||
|
||||
signals:
|
||||
void curveUpdated(QList<double>, double );
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
QGraphicsSvgItem *plot;
|
||||
QList<Node*> nodeList;
|
||||
double curveMin;
|
||||
double curveMax;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
|
||||
};
|
||||
#endif /* MIXERCURVEWIDGET_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user