Sketcher: Obey non-intrusive preferences for modal pop-ups

==========================================================

This commit turns the remaining blocking pop-ups in which the user can only click "ok"
into non-intrusive notifications, depending on the user preferences in settings.
This commit is contained in:
Abdullah Tahiri
2023-05-18 06:57:50 +02:00
committed by abdullahtahiriyo
parent 2a3fe4c628
commit 60d99ca570
10 changed files with 363 additions and 242 deletions

View File

@@ -42,6 +42,7 @@
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/PrefWidgets.h>
#include <Gui/QuantitySpinBox.h>
#include <Gui/SelectionFilter.h>
@@ -166,9 +167,9 @@ void CmdSketcherNewSketch::activated(int iMsg)
if (msgid == Attacher::SuggestResult::srOK)
bAttach = true;
if (msgid != Attacher::SuggestResult::srOK && msgid != Attacher::SuggestResult::srNoModesFit){
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Sketch mapping"),
QObject::tr("Can't map the sketch to selected object. %1.").arg(msg_str));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Sketch mapping"),
QObject::tr("Can't map the sketch to selected object. %1.").arg(msg_str));
return;
}
if (validModes.size() > 1){
@@ -524,9 +525,9 @@ void CmdSketcherMapSketch::activated(int iMsg)
App::Document* doc = App::GetApplication().getActiveDocument();
std::vector<App::DocumentObject*> sketches = doc->getObjectsOfType(Part::Part2DObject::getClassTypeId());
if (sketches.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("Sketcher_MapSketch", "No sketch found"),
qApp->translate("Sketcher_MapSketch", "The document doesn't have a sketch"));
Gui::TranslatedUserWarning(doc->Label.getStrValue(),
qApp->translate("Sketcher_MapSketch", "No sketch found"),
qApp->translate("Sketcher_MapSketch", "The document doesn't have a sketch"));
return;
}
@@ -652,9 +653,9 @@ void CmdSketcherMapSketch::activated(int iMsg)
doCommand(Gui,"App.activeDocument().recompute()");
}
} catch (ExceptionWrongInput &e) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("Sketcher_MapSketch", "Map sketch"),
qApp->translate("Sketcher_MapSketch",
Gui::TranslatedUserWarning(getActiveGuiDocument(),
qApp->translate("Sketcher_MapSketch", "Map sketch"),
qApp->translate("Sketcher_MapSketch",
"Can't map a sketch to support:\n"
"%1").arg(e.ErrMsg.length() ? e.ErrMsg : msg_str));
}
@@ -725,9 +726,9 @@ void CmdSketcherValidateSketch::activated(int iMsg)
Q_UNUSED(iMsg);
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(nullptr, Sketcher::SketchObject::getClassTypeId());
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdSketcherValidateSketch", "Wrong selection"),
qApp->translate("CmdSketcherValidateSketch", "Select only one sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
qApp->translate("CmdSketcherValidateSketch", "Wrong selection"),
qApp->translate("CmdSketcherValidateSketch", "Select only one sketch."));
return;
}
@@ -764,9 +765,9 @@ void CmdSketcherMirrorSketch::activated(int iMsg)
Q_UNUSED(iMsg);
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(nullptr, Sketcher::SketchObject::getClassTypeId());
if (selection.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdSketcherMirrorSketch", "Wrong selection"),
qApp->translate("CmdSketcherMirrorSketch", "Select one or more sketches."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
qApp->translate("CmdSketcherMirrorSketch", "Wrong selection"),
qApp->translate("CmdSketcherMirrorSketch", "Select one or more sketches."));
return;
}
@@ -869,9 +870,9 @@ void CmdSketcherMergeSketches::activated(int iMsg)
Q_UNUSED(iMsg);
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(nullptr, Sketcher::SketchObject::getClassTypeId());
if (selection.size() < 2) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdSketcherMergeSketches", "Wrong selection"),
qApp->translate("CmdSketcherMergeSketches", "Select at least two sketches."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
qApp->translate("CmdSketcherMergeSketches", "Wrong selection"),
qApp->translate("CmdSketcherMergeSketches", "Select at least two sketches."));
return;
}

View File

