From 8f6ae65224efa438503ec8ee67c6e49123ebb700 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 28 Oct 2019 17:44:31 +0200 Subject: [PATCH] New feature Pattern Messages. Added special field to show pattern warnings instead of warning dialogs. Fixed issue with tabified dockwidgets. --HG-- branch : develop --- ChangeLog.txt | 1 + src/app/valentina/core/vapplication.cpp | 111 +++++++------- src/app/valentina/mainwindow.cpp | 118 +++++++++++++-- src/app/valentina/mainwindow.h | 6 +- src/app/valentina/mainwindow.ui | 135 ++++++++++++++++-- src/app/valentina/mainwindowsnogui.cpp | 1 + src/app/valentina/mainwindowsnogui.h | 1 + src/libs/vlayout/vabstractpiece.cpp | 3 +- src/libs/vlayout/vbank.cpp | 3 +- src/libs/vlayout/vlayoutpiece.cpp | 9 +- src/libs/vmisc/customevents.h | 47 +++++- src/libs/vmisc/share/resources/icon.qrc | 2 + .../share/resources/icon/16x16/broom.png | Bin 0 -> 743 bytes .../share/resources/icon/16x16/broom@2x.png | Bin 0 -> 1653 bytes src/libs/vmisc/vabstractapplication.cpp | 16 +++ src/libs/vmisc/vabstractapplication.h | 5 + src/libs/vmisc/vsettings.cpp | 91 +++++++++++- src/libs/vmisc/vsettings.h | 17 +++ src/libs/vpatterndb/vpassmark.cpp | 30 ++-- src/libs/vpatterndb/vpiece.cpp | 9 +- src/libs/vpatterndb/vpiecenode.cpp | 15 +- src/libs/vpatterndb/vpiecepath.cpp | 6 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 3 +- .../toollinepoint/vtoollineintersectaxis.cpp | 3 +- .../vtoolpointfromarcandtangent.cpp | 3 +- .../vtoolpointfromcircleandtangent.cpp | 3 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 3 +- .../vtoolpointofintersectionarcs.cpp | 3 +- .../vtoolpointofintersectioncircles.cpp | 3 +- .../vtoolpointofintersectioncurves.cpp | 3 +- .../toolsinglepoint/vtooltriangle.cpp | 3 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 3 +- src/libs/vwidgets/vplaintextedit.cpp | 67 +++++++++ src/libs/vwidgets/vplaintextedit.h | 9 ++ 34 files changed, 628 insertions(+), 104 deletions(-) create mode 100644 src/libs/vmisc/share/resources/icon/16x16/broom.png create mode 100644 src/libs/vmisc/share/resources/icon/16x16/broom@2x.png diff --git a/ChangeLog.txt b/ChangeLog.txt index 37af7f9f6..3f45ddc99 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -32,6 +32,7 @@ - Added options to control passmark angle type and passmark mark type. - Improve for recent files list. Show duplicate file names with unique path section. - New command line option --cropWidth. Helps to crop unused width of paper. +- New feature Pattern Messages. # Version 0.6.2 (unreleased) - [#903] Bug in tool Cut Spline path. diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 36e0d31b0..d1af7bba5 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -145,36 +145,51 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con type = QtDebugMsg; } + QString logMsg = msg; + const bool isPatternMessage = qApp->IsPatternMessage(msg); + if (isPatternMessage) + { + logMsg = logMsg.remove(VAbstractApplication::patternMessageSignature); + } + { QString debugdate = "[" + QDateTime::currentDateTime().toString(QStringLiteral("yyyy.MM.dd hh:mm:ss")); switch (type) { case QtDebugMsg: - debugdate += QString(":DEBUG:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) - .arg(context.function, context.category, msg); - vStdOut() << QApplication::translate("vNoisyHandler", "DEBUG:") << msg << "\n"; + debugdate += QStringLiteral(":DEBUG:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function, context.category, logMsg); + vStdOut() << QApplication::translate("vNoisyHandler", "DEBUG:") << logMsg << "\n"; break; case QtWarningMsg: - debugdate += QString(":WARNING:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) - .arg(context.function, context.category, msg); - vStdErr() << QApplication::translate("vNoisyHandler", "WARNING:") << msg << "\n"; + if (isPatternMessage) + { + qApp->PostPatternMessage(logMsg, type); + } + debugdate += QStringLiteral(":WARNING:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function, context.category, logMsg); + vStdErr() << QApplication::translate("vNoisyHandler", "WARNING:") << logMsg << "\n"; break; case QtCriticalMsg: - debugdate += QString(":CRITICAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) - .arg(context.function, context.category, msg); - vStdErr() << QApplication::translate("vNoisyHandler", "CRITICAL:") << msg << "\n"; + debugdate += QStringLiteral(":CRITICAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function, context.category, logMsg); + vStdErr() << QApplication::translate("vNoisyHandler", "CRITICAL:") << logMsg << "\n"; break; case QtFatalMsg: - debugdate += QString(":FATAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) - .arg(context.function, context.category, msg); - vStdErr() << QApplication::translate("vNoisyHandler", "FATAL:") << msg << "\n"; + debugdate += QStringLiteral(":FATAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function, context.category, logMsg); + vStdErr() << QApplication::translate("vNoisyHandler", "FATAL:") << logMsg << "\n"; break; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtInfoMsg: - debugdate += QString(":INFO:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) - .arg(context.function, context.category, msg); - vStdOut() << QApplication::translate("vNoisyHandler", "INFO:") << msg << "\n"; + if (isPatternMessage) + { + qApp->PostPatternMessage(logMsg, type); + } + debugdate += QStringLiteral(":INFO:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function, context.category, logMsg); + vStdOut() << QApplication::translate("vNoisyHandler", "INFO:") << logMsg << "\n"; break; #endif default: @@ -188,44 +203,44 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (isGuiThread) { - //fixme: trying to make sure there are no save/load dialogs are opened, because error message during them will - //lead to crash - const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) || - !QApplication::activeModalWidget()->inherits("QFileDialog"); - - QMessageBox messageBox; - switch (type) - { - case QtWarningMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning")); - messageBox.setIcon(QMessageBox::Warning); - break; - case QtCriticalMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error")); - messageBox.setIcon(QMessageBox::Critical); - break; - case QtFatalMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error")); - messageBox.setIcon(QMessageBox::Critical); - break; - #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) - case QtInfoMsg: - messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information")); - messageBox.setIcon(QMessageBox::Information); - break; - #endif - case QtDebugMsg: - default: - break; - } - if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) { if (VApplication::IsGUIMode()) { - if (topWinAllowsPop) + //fixme: trying to make sure there are no save/load dialogs are opened, because error message during + // them will lead to crash + const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) || + !QApplication::activeModalWidget()->inherits("QFileDialog"); + + if (topWinAllowsPop && (not isPatternMessage || (type == QtCriticalMsg || type == QtFatalMsg))) { - messageBox.setText(VAbstractApplication::ClearMessage(msg)); + QMessageBox messageBox; + switch (type) + { + case QtWarningMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning")); + messageBox.setIcon(QMessageBox::Warning); + break; + case QtCriticalMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error")); + messageBox.setIcon(QMessageBox::Critical); + break; + case QtFatalMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error")); + messageBox.setIcon(QMessageBox::Critical); + break; + #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) + case QtInfoMsg: + messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information")); + messageBox.setIcon(QMessageBox::Information); + break; + #endif + case QtDebugMsg: + default: + break; + } + + messageBox.setText(VAbstractApplication::ClearMessage(logMsg)); messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setWindowModality(Qt::ApplicationModal); messageBox.setModal(true); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 834f274e9..292ea6295 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -174,8 +174,6 @@ MainWindow::MainWindow(QWidget *parent) dialogFMeasurements(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), currentDrawIndex(0), currentToolBoxIndex(0), - isDockToolOptionsVisible(true), - isDockGroupsVisible(true), drawMode(true), leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true), gradationHeights(nullptr), @@ -300,6 +298,44 @@ MainWindow::MainWindow(QWidget *parent) menu->setAsDockMenu(); #endif //defined(Q_OS_MAC) + + connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]() + { + VSettings *settings = qApp->ValentinaSettings(); + QFont f = ui->plainTextEditPatternMessages->font(); + if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize()) + { + f.setPointSize(f.pointSize()+1); + ui->plainTextEditPatternMessages->setFont(f); + settings->SetPatternMessageFontSize(f.pointSize()); + } + }); + + connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]() + { + VSettings *settings = qApp->ValentinaSettings(); + QFont f = ui->plainTextEditPatternMessages->font(); + if (f.pointSize() > settings->GetDefMinPatternMessageFontSize()) + { + f.setPointSize(f.pointSize()-1); + ui->plainTextEditPatternMessages->setFont(f); + settings->SetPatternMessageFontSize(f.pointSize()); + } + }); + + connect(ui->lineEditMessagesFilter, &QLineEdit::textChanged, this, [this](const QString &text) + { + ui->plainTextEditPatternMessages->SetFilter(text); + }); + + connect(ui->toolButtonClearMessages, &QToolButton::clicked, this, [this]() + { + ui->plainTextEditPatternMessages->clear(); + if (not m_unreadPatternMessage.isNull()) + { + m_unreadPatternMessage->setText(QString()); + } + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -1542,6 +1578,10 @@ void MainWindow::customEvent(QEvent *event) { ZoomFitBestCurrent(); } + else if (event->type() == PATTERN_MESSAGE_EVENT) + { + PrintPatternMessage(event); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1975,6 +2015,10 @@ void MainWindow::ToolBarOption() m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); + + ui->toolBarOption->addSeparator(); + m_unreadPatternMessage = new QLabel(); + ui->toolBarOption->addWidget(m_unreadPatternMessage); } //--------------------------------------------------------------------------------------------------------------------- @@ -2647,13 +2691,14 @@ void MainWindow::ActionDetails(bool checked) } ui->dockWidgetLayoutPages->setVisible(false); - ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); ui->dockWidgetGroups->setWidget(detailsWidget); ui->dockWidgetGroups->setWindowTitle(tr("Details")); ui->dockWidgetGroups->setVisible(isDockGroupsVisible); ui->dockWidgetGroups->setToolTip(tr("Show which details will go in layout")); + ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); + m_statusLabel->setText(QString()); } else @@ -3101,6 +3146,7 @@ void MainWindow::Clear() ui->actionDecreaseLabelFont->setEnabled(false); ui->actionOriginalLabelFont->setEnabled(false); ui->actionHideLabels->setEnabled(false); + ui->plainTextEditPatternMessages->clear(); } //--------------------------------------------------------------------------------------------------------------------- @@ -3921,6 +3967,10 @@ void MainWindow::ReadSettings() restoreState(settings->GetWindowState()); restoreState(settings->GetToolbarsState(), APP_VERSION); + ui->dockWidgetGroups->setVisible(settings->IsDockWidgetGroupsActive()); + ui->dockWidgetToolOptions->setVisible(settings->IsDockWidgetToolOptionsActive()); + ui->dockWidgetMessages->setVisible(settings->IsDockWidgetPatternMessagesActive()); + // Scene antialiasing ui->view->SetAntialiasing(settings->GetGraphicalOutput()); @@ -3930,8 +3980,12 @@ void MainWindow::ReadSettings() // Text under tool buton icon ToolBarStyles(); - isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible(); - isDockGroupsVisible = ui->dockWidgetGroups->isVisible(); + isDockToolOptionsVisible = ui->dockWidgetToolOptions->isEnabled(); + isDockGroupsVisible = ui->dockWidgetGroups->isEnabled(); + + QFont f = ui->plainTextEditPatternMessages->font(); + f.setPointSize(settings->GetPatternMessageFontSize(f.pointSize())); + ui->plainTextEditPatternMessages->setFont(f); } else { @@ -3952,6 +4006,10 @@ void MainWindow::WriteSettings() settings->SetWindowState(saveState()); settings->SetToolbarsState(saveState(APP_VERSION)); + settings->SetDockWidgetGroupsActive(ui->dockWidgetGroups->isEnabled()); + settings->SetDockWidgetToolOptionsActive(ui->dockWidgetToolOptions->isEnabled()); + settings->SetDockWidgetPatternMessagesActive(ui->dockWidgetMessages->isEnabled()); + settings->sync(); if (settings->status() == QSettings::AccessError) { @@ -4262,17 +4320,19 @@ void MainWindow::AddDocks() //Add dock actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction(); ui->menuWindow->addAction(actionDockWidgetToolOptions); - connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, this, [this](bool visible) + connect(actionDockWidgetToolOptions, &QAction::triggered, this, [this](bool checked) { - isDockToolOptionsVisible = visible; + isDockToolOptionsVisible = checked; }); actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction(); ui->menuWindow->addAction(actionDockWidgetGroups); - connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, this, [this](bool visible) + connect(actionDockWidgetGroups, &QAction::triggered, this, [this](bool checked) { - isDockGroupsVisible = visible; + isDockGroupsVisible = checked; }); + + ui->menuWindow->addAction(ui->dockWidgetMessages->toggleViewAction()); } //--------------------------------------------------------------------------------------------------------------------- @@ -6044,3 +6104,43 @@ void MainWindow::ToolSelectDetail() ui->view->AllowRubberBand(false); } + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::PrintPatternMessage(QEvent *event) +{ + SCASSERT(event != nullptr) + auto *patternMessage = static_cast(event); + + QString severity; + + switch(patternMessage->Severity()) + { + case QtDebugMsg: + severity = tr("DEBUG"); + break; + case QtWarningMsg: + severity = tr("WARNING"); + break; + case QtCriticalMsg: + severity = tr("CRITICAL"); + break; + case QtFatalMsg: + severity = tr("FATAL"); + break; + #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) + case QtInfoMsg: + severity = tr("INFO"); + break; + #endif + default: + break; + } + + const QString time = QDateTime::currentDateTime().toString(QStringLiteral("hh:mm:ss")); + const QString message = QStringLiteral("%1: [%2] %3").arg(time, severity, patternMessage->Message()); + ui->plainTextEditPatternMessages->appendPlainText(message); + if (not m_unreadPatternMessage.isNull()) + { + m_unreadPatternMessage->setText(DialogWarningIcon() + tr("Pattern messages")); + } +} diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index c2f60dbd0..192c66879 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -249,8 +249,8 @@ private: /** @brief currentToolBoxIndex save current set of tools. */ qint32 currentToolBoxIndex; - bool isDockToolOptionsVisible; - bool isDockGroupsVisible; + bool isDockToolOptionsVisible{false}; + bool isDockGroupsVisible{false}; /** @brief drawMode true if we current draw scene. */ bool drawMode; @@ -378,6 +378,8 @@ private: void ToolSelectOperationObjects(); void ToolSelectGroupObjects(); void ToolSelectDetail(); + + void PrintPatternMessage(QEvent *event); }; #endif // MAINWINDOW_H diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 4e4111a2f..ca589e4d5 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1100 - 709 + 809 @@ -55,7 +55,7 @@ 0 0 - 140 + 126 282 @@ -481,7 +481,7 @@ 0 0 - 140 + 126 243 @@ -746,7 +746,7 @@ 0 0 - 140 + 126 282 @@ -1120,8 +1120,8 @@ 0 0 - 140 - 331 + 126 + 192 @@ -1324,7 +1324,7 @@ 0 0 - 140 + 126 237 @@ -1590,7 +1590,7 @@ 0 0 140 - 331 + 163 @@ -2013,6 +2013,115 @@ + + + true + + + Pattern messages + + + 8 + + + + + + + + + Clear all messages + + + ... + + + + :/icon/16x16/broom@2x.png:/icon/16x16/broom@2x.png + + + + + + + + 0 + 0 + + + + + 1 + 0 + + + + Filter + + + true + + + + + + + Zoom in + + + ... + + + + .. + + + + + + + Zoom out + + + ... + + + + .. + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + true + + + 500 + + + + + + @@ -2859,6 +2968,16 @@ QGraphicsView
vmaingraphicsview.h
+ + VLineEdit + QLineEdit +
vlineedit.h
+
+ + VPlainTextEdit + QPlainTextEdit +
vplaintextedit.h
+
diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 6fa99c329..df258c541 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -174,6 +174,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- MainWindowsNoGUI::~MainWindowsNoGUI() { + delete m_unreadPatternMessage; delete m_mouseCoordinate; delete tempSceneLayout; delete pattern; diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 9eb3e3a0e..094d82604 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -122,6 +122,7 @@ protected: /** @brief mouseCoordinate pointer to label who show mouse coordinate. */ QPointer m_mouseCoordinate; + QPointer m_unreadPatternMessage{}; #if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) QWinTaskbarButton *m_taskbarButton; diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index a05576686..15bc43293 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1011,7 +1011,8 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid if ( points.size() < 3 ) { const QString errorMsg = tr("Piece '%1'. Not enough points to build seam allowance.").arg(name); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QVector(); } diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index 1d44f0e7f..7a987c259 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -385,7 +385,8 @@ bool VBank::PrepareDetails() { const QString errorMsg = QObject::tr("Piece '%1' has invalid layout allowance. Please, check seam allowance" " to check how seam allowance behave.").arg(details.at(i).GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } const qreal d = details.at(i).Diagonal(); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index d4ac8d97a..d51fa8d29 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -268,7 +268,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Passmark '%1' is not part of piece '%2'.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } }; @@ -302,7 +303,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Passmark '%1' is not part of piece '%2'.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } }; @@ -432,7 +434,8 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai { const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.") .arg(piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } det.SetCountourPoints(futureMainPath.result(), piece.IsHideMainPath()); diff --git a/src/libs/vmisc/customevents.h b/src/libs/vmisc/customevents.h index ff98c13d9..9a56e7f96 100644 --- a/src/libs/vmisc/customevents.h +++ b/src/libs/vmisc/customevents.h @@ -31,9 +31,18 @@ #include #include +#include -enum CustomEventType { UndoEventType = 1, LiteParseEventType = 2, FitBestCurrentEventType = 3 }; +#include "typedef.h" +enum CustomEventType { + UndoEventType = 1, + LiteParseEventType = 2, + FitBestCurrentEventType = 3, + PatternMessageEventType = 4, +}; + +//--------------------------------------------------------------------------------------------------------------------- // Define undo event identifier const QEvent::Type UNDO_EVENT = static_cast(QEvent::User + CustomEventType::UndoEventType); @@ -47,6 +56,7 @@ public: virtual ~UndoEvent() =default; }; +//--------------------------------------------------------------------------------------------------------------------- const QEvent::Type LITE_PARSE_EVENT = static_cast(QEvent::User + CustomEventType::LiteParseEventType); class LiteParseEvent : public QEvent @@ -59,6 +69,7 @@ public: virtual ~LiteParseEvent() =default; }; +//--------------------------------------------------------------------------------------------------------------------- const QEvent::Type FIT_BEST_CURRENT_EVENT = static_cast(QEvent::User + CustomEventType::FitBestCurrentEventType); @@ -72,4 +83,38 @@ public: virtual ~FitBestCurrentEvent() =default; }; +//--------------------------------------------------------------------------------------------------------------------- +const QEvent::Type PATTERN_MESSAGE_EVENT = static_cast(QEvent::User + + CustomEventType::PatternMessageEventType); + +class PatternMessageEvent : public QEvent +{ +public: + PatternMessageEvent(const QString &message, QtMsgType severity) + : QEvent(PATTERN_MESSAGE_EVENT), + m_message(message), + m_severity(severity) + {} + + virtual ~PatternMessageEvent() =default; + + QString Message() const; + + QtMsgType Severity() const; + +private: + QString m_message; + QtMsgType m_severity; +}; + #endif // CUSTOMEVENTS_H + +inline QString PatternMessageEvent::Message() const +{ + return m_message; +} + +inline QtMsgType PatternMessageEvent::Severity() const +{ + return m_severity; +} diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index eb7a14625..1e346727e 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -77,5 +77,7 @@ icon/32x32/passmark@2x.png icon/32x32/button.png icon/32x32/button@2x.png + icon/16x16/broom.png + icon/16x16/broom@2x.png diff --git a/src/libs/vmisc/share/resources/icon/16x16/broom.png b/src/libs/vmisc/share/resources/icon/16x16/broom.png new file mode 100644 index 0000000000000000000000000000000000000000..02a4f30482e27bad298f955fecb144f7a26bc0ff GIT binary patch literal 743 zcmV?P)YK=jo-V}{9uMOW)&c+#DXgezDq=zlZH=ZCl5Oq&|a`D5KRH zRUrT{3={Htnfr^}9~+#xRHwXMf7xj=<&)WB#luuiWKiX4h1QvPuH#!8D^+ER$ml46 z!{M;IJ+5<)D)V2Hkp>Ep|9k6=LSsUFTzTe3ZI+NH;OTWDL+l}Qx4Y@510%scHa(=# zY)TCTLnQ!y88n*$AmE3J&r?a7j|9o1UZBPfTW|L*snuyh6VF}3_G~KLCLVK zcv%K*4Th6)ndmCZ26el(r6GojT6WU0iRr1nPY#2js`V`Z2qK%u%3Cb9aqmu^=U)ZG z;Sd1$`~l4QSOCDB&mXi6P2O3Amu(PP?YE9s$!NN4jhKp0*RMk$80M|L{g#5WPl_US zf|U#kFSOQ7I%oIKdHr3!d6u{K3_PFsIDBfU?yuk2)@hr{Q;`B|L4B!+ugmJ-DKHpHrXU3WCMwY1Q1fDz&Obk zil8$J`awqpKR6w0OAE9V$=p(OtfV93OsgXsEJ>2WNRq^v4Z;`G zDyFlIgUv{k@ILlK{X`5VtIc6iO)oK$b&F zhGhqD2MPcNJ=0QJT5RJu4wM4D{R3V$fi0u!?5U%NA~WYNl>2)7r}y^u$?;@b+Pdla zBew&6@P$JSIXU9m;^JaG0Qh`9#q0O)d3RI8Uq^Fp>mDy%yT3pq2(M6zS_U6 z$f&$I2KHQSZHqA?zd8qF;dtG9FD-PB)@C))Po>vH3i7O?C@223@n;`r%lXOr zKNNY?!qEz+(_zpHBq+;Md%AlX`DD^xT3T!yh0382lBx9ZYoP#;eSk3B&MA}2UealV zeJj^D7iUY+@~Ok3PF&Dk-Ju#t# zQUG++apPjgrU#xYvYofYO$KIfr%%bXmBDJWGlUR`MsX}J7KactTxPzkFHA+(+9k9^DfhTgwK{7Lp_}CG3e;azx#V>ZoW+d1Elm$cMq13jhcu zIkcR#(MusKbyVEL2s+(ZZ8RD~S65d*qPS<@?;C?RJ@NQ>V}0YyJZ|VCXPLd>2X#)- zP;Q3WBEb9E05b73v~~m3tb#d3GMR4mkz-u}Wyl+)dZUT3EDN6J!SlS}3wnpXIj(4_w#k*VZkvFeFi=;Z(C!Dt-xtQfJT4(@iV4 z8;zncVMj8F3<9SH5x(ey{ozV*!WC0f3bcQngZ&o@6{tiS^AA1w&dZPO2Ci|n3h7y3 z`M)>{E&6JwgE1O(H^BgMI0mhn2hU$AXVoln>+Mimbm)Kk9F$ZBrrLa%XBWUVC4f51 zAhYcg+Fx_&{M+yRPh+gr2aa`Lbj_`3NhD&k(;3B7Fv+YTN^zmb4Xs)Qy`Z^a zLn^Ztrn-EXXV@@utRKW?Cuo^NbU=eylTJdeHM}cltl-MC&7eY+HHl+D)(1)^)B*wZQ+) zSyE6EkRzIY_XzHvdoOI0Ot%CD0KXhT`;pV9g|oUD%lGZe+!7c7_DaiCG6`>EKpv}~ z;Z!>c^0MY-6a|!0aO~Afl1ioV!AB?E!DyuZxfc)jj<30;0kVBV<6KUy+EricEG)F; zUN>fgas=K$7?T~=s~;&v`>``4Bi_J@XEuKLK{m}>8X)f<>F%FD&%VPmDA&oMXl_Bi zSxZ3h)z<^)=^H}Lv{GE_!;UYzgO`VW%`2rtEjQEr&i~^#H!gl$&9Ti4%UD^KfotA$ z@Z8n?U;4%!?da-hf4b@5LlfzI=Xdprrh~iuk?`zjJaMtWW(xD{Rf*oqo@B?_?oL6` zE&n#1|N8|(0n+-r#V_b|>gN~Csm}8S!>QvP|L*kp{PTbD>hak31|E%V8y3z|soA|$ zfpCW!w6}NBN literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 7a54caed2..28384e0eb 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -39,8 +39,12 @@ #include #include #include +#include #include "../vmisc/def.h" +#include "../vmisc/customevents.h" + +const QString VAbstractApplication::patternMessageSignature = QStringLiteral("[PATTERN MESSAGE]"); //--------------------------------------------------------------------------------------------------------------------- VAbstractApplication::VAbstractApplication(int &argc, char **argv) @@ -257,6 +261,18 @@ void VAbstractApplication::SetDrawMode(const Draw &value) mode = value; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractApplication::PostPatternMessage(const QString &message, QtMsgType severity) const +{ + QApplication::postEvent(mainWindow, new PatternMessageEvent(VAbstractApplication::ClearMessage(message), severity)); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractApplication::IsPatternMessage(const QString &message) const +{ + return VAbstractApplication::ClearMessage(message).startsWith(patternMessageSignature); +} + //--------------------------------------------------------------------------------------------------------------------- #if defined(Q_OS_WIN) void VAbstractApplication::WinAttachConsole() diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index 4de9f0990..e09ee2db3 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -124,6 +124,11 @@ public: const Draw &GetDrawMode() const; void SetDrawMode(const Draw &value); + void PostPatternMessage(const QString &message, QtMsgType severity) const; + + static const QString patternMessageSignature; + bool IsPatternMessage(const QString &message) const; + protected: QUndoStack *undoStack; diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp index 63f656c47..80053bf2c 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -105,10 +105,18 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1Str Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, (QLatin1String("scrolling/sensorMouseScale"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, + (QLatin1String("scrolling/sensorMouseScale"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, + (QLatin1String("dockWidget/toolOptionsActive"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, + (QLatin1String("dockWidget/patternMessagesActive"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) + // Reading settings file is very expensive, cache values to speed up getting a value int scrollingDurationCached = -1; int scrollingUpdateIntervalCached = -1; @@ -678,6 +686,87 @@ void VSettings::SetScrollingAcceleration(qreal acceleration) setValue(*settingScrollingAcceleration, scrollingAccelerationCached); } +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::IsDockWidgetGroupsActive() const +{ + return value(*settingdockWidgetGroupsActive, GetDefDockWidgetGroupsActive()).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetDefDockWidgetGroupsActive() +{ + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetDockWidgetGroupsActive(bool value) +{ + setValue(*settingdockWidgetGroupsActive, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::IsDockWidgetToolOptionsActive() const +{ + return value(*settingDockWidgetToolOptionsActive, GetDefDockWidgetToolOptionsActive()).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetDefDockWidgetToolOptionsActive() +{ + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetDockWidgetToolOptionsActive(bool value) +{ + setValue(*settingDockWidgetToolOptionsActive, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::IsDockWidgetPatternMessagesActive() const +{ + return value(*settingDockWidgetPatternMessagesActive, GetDefDockWidgetPatternMessagesActive()).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetDefDockWidgetPatternMessagesActive() +{ + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetDockWidgetPatternMessagesActive(bool value) +{ + setValue(*settingDockWidgetPatternMessagesActive, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VSettings::GetPatternMessageFontSize(int fontSizeDef) const +{ + fontSizeDef = qBound(GetDefMinPatternMessageFontSize(), fontSizeDef, GetDefMaxPatternMessageFontSize()); + const int fontSize = value(*settingPatternMessagesFontSize, fontSizeDef).toInt(); + return qBound(GetDefMinPatternMessageFontSize(), fontSize, GetDefMaxPatternMessageFontSize()); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VSettings::GetDefMinPatternMessageFontSize() +{ + return 5; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VSettings::GetDefMaxPatternMessageFontSize() +{ + return 40; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetPatternMessageFontSize(int size) +{ + setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size, + GetDefMaxPatternMessageFontSize())); +} + //--------------------------------------------------------------------------------------------------------------------- template T VSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const diff --git a/src/libs/vmisc/vsettings.h b/src/libs/vmisc/vsettings.h index 82a5f07c7..68e094d2e 100644 --- a/src/libs/vmisc/vsettings.h +++ b/src/libs/vmisc/vsettings.h @@ -178,6 +178,23 @@ public: qreal GetScrollingAcceleration() const; void SetScrollingAcceleration(qreal acceleration); + bool IsDockWidgetGroupsActive() const; + static bool GetDefDockWidgetGroupsActive(); + void SetDockWidgetGroupsActive(bool value); + + bool IsDockWidgetToolOptionsActive() const; + static bool GetDefDockWidgetToolOptionsActive(); + void SetDockWidgetToolOptionsActive(bool value); + + bool IsDockWidgetPatternMessagesActive() const; + static bool GetDefDockWidgetPatternMessagesActive(); + void SetDockWidgetPatternMessagesActive(bool value); + + int GetPatternMessageFontSize(int fontSizeDef) const; + static int GetDefMinPatternMessageFontSize(); + static int GetDefMaxPatternMessageFontSize(); + void SetPatternMessageFontSize(int size); + private: Q_DISABLE_COPY(VSettings) diff --git a/src/libs/vpatterndb/vpassmark.cpp b/src/libs/vpatterndb/vpassmark.cpp index e9973304c..8b1eb323d 100644 --- a/src/libs/vpatterndb/vpassmark.cpp +++ b/src/libs/vpatterndb/vpassmark.cpp @@ -575,7 +575,8 @@ QVector PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " "than minimal allowed.") .arg(passmarkData.nodeName, passmarkData.pieceName); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QVector(); } @@ -783,7 +784,8 @@ QVector VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " "than minimal allowed.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QVector(); } } @@ -798,7 +800,8 @@ QVector VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built in " "seam allowance. User must manually provide length.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QVector(); } } @@ -841,7 +844,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa { const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is " "empty.").arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QVector(); // Something wrong } @@ -852,7 +856,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find " "position for a notch.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QVector(); // Something wrong } @@ -861,7 +866,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a " "notch position.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } auto PassmarkIntersection = [this, seamAllowance] (QLineF line, qreal width) @@ -882,7 +888,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is " "less than minimal allowed.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return QLineF(); } line.setLength(length); @@ -898,7 +905,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " "collapse.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } } else @@ -906,7 +914,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find " "intersection.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } return QLineF(); @@ -920,7 +929,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " "than minimal allowed.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } else { diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index b94ed47f0..5a667a1d4 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -913,7 +913,8 @@ bool VPiece::GetPassmarkPreviousSAPoints(const QVector &path, int in { const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return false; // Something wrong } @@ -951,7 +952,8 @@ bool VPiece::GetPassmarkNextSAPoints(const QVector &path, int index, { const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return false; // Something wrong } @@ -1034,7 +1036,8 @@ VPassmark VPiece::CreatePassmark(const QVector &path, int previousIn { const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return VPassmark(); } diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 05a448da1..41cb4fff9 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -147,7 +147,8 @@ qreal VPieceNode::GetSABefore(const VContainer *data) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return -1; } return formula.getDoubleValue(); @@ -177,7 +178,8 @@ qreal VPieceNode::GetSABefore(const VContainer *data, Unit unit) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return -1; } @@ -228,7 +230,8 @@ qreal VPieceNode::GetSAAfter(const VContainer *data) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return -1; } @@ -259,7 +262,8 @@ qreal VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: ") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return -1; } @@ -324,7 +328,8 @@ qreal VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const const QString errorMsg = QObject::tr("Cannot calculate passmark length for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; return VSAPoint::maxPassmarkLength; } diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 6dd320a95..19798849f 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -369,7 +369,8 @@ QVector VPiecePath::PathPoints(const VContainer *data, const QVectorIsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } } @@ -386,7 +387,8 @@ QVector VPiecePath::PathPoints(const VContainer *data, const QVectorIsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index a76c22fae..648b8c2cd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -142,7 +142,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis const QString errorMsg = tr("Error calculating point '%1'. There is no intersection with curve '%2' and axis" " through point '%3' with angle %4°") .arg(initData.name, curve->name(), basePoint->name()).arg(angle); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } const qreal segLength = curve->GetLengthByPoint(fPoint); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 729a096cd..3060e5173 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -133,7 +133,8 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(VToolLineIntersectAxisIni const QString errorMsg = tr("Error calculating point '%1'. Line (%2;%3) doesn't have intersection with axis " "through point '%4' and angle %5°") .arg(initData.name, firstPoint->name(), secondPoint->name(), basePoint->name()).arg(axis.angle()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 657b95f0b..d20eadf52 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -121,7 +121,8 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(VToolPointFromA { const QString errorMsg = tr("Error calculating point '%1'. Tangent to arc '%2' from point '%3' cannot be found") .arg(initData.name, arc.name(), tPoint.name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index 69683c465..cf25fbc69 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -130,7 +130,8 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPoin "from point '%4' cannot be found") .arg(initData.name, cPoint.name()).arg(radius).arg(tPoint.name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 65ed8efd8..3ad98fadc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -216,7 +216,8 @@ VToolPointOfContact* VToolPointOfContact::Create(VToolPointOfContactInitData &in const QString errorMsg = tr("Error calculating point '%1'. Circle with center '%2' and radius '%3' doesn't have " "intersection with line (%4;%5)") .arg(initData.name, centerP->name()).arg(result).arg(firstP->name(), secondP->name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index 1c2dc5202..1b3f197a5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -120,7 +120,8 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(VToolPointOfI { const QString errorMsg = tr("Error calculating point '%1'. Arcs '%2' and '%3' have no point of intersection") .arg(initData.name, firstArc->name(), secondArc->name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index 16648085d..ae13c2f2d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -134,7 +134,8 @@ VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData { const QString errorMsg = tr("Error calculating point '%1'. Circles with centers in points '%2' and '%3' have " "no point of intersection").arg(initData.name, c1Point.name(), c2Point.name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 6baa677f5..5d0f0ddea 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -125,7 +125,8 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin { const QString errorMsg = tr("Error calculating point '%1'. Curves '%2' and '%3' have no point of intersection") .arg(initData.name, curve1->name(), curve2->name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 925022b42..39af8c1a8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -146,7 +146,8 @@ VToolTriangle* VToolTriangle::Create(VToolTriangleInitData initData) { const QString errorMsg = tr("Error calculating point '%1'. Point of intersection cannot be found") .arg(initData.name); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index bf4403dda..b22113396 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1342,7 +1342,8 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) { const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.") .arg(detail.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; } path.addPath(detail.SeamAllowancePath(futureSeamAllowance.result())); path.setFillRule(Qt::OddEvenFill); diff --git a/src/libs/vwidgets/vplaintextedit.cpp b/src/libs/vwidgets/vplaintextedit.cpp index 9e527a7ec..1532ac768 100644 --- a/src/libs/vwidgets/vplaintextedit.cpp +++ b/src/libs/vwidgets/vplaintextedit.cpp @@ -49,6 +49,50 @@ VPlainTextEdit::~VPlainTextEdit() document()->blockSignals(true); // prevent crash } +//--------------------------------------------------------------------------------------------------------------------- +void VPlainTextEdit::SetFilter(const QString &filter) +{ + if(m_filter.isEmpty() && not filter.isEmpty()) + { + QTextDocument *doc = document(); + m_allLines.clear(); + m_allLines.reserve(doc->lineCount()); + + for(int i=0; i < doc->blockCount(); ++i) + { + m_allLines.append(doc->findBlockByNumber(i).text()); + } + } + + m_filter = filter; + + Filter(); + + if(m_filter.isEmpty()) + { + m_allLines.clear(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlainTextEdit::appendPlainText(const QString &text) +{ + if (m_filter.isEmpty()) + { + QPlainTextEdit::appendPlainText(text); + } + else + { + m_allLines.append(text); + const int diff = m_allLines.size() - maximumBlockCount(); + if (diff > 0) + { + m_allLines = m_allLines.mid(diff); + } + Filter(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPlainTextEdit::MatchParentheses() { @@ -182,3 +226,26 @@ void VPlainTextEdit::CreateParenthesisSelection(int pos, bool match) setExtraSelections(selections); } + +//--------------------------------------------------------------------------------------------------------------------- +void VPlainTextEdit::Filter() +{ + clear(); + if(not m_filter.isEmpty()) + { + for(auto &line : m_allLines) + { + if (line.contains(m_filter)) + { + QPlainTextEdit::appendPlainText(line); + } + } + } + else + { + for(auto &line : m_allLines) + { + QPlainTextEdit::appendPlainText(line); + } + } +} diff --git a/src/libs/vwidgets/vplaintextedit.h b/src/libs/vwidgets/vplaintextedit.h index d257bd4d5..fb6a3b22a 100644 --- a/src/libs/vwidgets/vplaintextedit.h +++ b/src/libs/vwidgets/vplaintextedit.h @@ -39,15 +39,24 @@ public: VPlainTextEdit(const QString & text, QWidget * parent = nullptr); virtual ~VPlainTextEdit(); + void SetMatchParenthesesEnabled(bool enabled); + + void SetFilter(const QString &filter); + + void appendPlainText(const QString &text); + private slots: void MatchParentheses(); private: VHighlighter m_highlighter; + QString m_filter{}; + QStringList m_allLines{}; bool MatchLeftParenthesis(QTextBlock currentBlock, int i, int numLeftParentheses); bool MatchRightParenthesis(QTextBlock currentBlock, int i, int numRightParentheses); void CreateParenthesisSelection(int pos, bool match = true); + void Filter(); }; #endif // VPLAINTEXTEDIT_H