From a04280c7ef1989e619f914eedfb6e7436c6c1841 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 4 Jul 2012 06:27:40 +0200 Subject: [PATCH] ADDED: #1471 The first GUI editor widget, with some test data. Altough it's for verification purposes only, so later it will be removed. http://www.youtube.com/watch?v=CpcUp1RcsMQ --- .../src/plugins/gui_editor/CMakeLists.txt | 4 +- .../plugins/gui_editor/gui_editor_window.cpp | 15 +++ .../plugins/gui_editor/gui_editor_window.h | 5 +- .../plugins/gui_editor/widget_properties.cpp | 111 ++++++++++++++++++ .../plugins/gui_editor/widget_properties.h | 41 +++++++ .../plugins/gui_editor/widget_properties.ui | 84 +++++++++++++ 6 files changed, 257 insertions(+), 3 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt index 769561d34..9a24e2c3f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -9,8 +9,8 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) -SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h ) -SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui ) +SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h widget_properties.h ) +SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui widget_properties.ui ) SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTOPENGL TRUE) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index bd0b97d14..6faca8363 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -19,12 +19,16 @@ #include "../core/icore.h" #include "../core/core_constants.h" +#include "../core/core.h" +#include "../core/menu_manager.h" #include #include #include +#include "widget_properties.h" + namespace GUIEditor { QString _lastDir; @@ -34,6 +38,7 @@ namespace GUIEditor { m_ui.setupUi(this); m_undoStack = new QUndoStack(this); + widgetProps = new CWidgetProperties; createMenus(); readSettings(); } @@ -41,6 +46,8 @@ namespace GUIEditor GUIEditorWindow::~GUIEditorWindow() { writeSettings(); + delete widgetProps; + widgetProps = NULL; } QUndoStack *GUIEditorWindow::undoStack() const @@ -66,6 +73,14 @@ namespace GUIEditor void GUIEditorWindow::createMenus() { + Core::MenuManager *mm = Core::ICore::instance()->menuManager(); + QMenu *menu = mm->menu( Core::Constants::M_TOOLS ); + if( menu != NULL ) + { + QAction *a = new QAction( "Widget Properties", this ); + connect( a, SIGNAL( triggered( bool ) ), widgetProps, SLOT( show() ) ); + menu->addAction( a ); + } } void GUIEditorWindow::readSettings() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index 943a21655..a6883aa2f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -18,11 +18,13 @@ #define GUI_EDITOR_WINDOW_H #include "ui_gui_editor_window.h" - #include namespace GUIEditor { + + class CWidgetProperties; + class GUIEditorWindow: public QMainWindow { Q_OBJECT @@ -50,6 +52,7 @@ private: QUndoStack *m_undoStack; Ui::GUIEditorWindow m_ui; + CWidgetProperties *widgetProps; }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp new file mode 100644 index 000000000..053f77d20 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp @@ -0,0 +1,111 @@ +// Object Viewer Qt GUI Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "widget_properties.h" +#include +#include + +namespace +{ + struct SPropEntry + { + std::string propName; + std::string propType; + std::string propDefault; + + static SPropEntry create( const char *propname, const char *proptype, const char *propdefault ) + { + SPropEntry entry; + entry.propName = propname; + entry.propType = proptype; + entry.propDefault = propdefault; + return entry; + } + }; + + std::map< std::string, std::vector< SPropEntry > > props; +} + +namespace GUIEditor{ + + CWidgetProperties::CWidgetProperties( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + + widgetList->addItem( QString( "InterfaceElement" ) ); + widgetList->addItem( QString( "CtrlBase" ) ); + + props[ "InterfaceElement" ] = std::vector< SPropEntry >(); + props[ "CtrlBase" ] = std::vector< SPropEntry >(); + + std::map< std::string, std::vector< SPropEntry > >::iterator itr = + props.find( "InterfaceElement" ); + if( itr != props.end() ) + { + itr->second.push_back( SPropEntry::create( "id", "string", "ie" ) ); + itr->second.push_back( SPropEntry::create( "active", "bool", "false" ) ); + } + + itr = props.find( "CtrlBase" ); + if( itr != props.end() ) + { + itr->second.push_back( SPropEntry::create( "on_tooltip", "string", "tooltip" ) ); + itr->second.push_back( SPropEntry::create( "on_tooltip_params", "string", "params" ) ); + } + + connect( closeButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) ); + connect( widgetList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onListSelectionChanged( int ) ) ); + + } + + CWidgetProperties::~CWidgetProperties() + { + } + + void CWidgetProperties::onListSelectionChanged( int i ) + { + if( i >= widgetList->count() ) + return; + + QListWidgetItem *item = widgetList->item( i ); + setPropsOf( item->text().toStdString().c_str() ); + } + + void CWidgetProperties::setPropsOf( const char *name ) + { + std::map< std::string, std::vector< SPropEntry > >::iterator itr = + props.find( name ); + + if( itr == props.end() ) + return; + + widgetPropTree->clear(); + + std::vector< SPropEntry > &v = itr->second; + for( std::vector< SPropEntry >::iterator itr2 = v.begin(); itr2 != v.end(); ++itr2 ) + { + SPropEntry e = *itr2; + QTreeWidgetItem *item = new QTreeWidgetItem; + item->setText( 0, e.propName.c_str() ); + item->setText( 1, e.propType.c_str() ); + item->setText( 2, e.propDefault.c_str() ); + widgetPropTree->addTopLevelItem( item ); + } + } +} + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h new file mode 100644 index 000000000..c691806a2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h @@ -0,0 +1,41 @@ +// Object Viewer Qt GUI Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef WIDGETPROPS_H +#define WIDGETPROPS_H + +#include "ui_widget_properties.h" + +namespace GUIEditor +{ + class CWidgetProperties : public QWidget, public Ui::WidgetProperties + { + Q_OBJECT + + public: + CWidgetProperties( QWidget *parent = NULL ); + ~CWidgetProperties(); + + private Q_SLOTS: + void onListSelectionChanged( int i ); + + private: + void setPropsOf( const char *name ); + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui new file mode 100644 index 000000000..be65f5276 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui @@ -0,0 +1,84 @@ + + + WidgetProperties + + + + 0 + 0 + 618 + 308 + + + + Widget Properties + + + + + + + + + + + + Property + + + + + Type + + + + + Value + + + + + + + + + + Qt::Vertical + + + + 20 + 56 + + + + + + + + + + Qt::Horizontal + + + + 428 + 20 + + + + + + + + Close + + + + + + + + + +