@@ -22,7 +22,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMessageBox>
#endif
#include <Gui/Action.h>
@@ -30,6 +29,7 @@
#include <Gui/CommandT.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -138,16 +138,18 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select edge(s) from the sketch."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("Select edge(s) from the sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select edge(s) from the sketch."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("Select edge(s) from the sketch."));
return;
}

View File

@@ -23,7 +23,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cfloat>
# include <QMessageBox>
# include <QPainter>
# include <Precision.hxx>
#endif
@@ -226,7 +225,9 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj,
geoId1, geoId2 ,GeoIdPoint, static_cast<int>(Sketcher::PointPos::start));
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
tryAutoRecompute(Obj);
@@ -290,7 +291,9 @@ void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(Sketcher::SketchObject* O
geoId1, geoId2 ,GeoIdPoint, static_cast<int>(Sketcher::PointPos::start));
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
tryAutoRecompute(Obj);
@@ -371,7 +374,9 @@ void SketcherGui::makeTangentToArcOfHyperbolaviaNewPoint(Sketcher::SketchObject*
geoId1, geoId2 ,GeoIdPoint, static_cast<int>(Sketcher::PointPos::start));
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
tryAutoRecompute(Obj);
@@ -447,7 +452,10 @@ void SketcherGui::makeTangentToArcOfParabolaviaNewPoint(Sketcher::SketchObject*
geoId1, geoId2 ,GeoIdPoint, static_cast<int>(Sketcher::PointPos::start));
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
tryAutoRecompute(Obj);
@@ -945,8 +953,9 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg)
new DrawSketchHandlerGenConstraint(this));
getSelection().clearSelection();
} else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select an edge from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select an edge from the sketch."));
}
return;
}
@@ -1173,8 +1182,9 @@ void CmdSketcherConstrainVertical::activated(int iMsg)
new DrawSketchHandlerGenConstraint(this));
getSelection().clearSelection();
} else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select an edge from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select an edge from the sketch."));
}
return;
}
@@ -1411,8 +1421,9 @@ void CmdSketcherConstrainLock::activated(int iMsg)
new DrawSketchHandlerGenConstraint(this));
getSelection().clearSelection();
} else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select vertices from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select vertices from the sketch."));
}
return;
}
@@ -1636,8 +1647,9 @@ void CmdSketcherConstrainBlock::activated(int iMsg)
new DrawSketchHandlerGenConstraint(this));
getSelection().clearSelection();
} else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select vertices from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select vertices from the sketch."));
}
return;
}
@@ -2002,8 +2014,9 @@ void CmdSketcherConstrainCoincident::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select two or more points from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select two or more points from the sketch."));
}
return;
}
@@ -2198,8 +2211,9 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
getSelection().clearSelection();
}
else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select vertices from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select vertices from the sketch."));
}
return;
}
@@ -2724,8 +2738,9 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -2925,8 +2940,9 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
}
else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -3183,8 +3199,9 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -3434,8 +3451,9 @@ void CmdSketcherConstrainParallel::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select two or more lines from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select two or more lines from the sketch."));
}
return;
}
@@ -3607,8 +3625,9 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
QString strError = QObject::tr("Select some geometry from the sketch.", "perpendicular constraint");
strError.append(QString::fromLatin1("\n\n"));
strError.append(strBasicHelp);
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
std::move(strError));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
std::move(strError));
}
return;
}
@@ -3904,7 +3923,9 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
tryAutoRecompute(Obj);
@@ -4087,7 +4108,9 @@ void CmdSketcherConstrainPerpendicular::applyConstraint(std::vector<SelIdPair> &
commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
}
@@ -4309,8 +4332,9 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
QString strError = QObject::tr("Select some geometry from the sketch.", "tangent constraint");
strError.append(QString::fromLatin1("\n\n"));
strError.append(strBasicHelp);
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
std::move(strError));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
std::move(strError));
}
return;
}
@@ -4997,8 +5021,9 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -5304,8 +5329,9 @@ void CmdSketcherConstrainDiameter::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -5588,8 +5614,9 @@ void CmdSketcherConstrainRadiam::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -6055,8 +6082,9 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
getSelection().clearSelection();
} else {
// TODO: Get the exact message from git history and put it here
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select the right things from the sketch."));
}
return;
}
@@ -6583,8 +6611,9 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
new DrawSketchHandlerGenConstraint(this));
getSelection().clearSelection();
} else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select two edges from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select two edges from the sketch."));
}
return;
}
@@ -6828,8 +6857,9 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
new DrawSketchHandlerGenConstraint(this));
getSelection().clearSelection();
} else {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select two points and a symmetry line, "
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select two points and a symmetry line, "
"two points and a symmetry point "
"or a line and a symmetry point from the sketch."));
}
@@ -7135,8 +7165,9 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg)
"from one sketch.", dmbg);
strError.append(strHelp);
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
std::move(strError));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
std::move(strError));
}
// get the needed lists and objects
@@ -7324,8 +7355,9 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1 || !selection[0].isObjectTypeOf(Sketcher::SketchObject::getClassTypeId())) {
Gui::TranslatedUserWarning("Sketcher", QObject::tr("Wrong selection"),
QObject::tr("Select constraints from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select constraints from the sketch."));
return;
}
@@ -7442,7 +7474,7 @@ void CmdSketcherToggleActiveConstraint::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1 || !selection[0].isObjectTypeOf(Sketcher::SketchObject::getClassTypeId())) {
Gui::TranslatedUserWarning("Sketcher",
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select constraints from the sketch."));
return;

View File

@@ -23,10 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cfloat>
# include <QApplication>
# include <QMessageBox>
# include <Inventor/SbString.h>
#endif
@@ -38,6 +35,7 @@
#include <Gui/CommandT.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -461,8 +459,10 @@ void CmdSketcherConvertToNURBS::activated(int iMsg)
if (GeoIdList.empty()) {
abortCommand();
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("None of the selected elements is an edge."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("None of the selected elements is an edge."));
}
else {
commitCommand();
@@ -531,9 +531,9 @@ void CmdSketcherIncreaseDegree::activated(int iMsg)
}
if (ignored) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("At least one of the selected "
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("At least one of the selected "
"objects was not a B-Spline and was ignored."));
}
@@ -609,9 +609,9 @@ void CmdSketcherDecreaseDegree::activated(int iMsg)
}
if (ignored) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("At least one of the selected "
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("At least one of the selected "
"objects was not a B-Spline and was ignored."));
}
@@ -661,8 +661,9 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg)
if (SubNames.size() > 1) {
// Check that only one object is selected,
// as we need only one object to get the new GeoId after multiplicity change
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("The selection comprises more than one item. Please select just one knot."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("The selection comprises more than one item. Please select just one knot."));
return;
}
@@ -698,27 +699,28 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg)
catch (const Base::CADKernelError& e) {
e.ReportException();
if (e.getTranslatable()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("CAD Kernel Error"),
QObject::tr(e.getMessage().c_str()));
Gui::TranslatedUserError(Obj,
QObject::tr("CAD Kernel Error"),
QObject::tr(e.getMessage().c_str()));
}
getSelection().clearSelection();
}
catch (const Base::Exception& e) {
e.ReportException();
if (e.getTranslatable()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Input Error"),
QObject::tr(e.getMessage().c_str()));
Gui::TranslatedUserError(Obj,
QObject::tr("Input Error"),
QObject::tr(e.getMessage().c_str()));
}
getSelection().clearSelection();
}
}
if (notaknot) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("None of the selected elements is a knot of a B-spline"));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("None of the selected elements is a knot of a B-spline"));
}
if (applied)
@@ -742,7 +744,9 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg)
Gui::cmdAppObjectArgs(selection[0].getObject(), "exposeInternalGeometry(%d)", ngeoid);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
getSelection().clearSelection();
}
}
@@ -799,8 +803,9 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
if (SubNames.size() > 1) {
// Check that only one object is selected,
// as we need only one object to get the new GeoId after multiplicity change
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("The selection comprises more than one item. Please select just one knot."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("The selection comprises more than one item. Please select just one knot."));
return;
}
@@ -833,15 +838,18 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
// particularly B-spline GeoID might have changed.
}
catch (const Base::Exception& e) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"),
QObject::tr(getStrippedPythonExceptionString(e).c_str()));
Gui::TranslatedUserError(Obj,
QObject::tr("Error"),
QObject::tr(getStrippedPythonExceptionString(e).c_str()));
getSelection().clearSelection();
}
}
if (notaknot) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("None of the selected elements is a knot of a B-spline"));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("None of the selected elements is a knot of a B-spline"));
}
if (applied)
@@ -865,7 +873,9 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
Gui::cmdAppObjectArgs(selection[0].getObject(), "exposeInternalGeometry(%d)", ngeoid);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
getSelection().clearSelection();
}
}
@@ -1048,17 +1058,17 @@ public:
catch (const Base::CADKernelError& e) {
e.ReportException();
if (e.getTranslatable()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("CAD Kernel Error"),
QObject::tr(e.getMessage().c_str()));
Gui::TranslatedUserError(Obj,
QObject::tr("CAD Kernel Error"),
QObject::tr(e.getMessage().c_str()));
}
}
catch (const Base::Exception& e) {
e.ReportException();
if (e.getTranslatable()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Input Error"),
QObject::tr(e.getMessage().c_str()));
Gui::TranslatedUserError(Obj,
QObject::tr("Input Error"),
QObject::tr(e.getMessage().c_str()));
}
}
@@ -1083,7 +1093,9 @@ public:
Gui::cmdAppObjectArgs(Obj, "exposeInternalGeometry(%d)", newGeoId);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
}
}
}
@@ -1161,11 +1173,13 @@ void CmdSketcherInsertKnot::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
// Check that only one object is selected,
// as we need only one object to get the new GeoId after multiplicity change
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection is empty"),
QObject::tr("Nothing is selected. Please select a b-spline."));
return;
// Check that only one object is selected,
// as we need only one object to get the new GeoId after multiplicity change
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Selection is empty"),
QObject::tr("Nothing is selected. Please select a b-spline."));
return;
}
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
@@ -1176,10 +1190,10 @@ void CmdSketcherInsertKnot::activated(int iMsg)
if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId())
ActivateBSplineHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineInsertKnot(Obj, GeoId));
else {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Please select a b-spline curve to insert a knot (not a knot on it). "
"If the curve is not a b-spline, please convert it into one first."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("Please select a b-spline curve to insert a knot (not a knot on it). "
"If the curve is not a b-spline, please convert it into one first."));
}
getSelection().clearSelection();
@@ -1230,8 +1244,9 @@ void CmdSketcherJoinCurves::activated(int iMsg)
switch (SubNames.size()) {
case 0: {
// Nothing is selected
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection is empty"),
QObject::tr("Nothing is selected. Please select end points of curves."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Selection is empty"),
QObject::tr("Nothing is selected. Please select end points of curves."));
return;
}
case 1: {
@@ -1256,17 +1271,19 @@ void CmdSketcherJoinCurves::activated(int iMsg)
++j;
}
else {
QMessageBox::warning(
Gui::getMainWindow(), QObject::tr("Too many curves on point"),
QObject::tr("Exactly two curves should end at the selected point to be able to join them."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Too many curves on point"),
QObject::tr("Exactly two curves should end at the selected point to be able to join them."));
return;
}
}
}
if (j < 2) {
QMessageBox::warning(
Gui::getMainWindow(), QObject::tr("Too few curves on point"),
QObject::tr("Exactly two curves should end at the selected point to be able to join them."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Too few curves on point"),
QObject::tr("Exactly two curves should end at the selected point to be able to join them."));
return;
}
@@ -1278,8 +1295,10 @@ void CmdSketcherJoinCurves::activated(int iMsg)
break;
}
default: {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Two end points, or coincident point should be selected."));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("Two end points, or coincident point should be selected."));
return;
}
}
@@ -1296,8 +1315,10 @@ void CmdSketcherJoinCurves::activated(int iMsg)
// Warning: GeoId list will have changed
}
catch (const Base::Exception& e) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"),
QObject::tr(getStrippedPythonExceptionString(e).c_str()));
Gui::TranslatedUserError(Obj,
QObject::tr("Error"),
QObject::tr(getStrippedPythonExceptionString(e).c_str()));
getSelection().clearSelection();
}

View File

@@ -39,6 +39,7 @@
#include <Gui/CommandT.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -88,9 +89,10 @@ void CmdSketcherSelectConstraints::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(doc->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
@@ -623,9 +625,9 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg)
}
if (elementSubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("No constraint selected"),
QObject::tr("At least one constraint must be selected"));
Gui::TranslatedUserWarning(Obj,
QObject::tr("No constraint selected"),
QObject::tr("At least one constraint must be selected"));
}
else {
Gui::Selection().addSelections(doc_name.c_str(), obj_name.c_str(), elementSubNames);
@@ -762,9 +764,10 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(doc->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
@@ -825,7 +828,9 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
}
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject*>(Obj));
@@ -876,18 +881,19 @@ void CmdSketcherSymmetry::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string>& SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
@@ -992,9 +998,9 @@ void CmdSketcherSymmetry::activated(int iMsg)
}
if (geoids == 0 || (geoids == 1 && LastGeoId >= 0 && !lastvertexoraxis)) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("A symmetric construction requires "
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("A symmetric construction requires "
"at least two geometric elements, "
"the last geometric element being the reference "
"for the symmetry construction."));
@@ -1002,11 +1008,12 @@ void CmdSketcherSymmetry::activated(int iMsg)
}
if (lastgeotype == invalid) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("The last element must be a point "
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("The last element must be a point "
"or a line serving as reference "
"for the symmetry construction."));
return;
}
@@ -1042,7 +1049,9 @@ void CmdSketcherSymmetry::activated(int iMsg)
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Invalid Constraint"),
e.what());
Gui::Command::abortCommand();
}
tryAutoRecomputeIfNotSolve(Obj);
@@ -1209,7 +1218,9 @@ public:
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(sketchgui->getObject(),
QT_TRANSLATE_NOOP("Notifications", "Error"),
e.what());
Gui::Command::abortCommand();
}
@@ -1258,18 +1269,20 @@ void SketcherCopy::activate(SketcherCopy::Op op)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string>& SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
@@ -1327,10 +1340,10 @@ void SketcherCopy::activate(SketcherCopy::Op op)
}
if (geoids < 1) {
QMessageBox::warning(
Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("A copy requires at least one selected non-external geometric element"));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("A copy requires at least one selected non-external geometric element"));
return;
}
@@ -1780,7 +1793,9 @@ public:
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(sketchgui,
QT_TRANSLATE_NOOP("Notifications", "Error"),
e.what());
Gui::Command::abortCommand();
}
@@ -1853,18 +1868,19 @@ void CmdSketcherRectangularArray::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string>& SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
@@ -1925,10 +1941,10 @@ void CmdSketcherRectangularArray::activated(int iMsg)
}
if (geoids < 1) {
QMessageBox::warning(
Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("A copy requires at least one selected non-external geometric element"));
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("A copy requires at least one selected non-external geometric element"));
return;
}
@@ -2018,7 +2034,9 @@ void CmdSketcherDeleteAllGeometry::activated(int iMsg)
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to delete all geometry: %s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Failed to delete all geometry"),
e.what());
Gui::Command::abortCommand();
}
@@ -2085,7 +2103,9 @@ void CmdSketcherDeleteAllConstraints::activated(int iMsg)
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to delete All Constraints: %s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Failed to delete all constraints"),
e.what());
Gui::Command::abortCommand();
}
@@ -2138,18 +2158,19 @@ void CmdSketcherRemoveAxesAlignment::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string>& SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument()->getDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select elements from a single sketch."));
return;
}
@@ -2193,10 +2214,11 @@ void CmdSketcherRemoveAxesAlignment::activated(int iMsg)
}
if (geoids < 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
QObject::tr("Removal of axes alignment requires at least one selected "
Gui::TranslatedUserWarning(Obj,
QObject::tr("Wrong selection"),
QObject::tr("Removal of axes alignment requires at least one selected "
"non-external geometric element"));
return;
}
@@ -2215,7 +2237,9 @@ void CmdSketcherRemoveAxesAlignment::activated(int iMsg)
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Gui::NotifyUserError(Obj,
QT_TRANSLATE_NOOP("Notifications", "Error"),
e.what());
Gui::Command::abortCommand();
}

View File

@@ -23,7 +23,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cfloat>
# include <QMessageBox>
#endif
#include <Base/Console.h>
@@ -34,7 +33,7 @@
#include <Gui/SelectionObject.h>
#include <Gui/CommandT.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/Action.h>
#include <Gui/BitmapFactory.h>
@@ -108,16 +107,18 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1 || !selection[0].isObjectTypeOf(Sketcher::SketchObject::getClassTypeId())) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select constraint(s) from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select constraint(s) from the sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select constraint(s) from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select constraint(s) from the sketch."));
return;
}
@@ -139,8 +140,10 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select constraint(s) from the sketch."));
Gui::TranslatedUserWarning(getActiveGuiDocument(),
QObject::tr("Wrong selection"),
QObject::tr("Select constraint(s) from the sketch."));
return;
}

View File

@@ -23,7 +23,7 @@
#ifndef SKETCHERGUI_DrawSketchHandlerFillet_H
#define SKETCHERGUI_DrawSketchHandlerFillet_H
#include <QMessageBox>
#include <Gui/Notifications.h>
#include "GeometryCreationMode.h"
@@ -158,7 +158,9 @@ public:
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to create fillet: %s\n", e.what());
Gui::NotifyUserError(sketchgui->getObject(),
QT_TRANSLATE_NOOP("Notifications", "Failed to create fillet"),
e.what());
Gui::Command::abortCommand();
}
@@ -234,17 +236,19 @@ public:
Gui::Command::commitCommand();
}
catch (const Base::CADKernelError& e) {
e.ReportException();
if(e.getTranslatable()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("CAD Kernel Error"),
QObject::tr(e.getMessage().c_str()));
Gui::TranslatedUserError(sketchgui,
QObject::tr("CAD Kernel Error"),
QObject::tr(e.getMessage().c_str()));
}
Gui::Selection().clearSelection();
Gui::Command::abortCommand();
Mode = STATUS_SEEK_First;
}
catch (const Base::ValueError& e) {
e.ReportException();
Gui::TranslatedUserError(sketchgui,
QObject::tr("Value Error"),
QObject::tr(e.getMessage().c_str()));
Gui::Selection().clearSelection();
Gui::Command::abortCommand();
Mode = STATUS_SEEK_First;

View File

@@ -27,7 +27,6 @@
/// Qt Include Files
# include <QApplication>
# include <QDialog>
# include <QMessageBox>
# include <Inventor/sensors/SoSensor.h>
#endif
@@ -36,6 +35,7 @@
#include <Gui/CommandT.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -78,8 +78,9 @@ void EditDatumDialog::exec(bool atCursor)
if (Constr->isDimensional()) {
if (sketch->hasConflicts()) {
QMessageBox::critical(Gui::getMainWindow(), QObject::tr("Distance constraint"),
QObject::tr("Not allowed to edit the datum because the sketch contains conflicting constraints"));
Gui::TranslatedUserWarning(sketch,
QObject::tr("Dimensional constraint"),
QObject::tr("Not allowed to edit the datum because the sketch contains conflicting constraints"));
return;
}
@@ -219,7 +220,10 @@ void EditDatumDialog::accepted()
tryAutoRecompute(sketch);
}
catch (const Base::Exception& e) {
QMessageBox::critical(Gui::getMainWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));
Gui::NotifyUserError(sketch,
QT_TRANSLATE_NOOP("Notifications", "Value Error"),
e.what());
Gui::Command::abortCommand();
if(sketch->noRecomputes) // if setdatum failed, it is highly likely that solver information is invalid.

View File

@@ -26,7 +26,6 @@
# include <boost/core/ignore_unused.hpp>
# include <QContextMenuEvent>
# include <QMenu>
# include <QMessageBox>
# include <QPainter>
# include <QPixmapCache>
# include <QRegularExpression>
@@ -44,6 +43,7 @@
#include <Gui/CommandT.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <Gui/ViewProvider.h>
@@ -614,8 +614,10 @@ void ConstraintView::swapNamedOfSelectedItems()
//
// If names are empty then nothing should be done
if (escapedstr1.empty() || escapedstr2.empty()) {
QMessageBox::warning(Gui::MainWindow::getInstance(), tr("Unnamed constraint"),
tr("Only the names of named constraints can be swapped."));
Gui::TranslatedUserWarning(item1->sketch,
tr("Unnamed constraint"),
tr("Only the names of named constraints can be swapped."));
return;
}
@@ -1046,8 +1048,9 @@ void TaskSketcherConstraints::changeFilteredVisibility(bool show, ActionTarget t
catch (const Base::Exception& e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1("Impossible to update visibility tracking: ") + QString::fromLatin1(e.what()), QMessageBox::Ok, QMessageBox::Ok);
Gui::TranslatedUserError(sketch,
tr("Error"),
tr("Impossible to update visibility tracking"));
return;
}
@@ -1129,8 +1132,9 @@ void TaskSketcherConstraints::onListWidgetConstraintsItemChanged(QListWidgetItem
catch (const Base::Exception& e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1(e.what()), QMessageBox::Ok, QMessageBox::Ok);
Gui::NotifyUserError(sketch,
QT_TRANSLATE_NOOP("Notifications", "Value Error"),
e.what());
}
}
@@ -1145,8 +1149,9 @@ void TaskSketcherConstraints::onListWidgetConstraintsItemChanged(QListWidgetItem
catch (const Base::Exception& e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1(e.what()), QMessageBox::Ok, QMessageBox::Ok);
Gui::NotifyUserError(sketch,
QT_TRANSLATE_NOOP("Notifications", "Value Error"),
e.what());
}
inEditMode = false;
@@ -1422,8 +1427,9 @@ void TaskSketcherConstraints::change3DViewVisibilityToTrackFilter()
catch (const Base::Exception & e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1("Impossible to update visibility tracking: ") + QString::fromLatin1(e.what()), QMessageBox::Ok, QMessageBox::Ok);
Gui::TranslatedUserError(sketch,
tr("Error"),
tr("Impossible to update visibility tracking: "));
return false;
}

