From 3f06cf75ea1296ebc46a36ae3e98d4c63260edbf Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 31 Mar 2012 14:09:47 +0200 Subject: [PATCH] add drawing view to the list of document views --- src/Gui/Document.cpp | 4 ++-- src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp | 4 ++-- src/Mod/Drawing/Gui/DrawingView.cpp | 4 ++-- src/Mod/Drawing/Gui/DrawingView.h | 2 +- src/Mod/Drawing/Gui/ViewProviderPage.cpp | 7 +++++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index aaeab815e..87868271f 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1006,9 +1006,9 @@ MDIView* Document::getActiveView(void) const } } - // the active view is not part of this document, just use the first view + // the active view is not part of this document, just use the last view if (!ok && !mdis.empty()) - active = mdis.front(); + active = mdis.back(); return active; } diff --git a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp index 363e45e61..07aa2c471 100644 --- a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp +++ b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp @@ -55,7 +55,7 @@ open(PyObject *self, PyObject *args) if (file.hasExtension("svg") || file.hasExtension("svgz")) { QString fileName = QString::fromUtf8(Name); // Displaying the image in a view - DrawingView* view = new DrawingView(Gui::getMainWindow()); + DrawingView* view = new DrawingView(0, Gui::getMainWindow()); view->load(fileName); view->setWindowIcon(Gui::BitmapFactory().pixmap("actions/drawing-landscape")); view->setWindowTitle(QObject::tr("Drawing viewer")); @@ -85,7 +85,7 @@ importer(PyObject *self, PyObject *args) if (file.hasExtension("svg") || file.hasExtension("svgz")) { QString fileName = QString::fromUtf8(Name); // Displaying the image in a view - DrawingView* view = new DrawingView(Gui::getMainWindow()); + DrawingView* view = new DrawingView(0, Gui::getMainWindow()); view->load(fileName); view->setWindowIcon(Gui::BitmapFactory().pixmap("actions/drawing-landscape")); view->setWindowTitle(QObject::tr("Drawing viewer")); diff --git a/src/Mod/Drawing/Gui/DrawingView.cpp b/src/Mod/Drawing/Gui/DrawingView.cpp index 7ae0e5984..7ae3574d2 100644 --- a/src/Mod/Drawing/Gui/DrawingView.cpp +++ b/src/Mod/Drawing/Gui/DrawingView.cpp @@ -200,8 +200,8 @@ void SvgView::wheelEvent(QWheelEvent *event) /* TRANSLATOR DrawingGui::DrawingView */ -DrawingView::DrawingView(QWidget* parent) - : Gui::MDIView(0, parent), m_view(new SvgView) +DrawingView::DrawingView(Gui::Document* doc, QWidget* parent) + : Gui::MDIView(doc, parent), m_view(new SvgView) { m_backgroundAction = new QAction(tr("&Background"), this); m_backgroundAction->setEnabled(false); diff --git a/src/Mod/Drawing/Gui/DrawingView.h b/src/Mod/Drawing/Gui/DrawingView.h index 2b864090b..c7f161396 100644 --- a/src/Mod/Drawing/Gui/DrawingView.h +++ b/src/Mod/Drawing/Gui/DrawingView.h @@ -79,7 +79,7 @@ class DrawingGuiExport DrawingView : public Gui::MDIView Q_OBJECT public: - DrawingView(QWidget* parent = 0); + DrawingView(Gui::Document* doc, QWidget* parent = 0); public Q_SLOTS: void load(const QString &path = QString()); diff --git a/src/Mod/Drawing/Gui/ViewProviderPage.cpp b/src/Mod/Drawing/Gui/ViewProviderPage.cpp index 55528e9cb..e7f054cfc 100644 --- a/src/Mod/Drawing/Gui/ViewProviderPage.cpp +++ b/src/Mod/Drawing/Gui/ViewProviderPage.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -131,9 +132,11 @@ bool ViewProviderDrawingPage::doubleClicked(void) DrawingView* ViewProviderDrawingPage::showDrawingView() { if (!view){ - view = new DrawingView(Gui::getMainWindow()); + Gui::Document* doc = Gui::Application::Instance->getDocument + (this->pcObject->getDocument()); + view = new DrawingView(doc, Gui::getMainWindow()); view->setWindowIcon(Gui::BitmapFactory().pixmap("actions/drawing-landscape")); - view->setWindowTitle(QObject::tr("Drawing viewer")); + view->setWindowTitle(QObject::tr("Drawing viewer") + QString::fromAscii("[*]")); Gui::getMainWindow()->addWindow(view); }