From b1adb18e3941cb4aff46e2ee1344da116ab297b1 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Wed, 4 May 2022 19:47:48 +1000 Subject: [PATCH] fix(cpn): Improve layout and word wrap of Model -> Curves tab (#1923) --- companion/src/modeledit/curves.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp index d7a9068ea..b47d6759d 100644 --- a/companion/src/modeledit/curves.cpp +++ b/companion/src/modeledit/curves.cpp @@ -32,12 +32,15 @@ CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & maxCurves = firmware->getCapability(NumCurves); QStringList headerLabels; - headerLabels << "#"; - - headerLabels << tr("Plot") << tr("Details") << tr("Note: to create a curve right click on the curve row label"); + headerLabels << "#" << "" << tr("Note: to create a curve right click on the curve row label"); TableLayout *tableLayout = new TableLayout(this, maxCurves, headerLabels); + QFontMetrics *f = new QFontMetrics(QFont()); + QSize szpnts; + szpnts = f->size(Qt::TextSingleLine, QString(75, 'X')); + delete f; + for (int i = 0; i < maxCurves; i++) { int col = 0; @@ -81,8 +84,13 @@ CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & numpoints[i] = new QLabel(); grid[i]->addWidget(numpoints[i], row, 1); points[i] = new QLabel(); - points[i]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - points[i]->setWordWrap(true); + points[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + // at at Qt 5.12 + // setWordWrap(true) does not work well in this instance due to the nested widgets and + // the display results varying between OSes so as a compromise + // stop widget expanding uncontrolled and consequentally expanding edit dialog potentially off screen + // contents will be truncated if exceed maximum size + points[i]->setMaximumWidth(szpnts.width()); grid[i]->addWidget(points[i], row++, 2, Qt::AlignLeft); grid[i]->addWidget(new QLabel(tr("Smooth:")), row, 0, Qt::AlignLeft);