Moved the Expression Editor to it's right place.

This commit is contained in:
dfighter1985 2014-09-17 19:19:43 +02:00
parent e7f9487800
commit 8ca98c91e9
8 changed files with 73 additions and 21 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,20 +18,49 @@
#include "link_editor.h" #include "link_editor.h"
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h" #include "nel/gui/widget_manager.h"
#include "expression_editor.h"
#include <QMenu>
namespace GUIEditor namespace GUIEditor
{ {
class LinkEditorPvt
{
public:
LinkEditorPvt()
{
ee = new ExpressionEditor();
ee->load();
}
~LinkEditorPvt()
{
delete ee;
ee = NULL;
}
ExpressionEditor *ee;
};
LinkEditor::LinkEditor( QWidget *parent ) : LinkEditor::LinkEditor( QWidget *parent ) :
QWidget( parent ) QWidget( parent )
{ {
setupUi( this ); setupUi( this );
setup(); setup();
m_pvt = new LinkEditorPvt();
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKButtonClicked() ) ); connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKButtonClicked() ) );
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); 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() LinkEditor::~LinkEditor()
{ {
delete m_pvt;
m_pvt = NULL;
} }
void LinkEditor::setup() void LinkEditor::setup()
@ -89,4 +118,23 @@ namespace GUIEditor
hide(); 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 namespace GUIEditor
{ {
class LinkEditorPvt;
class LinkEditor : public QWidget, public Ui::LinkEditor class LinkEditor : public QWidget, public Ui::LinkEditor
{ {
Q_OBJECT Q_OBJECT
@ -35,12 +37,16 @@ namespace GUIEditor
Q_SIGNALS: Q_SIGNALS:
void okClicked(); void okClicked();
private Q_SLOTS: private Q_SLOTS:
void onOKButtonClicked(); void onOKButtonClicked();
void onTextEditContextMenu( const QPoint &pos );
void onEE();
void onEEClosing();
private: private:
uint32 currentLinkId; uint32 currentLinkId;
LinkEditorPvt *m_pvt;
}; };
} }

View file

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