From 8ca98c91e9e71b413d6512454a0f228bcc0c1e76 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 17 Sep 2014 19:19:43 +0200 Subject: [PATCH] Moved the Expression Editor to it's right place. --- .../plugins/gui_editor/expression_editor.cpp | 9 +++- .../plugins/gui_editor/expression_editor.h | 4 ++ .../plugins/gui_editor/expression_editor.ui | 3 ++ .../plugins/gui_editor/gui_editor_window.cpp | 15 ------ .../plugins/gui_editor/gui_editor_window.h | 4 -- .../src/plugins/gui_editor/link_editor.cpp | 48 +++++++++++++++++++ .../src/plugins/gui_editor/link_editor.h | 8 +++- .../src/plugins/gui_editor/link_editor.ui | 3 ++ 8 files changed, 73 insertions(+), 21 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp index 4aba6c4a5..5be3939fd 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.cpp +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -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(); } diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h index 9f7bd6101..ce13ff58e 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.h +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -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(); diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui index 342b2b5f1..fa21420a2 100644 --- a/code/studio/src/plugins/gui_editor/expression_editor.ui +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -2,6 +2,9 @@ ExpressionEditor + + Qt::ApplicationModal + 0 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 2447ac0af..3f4e318db 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -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; } } 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 d0dbe628e..978a8df72 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -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; }; } diff --git a/code/studio/src/plugins/gui_editor/link_editor.cpp b/code/studio/src/plugins/gui_editor/link_editor.cpp index c57a6cd09..3cb49f37a 100644 --- a/code/studio/src/plugins/gui_editor/link_editor.cpp +++ b/code/studio/src/plugins/gui_editor/link_editor.cpp @@ -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 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() ); + } } diff --git a/code/studio/src/plugins/gui_editor/link_editor.h b/code/studio/src/plugins/gui_editor/link_editor.h index b70019d20..f5617982e 100644 --- a/code/studio/src/plugins/gui_editor/link_editor.h +++ b/code/studio/src/plugins/gui_editor/link_editor.h @@ -23,6 +23,8 @@ namespace GUIEditor { + class LinkEditorPvt; + class LinkEditor : public QWidget, public Ui::LinkEditor { Q_OBJECT @@ -35,12 +37,16 @@ namespace GUIEditor Q_SIGNALS: void okClicked(); - + private Q_SLOTS: void onOKButtonClicked(); + void onTextEditContextMenu( const QPoint &pos ); + void onEE(); + void onEEClosing(); private: uint32 currentLinkId; + LinkEditorPvt *m_pvt; }; } diff --git a/code/studio/src/plugins/gui_editor/link_editor.ui b/code/studio/src/plugins/gui_editor/link_editor.ui index 13a6e7d7e..657b0eabc 100644 --- a/code/studio/src/plugins/gui_editor/link_editor.ui +++ b/code/studio/src/plugins/gui_editor/link_editor.ui @@ -26,6 +26,9 @@ + + Qt::CustomContextMenu +