Calculate the channel label width after font size is changed

This commit is contained in:
dreamsourcelabTAI 2023-06-16 18:19:17 +08:00
parent 2ee09b8257
commit 6fae130891
4 changed files with 17 additions and 3 deletions

View File

@ -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()));

View File

@ -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"))

View File

@ -1340,5 +1340,10 @@ int View::get_body_height()
_time_viewport->update();
}
void View::update_font()
{
headerWidth();
}
} // namespace view
} // namespace pv

View File

@ -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();