From c3010745ec0ab305609b2eee14fd3b372e64ebb9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 25 Nov 2021 19:53:00 +0100 Subject: [PATCH] WIP --- src/edt/edt/EditablePathPropertiesPage.ui | 252 ++++++++++--------- src/edt/edt/PathPropertiesPage.ui | 234 +++++++++-------- src/edt/edt/PolygonPropertiesPage.ui | 167 ++++++------ src/edt/edt/edtPropertiesPages.cc | 18 ++ src/lay/lay/layGSIHelpProvider.cc | 1 + src/lay/lay/layMacroEditorDialog.cc | 4 + src/lay/lay/layMacroEditorPage.cc | 16 +- src/lay/lay/layMacroEditorPage.h | 3 +- src/lay/lay/layMacroVariableView.cc | 9 +- src/lay/lay/layMainWindow.cc | 19 +- src/lay/lay/layProgressWidget.cc | 4 + src/lay/lay/laySaltDownloadManager.cc | 12 +- src/lay/lay/laySaltGrain.cc | 4 + src/lay/lay/laySaltGrainDetailsTextWidget.cc | 4 + src/lay/lay/laySaltManagerDialog.cc | 1 + src/lay/lay/laySearchReplaceDialog.cc | 4 +- src/lay/lay/laySystemPaths.cc | 4 + 17 files changed, 442 insertions(+), 314 deletions(-) diff --git a/src/edt/edt/EditablePathPropertiesPage.ui b/src/edt/edt/EditablePathPropertiesPage.ui index 7f63b54c4..f752c308d 100644 --- a/src/edt/edt/EditablePathPropertiesPage.ui +++ b/src/edt/edt/EditablePathPropertiesPage.ui @@ -1,7 +1,8 @@ - + + EditablePathPropertiesPage - - + + 0 0 @@ -9,25 +10,34 @@ 378 - + Form - - + + 9 - + + 9 + + + 9 + + + 9 + + 6 - + - + Qt::Vertical - + QSizePolicy::Fixed - + 456 16 @@ -35,45 +45,54 @@ - - - + + + Absolute (accumulated) transformations - - - + + + Coordinates in database units - - - + + + Extension type - - - + + + QFrame::NoFrame - + QFrame::Raised - - - 0 - - + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - + + Sans Serif 12 @@ -84,25 +103,23 @@ false - + Path Properties - - - - 7 - 5 + + + 0 0 - + - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -110,62 +127,66 @@ - - - + + + Width - - - + + + Points (x,y) - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 7 - 7 + + + + 1 0 - + 2 - - 100 - - - - + + + QFrame::NoFrame - + QFrame::Raised - - + + + 6 + + 0 - - 6 + + 0 + + + 0 + + + 0 - + Qt::Horizontal - + 211 20 @@ -174,15 +195,15 @@ - - + + User Properties - - + + Instantiation @@ -190,34 +211,41 @@ - - - + + + QFrame::NoFrame - + QFrame::Raised - - - 0 - - + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - + + start = - - - - 7 - 0 + + + 1 0 @@ -225,18 +253,16 @@ - - + + end = - - - - 7 - 0 + + + 1 0 @@ -246,24 +272,22 @@ - - - - - 7 - 0 + + + + 0 0 - + - + Qt::Horizontal - + 191 25 @@ -271,40 +295,38 @@ - - - + + + Var. extensions - - - - - 5 - 0 + + + + 0 0 - + Flush - + Square - + Variable - + Round diff --git a/src/edt/edt/PathPropertiesPage.ui b/src/edt/edt/PathPropertiesPage.ui index 9fdf60d74..a033ebb35 100644 --- a/src/edt/edt/PathPropertiesPage.ui +++ b/src/edt/edt/PathPropertiesPage.ui @@ -1,7 +1,8 @@ - + + PathPropertiesPage - - + + 0 0 @@ -9,44 +10,60 @@ 368 - + Form - - + + 9 - + + 9 + + + 9 + + + 9 + + 6 - - - + + + QFrame::NoFrame - + QFrame::Raised - - - 0 - - + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - + + start = - - - - 7 - 0 + + + 1 0 @@ -54,18 +71,16 @@ - - + + end = - - - - 7 - 0 + + + 1 0 @@ -75,41 +90,50 @@ - - - + + + Absolute (accumulated) transformations - - - + + + Coordinates in database units - - - + + + QFrame::NoFrame - + QFrame::Raised - - + + + 6 + + 0 - - 6 + + 0 + + + 0 + + + 0 - + Qt::Horizontal - + 211 20 @@ -118,15 +142,15 @@ - - + + User Properties - - + + Instantiation @@ -134,33 +158,28 @@ - - - - - 7 - 7 + + + + 1 0 - + 2 - - 100 - - + - + Qt::Vertical - + QSizePolicy::Fixed - + 451 8 @@ -168,12 +187,12 @@ - + - + Qt::Horizontal - + 135 20 @@ -181,60 +200,67 @@ - - - + + + Extensions - - - - - 7 - 0 + + + + 0 0 - - - + + + Points (x,y) - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - + + + Width - - - + + + QFrame::NoFrame - + QFrame::Raised - - - 0 - - + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - + + Sans Serif 12 @@ -245,25 +271,23 @@ false - + Path Properties - - - - 7 - 5 + + + 0 0 - + - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -271,9 +295,9 @@ - - - + + + Round path ends diff --git a/src/edt/edt/PolygonPropertiesPage.ui b/src/edt/edt/PolygonPropertiesPage.ui index 4b89c0389..4267391d8 100644 --- a/src/edt/edt/PolygonPropertiesPage.ui +++ b/src/edt/edt/PolygonPropertiesPage.ui @@ -1,7 +1,8 @@ - + + PolygonPropertiesPage - - + + 0 0 @@ -9,22 +10,31 @@ 282 - + Form - - + + 9 - + + 9 + + + 9 + + + 9 + + 6 - + - + Qt::Vertical - + 20 40 @@ -32,63 +42,70 @@ - - - - - 5 - 5 + + + + 0 0 - + - - - + + + Points (x,y) - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - + + + Absolute (accumulated) transformations - - - + + + Coordinates in database units - - - + + + QFrame::NoFrame - + QFrame::Raised - - - 0 - - + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - + + Sans Serif 12 @@ -99,25 +116,23 @@ false - + Polygon Properties - - - - 7 - 5 + + + 0 0 - + - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -125,27 +140,36 @@ - - - + + + QFrame::NoFrame - + QFrame::Raised - - + + + 6 + + 0 - - 6 + + 0 + + + 0 + + + 0 - + Qt::Horizontal - + 211 20 @@ -154,15 +178,15 @@ - - + + User Properties - - + + Instantiation @@ -170,33 +194,28 @@ - - - - - 7 - 7 + + + + 1 0 - + 2 - - 100 - - + - + Qt::Vertical - + QSizePolicy::Fixed - + 470 16 diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index b8a038291..026bcfc51 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -388,6 +388,12 @@ PolygonPropertiesPage::PolygonPropertiesPage (edt::Service *service, db::Manager setupUi (this); setup (); +#if QT_VERSION >= 0x60000 + pointListEdit->setTabStopDistance (100); +#else + pointListEdit->setTabStopWidth (100); +#endif + connect (inst_pb, SIGNAL (clicked ()), this, SLOT (show_inst ())); connect (prop_pb, SIGNAL (clicked ()), this, SLOT (show_props ())); @@ -905,6 +911,12 @@ PathPropertiesPage::PathPropertiesPage (edt::Service *service, db::Manager *mana setupUi (this); setup (); +#if QT_VERSION >= 0x60000 + ptlist_le->setTabStopDistance (100); +#else + ptlist_le->setTabStopWidth (100); +#endif + connect (inst_pb, SIGNAL (clicked ()), this, SLOT (show_inst ())); connect (prop_pb, SIGNAL (clicked ()), this, SLOT (show_props ())); @@ -966,6 +978,12 @@ EditablePathPropertiesPage::EditablePathPropertiesPage (edt::Service *service, d setupUi (this); setup (); +#if QT_VERSION >= 0x60000 + ptlist_le->setTabStopDistance (100); +#else + ptlist_le->setTabStopWidth (100); +#endif + connect (inst_pb, SIGNAL (clicked ()), this, SLOT (show_inst ())); connect (prop_pb, SIGNAL (clicked ()), this, SLOT (show_props ())); connect (type_cb, SIGNAL (currentIndexChanged (int)), this, SLOT (type_selected (int))); diff --git a/src/lay/lay/layGSIHelpProvider.cc b/src/lay/lay/layGSIHelpProvider.cc index 69cdc9145..d8fc7f45d 100644 --- a/src/lay/lay/layGSIHelpProvider.cc +++ b/src/lay/lay/layGSIHelpProvider.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/src/lay/lay/layMacroEditorDialog.cc b/src/lay/lay/layMacroEditorDialog.cc index 140f32057..6b9a53483 100644 --- a/src/lay/lay/layMacroEditorDialog.cc +++ b/src/lay/lay/layMacroEditorDialog.cc @@ -1550,7 +1550,11 @@ int MacroEditorDialog::columns () { QFontMetrics fm (mp_console_text->font ()); +#if QT_VERSION >= 0x60000 + int cw = fm.horizontalAdvance (QString::fromUtf8 ("X")); +#else int cw = fm.width (QString::fromUtf8 ("X")); +#endif if (cw > 0) { return mp_console_text->viewport ()->width () / cw; } else { diff --git a/src/lay/lay/layMacroEditorPage.cc b/src/lay/lay/layMacroEditorPage.cc index dd9d5b455..47fc45774 100644 --- a/src/lay/lay/layMacroEditorPage.cc +++ b/src/lay/lay/layMacroEditorPage.cc @@ -343,7 +343,13 @@ void MacroEditorSidePanel::set_debugging_on (bool on) QSize MacroEditorSidePanel::sizeHint () const { - return QSize (QFontMetrics (mp_text->font ()).width (QString::fromUtf8 ("12345")) + 3 * sidePanelMargin + m_breakpoint_pixmap.width (), 0); + int w; +#if QT_VERSION >= 0x60000 + w = QFontMetrics (mp_text->font ()).horizontalAdvance (QString::fromUtf8 ("12345")); +#else + w = QFontMetrics (mp_text->font ()).width (QString::fromUtf8 ("12345")); +#endif + return QSize (w + 3 * sidePanelMargin + m_breakpoint_pixmap.width (), 0); } void MacroEditorSidePanel::mousePressEvent (QMouseEvent *event) @@ -502,7 +508,11 @@ MacroEditorPage::MacroEditorPage (QWidget * /*parent*/, MacroEditorHighlighters hlayout->addWidget (mp_text); mp_text->setWordWrapMode(QTextOption::NoWrap); +#if QT_VERSION >= 0x60000 + mp_text->setTabStopDistance (m_ntab * QFontMetrics (mp_text->font ()).horizontalAdvance (QString::fromUtf8 ("x"))); +#else mp_text->setTabStopWidth (m_ntab * QFontMetrics (mp_text->font ()).width (QString::fromUtf8 ("x"))); +#endif m_is_modified = false; connect (mp_text, SIGNAL (textChanged ()), this, SLOT (text_changed ())); @@ -959,7 +969,11 @@ void MacroEditorPage::set_ntab (int n) { if (n != m_ntab) { m_ntab = n; +#if QT_VERSION >= 0x60000 + mp_text->setTabStopDistance (m_ntab * QFontMetrics (mp_text->font ()).horizontalAdvance (QString::fromUtf8 ("x"))); +#else mp_text->setTabStopWidth (m_ntab * QFontMetrics (mp_text->font ()).width (QString::fromUtf8 ("x"))); +#endif } } diff --git a/src/lay/lay/layMacroEditorPage.h b/src/lay/lay/layMacroEditorPage.h index 5392d4ace..7339c382c 100644 --- a/src/lay/lay/layMacroEditorPage.h +++ b/src/lay/lay/layMacroEditorPage.h @@ -20,8 +20,6 @@ */ - - #ifndef HDR_layMacroEditorPage #define HDR_layMacroEditorPage @@ -32,6 +30,7 @@ #include #include +#include #include diff --git a/src/lay/lay/layMacroVariableView.cc b/src/lay/lay/layMacroVariableView.cc index 8c4e3873b..8eb6a813d 100644 --- a/src/lay/lay/layMacroVariableView.cc +++ b/src/lay/lay/layMacroVariableView.cc @@ -71,20 +71,17 @@ pretty_print (const tl::Variant &v) } else if (v.is_double ()) { - QString res; - res.sprintf ("%.12g", v.to_double ()); + QString res (QString::fromUtf8 ("%.12g").arg (v.to_double ())); return res; } else if (v.is_char ()) { - QString details; - details.sprintf ("#%d (0x%x)", v.to_int (), v.to_uint ()); + QString details (QString::fromUtf8 ("#%d (0x%x)").arg (v.to_int ()).arg (v.to_uint ())); return tl::to_qstring (std::string ("'") + v.to_string () + "' ") + details; } else if (v.is_ulong () || v.is_long () || v.is_ulonglong () || v.is_longlong ()) { - QString details; - details.sprintf (" (0x%llx)", v.to_ulonglong ()); + QString details (QString::fromUtf8 ("(0x%llx)").arg (v.to_ulonglong ())); return tl::to_qstring (v.to_string ()) + details; } else { diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 48f0cc745..25bab85f3 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -793,6 +793,15 @@ MainWindow::tech_message (const std::string &s) mp_tech_status_label->setText(tl::to_qstring (s)); } +static int fm_width (const QFontMetrics &fm, const QString &s) +{ +#if QT_VERSION >= 0x60000 + return fm.horizontalAdvance (s); +#else + return fm.width (QString::fromUtf8 (s)); +#endif +} + void MainWindow::format_message () { @@ -841,7 +850,7 @@ MainWindow::format_message () ++ndrop; - } while (short_message.size () < prev_len && fm.width (QString::fromUtf8 (" ") + tl::to_qstring (short_message)) > mp_msg_label->width ()); + } while (short_message.size () < prev_len && fm_width (fm, QString::fromUtf8 (" ") + tl::to_qstring (short_message)) > mp_msg_label->width ()); mp_msg_label->setText (QString::fromUtf8 (" ") + tl::to_qstring (short_message)); mp_msg_label->setToolTip (tl::to_qstring (full_message)); @@ -1579,7 +1588,11 @@ MainWindow::cm_print () QFont header_font (QString::fromUtf8 ("Helvetica"), 8); int hh = QFontMetrics (header_font, mp_printer.get ()).height (); - QRect page_rect = mp_printer->pageRect (); +#if QT_VERSION >= 0x60000 + QRectF page_rect = mp_printer->pageRect (QPrinter::DevicePixel); +#else + QRectF page_rect = mp_printer->pageRect (); +#endif page_rect.moveTo (0, 0); int b = std::min (page_rect.width (), page_rect.height ()) / 50; @@ -1588,7 +1601,7 @@ MainWindow::cm_print () page_rect.setTop (page_rect.top () + b); page_rect.setBottom (page_rect.bottom () - b); - QRect text_rect = page_rect; + QRectF text_rect = page_rect; text_rect.setLeft (text_rect.left () + hh / 2); text_rect.setRight (text_rect.right () - hh / 2); text_rect.setBottom (text_rect.bottom () - hh / 2); diff --git a/src/lay/lay/layProgressWidget.cc b/src/lay/lay/layProgressWidget.cc index ef51cb1ee..e4fef2b81 100644 --- a/src/lay/lay/layProgressWidget.cc +++ b/src/lay/lay/layProgressWidget.cc @@ -90,7 +90,11 @@ QSize ProgressBarWidget::sizeHint () const { QFontMetrics fm (font ()); +#if QT_VERSION >= 0x60000 + return QSize (fm.horizontalAdvance (QString::fromUtf8("100%")) * 4, fm.height () + 2); +#else return QSize (fm.width (QString::fromUtf8("100%")) * 4, fm.height () + 2); +#endif } QSize diff --git a/src/lay/lay/laySaltDownloadManager.cc b/src/lay/lay/laySaltDownloadManager.cc index bc3ed4f4e..408c3b226 100644 --- a/src/lay/lay/laySaltDownloadManager.cc +++ b/src/lay/lay/laySaltDownloadManager.cc @@ -85,8 +85,8 @@ ConfirmationDialog::mark_fetching (const std::string &name) if (i != m_items_by_name.end ()) { list->scrollToItem (i->second); for (int c = 0; c < list->columnCount (); ++c) { - i->second->setData (c, Qt::BackgroundColorRole, QColor (224, 244, 244)); - i->second->setData (c, Qt::TextColorRole, QColor (Qt::blue)); + i->second->setData (c, Qt::BackgroundRole, QColor (224, 244, 244)); + i->second->setData (c, Qt::ForegroundRole, QColor (Qt::blue)); } i->second->setData (1, Qt::DisplayRole, tr ("FETCHING")); } @@ -101,8 +101,8 @@ ConfirmationDialog::mark_error (const std::string &name) if (i != m_items_by_name.end ()) { list->scrollToItem (i->second); for (int c = 0; c < list->columnCount (); ++c) { - i->second->setData (c, Qt::BackgroundColorRole, QColor (255, 224, 244)); - i->second->setData (c, Qt::TextColorRole, QColor (Qt::black)); + i->second->setData (c, Qt::BackgroundRole, QColor (255, 224, 244)); + i->second->setData (c, Qt::ForegroundRole, QColor (Qt::black)); } i->second->setData (1, Qt::DisplayRole, tr ("ERROR")); } @@ -117,8 +117,8 @@ ConfirmationDialog::mark_success (const std::string &name) if (i != m_items_by_name.end ()) { list->scrollToItem (i->second); for (int c = 0; c < list->columnCount (); ++c) { - i->second->setData (c, Qt::BackgroundColorRole, QColor (160, 255, 160)); - i->second->setData (c, Qt::TextColorRole, QColor (Qt::black)); + i->second->setData (c, Qt::BackgroundRole, QColor (160, 255, 160)); + i->second->setData (c, Qt::ForegroundRole, QColor (Qt::black)); } i->second->setData (1, Qt::DisplayRole, tr ("INSTALLED")); } diff --git a/src/lay/lay/laySaltGrain.cc b/src/lay/lay/laySaltGrain.cc index fed757097..6714361ed 100644 --- a/src/lay/lay/laySaltGrain.cc +++ b/src/lay/lay/laySaltGrain.cc @@ -463,7 +463,11 @@ SaltGrain::load (const std::string &p) QResource res (tl::to_qstring (p)); QByteArray data; +#if QT_VERSION >= 0x60000 + if (res.compressionAlgorithm () == QResource::ZlibCompression) { +#else if (res.isCompressed ()) { +#endif data = qUncompress ((const unsigned char *)res.data (), (int)res.size ()); } else { data = QByteArray ((const char *)res.data (), (int)res.size ()); diff --git a/src/lay/lay/laySaltGrainDetailsTextWidget.cc b/src/lay/lay/laySaltGrainDetailsTextWidget.cc index 820a334de..e32c35429 100644 --- a/src/lay/lay/laySaltGrainDetailsTextWidget.cc +++ b/src/lay/lay/laySaltGrainDetailsTextWidget.cc @@ -181,7 +181,11 @@ SaltGrainDetailsTextWidget::details_text () QBuffer buffer; buffer.open (QIODevice::WriteOnly); QTextStream stream (&buffer); +#if QT_VERSION >= 0x60000 + stream.setEncoding (QStringConverter::Utf8); +#else stream.setCodec ("UTF-8"); +#endif stream << ""; diff --git a/src/lay/lay/laySaltManagerDialog.cc b/src/lay/lay/laySaltManagerDialog.cc index a49f5c494..5c57023ae 100644 --- a/src/lay/lay/laySaltManagerDialog.cc +++ b/src/lay/lay/laySaltManagerDialog.cc @@ -43,6 +43,7 @@ #include #include #include +#include namespace lay { diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index 3c70640ba..b8a6e50c6 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -42,6 +42,7 @@ #include #include +#include #include @@ -1249,8 +1250,7 @@ SearchReplaceDialog::update_mru_list () for (std::vector::const_iterator mru = m_mru.begin (); mru != m_mru.end (); ++mru) { QString text = tl::to_qstring (*mru); - QString display_text = text; - display_text.replace (QRegExp (QString::fromUtf8 ("\\s+")), QString::fromUtf8 (" ")); + QString display_text = text.simplified (); int nmax = 50; if (display_text.size () > nmax) { display_text = display_text.left (nmax) + QString::fromUtf8 ("..."); diff --git a/src/lay/lay/laySystemPaths.cc b/src/lay/lay/laySystemPaths.cc index c33582051..cadd53474 100644 --- a/src/lay/lay/laySystemPaths.cc +++ b/src/lay/lay/laySystemPaths.cc @@ -65,7 +65,11 @@ split_path (const std::string &path, std::vector &pc) sep = QString::fromUtf8 (":"); #endif +#if QT_VERSION >= 0x60000 + QStringList pp = tl::to_qstring (path).split (sep, Qt::SkipEmptyParts); +#else QStringList pp = tl::to_qstring (path).split (sep, QString::SkipEmptyParts); +#endif for (QStringList::ConstIterator p = pp.begin (); p != pp.end (); ++p) { pc.push_back (tl::to_string (*p)); }