mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
MixerCurve, Popup Dialog Support.
This commit is contained in:
parent
2be7721a0f
commit
d2c99fefaf
@ -41,6 +41,11 @@ MixerCurve::MixerCurve(QWidget *parent) :
|
||||
m_curve = m_mixerUI->CurveWidget;
|
||||
m_settings = m_mixerUI->CurveSettings;
|
||||
|
||||
|
||||
m_mixerUI->SettingsGroup->hide();
|
||||
m_mixerUI->ValuesGroup->hide();
|
||||
m_curve->showCommands(false);
|
||||
|
||||
// create our spin delegate
|
||||
m_spinDelegate = new DoubleSpinDelegate();
|
||||
|
||||
@ -338,15 +343,26 @@ void MixerCurve::SettingsTableChanged()
|
||||
|
||||
void MixerCurve::CommandActivated(Node* node)
|
||||
{
|
||||
//m_mixerUI->GenerateCurve->hide();
|
||||
|
||||
m_mixerUI->SettingsGroup->hide();
|
||||
m_mixerUI->ValuesGroup->hide();
|
||||
|
||||
QString name = (node) ? node->getName() : "Reset";
|
||||
|
||||
if (name == "Reset") {
|
||||
if (name == "Reset") {
|
||||
ResetCurve();
|
||||
m_curve->showCommands(false);
|
||||
}
|
||||
else if (name == "Commands") {
|
||||
|
||||
}
|
||||
else if (name == "Popup") {
|
||||
m_mixerUI->SettingsGroup->show();
|
||||
m_mixerUI->ValuesGroup->show();
|
||||
|
||||
PopupWidget* popup = new PopupWidget();
|
||||
popup->setWidget(this);
|
||||
popup->exec();
|
||||
|
||||
m_mixerUI->SettingsGroup->hide();
|
||||
m_mixerUI->ValuesGroup->hide();
|
||||
m_curve->showCommands(false);
|
||||
}
|
||||
else if (name == "Linear") {
|
||||
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Linear"));
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "mixercurvewidget.h"
|
||||
#include "dblspindelegate.h"
|
||||
#include "uavobjectwidgetutils_global.h"
|
||||
#include "uavobjectwidgetutils/popupwidget.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
|
@ -196,6 +196,15 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
node->setNegativeColor("#000000", "#000000");
|
||||
scene->addItem(node);
|
||||
|
||||
// popup
|
||||
node = getCommandNode(14);
|
||||
node->setName("Popup");
|
||||
node->setToolTip("Advanced Mode...");
|
||||
node->setToggle(false);
|
||||
node->setPositiveColor("#ff0000", "#ff0000"); //red
|
||||
node->setNegativeColor("#ff0000", "#ff0000");
|
||||
scene->addItem(node);
|
||||
|
||||
resizeCommands();
|
||||
|
||||
initNodes(MixerCurveWidget::NODE_NUMELEM);
|
||||
@ -229,10 +238,11 @@ Node* MixerCurveWidget::getCommandNode(int index)
|
||||
node->setCommandIndex(index);
|
||||
node->setActive(false);
|
||||
node->setPositiveColor("#aaaa00", "#aaaa00");
|
||||
node->setNegativeColor("#aa00aa", "#aa00aa");
|
||||
node->setNegativeColor("#1c870b", "#116703");
|
||||
cmdNodePool.append(node);
|
||||
}
|
||||
return node;
|
||||
|
||||
}
|
||||
|
||||
Node* MixerCurveWidget::getNode(int index)
|
||||
@ -429,13 +439,17 @@ void MixerCurveWidget::resizeCommands()
|
||||
QRectF rect = plot->boundingRect();
|
||||
|
||||
Node* node;
|
||||
//popup
|
||||
node = getCommandNode(14);
|
||||
node->setPos((rect.left() + rect.width() / 2) - 20, rect.height() + 10);
|
||||
|
||||
//reset
|
||||
node = getCommandNode(0);
|
||||
node->setPos((rect.left() + rect.width() / 2) - 10, rect.height() + 10);
|
||||
node->setPos((rect.left() + rect.width() / 2) + 20, rect.height() + 10);
|
||||
|
||||
//commands on/off
|
||||
node = getCommandNode(13);
|
||||
node->setPos((rect.left() + rect.width() / 2) + 10, rect.height() + 10);
|
||||
node->setPos((rect.left() + rect.width() / 2) + 40, rect.height() + 10);
|
||||
|
||||
for (int i = 1; i<6; i++) {
|
||||
node = getCommandNode(i);
|
||||
@ -539,7 +553,7 @@ void MixerCurveWidget::setCommandText(const QString& name, const QString& text)
|
||||
}
|
||||
void MixerCurveWidget::activateCommand(const QString& name)
|
||||
{
|
||||
for (int i=1; i<cmdNodePool.count()-1; i++) {
|
||||
for (int i=1; i<cmdNodePool.count()-2; i++) {
|
||||
Node* node = cmdNodePool.at(i);
|
||||
node->setCommandActive(node->getName() == name);
|
||||
node->update();
|
||||
@ -548,7 +562,7 @@ void MixerCurveWidget::activateCommand(const QString& name)
|
||||
|
||||
void MixerCurveWidget::showCommands(bool show)
|
||||
{
|
||||
for (int i=1; i<cmdNodePool.count()-1; i++) {
|
||||
for (int i=1; i<cmdNodePool.count()-2; i++) {
|
||||
Node* node = cmdNodePool.at(i);
|
||||
if (show)
|
||||
node->show();
|
||||
@ -566,7 +580,7 @@ void MixerCurveWidget::cmdActivated(Node* node)
|
||||
showCommands(node->getCommandActive());
|
||||
}
|
||||
else {
|
||||
for (int i=1; i<cmdNodePool.count()-1; i++) {
|
||||
for (int i=1; i<cmdNodePool.count()-2; i++) {
|
||||
Node* n = cmdNodePool.at(i);
|
||||
n->setCommandActive(false);
|
||||
n->update();
|
||||
|
@ -0,0 +1,46 @@
|
||||
#include "popupwidget.h"
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
PopupWidget::PopupWidget(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
m_widget = 0;
|
||||
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout();
|
||||
|
||||
m_layout = new QHBoxLayout();
|
||||
mainLayout->addLayout(m_layout);
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout();
|
||||
|
||||
m_closeButton = new QPushButton(tr("Close"));
|
||||
buttonLayout->addWidget(m_closeButton);
|
||||
|
||||
mainLayout->addLayout(buttonLayout);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
connect(m_closeButton,SIGNAL(clicked()), this, SLOT(closePopup()));
|
||||
}
|
||||
|
||||
void PopupWidget::setWidget(QWidget* widget)
|
||||
{
|
||||
m_widget = widget;
|
||||
m_widgetParent = widget->parentWidget();
|
||||
|
||||
m_layout->addWidget(m_widget);
|
||||
}
|
||||
|
||||
|
||||
void PopupWidget::closePopup()
|
||||
{
|
||||
if (m_widget && m_widgetParent) {
|
||||
if(QGroupBox * w =qobject_cast<QGroupBox *>(m_widgetParent))
|
||||
{
|
||||
w->layout()->addWidget(m_widget);
|
||||
}
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
#ifndef POPUPWIDGET_H
|
||||
#define POPUPWIDGET_H
|
||||
|
||||
#include <QtGui>
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
#include "uavobjectwidgetutils_global.h"
|
||||
|
||||
namespace Ui {
|
||||
class PopupWidget;
|
||||
}
|
||||
|
||||
class UAVOBJECTWIDGETUTILS_EXPORT PopupWidget : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PopupWidget(QWidget *parent = 0);
|
||||
|
||||
void setWidget(QWidget* widget);
|
||||
QWidget* getWidget() { return m_widget; }
|
||||
QHBoxLayout* getLayout() { return m_layout; }
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void closePopup();
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QWidget* m_widget;
|
||||
QWidget* m_widgetParent;
|
||||
QPushButton* m_closeButton;
|
||||
};
|
||||
|
||||
#endif // POPUPWIDGET_H
|
@ -10,13 +10,15 @@ HEADERS += uavobjectwidgetutils_global.h \
|
||||
mixercurvewidget.h \
|
||||
mixercurvepoint.h \
|
||||
mixercurveline.h \
|
||||
smartsavebutton.h
|
||||
smartsavebutton.h \
|
||||
popupwidget.h
|
||||
SOURCES += uavobjectwidgetutilsplugin.cpp \
|
||||
configtaskwidget.cpp \
|
||||
mixercurvewidget.cpp \
|
||||
mixercurvepoint.cpp \
|
||||
mixercurveline.cpp \
|
||||
smartsavebutton.cpp
|
||||
smartsavebutton.cpp \
|
||||
popupwidget.cpp
|
||||
|
||||
|
||||
OTHER_FILES += UAVObjectWidgetUtils.pluginspec
|
||||
|
Loading…
x
Reference in New Issue
Block a user