mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-07 17:25:40 +08:00
@@ -141,11 +141,14 @@ void Settings::save() {
|
||||
s.setValue("fps", fps);
|
||||
s.setValue("log_size", can_msg_log_size);
|
||||
s.setValue("cached_segment", cached_segment_limit);
|
||||
s.setValue("chart_height", chart_height);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void Settings::load() {
|
||||
QSettings s("settings", QSettings::IniFormat);
|
||||
fps = s.value("fps", 10).toInt();
|
||||
can_msg_log_size = s.value("log_size", 100).toInt();
|
||||
cached_segment_limit = s.value("cached_segment", 3.).toInt();
|
||||
cached_segment_limit = s.value("cached_segment", 3).toInt();
|
||||
chart_height = s.value("chart_height", 200).toInt();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
int fps = 10;
|
||||
int can_msg_log_size = 100;
|
||||
int cached_segment_limit = 3;
|
||||
int chart_height = 200;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
@@ -76,6 +76,11 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
|
||||
docking = !docking;
|
||||
updateTitleBar();
|
||||
});
|
||||
QObject::connect(&settings, &Settings::changed, [this]() {
|
||||
for (auto chart : charts) {
|
||||
chart->setHeight(settings.chart_height);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ChartsWidget::updateTitleBar() {
|
||||
@@ -152,7 +157,7 @@ ChartWidget::ChartWidget(const QString &id, const Signal *sig, QWidget *parent)
|
||||
main_layout->addWidget(header);
|
||||
|
||||
chart_view = new ChartView(id, sig, this);
|
||||
chart_view->setFixedHeight(300);
|
||||
chart_view->setFixedHeight(settings.chart_height);
|
||||
main_layout->addWidget(chart_view);
|
||||
main_layout->addStretch();
|
||||
|
||||
@@ -205,6 +210,10 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
|
||||
updateSeries();
|
||||
}
|
||||
|
||||
void ChartWidget::setHeight(int height) {
|
||||
chart_view->setFixedHeight(height);
|
||||
}
|
||||
|
||||
void ChartView::updateState() {
|
||||
auto axis_x = dynamic_cast<QValueAxis *>(chart()->axisX());
|
||||
int x = chart()->plotArea().left() + chart()->plotArea().width() * (can->currentSec() - axis_x->min()) / (axis_x->max() - axis_x->min());
|
||||
|
||||
@@ -46,6 +46,7 @@ Q_OBJECT
|
||||
public:
|
||||
ChartWidget(const QString &id, const Signal *sig, QWidget *parent);
|
||||
void updateTitle();
|
||||
void setHeight(int height);
|
||||
|
||||
signals:
|
||||
void remove();
|
||||
|
||||
@@ -96,6 +96,12 @@ SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) {
|
||||
cached_segment->setValue(settings.cached_segment_limit);
|
||||
form_layout->addRow(tr("Cached segments limit"), cached_segment);
|
||||
|
||||
chart_height = new QSpinBox(this);
|
||||
chart_height->setRange(100, 500);
|
||||
chart_height->setSingleStep(10);
|
||||
chart_height->setValue(settings.chart_height);
|
||||
form_layout->addRow(tr("Chart height"), chart_height);
|
||||
|
||||
main_layout->addLayout(form_layout);
|
||||
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
@@ -110,6 +116,7 @@ void SettingsDlg::save() {
|
||||
settings.fps = fps->value();
|
||||
settings.can_msg_log_size = log_size->value();
|
||||
settings.cached_segment_limit = cached_segment->value();
|
||||
settings.chart_height = chart_height->value();
|
||||
settings.save();
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -33,4 +33,5 @@ public:
|
||||
QSpinBox *fps;
|
||||
QSpinBox *log_size ;
|
||||
QSpinBox *cached_segment;
|
||||
QSpinBox *chart_height;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user