Measure: Remove from menu + transfer ownership back
As discussed in 23399, discoverability is really poor as users doesn't know what Quick Measure is, neither is it easy to find out as there's no visual feedback when toggling this feature. The intension was to keep the command and only remove it from the menu, but that wasn't possible due to ownership of quick measure object was inside the command. In addition the parameter had to be renamed as well as mashing the qm button made them end up in an unknown state. As the measurement can be disabled now by simply hiding the info text from context menu, we don't need to keep the old toggling functionality.
This commit is contained in:
@@ -725,7 +725,6 @@ MenuItem* StdWorkbench::setupMenuBar() const
|
||||
#endif
|
||||
*tool << "Std_Measure"
|
||||
<< "Std_ClarifySelection"
|
||||
<< "Std_QuickMeasure"
|
||||
<< "Std_UnitsCalculator"
|
||||
<< "Separator"
|
||||
<< "Std_ViewLoadImage"
|
||||
|
||||
@@ -110,5 +110,8 @@ PyMOD_INIT_FUNC(MeasureGui)
|
||||
|
||||
Base::Interpreter().addType(&MeasureGui::QuickMeasurePy::Type, mod, "QuickMeasure");
|
||||
|
||||
// Create a QuickMeasure instance
|
||||
new MeasureGui::QuickMeasure(QApplication::instance());
|
||||
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Action.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
@@ -32,7 +31,6 @@
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include "QuickMeasure.h"
|
||||
#include "TaskMeasure.h"
|
||||
|
||||
|
||||
@@ -79,68 +77,6 @@ bool StdCmdMeasure::isActive()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
class StdCmdQuickMeasure: public Gui::Command
|
||||
{
|
||||
public:
|
||||
StdCmdQuickMeasure()
|
||||
: Command("Std_QuickMeasure")
|
||||
{
|
||||
sGroup = "Measure";
|
||||
sMenuText = QT_TR_NOOP("&Quick measure");
|
||||
sToolTipText = QT_TR_NOOP("Toggle quick measure");
|
||||
sWhatsThis = "Std_QuickMeasure";
|
||||
sStatusTip = QT_TR_NOOP("Toggle quick measure");
|
||||
accessParameter();
|
||||
}
|
||||
~StdCmdQuickMeasure() override = default;
|
||||
StdCmdQuickMeasure(const StdCmdQuickMeasure&) = delete;
|
||||
StdCmdQuickMeasure(StdCmdQuickMeasure&&) = delete;
|
||||
StdCmdQuickMeasure& operator=(const StdCmdQuickMeasure&) = delete;
|
||||
StdCmdQuickMeasure& operator=(StdCmdQuickMeasure&&) = delete;
|
||||
|
||||
const char* className() const override
|
||||
{
|
||||
return "StdCmdQuickMeasure";
|
||||
}
|
||||
|
||||
protected:
|
||||
void activated(int iMsg) override
|
||||
{
|
||||
if (parameter.isValid()) {
|
||||
parameter->SetBool("EnableQuickMeasure", iMsg > 0);
|
||||
}
|
||||
|
||||
if (iMsg == 0) {
|
||||
if (quickMeasure) {
|
||||
quickMeasure->print(QString());
|
||||
}
|
||||
quickMeasure.reset();
|
||||
}
|
||||
else {
|
||||
quickMeasure = std::make_unique<MeasureGui::QuickMeasure>(QApplication::instance());
|
||||
}
|
||||
}
|
||||
Gui::Action* createAction() override
|
||||
{
|
||||
Gui::Action* action = Gui::Command::createAction();
|
||||
action->setCheckable(true);
|
||||
action->setChecked(parameter->GetBool("EnableQuickMeasure", true));
|
||||
return action;
|
||||
}
|
||||
void accessParameter()
|
||||
{
|
||||
// clang-format off
|
||||
parameter = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp/Preferences/Mod/Measure");
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<MeasureGui::QuickMeasure> quickMeasure;
|
||||
ParameterGrp::handle parameter;
|
||||
};
|
||||
|
||||
void CreateMeasureCommands()
|
||||
{
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
@@ -148,5 +84,4 @@ void CreateMeasureCommands()
|
||||
auto cmd = new StdCmdMeasure();
|
||||
cmd->initAction();
|
||||
rcCmdMgr.addCommand(cmd);
|
||||
rcCmdMgr.addCommand(new StdCmdQuickMeasure);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user