MODIFIED: #1471 Exiting OVQT will now work again properly.

This commit is contained in:
dfighter1985 2012-11-22 21:22:28 +01:00
parent 0ce956b71a
commit bbaefe88d5
8 changed files with 87 additions and 8 deletions

View file

@ -176,11 +176,12 @@ void MainWindow::saveAll()
{ {
} }
void MainWindow::close() void MainWindow::closeDocument()
{ {
m_contextManager->currentContext()->close(); m_contextManager->currentContext()->close();
} }
void MainWindow::cut() void MainWindow::cut()
{ {
} }
@ -297,7 +298,7 @@ void MainWindow::createActions()
m_closeAction = new QAction(tr("Close"), this); m_closeAction = new QAction(tr("Close"), this);
m_closeAction->setShortcut(QKeySequence::Close); m_closeAction->setShortcut(QKeySequence::Close);
menuManager()->registerAction(m_closeAction, Constants::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_closeAction->setEnabled(false);
m_exitAction = new QAction(tr("E&xit"), this); m_exitAction = new QAction(tr("E&xit"), this);

View file

@ -71,7 +71,7 @@ private Q_SLOTS:
void save(); void save();
void saveAs(); void saveAs();
void saveAll(); void saveAll();
void close(); void closeDocument();
void cut(); void cut();
void copy(); void copy();
void paste(); void paste();

View file

@ -45,6 +45,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
gui_editor_plugin.h gui_editor_plugin.h
gui_editor_window.h gui_editor_window.h
gui_editor_context.h gui_editor_context.h
gui_editor_core_listener.h
widget_properties.h widget_properties.h
widget_hierarchy.h widget_hierarchy.h
link_list.h link_list.h

View file

@ -0,0 +1,28 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "gui_editor_core_listener.h"
#include "gui_editor_window.h"
namespace GUIEditor
{
bool GUIEditorCoreListener::closeMainWindow() const
{
return mainWindow->close();
}
}

View file

@ -0,0 +1,41 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -17,6 +17,7 @@
#include "gui_editor_plugin.h" #include "gui_editor_plugin.h"
#include "gui_editor_window.h" #include "gui_editor_window.h"
#include "gui_editor_context.h" #include "gui_editor_context.h"
#include "gui_editor_core_listener.h"
#include "../core/icore.h" #include "../core/icore.h"
#include "../core/core_constants.h" #include "../core/core_constants.h"
@ -42,7 +43,12 @@ namespace GUIEditor
{ {
Q_UNUSED(errorString); Q_UNUSED(errorString);
m_plugMan = pluginManager; 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; return true;
} }

View file

@ -249,17 +249,17 @@ namespace GUIEditor
} }
void GUIEditorWindow::close() bool GUIEditorWindow::close()
{ {
if( currentProject.isEmpty() ) if( currentProject.isEmpty() )
return; return false;
QMessageBox::StandardButton reply = QMessageBox::question( this, QMessageBox::StandardButton reply = QMessageBox::question( this,
tr( "Closing project" ), tr( "Closing project" ),
tr( "Are you sure you want to close this project?" ), tr( "Are you sure you want to close this project?" ),
QMessageBox::Yes | QMessageBox::No ); QMessageBox::Yes | QMessageBox::No );
if( reply != QMessageBox::Yes ) if( reply != QMessageBox::Yes )
return; return false;
projectFiles.clearAll(); projectFiles.clearAll();
projectWindow->clear(); projectWindow->clear();
@ -271,6 +271,8 @@ namespace GUIEditor
currentProject = ""; currentProject = "";
currentProjectFile = ""; currentProjectFile = "";
projectParser.clear(); projectParser.clear();
return true;
} }
void GUIEditorWindow::onProjectFilesChanged() void GUIEditorWindow::onProjectFilesChanged()

View file

@ -54,7 +54,7 @@ public Q_SLOTS:
void newDocument(); void newDocument();
void save(); void save();
void saveAs(); void saveAs();
void close(); bool close();
private Q_SLOTS: private Q_SLOTS:
void onProjectFilesChanged(); void onProjectFilesChanged();