MODIFIED: GUI Editor can now delete widgets.

This commit is contained in:
dfighter1985 2013-03-02 06:57:40 +01:00
parent 10adcb5549
commit b731004c61
6 changed files with 104 additions and 1 deletions

View file

@ -485,6 +485,7 @@ namespace NLGUI
IParser* getParser() const{ return parser; }
std::string& getCurrentEditorSelection(){ return currentEditorSelection; }
void setCurrentEditorSelection( const std::string &name );
void notifySelectionWatchers();
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );

View file

@ -61,6 +61,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
new_property_widget.h
new_widget_widget.h
editor_selection_watcher.h
editor_message_processor.h
)
SET(OVQT_PLUGIN_GUI_EDITOR_UIS

View file

@ -0,0 +1,56 @@
// 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 <QMessageBox>
#include "editor_message_processor.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
namespace GUIEditor
{
void CEditorMessageProcessor::onDelete()
{
std::string selection = CWidgetManager::getInstance()->getCurrentEditorSelection();
if( selection.empty() )
return;
QMessageBox::StandardButton r =
QMessageBox::question( NULL,
tr( "Deleting widget" ),
tr( "Are you sure you want to delete %1?" ).arg( selection.c_str() ),
QMessageBox::Yes | QMessageBox::No );
if( r != QMessageBox::Yes )
return;
CInterfaceElement *e =
CWidgetManager::getInstance()->getElementFromId( selection );
if( e == NULL )
return;
CInterfaceElement *p = e;
while( ( p != NULL ) && !p->isGroup() )
p = p->getParent();
CInterfaceGroup *g = dynamic_cast< CInterfaceGroup* >( p );
if( g == NULL )
return;
if( g->delElement( e ) )
CWidgetManager::getInstance()->setCurrentEditorSelection( "" );
}
}

View file

@ -0,0 +1,33 @@
// 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 <QObject>
namespace GUIEditor
{
/// Processes the GUI Editor's editor messages like delete, new, etc...
class CEditorMessageProcessor : public QObject
{
Q_OBJECT
public:
CEditorMessageProcessor( QObject *parent = NULL ) : QObject( parent ){}
~CEditorMessageProcessor(){}
public Q_SLOTS:
void onDelete();
};
}

View file

@ -42,6 +42,7 @@
#include "project_window.h"
#include "nelgui_widget.h"
#include "editor_selection_watcher.h"
#include "editor_message_processor.h"
namespace GUIEditor
{
@ -54,6 +55,7 @@ namespace GUIEditor
QMainWindow(parent)
{
m_ui.setupUi(this);
messageProcessor = new CEditorMessageProcessor;
m_undoStack = new QUndoStack(this);
widgetProps = new CWidgetProperties;
linkList = new LinkList;
@ -99,6 +101,9 @@ namespace GUIEditor
{
writeSettings();
delete messageProcessor;
messageProcessor = NULL;
delete widgetProps;
widgetProps = NULL;
@ -311,6 +316,7 @@ namespace GUIEditor
QAction *saveAction = mm->action( Core::Constants::SAVE );
QAction *saveAsAction = mm->action( Core::Constants::SAVE_AS );
QAction *closeAction = mm->action( Core::Constants::CLOSE );
QAction *delAction = mm->action( Core::Constants::DEL );
//if( newAction != NULL )
// newAction->setEnabled( true );
@ -320,6 +326,11 @@ namespace GUIEditor
saveAsAction->setEnabled( true );
if( closeAction != NULL )
closeAction->setEnabled( true );
if( delAction != NULL )
{
delAction->setEnabled( true );
connect( delAction, SIGNAL( triggered( bool ) ), messageProcessor, SLOT( onDelete() ) );
}
QMenu *menu = mm->menu( Core::Constants::M_TOOLS );
if( menu != NULL )

View file

@ -36,6 +36,7 @@ namespace GUIEditor
class ProjectWindow;
class NelGUIWidget;
class CWidgetInfoTree;
class CEditorMessageProcessor;
class GUIEditorWindow: public QMainWindow
{
@ -77,8 +78,8 @@ private:
ProcList *procList;
ProjectWindow *projectWindow;
NelGUIWidget *viewPort;
CWidgetInfoTree *widgetInfoTree;
CEditorMessageProcessor *messageProcessor;
CPropBrowserCtrl browserCtrl;
QString currentProject;