Commit 9ad1179b authored by Bryant's avatar Bryant

Now I've added suitable styling to the UASQuickView widget.

parent e536522e
......@@ -392,6 +392,17 @@ QToolTip {
color: #DDD;
}
UASQuickViewItem QLabel {
padding: 0;
margin: 0;
min-height: 1em;
font-weight: bold;
}
UASQuickViewItem QLabel#value {
font-size: 20pt;
}
WaypointEditableView, WaypointViewOnlyView {
border: 1px solid #777;
border-radius: 5px;
......
......@@ -396,6 +396,17 @@ QToolTip {
color: #000;
}
UASQuickViewItem QLabel {
padding: 0;
margin: 0;
min-height: 1em;
font-weight: bold;
}
UASQuickViewItem QLabel#value {
font-size: 20pt;
}
WaypointEditableView, WaypointViewOnlyView {
border: 1px solid #333;
border-radius: 5px;
......
#include "UASQuickView.h"
#include <QMetaMethod>
#include <QDebug>
UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
UASQuickView::UASQuickView(QWidget *parent) :
QWidget(parent),
m_ui(new Ui::UASQuickView)
{
ui.setupUi(this);
m_ui->setupUi(this);
connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(setActiveUAS(UASInterface*)));
connect(UASManager::instance(),SIGNAL(UASCreated(UASInterface*)),this,SLOT(addUAS(UASInterface*)));
if (UASManager::instance()->getActiveUAS())
......@@ -21,7 +24,7 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("latitude");
ui.verticalLayout->addWidget(item);
this->layout()->addWidget(item);
uasPropertyToLabelMap["latitude"] = item;
}
......@@ -33,7 +36,7 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("longitude");
ui.verticalLayout->addWidget(item);
this->layout()->addWidget(item);
uasPropertyToLabelMap["longitude"] = item;
}
......@@ -45,7 +48,7 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("altitude");
ui.verticalLayout->addWidget(item);
this->layout()->addWidget(item);
uasPropertyToLabelMap["altitude"] = item;
}
......@@ -57,7 +60,7 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("satelliteCount");
ui.verticalLayout->addWidget(item);
this->layout()->addWidget(item);
uasPropertyToLabelMap["satelliteCount"] = item;
}
......@@ -69,7 +72,7 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("distToWaypoint");
ui.verticalLayout->addWidget(item);
this->layout()->addWidget(item);
uasPropertyToLabelMap["distToWaypoint"] = item;
}
......@@ -146,12 +149,12 @@ void UASQuickView::actionTriggered(bool checked)
{
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle(senderlabel->text());
ui.verticalLayout->addWidget(item);
this->layout()->addWidget(item);
uasPropertyToLabelMap[senderlabel->text()] = item;
}
else
{
ui.verticalLayout->removeWidget(uasPropertyToLabelMap[senderlabel->text()]);
this->layout()->removeWidget(uasPropertyToLabelMap[senderlabel->text()]);
uasPropertyToLabelMap[senderlabel->text()]->deleteLater();
uasPropertyToLabelMap.remove(senderlabel->text());
......
......@@ -19,10 +19,9 @@ private:
QMap<QString,double> uasPropertyValueMap;
QMap<QString,UASQuickViewItem*> uasPropertyToLabelMap;
QTimer *updateTimer;
protected:
Ui::Form ui;
Ui::UASQuickView* m_ui;
signals:
public slots:
void valueChanged(const int uasid, const QString& name, const QString& unit, const QVariant value,const quint64 msecs);
void actionTriggered(bool checked);
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<class>UASQuickView</class>
<widget class="QWidget" name="UASQuickView">
<property name="geometry">
<rect>
<x>0</x>
......@@ -10,6 +10,12 @@
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
......@@ -20,9 +26,12 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout"/>
</item>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
<resources/>
......
#include "UASQuickViewItem.h"
#include <QVBoxLayout>
#include <QStyleOption>
#include <QPainter>
#include <QSizePolicy>
UASQuickViewItem::UASQuickViewItem(QWidget *parent) : QWidget(parent)
UASQuickViewItem::UASQuickViewItem(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout();
this->setLayout(layout);
QVBoxLayout* layout = new QVBoxLayout();
layout->setMargin(0);
layout->setSizeConstraint(QLayout::SetMinimumSize);
titleLabel = new QLabel(this);
titleLabel->setAlignment(Qt::AlignHCenter);
this->layout()->addWidget(titleLabel);
titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum);
titleLabel->setObjectName(QString::fromUtf8("title"));
layout->addWidget(titleLabel);
valueLabel = new QLabel(this);
valueLabel->setAlignment(Qt::AlignHCenter);
valueLabel->setText("<h1>0.00</h1>");
this->layout()->addWidget(valueLabel);
layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
valueLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum);
valueLabel->setObjectName(QString::fromUtf8("value"));
valueLabel->setText("0.00");
layout->addWidget(valueLabel);
layout->addSpacerItem(new QSpacerItem(20, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
this->setLayout(layout);
}
void UASQuickViewItem::setValue(double value)
{
valueLabel->setText("<h1>" + QString::number(value,'f',4) + "</h1>");
valueLabel->setText(QString::number(value,'f',4));
}
void UASQuickViewItem::setTitle(QString title)
{
titleLabel->setText(title);
}
/**
* Implement paintEvent() so that stylesheets work for our custom widget.
*/
void UASQuickViewItem::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
......@@ -13,10 +13,12 @@ public:
private:
QLabel *titleLabel;
QLabel *valueLabel;
protected:
virtual void paintEvent(QPaintEvent *);
signals:
public slots:
};
#endif // UASQUICKVIEWITEM_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment