mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-02 12:02:09 +08:00
cabana: extend max chart range to 30 minutes (#27555)
old-commit-hash: fc44ed63d78c3b45020db1130dae41f597c91e18
This commit is contained in:
@@ -45,7 +45,7 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QFrame(parent) {
|
||||
toolbar->addWidget(stretch_label);
|
||||
|
||||
range_lb_action = toolbar->addWidget(range_lb = new QLabel(this));
|
||||
range_slider = new QSlider(Qt::Horizontal, this);
|
||||
range_slider = new LogSlider(1000, Qt::Horizontal, this);
|
||||
range_slider->setMaximumWidth(200);
|
||||
range_slider->setToolTip(tr("Set the chart range"));
|
||||
range_slider->setRange(1, settings.max_cached_minutes * 60);
|
||||
@@ -163,7 +163,7 @@ void ChartsWidget::updateState() {
|
||||
}
|
||||
|
||||
void ChartsWidget::setMaxChartRange(int value) {
|
||||
max_chart_range = settings.chart_range = value;
|
||||
max_chart_range = settings.chart_range = range_slider->value();
|
||||
updateToolBar();
|
||||
updateState();
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
|
||||
QLabel *title_label;
|
||||
QLabel *range_lb;
|
||||
QSlider *range_slider;
|
||||
LogSlider *range_slider;
|
||||
QAction *range_lb_action;
|
||||
QAction *range_slider_action;
|
||||
bool docking = true;
|
||||
|
||||
@@ -32,7 +32,7 @@ void Settings::save() {
|
||||
void Settings::load() {
|
||||
QSettings s("settings", QSettings::IniFormat);
|
||||
fps = s.value("fps", 10).toInt();
|
||||
max_cached_minutes = s.value("max_cached_minutes", 5).toInt();
|
||||
max_cached_minutes = s.value("max_cached_minutes", 30).toInt();
|
||||
chart_height = s.value("chart_height", 200).toInt();
|
||||
chart_range = s.value("chart_range", 3 * 60).toInt();
|
||||
chart_column_count = s.value("chart_column_count", 1).toInt();
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
void load();
|
||||
|
||||
int fps = 10;
|
||||
int max_cached_minutes = 5;
|
||||
int max_cached_minutes = 30;
|
||||
int chart_height = 200;
|
||||
int chart_column_count = 1;
|
||||
int chart_range = 3 * 60; // e minutes
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QColor>
|
||||
@@ -29,6 +30,23 @@ private:
|
||||
QByteArray prev_dat;
|
||||
};
|
||||
|
||||
class LogSlider : public QSlider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogSlider(double factor, Qt::Orientation orientation, QWidget *parent = nullptr) : factor(factor), QSlider(orientation, parent) {};
|
||||
|
||||
void setRange(double min, double max) { QSlider::setRange(logScale(min), logScale(max)); }
|
||||
int value() const { return invLogScale(QSlider::value()); }
|
||||
void setValue(int value) { QSlider::setValue(logScale(value)); }
|
||||
|
||||
private:
|
||||
double factor;
|
||||
int logScale(int value) const { return factor * std::log10(value); }
|
||||
int invLogScale(int value) const { return std::pow(10, value / factor); }
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
ColorsRole = Qt::UserRole + 1,
|
||||
BytesRole = Qt::UserRole + 2
|
||||
|
||||
Reference in New Issue
Block a user