ActionList dialog can now select an action, and is used with the proc editor.

This commit is contained in:
dfighter1985 2014-07-03 00:44:38 +02:00
parent a30caef9e1
commit ed6f5d1412
6 changed files with 45 additions and 29 deletions

View file

@ -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();
}

View file

@ -3,6 +3,7 @@
#include "ui_action_list.h" #include "ui_action_list.h"
#include <QString>
class ActionList : public QDialog, public Ui::ActionListDialog class ActionList : public QDialog, public Ui::ActionListDialog
@ -13,6 +14,16 @@ public:
ActionList( QDialog *parent = NULL ); ActionList( QDialog *parent = NULL );
~ActionList(); ~ActionList();
void load(); void load();
QString getSelectedAction(){ return selectedAction; }
public Q_SLOTS:
void accept();
void reject();
private:
QString selectedAction;
}; };
#endif #endif

View file

@ -44,7 +44,6 @@
#include "editor_selection_watcher.h" #include "editor_selection_watcher.h"
#include "editor_message_processor.h" #include "editor_message_processor.h"
#include "add_widget_widget.h" #include "add_widget_widget.h"
#include "action_list.h"
namespace GUIEditor namespace GUIEditor
{ {
@ -71,8 +70,6 @@ namespace GUIEditor
widgetInfoTree = new CWidgetInfoTree; widgetInfoTree = new CWidgetInfoTree;
actionList = new ActionList();
createMenus(); createMenus();
readSettings(); readSettings();
@ -118,9 +115,6 @@ namespace GUIEditor
removeMenus(); removeMenus();
delete actionList;
actionList = NULL;
delete messageProcessor; delete messageProcessor;
messageProcessor = NULL; messageProcessor = NULL;
@ -347,12 +341,6 @@ namespace GUIEditor
} }
void GUIEditorWindow::test_actionList()
{
actionList->load();
actionList->show();
}
void GUIEditorWindow::hideEvent( QHideEvent *evnt ) void GUIEditorWindow::hideEvent( QHideEvent *evnt )
{ {
QWidget::hideEvent( evnt ); QWidget::hideEvent( evnt );
@ -411,10 +399,6 @@ namespace GUIEditor
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) );
m->addAction( a ); m->addAction( a );
a = new QAction( "Test actionlist", this );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( test_actionList() ) );
m->addAction( a );
menu = m; menu = m;
} }
} }

View file

@ -27,7 +27,6 @@
class QtTreePropertyBrowser; class QtTreePropertyBrowser;
class QMenu; class QMenu;
class ActionList;
namespace GUIEditor namespace GUIEditor
{ {
@ -67,7 +66,6 @@ private Q_SLOTS:
void onAddWidgetClicked(); void onAddWidgetClicked();
void onTreeChanged(); void onTreeChanged();
void test_actionList();
protected: protected:
void hideEvent( QHideEvent *evnt ); void hideEvent( QHideEvent *evnt );
@ -94,7 +92,6 @@ private:
CWidgetInfoTree *widgetInfoTree; CWidgetInfoTree *widgetInfoTree;
CEditorMessageProcessor *messageProcessor; CEditorMessageProcessor *messageProcessor;
AddWidgetWidget *addWidgetWidget; AddWidgetWidget *addWidgetWidget;
ActionList *actionList;
CPropBrowserCtrl browserCtrl; CPropBrowserCtrl browserCtrl;
QString currentProject; QString currentProject;

View file

@ -17,6 +17,7 @@
#include "proc_editor.h" #include "proc_editor.h"
#include "action_editor.h" #include "action_editor.h"
#include "action_list.h"
#include <QMessageBox> #include <QMessageBox>
#include <QInputDialog> #include <QInputDialog>
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
@ -35,10 +36,15 @@ namespace GUIEditor
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveButtonClicked() ) ); connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveButtonClicked() ) );
connect( upButton, SIGNAL( clicked( bool ) ), this, SLOT( onUpButtonClicked() ) ); connect( upButton, SIGNAL( clicked( bool ) ), this, SLOT( onUpButtonClicked() ) );
connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownButtonClicked() ) ); connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownButtonClicked() ) );
alist = new ActionList();
} }
ProcEditor::~ProcEditor() ProcEditor::~ProcEditor()
{ {
delete alist;
alist = NULL;
delete actionEditor; delete actionEditor;
actionEditor = NULL; actionEditor = NULL;
} }
@ -84,17 +90,13 @@ namespace GUIEditor
void ProcEditor::onAddButtonClicked() void ProcEditor::onAddButtonClicked()
{ {
bool ok; alist->load();
QString name = int result = alist->exec();
QInputDialog::getText( this,
tr( "Adding new Action" ), if( result == QDialog::Accepted )
tr( "Please specify the name of the new action handler" ),
QLineEdit::Normal,
QString(),
&ok );
if( ok )
{ {
QString name = alist->getSelectedAction();
CProcedure *proc = CProcedure *proc =
CWidgetManager::getInstance()->getParser()->getProc( currentProc.toUtf8().constData() ); CWidgetManager::getInstance()->getParser()->getProc( currentProc.toUtf8().constData() );
if( proc != NULL ) if( proc != NULL )

View file

@ -20,6 +20,8 @@
#include "ui_proc_editor.h" #include "ui_proc_editor.h"
class ActionList;
namespace GUIEditor namespace GUIEditor
{ {
class ActionEditor; class ActionEditor;
@ -46,6 +48,8 @@ namespace GUIEditor
ActionEditor *actionEditor; ActionEditor *actionEditor;
QString currentProc; QString currentProc;
ActionList *alist;
}; };
} }