Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sketcher: Tooltips for solver message hyperlinks #9343

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp
Expand Up @@ -30,7 +30,7 @@
#include <Gui/Command.h>
#include <Mod/Sketcher/App/SketchObject.h>

#include "ui_TaskSketcherMessages.h"

Check failure on line 33 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

'ui_TaskSketcherMessages.h' file not found [clang-diagnostic-error]
#include "TaskSketcherMessages.h"
#include "ViewProviderSketch.h"

Expand All @@ -39,7 +39,7 @@
using namespace Gui::TaskView;
namespace bp = boost::placeholders;

TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView) :

Check warning on line 42 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

constructor does not initialize these fields: proxy, ui [cppcoreguidelines-pro-type-member-init]
TaskBox(Gui::BitmapFactory().pixmap("document-new"), tr("Solver messages"), true, nullptr),
sketchView(sketchView),
ui(new Ui_TaskSketcherMessages)
Expand All @@ -51,7 +51,7 @@

this->groupLayout()->addWidget(proxy);

connectionSetUp = sketchView->signalSetUp.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSetUp, this, bp::_1, bp::_2, bp::_3, bp::_4));

Check warning on line 54 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

'connectionSetUp' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

ui->labelConstrainStatus->setOpenExternalLinks(false);

Expand All @@ -70,11 +70,11 @@

//Set Auto Update in the 'Manual Update' button menu.
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool state = hGrp->GetBool("AutoRecompute", false);

Check warning on line 73 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'state' is not initialized [cppcoreguidelines-init-variables]

sketchView->getSketchObject()->noRecomputes = !state;

QAction* action = new QAction(tr("Auto update"), this);

Check warning on line 77 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'action' is not initialized [cppcoreguidelines-init-variables]
action->setToolTip(tr("Executes a recomputation of active document after every sketch action"));
action->setCheckable(true);
action->setChecked(state);
Expand All @@ -99,20 +99,39 @@
this, &TaskSketcherMessages::onManualUpdateClicked);
}

void TaskSketcherMessages::slotSetUp(const QString& state, const QString& msg, const QString& link, const QString& linkText)

Check warning on line 102 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

4 adjacent parameters of 'slotSetUp' of similar type ('const QString &') are easily swapped by mistake [bugprone-easily-swappable-parameters]
{
ui->labelConstrainStatus->setState(state);
ui->labelConstrainStatus->setText(msg);
ui->labelConstrainStatusLink->setUrl(link);
ui->labelConstrainStatusLink->setText(linkText);
updateToolTip(link);
}

void TaskSketcherMessages::updateToolTip(const QString& link)
{
if( link == QString::fromLatin1("#conflicting"))
ui->labelConstrainStatusLink->setToolTip(tr("Click to select the conflicting constraints."));
else
if( link == QString::fromLatin1("#redundant"))
ui->labelConstrainStatusLink->setToolTip(tr("Click to select the redundant constraints."));
else
if( link == QString::fromLatin1("#dofs"))
ui->labelConstrainStatusLink->setToolTip(tr("The sketch has unconstrained elements giving raise to those Degrees Of Freedom. Click to select the unconstrained elements."));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdullahtahiriyo perhaps you meant 'giving rise' instead of 'giving raise' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. My bad English. I will fix it right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else
if( link == QString::fromLatin1("#malformed"))
ui->labelConstrainStatusLink->setToolTip(tr("Click to select the malformed constraints."));
else
if( link == QString::fromLatin1("#partiallyredundant"))
ui->labelConstrainStatusLink->setToolTip(tr("Some constraints in combination are partially redundant. Click to select the partially redundant constraints."));
}

void TaskSketcherMessages::onLabelConstrainStatusLinkClicked(const QString &str)

Check warning on line 129 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

method 'onLabelConstrainStatusLinkClicked' can be made static [readability-convert-member-functions-to-static]
{
if( str == QString::fromLatin1("#conflicting"))

Check warning on line 131 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

statement should be inside braces [readability-braces-around-statements]
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectConflictingConstraints");
else
if( str == QString::fromLatin1("#redundant"))

Check warning on line 134 in src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

statement should be inside braces [readability-braces-around-statements]
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectRedundantConstraints");
else
if( str == QString::fromLatin1("#dofs"))
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Sketcher/Gui/TaskSketcherMessages.h
Expand Up @@ -54,6 +54,8 @@ class TaskSketcherMessages : public Gui::TaskView::TaskBox
void onLabelConstrainStatusLinkClicked(const QString &);
void onAutoUpdateStateChanged();
void onManualUpdateClicked(bool checked);

void updateToolTip(const QString& link);

protected:
ViewProviderSketch *sketchView;
Expand Down