cabana: remove toolbutton padding (#27240)

* remove toolbutton padding

* fix incorrect checked state in setSeriesType
pull/27244/head
Dean Lee 2 years ago committed by GitHub
parent 6fb5661abb
commit 55ad7ee3cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      tools/cabana/chartswidget.cc
  2. 4
      tools/cabana/chartswidget.h

@ -10,7 +10,6 @@
#include <QMenu>
#include <QRubberBand>
#include <QToolBar>
#include <QToolButton>
#include <QToolTip>
#include <QtConcurrent>
@ -22,7 +21,6 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
// toolbar
QToolBar *toolbar = new QToolBar(tr("Charts"), this);
toolbar->setIconSize({16, 16});
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QAction *new_plot_btn = toolbar->addAction(utils::icon("file-plus"), "");
new_plot_btn->setToolTip(tr("New Plot"));
@ -45,8 +43,11 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
range_slider->setPageStep(60); // 1 min
range_slider_action = toolbar->addWidget(range_slider);
reset_zoom_btn = toolbar->addAction(utils::icon("zoom-out"), "");
reset_zoom_action = toolbar->addWidget(reset_zoom_btn = new QToolButton());
reset_zoom_btn->setIcon(utils::icon("zoom-out"));
reset_zoom_btn->setToolTip(tr("Reset zoom"));
reset_zoom_btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
remove_all_btn = toolbar->addAction(utils::icon("x"), "");
remove_all_btn->setToolTip(tr("Remove all charts"));
dock_btn = toolbar->addAction("");
@ -84,7 +85,7 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
QObject::connect(range_slider, &QSlider::valueChanged, this, &ChartsWidget::setMaxChartRange);
QObject::connect(new_plot_btn, &QAction::triggered, this, &ChartsWidget::newChart);
QObject::connect(remove_all_btn, &QAction::triggered, this, &ChartsWidget::removeAll);
QObject::connect(reset_zoom_btn, &QAction::triggered, this, &ChartsWidget::zoomReset);
QObject::connect(reset_zoom_btn, &QToolButton::clicked, this, &ChartsWidget::zoomReset);
QObject::connect(columns_cb, SIGNAL(activated(int)), SLOT(setColumnCount(int)));
QObject::connect(&settings, &Settings::changed, this, &ChartsWidget::settingChanged);
QObject::connect(dock_btn, &QAction::triggered, [this]() {
@ -163,8 +164,8 @@ void ChartsWidget::updateToolBar() {
range_lb->setText(QString("Range: %1:%2 ").arg(max_chart_range / 60, 2, 10, QLatin1Char('0')).arg(max_chart_range % 60, 2, 10, QLatin1Char('0')));
range_lb_action->setVisible(!is_zoomed);
range_slider_action->setVisible(!is_zoomed);
reset_zoom_btn->setVisible(is_zoomed);
reset_zoom_btn->setText(is_zoomed ? tr("Zoomin: %1-%2").arg(zoomed_range.first, 0, 'f', 2).arg(zoomed_range.second, 0, 'f', 2) : "");
reset_zoom_action->setVisible(is_zoomed);
reset_zoom_btn->setText(is_zoomed ? tr("Zoomin: %1-%2").arg(zoomed_range.first, 0, 'f', 1).arg(zoomed_range.second, 0, 'f', 1) : "");
remove_all_btn->setEnabled(!charts.isEmpty());
dock_btn->setIcon(utils::icon(docking ? "arrow-up-right-square" : "arrow-down-left-square"));
dock_btn->setToolTip(docking ? tr("Undock charts") : tr("Dock charts"));
@ -799,11 +800,10 @@ QXYSeries *ChartView::createSeries(QAbstractSeries::SeriesType type) {
}
void ChartView::setSeriesType(QAbstractSeries::SeriesType type) {
if (type != series_type) {
series_type = type;
line_series_action->setChecked(type == QAbstractSeries::SeriesTypeLine);
scatter_series_action->setChecked(type == QAbstractSeries::SeriesTypeScatter);
if (type != series_type) {
series_type = type;
for (auto &s : sigs) {
chart()->removeSeries(s.series);
s.series->deleteLater();

@ -8,6 +8,7 @@
#include <QGraphicsPixmapItem>
#include <QGraphicsProxyWidget>
#include <QSlider>
#include <QToolButton>
#include <QtCharts/QChartView>
#include <QtCharts/QLegendMarker>
#include <QtCharts/QLineSeries>
@ -138,7 +139,8 @@ private:
QAction *range_slider_action;
bool docking = true;
QAction *dock_btn;
QAction *reset_zoom_btn;
QAction *reset_zoom_action;
QToolButton *reset_zoom_btn;
QAction *remove_all_btn;
QGridLayout *charts_layout;
QList<ChartView *> charts;

Loading…
Cancel
Save