fix inconsistencies between default action of context menu and double-click
This commit is contained in:
@@ -25,13 +25,16 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QApplication>
|
||||
# include <QMenu>
|
||||
# include <QPixmap>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include <App/Part.h>
|
||||
#include <App/Document.h>
|
||||
|
||||
#include "ActiveObjectList.h"
|
||||
#include "ActionFunction.h"
|
||||
#include "BitmapFactory.h"
|
||||
#include "Command.h"
|
||||
|
||||
@@ -68,6 +71,15 @@ void ViewProviderPart::onChanged(const App::Property* prop) {
|
||||
ViewProviderDragger::onChanged(prop);
|
||||
}
|
||||
|
||||
void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Toggle active part"));
|
||||
func->trigger(act, boost::bind(&ViewProviderPart::doubleClicked, this));
|
||||
|
||||
ViewProviderDragger::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderPart::doubleClicked(void)
|
||||
{
|
||||
//make the part the active one
|
||||
|
||||
@@ -44,6 +44,8 @@ public:
|
||||
virtual ~ViewProviderPart();
|
||||
|
||||
virtual bool doubleClicked(void);
|
||||
virtual void setupContextMenu(QMenu* menu, QObject* receiver, const char* member);
|
||||
|
||||
protected:
|
||||
/// get called by the container whenever a property has been changed
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <QPlainTextEdit>
|
||||
# include <QMenu>
|
||||
# include <QPlainTextEdit>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include <Base/Type.h>
|
||||
@@ -32,6 +34,7 @@
|
||||
#include <Gui/TextDocumentEditorView.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/ActionFunction.h>
|
||||
|
||||
#include "ViewProviderTextDocument.h"
|
||||
|
||||
@@ -45,6 +48,15 @@ ViewProviderTextDocument::ViewProviderTextDocument()
|
||||
sPixmap = "TextDocument";
|
||||
}
|
||||
|
||||
void ViewProviderTextDocument::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Edit text"));
|
||||
func->trigger(act, boost::bind(&ViewProviderTextDocument::doubleClicked, this));
|
||||
|
||||
ViewProviderDocumentObject::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderTextDocument::doubleClicked()
|
||||
{
|
||||
if (!activateView()) {
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
~ViewProviderTextDocument() {}
|
||||
|
||||
bool doubleClicked();
|
||||
void setupContextMenu(QMenu* menu, QObject* receiver, const char* member);
|
||||
bool isShow() const { return true; }
|
||||
private:
|
||||
bool activateView() const;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/SoDB.h>
|
||||
# include <Inventor/SoInput.h>
|
||||
# include <Inventor/SbVec3f.h>
|
||||
@@ -42,18 +42,20 @@
|
||||
# include <Inventor/nodes/SoMarkerSet.h>
|
||||
# include <Inventor/nodes/SoShapeHints.h>
|
||||
# include <QFile>
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderTrajectory.h"
|
||||
|
||||
#include <Mod/Robot/App/TrajectoryObject.h>
|
||||
#include <Mod/Robot/App/Trajectory.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Document.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/Console.h>
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Inventor/MarkerBitmaps.h>
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Inventor/MarkerBitmaps.h>
|
||||
#include <sstream>
|
||||
using namespace Gui;
|
||||
using namespace RobotGui;
|
||||
@@ -62,9 +64,9 @@ using namespace Robot;
|
||||
PROPERTY_SOURCE(RobotGui::ViewProviderTrajectory, Gui::ViewProviderGeometryObject)
|
||||
|
||||
ViewProviderTrajectory::ViewProviderTrajectory()
|
||||
{
|
||||
|
||||
pcTrajectoryRoot = new Gui::SoFCSelection();
|
||||
{
|
||||
|
||||
pcTrajectoryRoot = new Gui::SoFCSelection();
|
||||
pcTrajectoryRoot->highlightMode = Gui::SoFCSelection::OFF;
|
||||
pcTrajectoryRoot->selectionMode = Gui::SoFCSelection::SEL_OFF;
|
||||
//pcRobotRoot->style = Gui::SoFCSelection::BOX;
|
||||
@@ -84,7 +86,7 @@ ViewProviderTrajectory::ViewProviderTrajectory()
|
||||
}
|
||||
|
||||
ViewProviderTrajectory::~ViewProviderTrajectory()
|
||||
{
|
||||
{
|
||||
pcTrajectoryRoot->unref();
|
||||
pcCoords->unref();
|
||||
pcDrawStyle->unref();
|
||||
@@ -108,32 +110,32 @@ void ViewProviderTrajectory::attach(App::DocumentObject *pcObj)
|
||||
SoBaseColor * markcol = new SoBaseColor;
|
||||
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
|
||||
SoMarkerSet* marker = new SoMarkerSet;
|
||||
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("CROSS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 5));
|
||||
marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("CROSS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 5));
|
||||
linesep->addChild(markcol);
|
||||
linesep->addChild(marker);
|
||||
|
||||
pcTrajectoryRoot->addChild(linesep);
|
||||
|
||||
addDisplayMaskMode(pcTrajectoryRoot, "Waypoints");
|
||||
|
||||
addDisplayMaskMode(pcTrajectoryRoot, "Waypoints");
|
||||
pcTrajectoryRoot->objectName = pcObj->getNameInDocument();
|
||||
pcTrajectoryRoot->documentName = pcObj->getDocument()->getName();
|
||||
pcTrajectoryRoot->subElementName = "Main";
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderTrajectory::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Waypoints",ModeName)==0 )
|
||||
setDisplayMaskMode("Waypoints");
|
||||
ViewProviderGeometryObject::setDisplayMode( ModeName );
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderTrajectory::getDisplayModes(void) const
|
||||
{
|
||||
std::vector<std::string> StrList;
|
||||
StrList.push_back("Waypoints");
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderTrajectory::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Waypoints",ModeName)==0 )
|
||||
setDisplayMaskMode("Waypoints");
|
||||
ViewProviderGeometryObject::setDisplayMode( ModeName );
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderTrajectory::getDisplayModes(void) const
|
||||
{
|
||||
std::vector<std::string> StrList;
|
||||
StrList.push_back("Waypoints");
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderTrajectory::updateData(const App::Property* prop)
|
||||
{
|
||||
@@ -150,9 +152,16 @@ void ViewProviderTrajectory::updateData(const App::Property* prop)
|
||||
|
||||
}
|
||||
pcLines->numVertices.set1Value(0, trak.getSize());
|
||||
}else if (prop == &pcTracObj->Base) {
|
||||
}
|
||||
else if (prop == &pcTracObj->Base) {
|
||||
Base::Placement loc = *(&pcTracObj->Base.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderTrajectory::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act = menu->addAction(QObject::tr("Modify"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,10 +51,11 @@ public:
|
||||
void attach(App::DocumentObject *pcObject);
|
||||
void setDisplayMode(const char* ModeName);
|
||||
std::vector<std::string> getDisplayModes() const;
|
||||
void updateData(const App::Property*);
|
||||
|
||||
protected:
|
||||
|
||||
void updateData(const App::Property*);
|
||||
void setupContextMenu(QMenu* menu, QObject* receiver, const char* member);
|
||||
|
||||
protected:
|
||||
|
||||
Gui::SoFCSelection * pcTrajectoryRoot;
|
||||
SoCoordinate3 * pcCoords;
|
||||
SoDrawStyle * pcDrawStyle;
|
||||
|
||||
Reference in New Issue
Block a user