Moved the Expression Editor to it's right place.

--HG--
branch : dfighter-tools
This commit is contained in:
dfighter1985 2014-09-17 19:19:43 +02:00
parent a9cd538786
commit df98492b1c
8 changed files with 73 additions and 21 deletions

View file

@ -140,6 +140,13 @@ void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
menu.exec( e->globalPos() );
}
void ExpressionEditor::closeEvent( QCloseEvent *e )
{
QMainWindow::closeEvent( e );
Q_EMIT closing();
}
void ExpressionEditor::onDeleteSelection()
{
QList< QGraphicsItem* > l = m_scene->selectedItems();
@ -324,7 +331,7 @@ void ExpressionEditor::onSave()
m_result = m_pvt->m_root->build();
}
hide();
close();
}

View file

@ -37,8 +37,12 @@ public:
void load();
QString result() const{ return m_result; }
Q_SIGNALS:
void closing();
protected:
void contextMenuEvent( QContextMenuEvent *e );
void closeEvent( QCloseEvent *e );
private Q_SLOTS:
void onDeleteSelection();

View file

@ -2,6 +2,9 @@
<ui version="4.0">
<class>ExpressionEditor</class>
<widget class="QMainWindow" name="ExpressionEditor">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>

View file

@ -46,8 +46,6 @@
#include "add_widget_widget.h"
#include "texture_chooser.h"
#include "expression_editor.h"
namespace GUIEditor
{
QString _lastDir;
@ -74,8 +72,6 @@ namespace GUIEditor
widgetInfoTree = new CWidgetInfoTree;
tc = new TextureChooser();
ee = new ExpressionEditor();
ee->load();
createMenus();
readSettings();
@ -124,8 +120,6 @@ namespace GUIEditor
delete tc;
tc = NULL;
delete ee;
ee = NULL;
delete messageProcessor;
messageProcessor = NULL;
@ -371,11 +365,6 @@ namespace GUIEditor
tc->exec();
}
void GUIEditorWindow::onEEClicked()
{
ee->show();
}
void GUIEditorWindow::createMenus()
{
Core::MenuManager *mm = Core::ICore::instance()->menuManager();
@ -426,10 +415,6 @@ namespace GUIEditor
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) );
m->addAction( a );
a = new QAction( "Expression Editor", this );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onEEClicked() ) );
m->addAction( a );
menu = m;
}
}

View file

@ -29,7 +29,6 @@ class QtTreePropertyBrowser;
class QMenu;
class TextureChooser;
class ExpressionEditor;
namespace GUIEditor
{
@ -69,8 +68,6 @@ private Q_SLOTS:
void onAddWidgetClicked();
void onTreeChanged();
void onTCClicked();
void onEEClicked();
protected:
void hideEvent( QHideEvent *evnt );
@ -105,7 +102,6 @@ private:
QMenu *menu;
TextureChooser *tc;
ExpressionEditor *ee;
};
}

View file

@ -18,20 +18,49 @@
#include "link_editor.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
#include "expression_editor.h"
#include <QMenu>
namespace GUIEditor
{
class LinkEditorPvt
{
public:
LinkEditorPvt()
{
ee = new ExpressionEditor();
ee->load();
}
~LinkEditorPvt()
{
delete ee;
ee = NULL;
}
ExpressionEditor *ee;
};
LinkEditor::LinkEditor( QWidget *parent ) :
QWidget( parent )
{
setupUi( this );
setup();
m_pvt = new LinkEditorPvt();
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKButtonClicked() ) );
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
connect( expressionEdit, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( onTextEditContextMenu( const QPoint& ) ) );
connect( m_pvt->ee, SIGNAL( closing() ), this, SLOT( onEEClosing() ) );
}
LinkEditor::~LinkEditor()
{
delete m_pvt;
m_pvt = NULL;
}
void LinkEditor::setup()
@ -89,4 +118,23 @@ namespace GUIEditor
hide();
}
void LinkEditor::onTextEditContextMenu( const QPoint &pos )
{
QMenu *menu = expressionEdit->createStandardContextMenu();
QAction *a = menu->addAction( "Expression Editor" );
connect( a, SIGNAL( triggered() ), this, SLOT( onEE() ) );
menu->exec( mapToGlobal( pos ) );
}
void LinkEditor::onEE()
{
m_pvt->ee->show();
}
void LinkEditor::onEEClosing()
{
expressionEdit->setPlainText( m_pvt->ee->result() );
}
}

View file

@ -23,6 +23,8 @@
namespace GUIEditor
{
class LinkEditorPvt;
class LinkEditor : public QWidget, public Ui::LinkEditor
{
Q_OBJECT
@ -38,9 +40,13 @@ namespace GUIEditor
private Q_SLOTS:
void onOKButtonClicked();
void onTextEditContextMenu( const QPoint &pos );
void onEE();
void onEEClosing();
private:
uint32 currentLinkId;
LinkEditorPvt *m_pvt;
};
}

View file

@ -26,6 +26,9 @@
</item>
<item row="1" column="0" colspan="3">
<widget class="QPlainTextEdit" name="expressionEdit">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="plainText">
<string/>
</property>