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 63a7d00cc..893ec263e 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 @@ -60,6 +60,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR nelgui_widget.h new_property_widget.h new_widget_widget.h + add_widget_widget.h editor_selection_watcher.h editor_message_processor.h ) @@ -76,6 +77,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS project_window.ui new_property_widget.ui new_widget_widget.ui + add_widget_widget.ui ) SET(QT_USE_QTGUI TRUE) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp new file mode 100644 index 000000000..24bd70f63 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.cpp @@ -0,0 +1,64 @@ +#include "add_widget_widget.h" +#include "widget_info_tree.h" +#include +#include +#include + +namespace GUIEditor +{ + + AddWidgetWidget::AddWidgetWidget( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + setupConnections(); + } + + AddWidgetWidget::~AddWidgetWidget() + { + } + + void AddWidgetWidget::setCurrentGroup( const QString &g ) + { + groupEdit->setText( g ); + } + + void AddWidgetWidget::setupWidgetInfo( const CWidgetInfoTree *tree ) + { + std::vector< std::string > names; + tree->getNames( names, false ); + + widgetCB->clear(); + + std::sort( names.begin(), names.end() ); + + std::vector< std::string >::const_iterator itr = names.begin(); + while( itr != names.end() ) + { + widgetCB->addItem( QString( itr->c_str() ) ); + ++itr; + } + + } + + void AddWidgetWidget::setupConnections() + { + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( close() ) ); + connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); + } + + void AddWidgetWidget::onAddClicked() + { + if( nameEdit->text().isEmpty() ) + { + QMessageBox::warning( NULL, + tr( "WARNING" ), + tr( "You need to specify a name for your new widget!" ), + QMessageBox::Ok ); + + return; + } + + close(); + } +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h new file mode 100644 index 000000000..fa5045ac2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.h @@ -0,0 +1,29 @@ +#ifndef ADD_WIDGET_WIDGET_H +#define ADD_WIDGET_WIDGET_H + +#include "ui_add_widget_widget.h" + +namespace GUIEditor +{ + class CWidgetInfoTree; + + class AddWidgetWidget : public QWidget, public Ui::AddWidgetWidget + { + Q_OBJECT + public: + AddWidgetWidget( QWidget *parent = NULL ); + ~AddWidgetWidget(); + + void setCurrentGroup( const QString &g ); + void setupWidgetInfo( const CWidgetInfoTree *tree ); + + private: + void setupConnections(); + + private Q_SLOTS: + void onAddClicked(); + }; + +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui new file mode 100644 index 000000000..dd7e14e48 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/add_widget_widget.ui @@ -0,0 +1,76 @@ + + + AddWidgetWidget + + + Qt::ApplicationModal + + + + 0 + 0 + 318 + 132 + + + + Add new widget + + + + + + + + Group + + + + + + + + + + + + + + Widget + + + + + + + + + + Name + + + + + + + + + + + + Add + + + + + + + Cancel + + + + + + + + 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 f84b555d1..33cb5e647 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 @@ -43,6 +43,7 @@ #include "nelgui_widget.h" #include "editor_selection_watcher.h" #include "editor_message_processor.h" +#include "add_widget_widget.h" namespace GUIEditor { @@ -61,6 +62,7 @@ namespace GUIEditor linkList = new LinkList; procList = new ProcList; projectWindow = new ProjectWindow; + addWidgetWidget = new AddWidgetWidget; connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) ); viewPort = new NelGUIWidget; setCentralWidget( viewPort ); @@ -76,6 +78,7 @@ namespace GUIEditor parser.setWidgetInfoTree( widgetInfoTree ); parser.parseGUIWidgets(); widgetProps->setupWidgetInfo( widgetInfoTree ); + addWidgetWidget->setupWidgetInfo( widgetInfoTree ); QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this ); dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); @@ -95,6 +98,7 @@ namespace GUIEditor viewPort->init(); connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) ); + connect( widgetProps, SIGNAL( treeChanged() ), this, SLOT( onTreeChanged() ) ); } GUIEditorWindow::~GUIEditorWindow() @@ -119,6 +123,9 @@ namespace GUIEditor delete viewPort; viewPort = NULL; + delete addWidgetWidget; + addWidgetWidget = NULL; + // no deletion needed for these, since dockwidget owns them hierarchyView = NULL; propBrowser = NULL; @@ -309,6 +316,20 @@ namespace GUIEditor connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) ); } + void GUIEditorWindow::onAddWidgetClicked() + { + QString g; + hierarchyView->getCurrentGroup( g ); + + addWidgetWidget->setCurrentGroup( g ); + addWidgetWidget->show(); + } + + void GUIEditorWindow::onTreeChanged() + { + addWidgetWidget->setupWidgetInfo( widgetInfoTree ); + } + void GUIEditorWindow::createMenus() { Core::MenuManager *mm = Core::ICore::instance()->menuManager(); @@ -352,6 +373,10 @@ namespace GUIEditor a = new QAction( "Project Window", this ); connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) ); m->addAction( a ); + + a = new QAction( "Add Widget", this ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) ); + m->addAction( a ); } } 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 37f33e91c..e1a8b8b2d 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 @@ -37,6 +37,7 @@ namespace GUIEditor class NelGUIWidget; class CWidgetInfoTree; class CEditorMessageProcessor; + class AddWidgetWidget; class GUIEditorWindow: public QMainWindow { @@ -60,6 +61,8 @@ public Q_SLOTS: private Q_SLOTS: void onProjectFilesChanged(); void onGUILoaded(); + void onAddWidgetClicked(); + void onTreeChanged(); private: void createMenus(); @@ -80,6 +83,7 @@ private: NelGUIWidget *viewPort; CWidgetInfoTree *widgetInfoTree; CEditorMessageProcessor *messageProcessor; + AddWidgetWidget *addWidgetWidget; CPropBrowserCtrl browserCtrl; QString currentProject; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp index 85b662628..f48c35e93 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp @@ -187,6 +187,38 @@ namespace GUIEditor widgetHierarchyMap.erase( itr ); } + void WidgetHierarchy::getCurrentGroup( QString &g ) + { + std::string s = CWidgetManager::getInstance()->getCurrentEditorSelection(); + if( s.empty() ) + { + g = ""; + return; + } + + NLGUI::CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( s ); + if( e == NULL ) + { + g = ""; + return; + } + + if( e->isGroup() ) + { + g = e->getId().c_str(); + return; + } + + NLGUI::CInterfaceGroup *p = e->getParent(); + if( p == NULL ) + { + g = ""; + return; + } + + g = p->getId().c_str(); + } + void WidgetHierarchy::onGUILoaded() { if( masterGroup.empty() ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h index 6de6b1366..bfc68ea4f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h @@ -44,6 +44,8 @@ namespace GUIEditor void onWidgetDeleted( const std::string &id ); + void getCurrentGroup( QString &g ); + private: void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group ); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree.h index 25ad7bb40..5e717923c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree.h @@ -93,11 +93,11 @@ namespace GUIEditor } /// Get the node names and put them into the vector - void getNames( std::vector< std::string > &v ) const + void getNames( std::vector< std::string > &v, bool includeAbstract = true ) const { if( root == NULL ) return; - root->getNames( v ); + root->getNames( v, includeAbstract ); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree_node.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree_node.h index 81adfe06c..0de9e6977 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree_node.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info_tree_node.h @@ -215,11 +215,13 @@ namespace GUIEditor } /// Get the node names and put them into the vector - void getNames( std::vector< std::string > &v ) const + void getNames( std::vector< std::string > &v, bool includeAbstract = true ) const { - v.push_back( info.name ); + if( !info.isAbstract || ( info.isAbstract && includeAbstract ) ) + v.push_back( info.name ); + for( std::vector< CWidgetInfoTreeNode* >::const_iterator itr = children.begin(); itr != children.end(); ++itr ) - ( *itr )->getNames( v ); + ( *itr )->getNames( v, includeAbstract ); } /// Accepts a visitor to itself and to the children nodes diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp index 0a9337e6c..69d556975 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp @@ -84,6 +84,7 @@ namespace GUIEditor{ return; tree->removeNode( widgetName.toUtf8().constData() ); + Q_EMIT treeChanged(); widgetPropTree->clear(); buildWidgetList(); } @@ -156,6 +157,7 @@ namespace GUIEditor{ void CWidgetProperties::onWidgetAdded() { buildWidgetList(); + Q_EMIT treeChanged(); } void CWidgetProperties::buildWidgetList() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h index b14bf2f72..44e535b0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h @@ -74,6 +74,9 @@ namespace GUIEditor CWidgetInfoTree *tree; NewPropertyWidget *newPropertyWidget; NewWidgetWidget *newWidgetWidget; + + Q_SIGNALS: + void treeChanged(); }; }