From 668bbc17805f06026e51daf1c344f51a5f557bbc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 2 Jul 2014 22:27:04 +0200 Subject: [PATCH] Added facilities for viewing the loaded actions. --- code/nel/include/nel/gui/action_handler.h | 2 + code/nel/src/gui/action_handler.cpp | 12 +++ .../src/plugins/gui_editor/CMakeLists.txt | 2 + .../src/plugins/gui_editor/action_list.cpp | 31 ++++++ .../src/plugins/gui_editor/action_list.h | 18 ++++ .../src/plugins/gui_editor/action_list.ui | 94 +++++++++++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 15 +++ .../plugins/gui_editor/gui_editor_window.h | 4 + 8 files changed, 178 insertions(+) create mode 100644 code/studio/src/plugins/gui_editor/action_list.cpp create mode 100644 code/studio/src/plugins/gui_editor/action_list.h create mode 100644 code/studio/src/plugins/gui_editor/action_list.ui diff --git a/code/nel/include/nel/gui/action_handler.h b/code/nel/include/nel/gui/action_handler.h index 70c4b386e..48b49e451 100644 --- a/code/nel/include/nel/gui/action_handler.h +++ b/code/nel/include/nel/gui/action_handler.h @@ -68,6 +68,8 @@ namespace NLGUI return _GlobalInstance; } + void getActionHandlers( std::vector< std::string > &handlers ); + /// return pointer to action handler or null if it doesn't exist IActionHandler *getActionHandler(const std::string &name) const { diff --git a/code/nel/src/gui/action_handler.cpp b/code/nel/src/gui/action_handler.cpp index 8b0d9c4ee..d7214ef06 100644 --- a/code/nel/src/gui/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -111,6 +111,18 @@ namespace NLGUI } } + void CAHManager::getActionHandlers( std::vector< std::string > &handlers ) + { + handlers.clear(); + + std::map< string, IActionHandler* >::iterator itr = FactoryMap.begin(); + while( itr != FactoryMap.end() ) + { + handlers.push_back( itr->first ); + ++itr; + } + } + // ------------------------------------------------------------------------------------------------ IActionHandler* CAHManager::getAH(const std::string &name, std::string ¶ms) { diff --git a/code/studio/src/plugins/gui_editor/CMakeLists.txt b/code/studio/src/plugins/gui_editor/CMakeLists.txt index 0c13c4cd6..33b016bd6 100644 --- a/code/studio/src/plugins/gui_editor/CMakeLists.txt +++ b/code/studio/src/plugins/gui_editor/CMakeLists.txt @@ -30,6 +30,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR add_widget_widget.h editor_selection_watcher.h editor_message_processor.h + action_list.h ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS @@ -45,6 +46,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS new_property_widget.ui new_widget_widget.ui add_widget_widget.ui + action_list.ui ) SET(QT_USE_QTGUI TRUE) diff --git a/code/studio/src/plugins/gui_editor/action_list.cpp b/code/studio/src/plugins/gui_editor/action_list.cpp new file mode 100644 index 000000000..fa61dd6b6 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/action_list.cpp @@ -0,0 +1,31 @@ +#include "action_list.h" +#include "nel/gui/action_handler.h" +#include +#include + +ActionList::ActionList( QDialog *parent ) : +QDialog( parent ) +{ + setupUi( this ); +} + +ActionList::~ActionList() +{ +} + +void ActionList::load() +{ + actionList->clear(); + + NLGUI::CAHManager *am = NLGUI::CAHManager::getInstance(); + std::vector< std::string > handlers; + am->getActionHandlers( handlers ); + + std::vector< std::string >::const_iterator itr = handlers.begin(); + while( itr != handlers.end() ) + { + actionList->addItem( itr->c_str() ); + ++itr; + } +} + diff --git a/code/studio/src/plugins/gui_editor/action_list.h b/code/studio/src/plugins/gui_editor/action_list.h new file mode 100644 index 000000000..ba668f99e --- /dev/null +++ b/code/studio/src/plugins/gui_editor/action_list.h @@ -0,0 +1,18 @@ +#ifndef ACTION_LIST_H +#define ACTION_LIST_H + + +#include "ui_action_list.h" + + +class ActionList : public QDialog, public Ui::ActionListDialog +{ + Q_OBJECT + +public: + ActionList( QDialog *parent = NULL ); + ~ActionList(); + void load(); +}; + +#endif diff --git a/code/studio/src/plugins/gui_editor/action_list.ui b/code/studio/src/plugins/gui_editor/action_list.ui new file mode 100644 index 000000000..ba147cfc2 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/action_list.ui @@ -0,0 +1,94 @@ + + + ActionListDialog + + + + 0 + 0 + 359 + 258 + + + + Action List + + + + + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + okButton + clicked() + ActionListDialog + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + ActionListDialog + reject() + + + 369 + 253 + + + 179 + 282 + + + + + diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index 4f66b61fc..0cbc94947 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -44,6 +44,7 @@ #include "editor_selection_watcher.h" #include "editor_message_processor.h" #include "add_widget_widget.h" +#include "action_list.h" namespace GUIEditor { @@ -70,6 +71,8 @@ namespace GUIEditor widgetInfoTree = new CWidgetInfoTree; + actionList = new ActionList(); + createMenus(); readSettings(); @@ -115,6 +118,9 @@ namespace GUIEditor removeMenus(); + delete actionList; + actionList = NULL; + delete messageProcessor; messageProcessor = NULL; @@ -341,6 +347,11 @@ namespace GUIEditor } + void GUIEditorWindow::test_actionList() + { + actionList->load(); + actionList->show(); + } void GUIEditorWindow::hideEvent( QHideEvent *evnt ) { @@ -400,6 +411,10 @@ namespace GUIEditor connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) ); m->addAction( a ); + a = new QAction( "Test actionlist", this ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( test_actionList() ) ); + m->addAction( a ); + menu = m; } } diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.h b/code/studio/src/plugins/gui_editor/gui_editor_window.h index 517186739..fc1f533cc 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -27,6 +27,7 @@ class QtTreePropertyBrowser; class QMenu; +class ActionList; namespace GUIEditor { @@ -66,6 +67,8 @@ private Q_SLOTS: void onAddWidgetClicked(); void onTreeChanged(); + void test_actionList(); + protected: void hideEvent( QHideEvent *evnt ); void showEvent( QShowEvent *evnt ); @@ -91,6 +94,7 @@ private: CWidgetInfoTree *widgetInfoTree; CEditorMessageProcessor *messageProcessor; AddWidgetWidget *addWidgetWidget; + ActionList *actionList; CPropBrowserCtrl browserCtrl; QString currentProject;