diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp index 2247274a6..a90e67bc0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -176,11 +176,12 @@ void MainWindow::saveAll() { } -void MainWindow::close() +void MainWindow::closeDocument() { m_contextManager->currentContext()->close(); } + void MainWindow::cut() { } @@ -297,7 +298,7 @@ void MainWindow::createActions() m_closeAction = new QAction(tr("Close"), this); m_closeAction->setShortcut(QKeySequence::Close); menuManager()->registerAction(m_closeAction, Constants::CLOSE); - connect(m_closeAction, SIGNAL(triggered()), this, SLOT(close())); + connect(m_closeAction, SIGNAL(triggered()), this, SLOT(closeDocument())); m_closeAction->setEnabled(false); m_exitAction = new QAction(tr("E&xit"), this); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h index 11bfd22b6..d258a5eba 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -71,7 +71,7 @@ private Q_SLOTS: void save(); void saveAs(); void saveAll(); - void close(); + void closeDocument(); void cut(); void copy(); void paste(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt index d8a8a094f..c2c74038b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -45,6 +45,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h + gui_editor_core_listener.h widget_properties.h widget_hierarchy.h link_list.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_core_listener.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_core_listener.cpp new file mode 100644 index 000000000..bbe6cd720 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_core_listener.cpp @@ -0,0 +1,28 @@ +// Object Viewer Qt GUI Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "gui_editor_core_listener.h" +#include "gui_editor_window.h" + +namespace GUIEditor +{ + bool GUIEditorCoreListener::closeMainWindow() const + { + return mainWindow->close(); + } +} + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_core_listener.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_core_listener.h new file mode 100644 index 000000000..550495e11 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_core_listener.h @@ -0,0 +1,41 @@ +// Object Viewer Qt GUI Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef GUI_EDITOR_CORE_LISTENER_H +#define GUI_EDITOR_CORE_LISTENER_H + +#include "../core/icore_listener.h" + +namespace GUIEditor +{ + class GUIEditorWindow; + + class GUIEditorCoreListener : public Core::ICoreListener + { + Q_OBJECT + public: + GUIEditorCoreListener( GUIEditorWindow *mainWindow, QObject *parent = NULL ){ this->mainWindow = mainWindow; } + ~GUIEditorCoreListener(){} + bool closeMainWindow() const; + + private: + GUIEditorWindow *mainWindow; + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp index d135dde9a..2fbaa0f13 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp @@ -17,6 +17,7 @@ #include "gui_editor_plugin.h" #include "gui_editor_window.h" #include "gui_editor_context.h" +#include "gui_editor_core_listener.h" #include "../core/icore.h" #include "../core/core_constants.h" @@ -42,7 +43,12 @@ namespace GUIEditor { Q_UNUSED(errorString); m_plugMan = pluginManager; - addAutoReleasedObject(new GUIEditorContext(this)); + GUIEditorContext *context = new GUIEditorContext( this ); + GUIEditorWindow *window = static_cast< GUIEditorWindow* >( context->widget() ); + + addAutoReleasedObject( context ); + addAutoReleasedObject( new GUIEditorCoreListener( window, this ) ); + return true; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 17325676a..99ade3b18 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -249,17 +249,17 @@ namespace GUIEditor } - void GUIEditorWindow::close() + bool GUIEditorWindow::close() { if( currentProject.isEmpty() ) - return; + return false; QMessageBox::StandardButton reply = QMessageBox::question( this, tr( "Closing project" ), tr( "Are you sure you want to close this project?" ), QMessageBox::Yes | QMessageBox::No ); if( reply != QMessageBox::Yes ) - return; + return false; projectFiles.clearAll(); projectWindow->clear(); @@ -271,6 +271,8 @@ namespace GUIEditor currentProject = ""; currentProjectFile = ""; projectParser.clear(); + + return true; } void GUIEditorWindow::onProjectFilesChanged() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index 8f927e979..d4327d3d9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -54,7 +54,7 @@ public Q_SLOTS: void newDocument(); void save(); void saveAs(); - void close(); + bool close(); private Q_SLOTS: void onProjectFilesChanged();