View File

@@ -37,6 +37,7 @@
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Notifications.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Gui/Inventor/MarkerBitmaps.h>
@@ -159,14 +160,18 @@ void SketcherValidation::onFindButtonClicked()
hidePoints();
if (vertexConstraints.empty()) {
QMessageBox::information(this, tr("No missing coincidences"),
tr("No missing coincidences found"));
Gui::TranslatedNotification(*sketch,
tr("No missing coincidences"),
tr("No missing coincidences found"));
ui->fixButton->setEnabled(false);
}
else {
showPoints(points);
QMessageBox::warning(this, tr("Missing coincidences"),
tr("%1 missing coincidences found").arg(vertexConstraints.size()));
Gui::TranslatedUserWarning(*sketch,
tr("Missing coincidences"),
tr("%1 missing coincidences found").arg(vertexConstraints.size()));
ui->fixButton->setEnabled(true);
}
}
@@ -211,13 +216,17 @@ void SketcherValidation::onFindConstraintClicked()
return;
if (sketch->evaluateConstraints()) {
QMessageBox::information(this, tr("No invalid constraints"),
tr("No invalid constraints found"));
Gui::TranslatedNotification(*sketch,
tr("No invalid constraints"),
tr("No invalid constraints found"));
ui->fixConstraint->setEnabled(false);
}
else {
QMessageBox::warning(this, tr("Invalid constraints"),
tr("Invalid constraints found"));
Gui::TranslatedUserError(*sketch,
tr("Invalid constraints"),
tr("Invalid constraints found"));
ui->fixConstraint->setEnabled(true);
}
}
@@ -254,26 +263,31 @@ void SketcherValidation::onFindReversedClicked()
int nc = sketch->port_reversedExternalArcs(/*justAnalyze=*/true);
showPoints(points);
if(nc>0){
QMessageBox::warning(this, tr("Reversed external geometry"),
tr("%1 reversed external-geometry arcs were found. Their endpoints are"
Gui::TranslatedUserWarning(*sketch,
tr("Reversed external geometry"),
tr("%1 reversed external-geometry arcs were found. Their endpoints are"
" encircled in 3d view.\n\n"
"%2 constraints are linking to the endpoints. The constraints have"
" been listed in Report view (menu View -> Panels -> Report view).\n\n"
"Click \"Swap endpoints in constraints\" button to reassign endpoints."
" Do this only once to sketches created in FreeCAD older than v0.15"
).arg(points.size()/2).arg(nc)
);
);
ui->swapReversed->setEnabled(true);
} else {
QMessageBox::warning(this, tr("Reversed external geometry"),
tr("%1 reversed external-geometry arcs were found. Their endpoints are "
Gui::TranslatedUserWarning(*sketch,
tr("Reversed external geometry"),
tr("%1 reversed external-geometry arcs were found. Their endpoints are "
"encircled in 3d view.\n\n"
"However, no constraints linking to the endpoints were found.").arg(points.size()/2));
ui->swapReversed->setEnabled(false);
}
} else {
QMessageBox::information(this, tr("Reversed external geometry"),
tr("No reversed external-geometry arcs were found."));
Gui::TranslatedNotification(*sketch,
tr("Reversed external geometry"),
tr("No reversed external-geometry arcs were found."));
}
}
@@ -286,8 +300,10 @@ void SketcherValidation::onSwapReversedClicked()
doc->openTransaction("Sketch porting");
int n = sketch->port_reversedExternalArcs(/*justAnalyze=*/false);
QMessageBox::warning(this, tr("Reversed external geometry"),
tr("%1 changes were made to constraints linking to endpoints of reversed arcs.").arg(n));
Gui::TranslatedNotification(*sketch,
tr("Reversed external geometry"),
tr("%1 changes were made to constraints linking to endpoints of reversed arcs.").arg(n));
hidePoints();
ui->swapReversed->setEnabled(false);
@@ -303,8 +319,9 @@ void SketcherValidation::onOrientLockEnableClicked()
doc->openTransaction("Constraint orientation lock");
int n = sketch->changeConstraintsLocking(/*bLock=*/true);
QMessageBox::warning(this, tr("Constraint orientation locking"),
tr("Orientation locking was enabled and recomputed for %1 constraints. The"
Gui::TranslatedNotification(*sketch,
tr("Constraint orientation locking"),
tr("Orientation locking was enabled and recomputed for %1 constraints. The"
" constraints have been listed in Report view (menu View -> Panels ->"
" Report view).").arg(n));
@@ -320,8 +337,9 @@ void SketcherValidation::onOrientLockDisableClicked()
doc->openTransaction("Constraint orientation unlock");
int n = sketch->changeConstraintsLocking(/*bLock=*/false);
QMessageBox::warning(this, tr("Constraint orientation locking"),
tr("Orientation locking was disabled for %1 constraints. The"
Gui::TranslatedNotification(*sketch,
tr("Constraint orientation locking"),
tr("Orientation locking was disabled for %1 constraints. The"
" constraints have been listed in Report view (menu View -> Panels ->"
" Report view). Note that for all future constraints, the locking still"
" defaults to ON.").arg(n));
@@ -349,8 +367,10 @@ void SketcherValidation::onDelConstrExtrClicked()
doc->commitTransaction();
QMessageBox::warning(this, tr("Delete constraints to external geom."),
tr("All constraints that deal with external geometry were deleted."));
Gui::TranslatedNotification(*sketch,
tr("Delete constraints to external geom."),
tr("All constraints that deal with external geometry were deleted."));
}
void SketcherValidation::showPoints(const std::vector<Base::Vector3d>& pts)
@@ -414,13 +434,17 @@ void SketcherValidation::onFindDegeneratedClicked()
int count = sketchAnalyser.detectDegeneratedGeometries(prec);
if (count == 0) {
QMessageBox::information(this, tr("No degenerated geometry"),
tr("No degenerated geometry found"));
Gui::TranslatedNotification(*sketch,
tr("No degenerated geometry"),
tr("No degenerated geometry found"));
ui->fixDegenerated->setEnabled(false);
}
else {
QMessageBox::warning(this, tr("Degenerated geometry"),
tr("%1 degenerated geometry found").arg(count));
Gui::TranslatedUserWarning(*sketch,
tr("Degenerated geometry"),
tr("%1 degenerated geometry found").arg(count));
ui->fixDegenerated->setEnabled(true);
}
}