From 6fae13089189e967fc00dd18d6df6d4632713161 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Fri, 16 Jun 2023 18:19:17 +0800 Subject: [PATCH] Calculate the channel label width after font size is changed --- DSView/pv/mainwindow.cpp | 1 + DSView/pv/view/trace.cpp | 8 ++++++-- DSView/pv/view/view.cpp | 5 +++++ DSView/pv/view/view.h | 6 +++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 6db573e0..cdbc3dbd 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -254,6 +254,7 @@ namespace pv AppControl::Instance()->add_font_form(_search_widget); AppControl::Instance()->add_font_form(_trigger_widget); AppControl::Instance()->add_font_form(_view->get_time_view()); + AppControl::Instance()->add_font_form(_view); // event connect(&_event, SIGNAL(session_error()), this, SLOT(on_session_error())); diff --git a/DSView/pv/view/trace.cpp b/DSView/pv/view/trace.cpp index 1584112a..4efeb966 100644 --- a/DSView/pv/view/trace.cpp +++ b/DSView/pv/view/trace.cpp @@ -31,6 +31,8 @@ #include "view.h" #include "../sigsession.h" #include "../dsvdef.h" +#include "../config/appconfig.h" +#include "../appcontrol.h" namespace pv { @@ -93,7 +95,9 @@ Trace::Trace(const Trace &t) : int Trace::get_name_width() { - QFont font = QApplication::font(); + QFont font; + float fSize = AppConfig::Instance().appOptions.fontSize; + font.setPointSizeF(fSize <= 10 ? fSize : 10); QFontMetrics fm(font); return fm.boundingRect(get_name()).width(); @@ -362,8 +366,8 @@ int Trace::rows_size() QRectF Trace::get_rect(const char *s, int y, int right) { const QSizeF color_size(get_leftWidth() - Margin, SquareWidth); + // const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth); const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth); - //const QSizeF label_size(_text_size.width() + Margin, SquareWidth); const QSizeF label_size(SquareWidth, SquareWidth); if (!strcmp(s, "name")) diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp index 1c2ffcf7..5eeb246d 100644 --- a/DSView/pv/view/view.cpp +++ b/DSView/pv/view/view.cpp @@ -1340,5 +1340,10 @@ int View::get_body_height() _time_viewport->update(); } + void View::update_font() + { + headerWidth(); + } + } // namespace view } // namespace pv diff --git a/DSView/pv/view/view.h b/DSView/pv/view/view.h index 8e30eb17..10800bd5 100644 --- a/DSView/pv/view/view.h +++ b/DSView/pv/view/view.h @@ -42,6 +42,7 @@ #include "signal.h" #include "viewstatus.h" #include "../dsvdef.h" +#include "../interface/icallbacks.h" class DeviceAgent; @@ -68,7 +69,7 @@ class Viewport; class LissajousFigure; //created by MainWindow -class View : public QScrollArea { +class View : public QScrollArea, public IFontForm{ Q_OBJECT private: @@ -319,6 +320,9 @@ public: return _time_viewport; } + //IFontForm + void update_font(); + signals: void hover_point_changed(); void cursor_update();