mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 23:56:15 +00:00
MODIFIED: GUI Editor can now delete widgets.
This commit is contained in:
parent
10adcb5549
commit
b731004c61
6 changed files with 104 additions and 1 deletions
|
@ -485,6 +485,7 @@ namespace NLGUI
|
||||||
|
|
||||||
IParser* getParser() const{ return parser; }
|
IParser* getParser() const{ return parser; }
|
||||||
|
|
||||||
|
std::string& getCurrentEditorSelection(){ return currentEditorSelection; }
|
||||||
void setCurrentEditorSelection( const std::string &name );
|
void setCurrentEditorSelection( const std::string &name );
|
||||||
void notifySelectionWatchers();
|
void notifySelectionWatchers();
|
||||||
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
|
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
|
||||||
|
|
|
@ -61,6 +61,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
|
||||||
new_property_widget.h
|
new_property_widget.h
|
||||||
new_widget_widget.h
|
new_widget_widget.h
|
||||||
editor_selection_watcher.h
|
editor_selection_watcher.h
|
||||||
|
editor_message_processor.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
||||||
|
|
|
@ -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( "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "project_window.h"
|
#include "project_window.h"
|
||||||
#include "nelgui_widget.h"
|
#include "nelgui_widget.h"
|
||||||
#include "editor_selection_watcher.h"
|
#include "editor_selection_watcher.h"
|
||||||
|
#include "editor_message_processor.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,7 @@ namespace GUIEditor
|
||||||
QMainWindow(parent)
|
QMainWindow(parent)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
messageProcessor = new CEditorMessageProcessor;
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
widgetProps = new CWidgetProperties;
|
widgetProps = new CWidgetProperties;
|
||||||
linkList = new LinkList;
|
linkList = new LinkList;
|
||||||
|
@ -99,6 +101,9 @@ namespace GUIEditor
|
||||||
{
|
{
|
||||||
writeSettings();
|
writeSettings();
|
||||||
|
|
||||||
|
delete messageProcessor;
|
||||||
|
messageProcessor = NULL;
|
||||||
|
|
||||||
delete widgetProps;
|
delete widgetProps;
|
||||||
widgetProps = NULL;
|
widgetProps = NULL;
|
||||||
|
|
||||||
|
@ -311,6 +316,7 @@ namespace GUIEditor
|
||||||
QAction *saveAction = mm->action( Core::Constants::SAVE );
|
QAction *saveAction = mm->action( Core::Constants::SAVE );
|
||||||
QAction *saveAsAction = mm->action( Core::Constants::SAVE_AS );
|
QAction *saveAsAction = mm->action( Core::Constants::SAVE_AS );
|
||||||
QAction *closeAction = mm->action( Core::Constants::CLOSE );
|
QAction *closeAction = mm->action( Core::Constants::CLOSE );
|
||||||
|
QAction *delAction = mm->action( Core::Constants::DEL );
|
||||||
|
|
||||||
//if( newAction != NULL )
|
//if( newAction != NULL )
|
||||||
// newAction->setEnabled( true );
|
// newAction->setEnabled( true );
|
||||||
|
@ -320,6 +326,11 @@ namespace GUIEditor
|
||||||
saveAsAction->setEnabled( true );
|
saveAsAction->setEnabled( true );
|
||||||
if( closeAction != NULL )
|
if( closeAction != NULL )
|
||||||
closeAction->setEnabled( true );
|
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 );
|
QMenu *menu = mm->menu( Core::Constants::M_TOOLS );
|
||||||
if( menu != NULL )
|
if( menu != NULL )
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace GUIEditor
|
||||||
class ProjectWindow;
|
class ProjectWindow;
|
||||||
class NelGUIWidget;
|
class NelGUIWidget;
|
||||||
class CWidgetInfoTree;
|
class CWidgetInfoTree;
|
||||||
|
class CEditorMessageProcessor;
|
||||||
|
|
||||||
class GUIEditorWindow: public QMainWindow
|
class GUIEditorWindow: public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -77,8 +78,8 @@ private:
|
||||||
ProcList *procList;
|
ProcList *procList;
|
||||||
ProjectWindow *projectWindow;
|
ProjectWindow *projectWindow;
|
||||||
NelGUIWidget *viewPort;
|
NelGUIWidget *viewPort;
|
||||||
|
|
||||||
CWidgetInfoTree *widgetInfoTree;
|
CWidgetInfoTree *widgetInfoTree;
|
||||||
|
CEditorMessageProcessor *messageProcessor;
|
||||||
|
|
||||||
CPropBrowserCtrl browserCtrl;
|
CPropBrowserCtrl browserCtrl;
|
||||||
QString currentProject;
|
QString currentProject;
|
||||||
|
|
Loading…
Reference in a new issue