Update context menu
- Page context menu was left over from Drawing module. Now updated with appropriate actions.
This commit is contained in:
committed by
Yorik van Havre
parent
6e05b0f4ca
commit
22ff1e2cea
@@ -52,6 +52,7 @@
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
@@ -108,39 +109,17 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||
m_scene = new QGraphicsScene(this);
|
||||
m_view = new QGVPage(pageVp,m_scene,this);
|
||||
|
||||
m_toggleKeepUpdatedAction = new QAction(tr("Toggle &Keep Updated"), this);
|
||||
connect(m_toggleKeepUpdatedAction, SIGNAL(triggered()), this, SLOT(toggleKeepUpdated()));
|
||||
|
||||
m_toggleFrameAction = new QAction(tr("Toggle &Frames"), this);
|
||||
connect(m_toggleFrameAction, SIGNAL(triggered()), this, SLOT(toggleFrame()));
|
||||
|
||||
m_exportSVGAction = new QAction(tr("&Export SVG"), this);
|
||||
connect(m_exportSVGAction, SIGNAL(triggered()), this, SLOT(saveSVG()));
|
||||
|
||||
m_nativeAction = new QAction(tr("&Native"), this);
|
||||
m_nativeAction->setCheckable(true);
|
||||
m_nativeAction->setChecked(false);
|
||||
#ifndef QT_NO_OPENGL
|
||||
m_glAction = new QAction(tr("&OpenGL"), this);
|
||||
m_glAction->setCheckable(true);
|
||||
#endif
|
||||
m_imageAction = new QAction(tr("&Image"), this);
|
||||
m_imageAction->setCheckable(true);
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
m_highQualityAntialiasingAction = new QAction(tr("&High Quality Antialiasing"), this);
|
||||
m_highQualityAntialiasingAction->setEnabled(false);
|
||||
m_highQualityAntialiasingAction->setCheckable(true);
|
||||
m_highQualityAntialiasingAction->setChecked(false);
|
||||
connect(m_highQualityAntialiasingAction, SIGNAL(toggled(bool)),
|
||||
m_view, SLOT(setHighQualityAntialiasing(bool)));
|
||||
#endif
|
||||
|
||||
isSelectionBlocked = false;
|
||||
|
||||
QActionGroup *rendererGroup = new QActionGroup(this);
|
||||
rendererGroup->addAction(m_nativeAction);
|
||||
#ifndef QT_NO_OPENGL
|
||||
rendererGroup->addAction(m_glAction);
|
||||
#endif
|
||||
rendererGroup->addAction(m_imageAction);
|
||||
connect(rendererGroup, SIGNAL(triggered(QAction *)),
|
||||
this, SLOT(setRenderer(QAction *)));
|
||||
|
||||
setWindowTitle(tr("dummy[*]")); //Yuck. prevents "QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"
|
||||
setCentralWidget(m_view); //this makes m_view a Qt child of MDIViewPage
|
||||
|
||||
@@ -250,21 +229,6 @@ void MDIViewPage::closeEvent(QCloseEvent* ev)
|
||||
blockSelection(false);
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(m_exportSVGAction);
|
||||
QMenu* submenu = menu.addMenu(tr("&Renderer"));
|
||||
submenu->addAction(m_nativeAction);
|
||||
submenu->addAction(m_glAction);
|
||||
submenu->addAction(m_imageAction);
|
||||
submenu->addSeparator();
|
||||
submenu->addAction(m_highQualityAntialiasingAction);
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
|
||||
{
|
||||
m_view->setPageTemplate(obj);
|
||||
@@ -788,25 +752,26 @@ PyObject* MDIViewPage::getPyObject()
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
void MDIViewPage::setRenderer(QAction *action)
|
||||
void MDIViewPage::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
#ifndef QT_NO_OPENGL
|
||||
m_highQualityAntialiasingAction->setEnabled(false);
|
||||
#endif
|
||||
|
||||
if (action == m_nativeAction)
|
||||
m_view->setRenderer(QGVPage::Native);
|
||||
#ifndef QT_NO_OPENGL
|
||||
else if (action == m_glAction) {
|
||||
m_highQualityAntialiasingAction->setEnabled(true);
|
||||
m_view->setRenderer(QGVPage::OpenGL);
|
||||
}
|
||||
#endif
|
||||
else if (action == m_imageAction) {
|
||||
m_view->setRenderer(QGVPage::Image);
|
||||
}
|
||||
QMenu menu;
|
||||
menu.addAction(m_toggleFrameAction);
|
||||
menu.addAction(m_toggleKeepUpdatedAction);
|
||||
menu.addAction(m_exportSVGAction);
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
void MDIViewPage::toggleFrame(void)
|
||||
{
|
||||
setFrameState(!getFrameState());
|
||||
}
|
||||
|
||||
void MDIViewPage::toggleKeepUpdated(void)
|
||||
{
|
||||
bool state = m_vpPage->getDrawPage()->KeepUpdated.getValue();
|
||||
m_vpPage->getDrawPage()->KeepUpdated.setValue(!state);
|
||||
App::GetApplication().signalChangePropertyEditor(m_vpPage->getDrawPage()->KeepUpdated);
|
||||
}
|
||||
|
||||
void MDIViewPage::viewAll()
|
||||
{
|
||||
@@ -814,7 +779,6 @@ void MDIViewPage::viewAll()
|
||||
m_view->fitInView(m_view->scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::saveSVG()
|
||||
{
|
||||
QStringList filter;
|
||||
|
||||
@@ -102,9 +102,11 @@ public:
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void setRenderer(QAction *action);
|
||||
void viewAll();
|
||||
void saveSVG(void);
|
||||
void toggleFrame(void);
|
||||
void toggleKeepUpdated(void);
|
||||
// void testAction(void);
|
||||
void sceneSelectionChanged();
|
||||
|
||||
protected:
|
||||
@@ -132,11 +134,10 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
QAction *m_nativeAction;
|
||||
QAction *m_glAction;
|
||||
QAction *m_toggleFrameAction;
|
||||
QAction *m_toggleKeepUpdatedAction;
|
||||
QAction *m_exportSVGAction;
|
||||
QAction *m_imageAction;
|
||||
QAction *m_highQualityAntialiasingAction;
|
||||
// QAction* m_testAction;
|
||||
|
||||
std::string m_objectName;
|
||||
std::string m_documentName;
|
||||
|
||||
@@ -304,11 +304,11 @@ MDIViewPage* ViewProviderPage::getMDIViewPage()
|
||||
|
||||
void ViewProviderPage::onChanged(const App::Property *prop)
|
||||
{
|
||||
if (prop == &(getDrawPage()->Template)) {
|
||||
if(m_mdiView) {
|
||||
m_mdiView->updateTemplate();
|
||||
}
|
||||
}
|
||||
// if (prop == &(getDrawPage()->Template)) {
|
||||
// if(m_mdiView) {
|
||||
// m_mdiView->updateTemplate();
|
||||
// }
|
||||
// }
|
||||
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user