diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 025c56235..e0e48e7bd 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -1290,7 +1290,7 @@ int Component::analyseLine(const QString &Row, int numProps) { return 1; } else if (s == "Text") { // must be last in order to reuse "s" ********* if (!getIntegers(Row, &i1, &i2, &i3, 0, &i4)) return -1; - Color.setNamedColor(Row.section(' ', 4, 4)); + Color=misc::ColorFromString(Row.section(' ', 4, 4)); if (!Color.isValid()) return -1; s = Row.mid(Row.indexOf('"') + 1); // Text (can contain " !!!) @@ -1372,8 +1372,7 @@ bool Component::getPen(const QString &s, QPen &Pen, int i) { QString n; n = s.section(' ', i, i); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if (!Pen.color().isValid()) return false; @@ -1396,8 +1395,7 @@ bool Component::getBrush(const QString &s, QBrush &Brush, int i) { QString n; n = s.section(' ', i, i); // fill color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Brush.setColor(co); if (!Brush.color().isValid()) return false; diff --git a/qucs/diagrams/diagram.cpp b/qucs/diagrams/diagram.cpp index f66d4bb5f..df26249b8 100644 --- a/qucs/diagrams/diagram.cpp +++ b/qucs/diagrams/diagram.cpp @@ -1322,8 +1322,7 @@ bool Diagram::load(const QString &Line, QTextStream *stream) { hideLines = (c & 2) != 0; n = s.section(' ', 6, 6); // color for GridPen - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); GridPen.setColor(co); if (!GridPen.color().isValid()) return false; diff --git a/qucs/diagrams/graph.cpp b/qucs/diagrams/graph.cpp index 5e8efa5bd..5b899a1ba 100644 --- a/qucs/diagrams/graph.cpp +++ b/qucs/diagrams/graph.cpp @@ -15,6 +15,7 @@ * * ***************************************************************************/ #include "graph.h" +#include "misc.h" #include #include @@ -123,7 +124,7 @@ bool Graph::load(const QString& _s) QString n; n = s.section(' ',1,1); // Color - Color.setNamedColor(n); + Color = misc::ColorFromString(n); if(!Color.isValid()) return false; n = s.section(' ',2,2); // Thick diff --git a/qucs/extsimkernels/abstractspicekernel.cpp b/qucs/extsimkernels/abstractspicekernel.cpp index ee2fca690..066f6d48b 100644 --- a/qucs/extsimkernels/abstractspicekernel.cpp +++ b/qucs/extsimkernels/abstractspicekernel.cpp @@ -1331,8 +1331,8 @@ void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list) QString suffix; if ((*it).startsWith('I')) suffix = ".Ib"; else suffix = ".Vb"; - int idx = it->indexOf('('); - int cnt = it->count(); + auto idx = it->indexOf('('); + auto cnt = it->size(); *it = it->right(cnt-idx-1); it->remove(')'); *it += suffix; diff --git a/qucs/extsimkernels/qucs2spice.cpp b/qucs/extsimkernels/qucs2spice.cpp index c6ed2b597..a24b51db6 100644 --- a/qucs/extsimkernels/qucs2spice.cpp +++ b/qucs/extsimkernels/qucs2spice.cpp @@ -34,9 +34,9 @@ namespace qucs2spice QString convert_rcl(const QString& line); QString convert_header(QString line); QString convert_diode(QString line,bool xyce=false); - QString convert_jfet(QString line, bool xyce=false); + QString convert_jfet(const QString& line, bool xyce=false); QString convert_mosfet(QString line, bool xyce=false); - QString convert_bjt(QString line); + QString convert_bjt(const QString& line); QString convert_cccs(const QString& line); QString convert_ccvs(const QString& line); QString convert_ccs(const QString& line, bool voltage); @@ -131,8 +131,8 @@ QString qucs2spice::convert_rcl(const QString& line) s += " " + lst.takeFirst(); s += " " + lst.takeFirst() + " "; s1 = lst.takeFirst().remove("\""); - int idx = s1.indexOf('='); - s += s1.right(s1.count()-idx-1); + auto idx = s1.indexOf('='); + s += s1.right(s1.size()-idx-1); s += "\n"; return s; } @@ -153,8 +153,8 @@ QString qucs2spice::convert_diode(QString line,bool xyce) QString s=""; QStringList lst = line.split(" ",qucs::SkipEmptyParts); QString name = lst.takeFirst(); - int idx = name.indexOf(':'); - name = name.right(name.count()-idx-1); // name + auto idx = name.indexOf(':'); + name = name.right(name.size()-idx-1); // name QString K = lst.takeFirst(); QString A = lst.takeFirst(); s += QString("D%1 %2 %3 DMOD_%4 \n").arg(name).arg(A).arg(K).arg(name); @@ -170,8 +170,8 @@ QString qucs2spice::convert_mosfet(QString line, bool xyce) QString s=""; QStringList lst = line.split(" ",qucs::SkipEmptyParts); QString name = lst.takeFirst(); - int idx = name.indexOf(':'); - name = name.right(name.count()-idx-1); // name + auto idx = name.indexOf(':'); + name = name.right(name.size()-idx-1); // name QString G = lst.takeFirst(); QString D = lst.takeFirst(); QString S = lst.takeFirst(); @@ -207,13 +207,13 @@ QString qucs2spice::convert_mosfet(QString line, bool xyce) return s; } -QString qucs2spice::convert_jfet(QString line, bool xyce) +QString qucs2spice::convert_jfet(const QString& line, bool xyce) { QString s=""; QStringList lst = line.split(" ",qucs::SkipEmptyParts); QString name = lst.takeFirst(); - int idx = name.indexOf(':'); - name = name.right(name.count()-idx-1); // name + auto idx = name.indexOf(':'); + name = name.right(name.size()-idx-1); // name QString G = lst.takeFirst(); QString D = lst.takeFirst(); QString S = lst.takeFirst(); @@ -221,7 +221,7 @@ QString qucs2spice::convert_jfet(QString line, bool xyce) QStringList par_lst; par_lst.clear(); for(int i=0;iendsWith(".Vt"))||(it->endsWith(".It"))) sim = "tran"; if ((it->endsWith(".V"))||(it->endsWith(".I"))) sim = "dc"; QString suffix = it->section('.',1,1); - int idx = it->indexOf('.'); - int cnt = it->count(); + auto idx = it->indexOf('.'); + auto cnt = it->size(); it->chop(cnt-idx); if (suffix.toUpper().startsWith("I")) *it = QString("V%1#branch").arg(*it); diff --git a/qucs/imagewriter.cpp b/qucs/imagewriter.cpp index 5235fe666..042ce2d4c 100644 --- a/qucs/imagewriter.cpp +++ b/qucs/imagewriter.cpp @@ -370,9 +370,10 @@ void ImageWriter::getSelAreaWidthAndHeight(Schematic *sch, int &wsel, int &hsel, int x1,y1,x2,y2; pd->Bounding(x1,y1,x2,y2); updateMinMax(xmin,xmax,ymin,ymax,x1,x2,y1,y2); - - for (auto& pg: qAsConst(pd->Graphs)) { - for (auto& pm: qAsConst(pg->Markers)) { + auto const graphs = pd->Graphs; + for (auto& pg: graphs) { + auto const markers = pg->Markers; + for (auto& pm: markers) { if (pm->isSelected) { //int x1,y1,x2,y2; pm->Bounding(x1,y1,x2,y2); diff --git a/qucs/main.cpp b/qucs/main.cpp index 3c35433ed..f1a579533 100644 --- a/qucs/main.cpp +++ b/qucs/main.cpp @@ -92,19 +92,19 @@ bool loadSettings() if(settings.contains("LargeFontSize"))QucsSettings.largeFontSize=settings.value("LargeFontSize").toDouble(); // use toDouble() as it can interpret the string according to the current locale if(settings.contains("maxUndo"))QucsSettings.maxUndo=settings.value("maxUndo").toInt(); if(settings.contains("NodeWiring"))QucsSettings.NodeWiring=settings.value("NodeWiring").toInt(); - if(settings.contains("BGColor"))QucsSettings.BGColor.setNamedColor(settings.value("BGColor").toString()); + if(settings.contains("BGColor"))QucsSettings.BGColor = misc::ColorFromString(settings.value("BGColor").toString()); if(settings.contains("Editor"))QucsSettings.Editor=settings.value("Editor").toString(); if(settings.contains("FileTypes"))QucsSettings.FileTypes=settings.value("FileTypes").toStringList(); if(settings.contains("Language"))QucsSettings.Language=settings.value("Language").toString(); - if(settings.contains("Comment"))QucsSettings.Comment.setNamedColor(settings.value("Comment").toString()); - if(settings.contains("String"))QucsSettings.String.setNamedColor(settings.value("String").toString()); - if(settings.contains("Integer"))QucsSettings.Integer.setNamedColor(settings.value("Integer").toString()); - if(settings.contains("Real"))QucsSettings.Real.setNamedColor(settings.value("Real").toString()); - if(settings.contains("Character"))QucsSettings.Character.setNamedColor(settings.value("Character").toString()); - if(settings.contains("Type"))QucsSettings.Type.setNamedColor(settings.value("Type").toString()); - if(settings.contains("Attribute"))QucsSettings.Attribute.setNamedColor(settings.value("Attribute").toString()); - if(settings.contains("Directive"))QucsSettings.Directive.setNamedColor(settings.value("Directive").toString()); - if(settings.contains("Task"))QucsSettings.Task.setNamedColor(settings.value("Task").toString()); + if(settings.contains("Comment"))QucsSettings.Comment=misc::ColorFromString(settings.value("Comment").toString()); + if(settings.contains("String"))QucsSettings.String=misc::ColorFromString(settings.value("String").toString()); + if(settings.contains("Integer"))QucsSettings.Integer=misc::ColorFromString(settings.value("Integer").toString()); + if(settings.contains("Real"))QucsSettings.Real=misc::ColorFromString(settings.value("Real").toString()); + if(settings.contains("Character"))QucsSettings.Character=misc::ColorFromString(settings.value("Character").toString()); + if(settings.contains("Type"))QucsSettings.Type=misc::ColorFromString(settings.value("Type").toString()); + if(settings.contains("Attribute"))QucsSettings.Attribute=misc::ColorFromString(settings.value("Attribute").toString()); + if(settings.contains("Directive"))QucsSettings.Directive=misc::ColorFromString(settings.value("Directive").toString()); + if(settings.contains("Task"))QucsSettings.Task=misc::ColorFromString(settings.value("Task").toString()); if (settings.contains("panelIconsTheme")) QucsSettings.panelIconsTheme = settings.value("panelIconsTheme").toInt(); else QucsSettings.panelIconsTheme = qucs::autoIcons; @@ -823,8 +823,8 @@ int main(int argc, char *argv[]) QucsSettings.maxUndo = 20; QucsSettings.NodeWiring = 0; - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling,true); #if QT_VERSION < 0x060000 + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling,true); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps,true); #endif @@ -955,7 +955,7 @@ int main(int argc, char *argv[]) QucsSettings.Task = Qt::darkRed; QucsSettings.sysDefaultFont = QApplication::font(); - a.setFont(QucsSettings.appFont); + QApplication::setFont(QucsSettings.appFont); QTranslator tor( 0 ); QString lang = QucsSettings.Language; @@ -965,7 +965,7 @@ int main(int argc, char *argv[]) // lang = QTextCodec::locale(); } tor.load( QString("qucs_") + lang, QucsSettings.LangDir); - a.installTranslator( &tor ); + QApplication::installTranslator( &tor ); // This seems to be necessary on a few system to make strtod() // work properly !???! diff --git a/qucs/misc.cpp b/qucs/misc.cpp index 477ffc143..7dbd66585 100644 --- a/qucs/misc.cpp +++ b/qucs/misc.cpp @@ -284,6 +284,18 @@ QString misc::num2str(double Num) return Str; } +QColor misc::ColorFromString(const QString& color) +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + return QColor::fromString(color); +#else + QColor c; + c.setNamedColor(color); + return c; +#endif + +} + // ######################################################################### void misc::convert2Unicode(QString& Text) { diff --git a/qucs/misc.h b/qucs/misc.h index af14b1e56..c5047c39a 100644 --- a/qucs/misc.h +++ b/qucs/misc.h @@ -51,6 +51,7 @@ namespace misc { QString StringNum (double, char form='g', int Precision=3); void str2num (const QString&, double&, QString&, double&); QString num2str (double); + QColor ColorFromString(const QString& color); QString StringNiceNum(double); void convert2Unicode(QString&); void convert2ASCII(QString&); diff --git a/qucs/paintings/arrow.cpp b/qucs/paintings/arrow.cpp index 3aff065a3..4759a38d6 100644 --- a/qucs/paintings/arrow.cpp +++ b/qucs/paintings/arrow.cpp @@ -23,6 +23,7 @@ #include "arrow.h" #include "arrowdialog.h" #include "schematic.h" +#include "misc.h" #include #include @@ -176,8 +177,7 @@ bool Arrow::load(const QString& s) if(!ok) return false; n = s.section(' ',7,7); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if(!Pen.color().isValid()) return false; diff --git a/qucs/paintings/ellipse.cpp b/qucs/paintings/ellipse.cpp index 027101de2..b253218b1 100644 --- a/qucs/paintings/ellipse.cpp +++ b/qucs/paintings/ellipse.cpp @@ -137,8 +137,7 @@ bool qucs::Ellipse::load(const QString& s) if(!ok) return false; n = s.section(' ',5,5); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if(!Pen.color().isValid()) return false; @@ -151,7 +150,7 @@ bool qucs::Ellipse::load(const QString& s) if(!ok) return false; n = s.section(' ',8,8); // fill color - co.setNamedColor(n); + co = misc::ColorFromString(n); Brush.setColor(co); if(!Brush.color().isValid()) return false; diff --git a/qucs/paintings/ellipsearc.cpp b/qucs/paintings/ellipsearc.cpp index 04409e641..1ed8f4b17 100644 --- a/qucs/paintings/ellipsearc.cpp +++ b/qucs/paintings/ellipsearc.cpp @@ -128,8 +128,7 @@ bool EllipseArc::load(const QString& s) if(!ok) return false; n = s.section(' ',7,7); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if(!Pen.color().isValid()) return false; diff --git a/qucs/paintings/graphicline.cpp b/qucs/paintings/graphicline.cpp index 99663ea5d..fb8007763 100644 --- a/qucs/paintings/graphicline.cpp +++ b/qucs/paintings/graphicline.cpp @@ -119,8 +119,7 @@ bool GraphicLine::load(const QString& s) if(!ok) return false; n = s.section(' ',5,5); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if(!Pen.color().isValid()) return false; diff --git a/qucs/paintings/graphictext.cpp b/qucs/paintings/graphictext.cpp index 9875a4352..7d0e308a6 100644 --- a/qucs/paintings/graphictext.cpp +++ b/qucs/paintings/graphictext.cpp @@ -156,7 +156,7 @@ bool GraphicText::load(const QString& s) if(!ok) return false; n = s.section(' ',4,4); // Color - Color.setNamedColor(n); + Color = misc::ColorFromString(n); if(!Color.isValid()) return false; n = s.section(' ',5,5); // Angle diff --git a/qucs/paintings/rectangle.cpp b/qucs/paintings/rectangle.cpp index 01468ffc4..443296320 100644 --- a/qucs/paintings/rectangle.cpp +++ b/qucs/paintings/rectangle.cpp @@ -136,8 +136,7 @@ bool qucs::Rectangle::load(const QString& s) if(!ok) return false; n = s.section(' ',5,5); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if(!Pen.color().isValid()) return false; @@ -150,7 +149,7 @@ bool qucs::Rectangle::load(const QString& s) if(!ok) return false; n = s.section(' ',8,8); // fill color - co.setNamedColor(n); + co = misc::ColorFromString(n); Brush.setColor(co); if(!Brush.color().isValid()) return false; diff --git a/qucs/symbolwidget.cpp b/qucs/symbolwidget.cpp index 7b886856c..3b6cc8ca6 100644 --- a/qucs/symbolwidget.cpp +++ b/qucs/symbolwidget.cpp @@ -25,6 +25,7 @@ #include "symbolwidget.h" #include "main.h" #include "qucslib_common.h" +#include "misc.h" /*! * \file symbolwidget.cpp @@ -591,7 +592,7 @@ int SymbolWidget::analyseLine(const QString& Row) } else if(s == "Text") { // must be last in order to reuse "s" ********* if(!getCompLineIntegers(Row, &i1, &i2, &i3)) return -1; - Color.setNamedColor(Row.section(' ',4,4)); + Color=misc::ColorFromString(Row.section(' ',4,4)); if(!Color.isValid()) return -1; s = Row.mid(Row.indexOf('"')+1); // Text (can contain " !!!) @@ -626,8 +627,7 @@ bool SymbolWidget::getPen(const QString& s, QPen& Pen, int i) QString n; n = s.section(' ',i,i); // color - QColor co; - co.setNamedColor(n); + QColor co = misc::ColorFromString(n); Pen.setColor(co); if(!Pen.color().isValid()) return false; @@ -651,8 +651,7 @@ bool SymbolWidget::getBrush(const QString& s, QBrush& Brush, int i) QString n; n = s.section(' ',i,i); // fill color - QColor co; - co.setNamedColor(n); + QColor co=misc::ColorFromString(n); Brush.setColor(co); if(!Brush.color().isValid()) return false; diff --git a/qucs/symbolwidget.h b/qucs/symbolwidget.h index 208e8bd54..b38e418f1 100644 --- a/qucs/symbolwidget.h +++ b/qucs/symbolwidget.h @@ -66,7 +66,7 @@ class SymbolWidget : public QWidget { int analyseLine(const QString&); - bool getPen (const QString&, QPen&, int); + static bool getPen (const QString&, QPen&, int); bool getBrush(const QString&, QBrush&, int); bool dragNDrop;