From cf2e18143f535eeb49a201f8955dc2b133398ee0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 3 Jul 2014 00:44:38 +0200 Subject: [PATCH] ActionList dialog can now select an action, and is used with the proc editor. --- .../src/plugins/gui_editor/action_list.cpp | 18 +++++++++++++++ .../src/plugins/gui_editor/action_list.h | 11 ++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 16 -------------- .../plugins/gui_editor/gui_editor_window.h | 3 --- .../src/plugins/gui_editor/proc_editor.cpp | 22 ++++++++++--------- .../src/plugins/gui_editor/proc_editor.h | 4 ++++ 6 files changed, 45 insertions(+), 29 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/action_list.cpp b/code/studio/src/plugins/gui_editor/action_list.cpp index fa61dd6b6..8925e6d04 100644 --- a/code/studio/src/plugins/gui_editor/action_list.cpp +++ b/code/studio/src/plugins/gui_editor/action_list.cpp @@ -29,3 +29,21 @@ void ActionList::load() } } +void ActionList::accept() +{ + QListWidgetItem *item = actionList->currentItem(); + if( item == NULL ) + return; + + selectedAction = item->text(); + + QDialog::accept(); +} + +void ActionList::reject() +{ + selectedAction = ""; + + QDialog::reject(); +} + diff --git a/code/studio/src/plugins/gui_editor/action_list.h b/code/studio/src/plugins/gui_editor/action_list.h index ba668f99e..752d66467 100644 --- a/code/studio/src/plugins/gui_editor/action_list.h +++ b/code/studio/src/plugins/gui_editor/action_list.h @@ -3,6 +3,7 @@ #include "ui_action_list.h" +#include class ActionList : public QDialog, public Ui::ActionListDialog @@ -13,6 +14,16 @@ public: ActionList( QDialog *parent = NULL ); ~ActionList(); void load(); + + QString getSelectedAction(){ return selectedAction; } + + +public Q_SLOTS: + void accept(); + void reject(); + +private: + QString selectedAction; }; #endif 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 0cbc94947..9f6568936 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -44,7 +44,6 @@ #include "editor_selection_watcher.h" #include "editor_message_processor.h" #include "add_widget_widget.h" -#include "action_list.h" namespace GUIEditor { @@ -71,8 +70,6 @@ namespace GUIEditor widgetInfoTree = new CWidgetInfoTree; - actionList = new ActionList(); - createMenus(); readSettings(); @@ -118,9 +115,6 @@ namespace GUIEditor removeMenus(); - delete actionList; - actionList = NULL; - delete messageProcessor; messageProcessor = NULL; @@ -347,12 +341,6 @@ namespace GUIEditor } - void GUIEditorWindow::test_actionList() - { - actionList->load(); - actionList->show(); - } - void GUIEditorWindow::hideEvent( QHideEvent *evnt ) { QWidget::hideEvent( evnt ); @@ -411,10 +399,6 @@ 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 fc1f533cc..15935fe74 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -27,7 +27,6 @@ class QtTreePropertyBrowser; class QMenu; -class ActionList; namespace GUIEditor { @@ -67,7 +66,6 @@ private Q_SLOTS: void onAddWidgetClicked(); void onTreeChanged(); - void test_actionList(); protected: void hideEvent( QHideEvent *evnt ); @@ -94,7 +92,6 @@ private: CWidgetInfoTree *widgetInfoTree; CEditorMessageProcessor *messageProcessor; AddWidgetWidget *addWidgetWidget; - ActionList *actionList; CPropBrowserCtrl browserCtrl; QString currentProject; diff --git a/code/studio/src/plugins/gui_editor/proc_editor.cpp b/code/studio/src/plugins/gui_editor/proc_editor.cpp index c36b16f64..e96a1cce1 100644 --- a/code/studio/src/plugins/gui_editor/proc_editor.cpp +++ b/code/studio/src/plugins/gui_editor/proc_editor.cpp @@ -17,6 +17,7 @@ #include "proc_editor.h" #include "action_editor.h" +#include "action_list.h" #include #include #include "nel/gui/interface_group.h" @@ -35,10 +36,15 @@ namespace GUIEditor connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveButtonClicked() ) ); connect( upButton, SIGNAL( clicked( bool ) ), this, SLOT( onUpButtonClicked() ) ); connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownButtonClicked() ) ); + + alist = new ActionList(); } ProcEditor::~ProcEditor() { + delete alist; + alist = NULL; + delete actionEditor; actionEditor = NULL; } @@ -84,17 +90,13 @@ namespace GUIEditor void ProcEditor::onAddButtonClicked() { - bool ok; - QString name = - QInputDialog::getText( this, - tr( "Adding new Action" ), - tr( "Please specify the name of the new action handler" ), - QLineEdit::Normal, - QString(), - &ok ); - - if( ok ) + alist->load(); + int result = alist->exec(); + + if( result == QDialog::Accepted ) { + QString name = alist->getSelectedAction(); + CProcedure *proc = CWidgetManager::getInstance()->getParser()->getProc( currentProc.toUtf8().constData() ); if( proc != NULL ) diff --git a/code/studio/src/plugins/gui_editor/proc_editor.h b/code/studio/src/plugins/gui_editor/proc_editor.h index 90579daa4..8debfef02 100644 --- a/code/studio/src/plugins/gui_editor/proc_editor.h +++ b/code/studio/src/plugins/gui_editor/proc_editor.h @@ -20,6 +20,8 @@ #include "ui_proc_editor.h" +class ActionList; + namespace GUIEditor { class ActionEditor; @@ -46,6 +48,8 @@ namespace GUIEditor ActionEditor *actionEditor; QString currentProc; + + ActionList *alist; }; }