1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS-Review comments changes

Added font mixer curve font size to linux default and wide stylesheets
Change Node class name to MixerNode to ease stylesheet access
Changed language selection to top of the list
This commit is contained in:
PT_Dreamer 2012-09-12 11:09:30 +01:00
parent 09f950ff76
commit c11958c9b6
12 changed files with 165 additions and 164 deletions

View File

@ -1,4 +1,5 @@
MyListWidget {font-size: 11px;}
MixerCurveWidget {font-size: 12px;}
Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));}

View File

@ -1,4 +1,5 @@
MyListWidget {font-size: 11px;}
MixerCurveWidget {font-size: 12px;}
Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));}

View File

@ -67,7 +67,7 @@ MixerCurve::MixerCurve(QWidget *parent) :
connect(m_mixerUI->PopupCurve, SIGNAL(clicked()),this,SLOT(PopupCurve()));
connect(m_mixerUI->GenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve()));
connect(m_curve, SIGNAL(curveUpdated()), this, SLOT(UpdateSettingsTable()));
connect(m_curve, SIGNAL(commandActivated(Node*)),this, SLOT(CommandActivated(Node*)));
connect(m_curve, SIGNAL(commandActivated(MixerNode*)),this, SLOT(CommandActivated(MixerNode*)));
connect(m_settings, SIGNAL(cellChanged(int,int)), this, SLOT(SettingsTableChanged()));
connect(m_mixerUI->CurveMin, SIGNAL(valueChanged(double)), this, SLOT(CurveMinChanged(double)));
connect(m_mixerUI->CurveMax, SIGNAL(valueChanged(double)), this, SLOT(CurveMaxChanged(double)));
@ -370,7 +370,7 @@ void MixerCurve::SettingsTableChanged()
m_curve->setCurve(&points);
}
void MixerCurve::CommandActivated(Node* node)
void MixerCurve::CommandActivated(MixerNode* node)
{
QString name = (node) ? node->getName() : "Reset";

View File

@ -84,7 +84,7 @@ public slots:
void UpdateSettingsTable();
private slots:
void CommandActivated(Node* node = 0);
void CommandActivated(MixerNode* node = 0);
void SettingsTableChanged();
void CurveTypeChanged();
void CurveMinChanged(double value);

View File

@ -103,8 +103,7 @@ private slots:
void onConnectClicked();
void devChanged(IConnection *connection);
// void onConnectionClosed(QObject *obj);
void onConnectionDestroyed(QObject *obj);
void onConnectionDestroyed(QObject *obj);
void connectionsCallBack(); //used to call devChange after all the plugins are loaded
void reconnectSlot();
void reconnectCheckSlot();

View File

@ -17,14 +17,14 @@
<string>General settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>User interface color:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
@ -79,7 +79,7 @@
</layout>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
@ -88,14 +88,98 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<item row="10" column="1">
<widget class="QCheckBox" name="checkBoxSaveOnExit">
<property name="text">
<string>Language:</string>
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="10" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Save configuration settings on exit:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Automatically connect an OpenPilot USB device:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="checkAutoConnect">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Automatically select an OpenPilot USB device:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QCheckBox" name="checkAutoSelect">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QCheckBox" name="cbUseUDPMirror">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="labelUDP">
<property name="text">
<string>Use UDP Mirror</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="labelExpert">
<property name="text">
<string>Expert Mode</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="cbExpertMode">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="languageBox"/>
@ -115,94 +199,10 @@
</item>
</layout>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="checkBoxSaveOnExit">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Save configuration settings on exit:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Automatically connect an OpenPilot USB device:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="checkAutoConnect">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Automatically select an OpenPilot USB device:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="checkAutoSelect">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QCheckBox" name="cbUseUDPMirror">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="labelUDP">
<property name="text">
<string>Use UDP Mirror</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="labelExpert">
<property name="text">
<string>Expert Mode</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QCheckBox" name="cbExpertMode">
<property name="text">
<string/>
<string>Language:</string>
</property>
</widget>
</item>

View File

@ -35,7 +35,7 @@
static const double Pi = 3.14159265358979323846264338327950288419717;
// static double TwoPi = 2.0 * Pi;
Edge::Edge(Node *sourceNode, Node *destNode)
Edge::Edge(MixerNode *sourceNode, MixerNode *destNode)
: arrowSize(10)
{
setAcceptedMouseButtons(0);
@ -50,23 +50,23 @@ Edge::~Edge()
{
}
Node *Edge::sourceNode() const
MixerNode *Edge::sourceNode() const
{
return source;
}
void Edge::setSourceNode(Node *node)
void Edge::setSourceNode(MixerNode *node)
{
source = node;
adjust();
}
Node *Edge::destNode() const
MixerNode *Edge::destNode() const
{
return dest;
}
void Edge::setDestNode(Node *node)
void Edge::setDestNode(MixerNode *node)
{
dest = node;
adjust();

View File

@ -35,19 +35,19 @@
#include <QGraphicsItem>
class Node;
class MixerNode;
class Edge : public QGraphicsItem
{
public:
Edge(Node *sourceNode, Node *destNode);
Edge(MixerNode *sourceNode, MixerNode *destNode);
~Edge();
Node *sourceNode() const;
void setSourceNode(Node *node);
MixerNode *sourceNode() const;
void setSourceNode(MixerNode *node);
Node *destNode() const;
void setDestNode(Node *node);
MixerNode *destNode() const;
void setDestNode(MixerNode *node);
void adjust();
@ -59,7 +59,7 @@ protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
Node *source, *dest;
MixerNode *source, *dest;
QPointF sourcePoint;
QPointF destPoint;

View File

@ -36,7 +36,7 @@
#include "mixercurvepoint.h"
#include "mixercurvewidget.h"
Node::Node(MixerCurveWidget *graphWidget)
MixerNode::MixerNode(MixerCurveWidget *graphWidget)
: graph(graphWidget)
{
setFlag(ItemIsMovable);
@ -54,37 +54,36 @@ Node::Node(MixerCurveWidget *graphWidget)
posColor1 = "#116703"; //greenish?
negColor0 = "#aa0000"; //red
negColor1 = "#aa0000"; //red
}
void Node::addEdge(Edge *edge)
void MixerNode::addEdge(Edge *edge)
{
edgeList << edge;
edge->adjust();
}
QList<Edge *> Node::edges() const
QList<Edge *> MixerNode::edges() const
{
return edgeList;
}
QRectF Node::boundingRect() const
QRectF MixerNode::boundingRect() const
{
return cmdNode ? QRectF(-4, -4, 15, 10) : QRectF(-13, -13, 26, 26);
}
QPainterPath Node::shape() const
QPainterPath MixerNode::shape() const
{
QPainterPath path;
path.addEllipse(boundingRect());
return path;
}
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
void MixerNode::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QString text = cmdNode ? cmdText : QString().sprintf("%.2f", value());
painter->setFont(graph->font());
if (drawNode) {
QRadialGradient gradient(-3, -3, 10);
if (option->state & QStyle::State_Sunken) {
@ -128,25 +127,25 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
}
}
void Node::verticalMove(bool flag){
void MixerNode::verticalMove(bool flag){
vertical = flag;
}
void Node::commandNode(bool enable){
void MixerNode::commandNode(bool enable){
cmdNode = enable;
}
void Node::commandText(QString text){
void MixerNode::commandText(QString text){
cmdText = text;
}
double Node::value() {
double MixerNode::value() {
double h = graph->sceneRect().height();
double ratio = (h - pos().y()) / h;
return ((graph->getMax() - graph->getMin()) * ratio ) + graph->getMin();
}
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &val)
QVariant MixerNode::itemChange(GraphicsItemChange change, const QVariant &val)
{
QPointF newPos = val.toPointF();
double h = graph->sceneRect().height();
@ -185,7 +184,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &val)
return QGraphicsItem::itemChange(change, val);
}
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
void MixerNode::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (cmdNode) {
graph->cmdActivated(this);
@ -195,7 +194,7 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mousePressEvent(event);
}
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void MixerNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
update();
QGraphicsItem::mouseReleaseEvent(event);

View File

@ -31,6 +31,7 @@
#include <QGraphicsItem>
#include <QColor>
#include <QList>
#include <QFont>
class Edge;
class MixerCurveWidget;
@ -38,11 +39,11 @@ QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
QT_END_NAMESPACE
class Node : public QGraphicsItem
class MixerNode : public QObject,public QGraphicsItem
{
Q_OBJECT
public:
Node(MixerCurveWidget *graphWidget);
MixerNode(MixerCurveWidget *graphWidget);
void addEdge(Edge *edge);
QList<Edge *> edges() const;

View File

@ -80,7 +80,7 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
// commmand nodes
// reset
Node* node = getCommandNode(0);
MixerNode* node = getCommandNode(0);
node->setName("Reset");
node->setToolTip("Reset Curve to Defaults");
node->setToggle(false);
@ -274,16 +274,16 @@ MixerCurveWidget::~MixerCurveWidget()
delete cmdNodePool.takeFirst();
}
Node* MixerCurveWidget::getCommandNode(int index)
MixerNode* MixerCurveWidget::getCommandNode(int index)
{
Node* node;
MixerNode* node;
if (index >= 0 && index < cmdNodePool.count())
{
node = cmdNodePool.at(index);
}
else {
node = new Node(this);
node = new MixerNode(this);
node->commandNode(true);
node->commandText("");
node->setCommandIndex(index);
@ -296,21 +296,21 @@ Node* MixerCurveWidget::getCommandNode(int index)
}
Node* MixerCurveWidget::getNode(int index)
MixerNode* MixerCurveWidget::getNode(int index)
{
Node* node;
MixerNode* node;
if (index >= 0 && index < nodePool.count())
{
node = nodePool.at(index);
}
else {
node = new Node(this);
node = new MixerNode(this);
nodePool.append(node);
}
return node;
}
Edge* MixerCurveWidget::getEdge(int index, Node* sourceNode, Node* destNode)
Edge* MixerCurveWidget::getEdge(int index, MixerNode* sourceNode, MixerNode* destNode)
{
Edge* edge;
@ -332,7 +332,7 @@ void MixerCurveWidget::setPositiveColor(QString color0, QString color1)
posColor0 = color0;
posColor1 = color1;
for (int i=0; i<nodePool.count(); i++) {
Node* node = nodePool.at(i);
MixerNode* node = nodePool.at(i);
node->setPositiveColor(color0, color1);
}
}
@ -341,7 +341,7 @@ void MixerCurveWidget::setNegativeColor(QString color0, QString color1)
negColor0 = color0;
negColor1 = color1;
for (int i=0; i<nodePool.count(); i++) {
Node* node = nodePool.at(i);
MixerNode* node = nodePool.at(i);
node->setNegativeColor(color0, color1);
}
}
@ -366,7 +366,7 @@ void MixerCurveWidget::initNodes(int numPoints)
{
// First of all, clear any existing list
if (nodeList.count()) {
foreach (Node *node, nodeList ) {
foreach (MixerNode *node, nodeList ) {
foreach(Edge *edge, node->edges()) {
if (edge->sourceNode() == node) {
scene()->removeItem(edge);
@ -379,10 +379,10 @@ void MixerCurveWidget::initNodes(int numPoints)
}
// Create the nodes and edges
Node* prevNode = 0;
MixerNode* prevNode = 0;
for (int i=0; i<numPoints; i++) {
Node *node = getNode(i);
MixerNode *node = getNode(i);
nodeList.append(node);
scene()->addItem(node);
@ -404,7 +404,7 @@ QList<double> MixerCurveWidget::getCurve() {
QList<double> list;
foreach(Node *node, nodeList) {
foreach(MixerNode *node, nodeList) {
list.append(node->value());
}
@ -447,7 +447,7 @@ void MixerCurveWidget::setCurve(const QList<double>* points)
val -= (curveMin + range);
val /= range;
Node* node = nodeList.at(i);
MixerNode* node = nodeList.at(i);
node->setPos(w*i, h - (val*h));
node->verticalMove(true);
@ -486,7 +486,7 @@ void MixerCurveWidget::resizeCommands()
{
QRectF rect = plot->boundingRect();
Node* node;
MixerNode* node;
//popup
node = getCommandNode(14);
node->setPos((rect.left() + rect.width() / 2) - 20, rect.height() + 10);
@ -575,11 +575,11 @@ double MixerCurveWidget::setRange(double min, double max)
return curveMax - curveMin;
}
Node* MixerCurveWidget::getCmdNode(const QString& name)
MixerNode* MixerCurveWidget::getCmdNode(const QString& name)
{
Node* node = 0;
MixerNode* node = 0;
for (int i=0; i<cmdNodePool.count(); i++) {
Node* n = cmdNodePool.at(i);
MixerNode* n = cmdNodePool.at(i);
if (n->getName() == name)
node = n;
}
@ -589,7 +589,7 @@ Node* MixerCurveWidget::getCmdNode(const QString& name)
void MixerCurveWidget::setCommandText(const QString& name, const QString& text)
{
for (int i=0; i<cmdNodePool.count(); i++) {
Node* n = cmdNodePool.at(i);
MixerNode* n = cmdNodePool.at(i);
if (n->getName() == name) {
n->commandText(text);
n->update();
@ -599,7 +599,7 @@ void MixerCurveWidget::setCommandText(const QString& name, const QString& text)
void MixerCurveWidget::activateCommand(const QString& name)
{
for (int i=1; i<cmdNodePool.count()-2; i++) {
Node* node = cmdNodePool.at(i);
MixerNode* node = cmdNodePool.at(i);
node->setCommandActive(node->getName() == name);
node->update();
}
@ -607,7 +607,7 @@ void MixerCurveWidget::activateCommand(const QString& name)
void MixerCurveWidget::showCommand(const QString& name, bool show)
{
Node* node = getCmdNode(name);
MixerNode* node = getCmdNode(name);
if (node) {
if (show)
node->show();
@ -618,7 +618,7 @@ void MixerCurveWidget::showCommand(const QString& name, bool show)
void MixerCurveWidget::showCommands(bool show)
{
for (int i=1; i<cmdNodePool.count()-2; i++) {
Node* node = cmdNodePool.at(i);
MixerNode* node = cmdNodePool.at(i);
if (show)
node->show();
else
@ -630,14 +630,14 @@ void MixerCurveWidget::showCommands(bool show)
bool MixerCurveWidget::isCommandActive(const QString& name)
{
bool active = false;
Node* node = getCmdNode(name);
MixerNode* node = getCmdNode(name);
if (node) {
active = node->getCommandActive();
}
return active;
}
void MixerCurveWidget::cmdActivated(Node* node)
void MixerCurveWidget::cmdActivated(MixerNode* node)
{
if (node->getToggle()) {
if (node->getName() == "Commands") {
@ -646,7 +646,7 @@ void MixerCurveWidget::cmdActivated(Node* node)
}
else {
for (int i=1; i<cmdNodePool.count()-2; i++) {
Node* n = cmdNodePool.at(i);
MixerNode* n = cmdNodePool.at(i);
n->setCommandActive(false);
n->update();
}

View File

@ -59,12 +59,12 @@ public:
double setRange(double min, double max);
void cmdActivated(Node* node);
void cmdActivated(MixerNode* node);
void activateCommand(const QString& name);
bool isCommandActive(const QString& name);
void showCommand(const QString& name, bool show);
void showCommands(bool show);
Node* getCmdNode(const QString& name);
MixerNode* getCmdNode(const QString& name);
void setCommandText(const QString& name, const QString& text);
static const int NODE_NUMELEM = 5;
@ -73,17 +73,17 @@ signals:
void curveUpdated();
void curveMinChanged(double value);
void curveMaxChanged(double value);
void commandActivated(Node* node);
void commandActivated(MixerNode* node);
private slots:
private:
QGraphicsSvgItem *plot;
QList<Node*> nodePool;
QList<Node*> cmdNodePool;
QList<MixerNode*> nodePool;
QList<MixerNode*> cmdNodePool;
QList<Edge*> edgePool;
QList<Node*> nodeList;
QList<MixerNode*> nodeList;
double curveMin;
double curveMax;
@ -95,9 +95,9 @@ private:
QString negColor1;
void initNodes(int numPoints);
Node* getNode(int index);
Node* getCommandNode(int index);
Edge* getEdge(int index, Node* sourceNode, Node* destNode);
MixerNode* getNode(int index);
MixerNode* getCommandNode(int index);
Edge* getEdge(int index, MixerNode* sourceNode, MixerNode* destNode);
void setPositiveColor(QString color0 = "#00ff00", QString color1 = "#00ff00");
void setNegativeColor(QString color0 = "#ff0000", QString color1 = "#ff0000");