From 0d69b6a67937075598c8f587827188e12ce35a73 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Fri, 21 Jun 2024 14:58:04 +0300 Subject: [PATCH] Correct symbol widget text --- qucs/extsimkernels/spicelibcompdialog.cpp | 2 ++ qucs/symbolwidget.cpp | 7 +++++++ qucs/symbolwidget.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/qucs/extsimkernels/spicelibcompdialog.cpp b/qucs/extsimkernels/spicelibcompdialog.cpp index fc867d77..35cc8ca5 100644 --- a/qucs/extsimkernels/spicelibcompdialog.cpp +++ b/qucs/extsimkernels/spicelibcompdialog.cpp @@ -93,6 +93,7 @@ SpiceLibCompDialog::SpiceLibCompDialog(Component *pc, Schematic *sch) : QDialog{ symbol = new SymbolWidget; symbol->disableDragNDrop(); symbol->enableShowPinNumbers(); + symbol->setPaintText(""); tbwPinsTable = new QTableWidget; tbwPinsTable->setColumnCount(2); @@ -290,6 +291,7 @@ void SpiceLibCompDialog::slotSetSymbol() QString s1 = ""; QString s2 = "SpLib"; symbol->setSymbol(s1, s1, s2); + symbol->setWarning(tr("No symbol loaded")); symbolPinsCount = 0; } else if (rbSymFromTemplate->isChecked()) { tbwPinsTable->setEnabled(true); diff --git a/qucs/symbolwidget.cpp b/qucs/symbolwidget.cpp index f469709e..49d9b161 100644 --- a/qucs/symbolwidget.cpp +++ b/qucs/symbolwidget.cpp @@ -744,3 +744,10 @@ bool SymbolWidget::getBrush(const QString& s, QBrush& Brush, int i) return true; } + +void SymbolWidget::setPaintText(const QString &txt) +{ + PaintText = txt; + QFontMetrics metrics(QucsSettings.font, 0); // use the the screen-compatible metric + TextWidth = metrics.size(0,PaintText).width() + 4; // get size of text +} diff --git a/qucs/symbolwidget.h b/qucs/symbolwidget.h index 831c5057..bf2d3c5c 100644 --- a/qucs/symbolwidget.h +++ b/qucs/symbolwidget.h @@ -55,6 +55,8 @@ public: void disableShowPinNumbers() { showPinNumbers = false; } bool showPinNumbersEnabled() { return showPinNumbers; } int getPortsNumber() { return portsNumber; } + void setPaintText(const QString &txt); + void setWarning(const QString &warn) { Warning = warn; } // component properties int Text_x, Text_y; QString Prefix, LibraryPath, ComponentName;