mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
The bargraph dial can now select its font for each dial type.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@737 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
a8ba7f8d25
commit
204f264a6e
@ -54,5 +54,5 @@ void LineardialGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
m_widget->setRedRange(m->getRedMin(), m->getRedMax());
|
||||
m_widget->connectInput(m->getSourceDataObject(), m->getSourceObjectField());
|
||||
m_widget->setDialFile(m->getDialFile()); // Triggers widget repaint
|
||||
|
||||
m_widget->setDialFont(m->getFont());
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, co
|
||||
stream >> yellowMax;
|
||||
stream >> greenMin;
|
||||
stream >> greenMax;
|
||||
stream >> font;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -91,6 +92,7 @@ QByteArray LineardialGadgetConfiguration::saveState() const
|
||||
stream << yellowMax;
|
||||
stream << greenMin;
|
||||
stream << greenMax;
|
||||
stream << font;
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
void setYellowRange(double min, double max) { yellowMin = min; yellowMax = max;}
|
||||
void setRedRange(double min, double max) { redMin = min; redMax = max;}
|
||||
|
||||
void setFont(QString text) { font = text; }
|
||||
|
||||
void setSourceDataObject(QString text) {sourceDataObject = text; }
|
||||
void setSourceObjField(QString text) { sourceObjectField = text; }
|
||||
|
||||
@ -63,6 +65,7 @@ public:
|
||||
double getRedMax(){ return redMax;}
|
||||
QString getSourceDataObject() { return sourceDataObject;}
|
||||
QString getSourceObjectField() { return sourceObjectField;}
|
||||
QString getFont() { return font;}
|
||||
|
||||
QByteArray saveState() const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
@ -76,6 +79,8 @@ private:
|
||||
// * The name of the UAVObject field to display
|
||||
QString sourceDataObject;
|
||||
QString sourceObjectField;
|
||||
// The font used for the dial
|
||||
QString font;
|
||||
// * The minimum and maximum values to be displayed
|
||||
double minValue;
|
||||
double maxValue;
|
||||
|
@ -35,11 +35,13 @@
|
||||
#include <QFileDialog>
|
||||
#include <QtAlgorithms>
|
||||
#include <QStringList>
|
||||
#include <QFontDialog>
|
||||
|
||||
LineardialGadgetOptionsPage::LineardialGadgetOptionsPage(LineardialGadgetConfiguration *config, QObject *parent) :
|
||||
IOptionsPage(parent),
|
||||
m_config(config)
|
||||
{
|
||||
font = QFont("Arial", 12); // Default in case nothing exists yet.
|
||||
}
|
||||
|
||||
//creates options page widget (uses the UI file)
|
||||
@ -62,6 +64,7 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
options_page->yellowMax->setValue(m_config->getYellowMax());
|
||||
options_page->redMin->setValue(m_config->getRedMin());
|
||||
options_page->redMax->setValue(m_config->getRedMax());
|
||||
font.fromString(m_config->getFont());
|
||||
|
||||
// Fills the combo boxes for the UAVObjects
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
@ -89,6 +92,7 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
|
||||
connect(options_page->objectName, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_objectName_currentIndexChanged(QString)));
|
||||
connect(options_page->loadFile, SIGNAL(clicked()), this, SLOT(on_loadFile_clicked()));
|
||||
connect(options_page->fontPicker, SIGNAL(clicked()), this, SLOT(on_fontPicker_clicked()));
|
||||
|
||||
return optionsPageWidget;
|
||||
}
|
||||
@ -108,8 +112,20 @@ void LineardialGadgetOptionsPage::apply()
|
||||
m_config->setRedRange(options_page->redMin->value(),options_page->redMax->value());
|
||||
m_config->setSourceDataObject(options_page->objectName->currentText());
|
||||
m_config->setSourceObjField(options_page->objectField->currentText());
|
||||
m_config->setFont(font.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a font picker.
|
||||
*
|
||||
*/
|
||||
void LineardialGadgetOptionsPage::on_fontPicker_clicked()
|
||||
{
|
||||
bool ok;
|
||||
font = QFontDialog::getFont(&ok, QFont("Arial", 12), qobject_cast<QWidget*>(this));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Opens an open file dialog.
|
||||
|
@ -29,7 +29,8 @@
|
||||
#define LINEARDIALGADGETOPTIONSPAGE_H
|
||||
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
#include "QString"
|
||||
#include <QString>
|
||||
#include <QFont>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
@ -58,9 +59,11 @@ public:
|
||||
private:
|
||||
Ui::LineardialGadgetOptionsPage *options_page;
|
||||
LineardialGadgetConfiguration *m_config;
|
||||
QFont font;
|
||||
|
||||
private slots:
|
||||
void on_loadFile_clicked();
|
||||
void on_fontPicker_clicked();
|
||||
void on_objectName_currentIndexChanged(QString val);
|
||||
|
||||
};
|
||||
|
@ -28,7 +28,7 @@
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
@ -422,6 +422,46 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dial font:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="fontPicker">
|
||||
<property name="text">
|
||||
<string>Select...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -234,6 +234,16 @@ void LineardialGadgetWidget::setDialFile(QString dfn)
|
||||
{ std::cout<<"no file: "<<std::endl; }
|
||||
}
|
||||
|
||||
|
||||
void LineardialGadgetWidget::setDialFont(QString fontProps)
|
||||
{
|
||||
QFont font = QFont("Arial",12);
|
||||
font.fromString(fontProps);
|
||||
fieldName->setFont(font);
|
||||
fieldValue->setFont(font);
|
||||
}
|
||||
|
||||
|
||||
void LineardialGadgetWidget::paint()
|
||||
{
|
||||
QGraphicsScene *l_scene = scene();
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
void setRedRange(double min, double max) {redMin=min; redMax=max;}
|
||||
void connectInput(QString obj, QString field);
|
||||
void setIndex(double val);
|
||||
void setDialFont(QString fontProps);
|
||||
|
||||
public slots:
|
||||
void updateIndex(UAVObject *object1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user