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