Sketcher: restore toolbars when changing between workbenches in edit mode
This partially fixes issue #9135
This commit is contained in:
@@ -51,7 +51,6 @@
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionObject.h>
|
||||
#include <Gui/SoFCUnifiedSelection.h>
|
||||
#include "Gui/ToolBarManager.h"
|
||||
#include <Gui/Utilities.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
@@ -70,6 +69,7 @@
|
||||
#include "TaskSketcherValidation.h"
|
||||
#include "Utils.h"
|
||||
#include "ViewProviderSketchGeometryExtension.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
|
||||
FC_LOG_LEVEL_INIT("Sketch",true,true)
|
||||
@@ -2770,25 +2770,6 @@ void ViewProviderSketch::setupContextMenu(QMenu *menu, QObject *receiver, const
|
||||
Gui::ViewProvider::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
inline const QStringList editModeToolbarNames()
|
||||
{
|
||||
return QStringList{ QString::fromLatin1("Sketcher Edit Mode"),
|
||||
QString::fromLatin1("Sketcher geometries"),
|
||||
QString::fromLatin1("Sketcher constraints"),
|
||||
QString::fromLatin1("Sketcher tools"),
|
||||
QString::fromLatin1("Sketcher B-spline tools"),
|
||||
QString::fromLatin1("Sketcher virtual space") };
|
||||
}
|
||||
|
||||
inline const QStringList nonEditModeToolbarNames()
|
||||
{
|
||||
return QStringList{ QString::fromLatin1("Structure"),
|
||||
QString::fromLatin1("Sketcher") };
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderSketch::setEdit(int ModNum)
|
||||
{
|
||||
Q_UNUSED(ModNum)
|
||||
@@ -2935,13 +2916,7 @@ bool ViewProviderSketch::setEdit(int ModNum)
|
||||
|
||||
Gui::getMainWindow()->installEventFilter(listener);
|
||||
|
||||
/*Modify toolbars dynamically.
|
||||
First save state of toolbars in case user changed visibility of a toolbar but he's not changing the wb.
|
||||
This happens in someone works directly from sketcher, changing from edit mode to not-edit-mode*/
|
||||
Gui::ToolBarManager::getInstance()->saveState();
|
||||
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(true, editModeToolbarNames());
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(false, nonEditModeToolbarNames());
|
||||
Workbench::enterEditMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -3078,13 +3053,7 @@ void ViewProviderSketch::unsetEdit(int ModNum)
|
||||
auto gridnode = getGridNode();
|
||||
pcRoot->removeChild(gridnode);
|
||||
|
||||
/*Modify toolbars dynamically.
|
||||
First save state of toolbars in case user changed visibility of a toolbar but he's not changing the wb.
|
||||
This happens in someone works directly from sketcher, changing from edit mode to not-edit-mode*/
|
||||
Gui::ToolBarManager::getInstance()->saveState();
|
||||
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(false, editModeToolbarNames());
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(true, nonEditModeToolbarNames());
|
||||
Workbench::leaveEditMode();
|
||||
|
||||
if(listener) {
|
||||
Gui::getMainWindow()->removeEventFilter(listener);
|
||||
|
||||
@@ -22,8 +22,11 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <Mod/Sketcher/App/Constraint.h>
|
||||
#include "Utils.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
|
||||
using namespace SketcherGui;
|
||||
|
||||
@@ -142,6 +145,54 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
return root;
|
||||
}
|
||||
|
||||
void Workbench::activated()
|
||||
{
|
||||
Gui::Document *doc = Gui::Application::Instance->activeDocument();
|
||||
if (isSketchInEdit(doc)) {
|
||||
enterEditMode();
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
inline const QStringList editModeToolbarNames()
|
||||
{
|
||||
return QStringList{ QString::fromLatin1("Sketcher Edit Mode"),
|
||||
QString::fromLatin1("Sketcher geometries"),
|
||||
QString::fromLatin1("Sketcher constraints"),
|
||||
QString::fromLatin1("Sketcher tools"),
|
||||
QString::fromLatin1("Sketcher B-spline tools"),
|
||||
QString::fromLatin1("Sketcher virtual space") };
|
||||
}
|
||||
|
||||
inline const QStringList nonEditModeToolbarNames()
|
||||
{
|
||||
return QStringList{ QString::fromLatin1("Structure"),
|
||||
QString::fromLatin1("Sketcher") };
|
||||
}
|
||||
}
|
||||
|
||||
void Workbench::enterEditMode()
|
||||
{
|
||||
/*Modify toolbars dynamically.
|
||||
First save state of toolbars in case user changed visibility of a toolbar but he's not changing the wb.
|
||||
This happens in someone works directly from sketcher, changing from edit mode to not-edit-mode*/
|
||||
Gui::ToolBarManager::getInstance()->saveState();
|
||||
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(true, editModeToolbarNames());
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(false, nonEditModeToolbarNames());
|
||||
}
|
||||
|
||||
void Workbench::leaveEditMode()
|
||||
{
|
||||
/*Modify toolbars dynamically.
|
||||
First save state of toolbars in case user changed visibility of a toolbar but he's not changing the wb.
|
||||
This happens in someone works directly from sketcher, changing from edit mode to not-edit-mode*/
|
||||
Gui::ToolBarManager::getInstance()->saveState();
|
||||
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(false, editModeToolbarNames());
|
||||
Gui::ToolBarManager::getInstance()->setToolbarVisibility(true, nonEditModeToolbarNames());
|
||||
}
|
||||
|
||||
namespace SketcherGui {
|
||||
|
||||
|
||||
@@ -43,10 +43,14 @@ public:
|
||||
Workbench();
|
||||
~Workbench() override;
|
||||
|
||||
static void enterEditMode();
|
||||
static void leaveEditMode();
|
||||
|
||||
protected:
|
||||
Gui::MenuItem* setupMenuBar() const override;
|
||||
Gui::ToolBarItem* setupToolBars() const override;
|
||||
Gui::ToolBarItem* setupCommandBars() const override;
|
||||
void activated() override;
|
||||
};
|
||||
|
||||
SketcherGuiExport void addSketcherWorkbenchSketchActions(Gui::MenuItem& sketch);
|
||||
|
||||
Reference in New Issue
Block a user