mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
Update UI::Dashboard rendering
This commit is contained in:
parent
a07cfbecdc
commit
8e4d2c9fcd
@ -39,6 +39,7 @@ void Misc::TimerEvents::stopTimers()
|
||||
{
|
||||
m_timer1Hz.stop();
|
||||
m_timer10Hz.stop();
|
||||
m_timer20Hz.stop();
|
||||
m_timer24Hz.stop();
|
||||
}
|
||||
|
||||
@ -53,6 +54,9 @@ void Misc::TimerEvents::timerEvent(QTimerEvent *event)
|
||||
else if (event->timerId() == m_timer10Hz.timerId())
|
||||
Q_EMIT timeout10Hz();
|
||||
|
||||
else if (event->timerId() == m_timer20Hz.timerId())
|
||||
Q_EMIT timeout20Hz();
|
||||
|
||||
else if (event->timerId() == m_timer24Hz.timerId())
|
||||
Q_EMIT timeout24Hz();
|
||||
}
|
||||
@ -63,6 +67,7 @@ void Misc::TimerEvents::timerEvent(QTimerEvent *event)
|
||||
void Misc::TimerEvents::startTimers()
|
||||
{
|
||||
m_timer1Hz.start(1000, Qt::PreciseTimer, this);
|
||||
m_timer20Hz.start(1000 / 20, Qt::PreciseTimer, this);
|
||||
m_timer24Hz.start(1000 / 24, Qt::PreciseTimer, this);
|
||||
m_timer10Hz.start(1000 / 10, Qt::PreciseTimer, this);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class TimerEvents : public QObject
|
||||
signals:
|
||||
void timeout1Hz();
|
||||
void timeout10Hz();
|
||||
void timeout20Hz();
|
||||
void timeout24Hz();
|
||||
|
||||
private:
|
||||
@ -62,6 +63,7 @@ public slots:
|
||||
private:
|
||||
QBasicTimer m_timer1Hz;
|
||||
QBasicTimer m_timer10Hz;
|
||||
QBasicTimer m_timer20Hz;
|
||||
QBasicTimer m_timer24Hz;
|
||||
};
|
||||
} // namespace Misc
|
||||
|
@ -71,7 +71,7 @@ UI::DeclarativeWidget::DeclarativeWidget(QQuickItem *parent)
|
||||
&UI::DeclarativeWidget::resizeWidget);
|
||||
|
||||
// Configure render loop
|
||||
connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout24Hz, this,
|
||||
connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout20Hz, this,
|
||||
&UI::DeclarativeWidget::renderWidget);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ void UI::DeclarativeWidget::setWidget(QWidget *widget)
|
||||
delete m_widget;
|
||||
|
||||
m_widget = widget;
|
||||
m_widget->setAttribute(Qt::WA_UpdatesDisabled, true);
|
||||
m_widget->setUpdatesEnabled(false);
|
||||
Q_EMIT widgetChanged();
|
||||
}
|
||||
}
|
||||
@ -227,10 +227,11 @@ void UI::DeclarativeWidget::setWidget(QWidget *widget)
|
||||
*/
|
||||
void UI::DeclarativeWidget::renderWidget()
|
||||
{
|
||||
if (widget() && isVisible())
|
||||
if (m_widget && isVisible())
|
||||
{
|
||||
widget()->update();
|
||||
m_widget->setUpdatesEnabled(true);
|
||||
m_pixmap = widget()->grab();
|
||||
m_widget->setUpdatesEnabled(false);
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -245,7 +246,7 @@ void UI::DeclarativeWidget::resizeWidget()
|
||||
if (width() > 0 && height() > 0)
|
||||
{
|
||||
widget()->setFixedSize(width(), height());
|
||||
update();
|
||||
renderWidget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,5 +139,4 @@ void Widgets::Accelerometer::onThemeChanged()
|
||||
// Update gauge colors
|
||||
m_gauge.setPalette(palette);
|
||||
m_gauge.setNeedle(needle);
|
||||
update();
|
||||
}
|
||||
|
@ -131,6 +131,4 @@ void Widgets::Bar::onThemeChanged()
|
||||
: colors.at(colors.count() % m_index).toString();
|
||||
|
||||
m_thermo.setFillBrush(QBrush(QColor(color)));
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -108,10 +108,7 @@ void AttitudeIndicator::setGradient(const double &gradient)
|
||||
auto grad = qMin(1.0, qMax(gradient, -1.0));
|
||||
|
||||
if (m_gradient != grad)
|
||||
{
|
||||
m_gradient = grad;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void AttitudeIndicator::drawScale(QPainter *painter, const QPointF ¢er,
|
||||
|
@ -66,7 +66,7 @@ Widgets::Compass::Compass(const int index)
|
||||
this, &Widgets::Compass::onThemeChanged);
|
||||
|
||||
// Connect update signal
|
||||
connect(dash, &UI::Dashboard::updated, this, &Compass::update,
|
||||
connect(dash, &UI::Dashboard::updated, this, &Compass::updateData,
|
||||
Qt::DirectConnection);
|
||||
}
|
||||
|
||||
@ -75,9 +75,9 @@ Widgets::Compass::Compass(const int index)
|
||||
* to display the latest data frame.
|
||||
*
|
||||
* If the widget is disabled (e.g. the user hides it, or the external
|
||||
* window is hidden), then the widget shall ignore the update request.
|
||||
* window is hidden), then the widget shall ignore the updateData request.
|
||||
*/
|
||||
void Widgets::Compass::update()
|
||||
void Widgets::Compass::updateData()
|
||||
{
|
||||
// Widget disabled
|
||||
if (!isEnabled())
|
||||
@ -118,5 +118,4 @@ void Widgets::Compass::onThemeChanged()
|
||||
palette.setColor(QPalette::Text,
|
||||
theme->getColor(QStringLiteral("widget_text")));
|
||||
m_compass.setPalette(palette);
|
||||
update();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
Compass(const int index = -1);
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
void updateData();
|
||||
void onThemeChanged();
|
||||
|
||||
private:
|
||||
|
@ -241,9 +241,6 @@ void Widgets::DataGrid::onThemeChanged()
|
||||
units->setStyleSheet(unitsQSS);
|
||||
dicon->setStyleSheet(iconsQSS);
|
||||
}
|
||||
|
||||
// Redraw widget
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,9 +185,6 @@ void Widgets::FFTPlot::onThemeChanged()
|
||||
|
||||
// Set curve color & plot style
|
||||
m_curve.setPen(QColor(color), 2, Qt::SolidLine);
|
||||
|
||||
// Redraw widget
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,9 +195,6 @@ void Widgets::FFTPlot::onThemeChanged()
|
||||
* dashboard. Depending on the user’s selection, it will set the visibility of
|
||||
* the X and/or Y axes on the plot.
|
||||
*
|
||||
* After adjusting the visibility settings, the plot is updated by calling the
|
||||
* `update()` method.
|
||||
*
|
||||
* @see UI::Dashboard::axisVisibility()
|
||||
* @see QwtPlot::setAxisVisible()
|
||||
*/
|
||||
@ -225,6 +219,4 @@ void Widgets::FFTPlot::onAxisOptionsChanged()
|
||||
m_plot.setAxisVisible(QwtPlot::xBottom, false);
|
||||
break;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -126,5 +126,4 @@ void Widgets::GPS::onThemeChanged()
|
||||
palette.setColor(QPalette::Window,
|
||||
theme->getColor(QStringLiteral("widget_window")));
|
||||
setPalette(palette);
|
||||
update();
|
||||
}
|
||||
|
@ -108,5 +108,4 @@ void Widgets::Gauge::onThemeChanged()
|
||||
// Update gauge colors
|
||||
m_gauge.setPalette(palette);
|
||||
m_gauge.setNeedle(needle);
|
||||
update();
|
||||
}
|
||||
|
@ -229,7 +229,4 @@ void Widgets::LEDPanel::onThemeChanged()
|
||||
title->setPalette(palette);
|
||||
led->setColor(theme->getColor("led_color"));
|
||||
}
|
||||
|
||||
// Redraw widget
|
||||
update();
|
||||
}
|
||||
|
@ -235,9 +235,6 @@ void Widgets::MultiPlot::onThemeChanged()
|
||||
* dashboard. Depending on the user’s selection, it will set the visibility of
|
||||
* the X and/or Y axes on the plot.
|
||||
*
|
||||
* After adjusting the visibility settings, the plot is updated by calling the
|
||||
* `update()` method.
|
||||
*
|
||||
* @see UI::Dashboard::axisVisibility()
|
||||
* @see QwtPlot::setAxisVisible()
|
||||
*/
|
||||
@ -262,6 +259,4 @@ void Widgets::MultiPlot::onAxisOptionsChanged()
|
||||
m_plot.setAxisVisible(QwtPlot::xBottom, false);
|
||||
break;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -237,7 +237,6 @@ void Widgets::Plot::onThemeChanged()
|
||||
|
||||
// Set curve color & plot style
|
||||
m_curve.setPen(QColor(color), 2, Qt::SolidLine);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,9 +247,6 @@ void Widgets::Plot::onThemeChanged()
|
||||
* dashboard. Depending on the user’s selection, it will set the visibility of
|
||||
* the X and/or Y axes on the plot.
|
||||
*
|
||||
* After adjusting the visibility settings, the plot is updated by calling the
|
||||
* `update()` method.
|
||||
*
|
||||
* @see UI::Dashboard::axisVisibility()
|
||||
* @see QwtPlot::setAxisVisible()
|
||||
*/
|
||||
@ -275,6 +271,4 @@ void Widgets::Plot::onAxisOptionsChanged()
|
||||
m_plot.setAxisVisible(QwtPlot::xBottom, false);
|
||||
break;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
],
|
||||
"decoder": 1,
|
||||
"frameEnd": ";",
|
||||
"frameParser": "/**\n * This function parses a binary data frame (represented as a hexadecimal string),\n * and converts it into an array of decimal values (0-255).\n *\n * @param[in] frame The latest received frame as a hexadecimal string.\n * @return Array of integers containing the parsed frame elements.\n */\nfunction parse(frame, separator) {\n let dataArray = [];\n for (let i = 0; i < frame.length; i += 2) {\n let hexByte = frame.substring(i, i + 2);\n let decimalValue = parseInt(hexByte, 16);\n dataArray.push(decimalValue);\n }\n\n return dataArray;\n}",
|
||||
"frameParser": "/**\n * This function parses a binary data frame (represented as a hexadecimal string),\n * and converts it into an array of decimal values (0-255).\n *\n * @param[in] frame The latest received frame as a hexadecimal string.\n * @return Array of integers containing the parsed frame elements.\n */\nfunction parse(frame, separator) {\n let dataArray = [];\n for (let i = 0; i < frame.length; i += 2) {\n let hexByte = frame.substring(i, i + 2);\n let decimalValue = parseInt(hexByte, 16);\n dataArray.push(decimalValue * 5.0 / 255);\n }\n\n return dataArray;\n}",
|
||||
"frameStart": "$",
|
||||
"groups": [
|
||||
{
|
||||
@ -18,7 +18,7 @@
|
||||
"led": false,
|
||||
"ledHigh": 1,
|
||||
"log": false,
|
||||
"max": 0,
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"title": "ADC 0",
|
||||
"units": "Volts",
|
||||
@ -35,7 +35,7 @@
|
||||
"led": false,
|
||||
"ledHigh": 1,
|
||||
"log": false,
|
||||
"max": 0,
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"title": "ADC 1",
|
||||
"units": "Volts",
|
||||
@ -52,7 +52,7 @@
|
||||
"led": false,
|
||||
"ledHigh": 1,
|
||||
"log": false,
|
||||
"max": 0,
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"title": "ADC 2",
|
||||
"units": "Volts",
|
||||
@ -69,7 +69,7 @@
|
||||
"led": false,
|
||||
"ledHigh": 1,
|
||||
"log": false,
|
||||
"max": 0,
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"title": "ADC 3",
|
||||
"units": "Volts",
|
||||
@ -86,7 +86,7 @@
|
||||
"led": false,
|
||||
"ledHigh": 1,
|
||||
"log": false,
|
||||
"max": 0,
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"title": "ADC 4",
|
||||
"units": "Volts",
|
||||
@ -103,7 +103,7 @@
|
||||
"led": false,
|
||||
"ledHigh": 1,
|
||||
"log": false,
|
||||
"max": 0,
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"title": "ADC 5",
|
||||
"units": "Volts",
|
||||
|
Loading…
x
Reference in New Issue
Block a user