diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index 467b00876..945e0825f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -6,6 +6,7 @@ ADD_SUBDIRECTORY(log) ADD_SUBDIRECTORY(disp_sheet_id) ADD_SUBDIRECTORY(object_viewer) ADD_SUBDIRECTORY(georges_editor) +ADD_SUBDIRECTORY(gui_editor) ADD_SUBDIRECTORY(translation_manager) ADD_SUBDIRECTORY(bnp_manager) # Note: Temporarily disabled until development continues. 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 new file mode 100644 index 000000000..a1e1c5727 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -0,0 +1,72 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) + +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${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 + widget_properties.h + widget_hierarchy.h + action_editor.h + link_editor.h + proc_editor.h + property_browser_ctrl.h + ) + +SET(OVQT_PLUGIN_GUI_EDITOR_UIS + gui_editor_window.ui + widget_properties.ui + widget_hierarchy.ui + action_editor.ui + link_editor.ui + proc_editor.ui + ) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_ADD_RESOURCES(OVQT_PLUGIN_GUI_EDITOR_RC_SRCS ${OVQT_PLUGIN_GUI_EDITOR_RCS}) +QT4_WRAP_CPP(OVQT_PLUGIN_GUI_EDITOR_MOC_SRC ${OVQT_PLUGIN_GUI_EDITOR_HDR}) +QT4_WRAP_UI(OVQT_PLUGIN_GUI_EDITOR_UI_HDRS ${OVQT_PLUGIN_GUI_EDITOR_UIS}) + +SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_GUI_EDITOR_UIS}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_GUI_EDITOR_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_GUI_EDITOR_MOC_SRC} OVQT_PLUGIN_GUI_EDITOR_RC_SRCS) +SOURCE_GROUP("GUI Editor Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_gui_editor MODULE ${SRC} + ${OVQT_PLUGIN_GUI_EDITOR_MOC_SRC} + ${OVQT_EXT_SYS_SRC} + ${OVQT_PLUGIN_GUI_EDITOR_UI_HDRS} + ${OVQT_PLUGIN_GUI_EDITOR_RC_SRCS} + ) + +TARGET_LINK_LIBRARIES( + ovqt_plugin_gui_editor + ovqt_plugin_core + nelmisc + nel3d + nelgui + ${QT_LIBRARIES} + ${QT_QTOPENGL_LIBRARY} + qt_property_browser + ${LUA_LIBRARIES} + ${LUABIND_LIBRARIES} + ) + +NL_DEFAULT_PROPS(ovqt_plugin_gui_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: GUI Editor") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_gui_editor) +NL_ADD_LIB_SUFFIX(ovqt_plugin_gui_editor) + +ADD_DEFINITIONS(-DGUI_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_gui_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp new file mode 100644 index 000000000..abcfe1ec5 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp @@ -0,0 +1,32 @@ +// 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 "action_editor.h" + +namespace GUIEditor +{ + ActionEditor::ActionEditor( QWidget *parent ) + { + setupUi( this ); + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + } + + ActionEditor::~ActionEditor() + { + } +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h new file mode 100644 index 000000000..6d2128c7d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h @@ -0,0 +1,34 @@ +// 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 ACTION_EDITOR_H +#define ACTION_EDITOR_H + +#include "ui_action_editor.h" + +namespace GUIEditor +{ + class ActionEditor : public QWidget, public Ui::ActionEditor + { + Q_OBJECT + public: + ActionEditor( QWidget *parent = NULL ); + ~ActionEditor(); + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui new file mode 100644 index 000000000..e9d0188d9 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui @@ -0,0 +1,88 @@ + + + ActionEditor + + + + 0 + 0 + 340 + 111 + + + + Action Editor + + + + + + + + Handler + + + + + + + Handler + + + + + + + Parameters + + + + + + + Parameters + + + + + + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + Qt::Horizontal + + + + 38 + 20 + + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h new file mode 100644 index 000000000..2c50d9453 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h @@ -0,0 +1,33 @@ +// 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 GUI_EDITOR_CONSTANTS_H +#define GUI_EDITOR_CONSTANTS_H + +namespace GUIEditor +{ + namespace Constants + { + + const char * const GUI_EDITOR_PLUGIN = "GUIEditor"; + const char * const GUI_EDITOR_SECTION = "GUIEditor"; + + } + +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp new file mode 100644 index 000000000..32dba0e25 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp @@ -0,0 +1,46 @@ +// 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 "gui_editor_context.h" +#include "gui_editor_window.h" + +namespace GUIEditor +{ + GUIEditorContext::GUIEditorContext(QObject *parent) : + IContext(parent), + m_guiEditorWindow(0) + { + m_guiEditorWindow = new GUIEditorWindow(); + } + + QUndoStack *GUIEditorContext::undoStack() + { + return m_guiEditorWindow->undoStack(); + } + + void GUIEditorContext::open() + { + m_guiEditorWindow->open(); + } + + QWidget *GUIEditorContext::widget() + { + return m_guiEditorWindow; + } + +} + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h new file mode 100644 index 000000000..39c521cdf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h @@ -0,0 +1,56 @@ +// 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 GUI_EDITOR_CONTEXT_H +#define GUI_EDITOR_CONTEXT_H + +#include "../core/icontext.h" + +#include "nel/misc/app_context.h" + +#include +#include + +namespace GUIEditor +{ + class GUIEditorWindow; + + class GUIEditorContext: public Core::IContext + { + Q_OBJECT + public: + GUIEditorContext(QObject *parent = 0); + virtual ~GUIEditorContext() {} + + virtual QString id() const{ return QLatin1String("GUIEditorContext"); } + + virtual QString trName() const{ return tr("GUI Editor"); } + + virtual QIcon icon() const{ return QIcon(); } + + virtual void open(); + + virtual QUndoStack *undoStack(); + + virtual QWidget *widget(); + + GUIEditorWindow *m_guiEditorWindow; + }; + +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h new file mode 100644 index 000000000..82ca563a6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h @@ -0,0 +1,30 @@ +// 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 GUI_EDITOR_GLOBAL_H +#define GUI_EDITOR_GLOBAL_H + +#include + +#if defined( GUI_EDITOR_LIBRARY ) +# define GUI_EDITOR_EXPORT Q_DECL_EXPORT +#else +# define GUI_EDITOR_EXPORT Q_DECL_IMPORT +#endif + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp new file mode 100644 index 000000000..d135dde9a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp @@ -0,0 +1,76 @@ +// 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 "gui_editor_plugin.h" +#include "gui_editor_window.h" +#include "gui_editor_context.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +#include "nel/misc/debug.h" + +#include + +namespace GUIEditor +{ + GUIEditorPlugin::~GUIEditorPlugin() + { + Q_FOREACH(QObject *obj, m_autoReleaseObjects) + { + m_plugMan->removeObject(obj); + } + + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); + } + + bool GUIEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) + { + Q_UNUSED(errorString); + m_plugMan = pluginManager; + addAutoReleasedObject(new GUIEditorContext(this)); + return true; + } + + void GUIEditorPlugin::extensionsInitialized() + { + } + + void GUIEditorPlugin::shutdown() + { + } + + void GUIEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) + { + +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + m_libContext = new NLMISC::CLibraryContext(*nelContext); + } + + void GUIEditorPlugin::addAutoReleasedObject(QObject *obj) + { + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); + } + +} + +Q_EXPORT_PLUGIN(GUIEditor::GUIEditorPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h new file mode 100644 index 000000000..3b9fac2e7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h @@ -0,0 +1,69 @@ +// 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 GUI_EDITOR_PLUGIN_H +#define GUI_EDITOR_PLUGIN_H + +#include "gui_editor_constants.h" +#include "../../extension_system/iplugin.h" +#include "../core/icontext.h" + +#include "nel/misc/app_context.h" + +#include +#include + +namespace NLMISC +{ + class CLibraryContext; +} + +namespace ExtensionSystem +{ + class IPluginSpec; +} + +namespace GUIEditor +{ + class GUIEditorWindow; + + class GUIEditorPlugin : public QObject, public ExtensionSystem::IPlugin + { + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) + public: + virtual ~GUIEditorPlugin(); + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + + void extensionsInitialized(); + + void shutdown(); + + void setNelContext(NLMISC::INelContext *nelContext); + + void addAutoReleasedObject(QObject *obj); + + protected: + NLMISC::CLibraryContext *m_libContext; + + private: + ExtensionSystem::IPluginManager *m_plugMan; + QList m_autoReleaseObjects; + }; +} + +#endif 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 new file mode 100644 index 000000000..566e86fd2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -0,0 +1,145 @@ +// 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 "gui_editor_window.h" +#include "gui_editor_constants.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" +#include "../core/core.h" +#include "../core/menu_manager.h" + +#include + +#include +#include +#include +#include "../../3rdparty/qtpropertybrowser/QtTreePropertyBrowser" + +#include "widget_properties.h" +#include "widget_properties_parser.h" +#include "widget_hierarchy.h" +#include "link_editor.h" +#include "proc_editor.h" + +namespace GUIEditor +{ + QString _lastDir; + std::map< std::string, SWidgetInfo > widgetInfo; + + GUIEditorWindow::GUIEditorWindow(QWidget *parent) : + QMainWindow(parent) + { + m_ui.setupUi(this); + m_undoStack = new QUndoStack(this); + widgetProps = new CWidgetProperties; + linkEditor = new LinkEditor; + procEditor = new ProcEditor; + createMenus(); + readSettings(); + + CWidgetPropParser parser; + + parser.setWidgetPropMap( &widgetInfo ); + parser.parseGUIWidgets(); + widgetProps->setupWidgetInfo( &widgetInfo ); + + QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this ); + dock->setAllowedAreas( Qt::LeftDockWidgetArea ); + WidgetHierarchy *ha = new WidgetHierarchy; + dock->setWidget( ha ); + addDockWidget( Qt::LeftDockWidgetArea, dock ); + + dock = new QDockWidget( "Widget Properties", this ); + dock->setAllowedAreas( Qt::RightDockWidgetArea ); + QtTreePropertyBrowser *tb = new QtTreePropertyBrowser; + browserCtrl.setBrowser( tb ); + browserCtrl.setup(); + dock->setWidget( tb ); + addDockWidget( Qt::RightDockWidgetArea, dock ); + } + + GUIEditorWindow::~GUIEditorWindow() + { + writeSettings(); + + delete widgetProps; + widgetProps = NULL; + + delete linkEditor; + linkEditor = NULL; + + delete procEditor; + procEditor = NULL; + } + + QUndoStack *GUIEditorWindow::undoStack() const + { + return m_undoStack; + } + + void GUIEditorWindow::open() + { + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open GUI XML files"), + _lastDir, + tr("All XML files (*.xml)")); + + setCursor(Qt::WaitCursor); + if(!fileNames.isEmpty()) + { + QStringList list = fileNames; + _lastDir = QFileInfo(list.front()).absolutePath(); + } + setCursor(Qt::ArrowCursor); + } + + + 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 ); + + a = new QAction( "Link Editor", this ); + connect( a, SIGNAL( triggered( bool ) ), linkEditor, SLOT( show() ) ); + menu->addAction( a ); + + a = new QAction( "Proc Editor", this ); + connect( a, SIGNAL( triggered( bool ) ), procEditor, SLOT( show() ) ); + menu->addAction( a ); + } + } + + void GUIEditorWindow::readSettings() + { + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::GUI_EDITOR_SECTION); + settings->endGroup(); + } + + void GUIEditorWindow::writeSettings() + { + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::GUI_EDITOR_SECTION); + settings->endGroup(); + settings->sync(); + } +} 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 new file mode 100644 index 000000000..25f454fb4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -0,0 +1,76 @@ +// 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 GUI_EDITOR_WINDOW_H +#define GUI_EDITOR_WINDOW_H + +#include "ui_gui_editor_window.h" +#include +#include +#include +#include "widget_info.h" +#include "property_browser_ctrl.h" + +namespace GUIEditor +{ + + class CWidgetProperties; + class LinkEditor; + class ProcEditor; + + class GUIEditorWindow: public QMainWindow + { + Q_OBJECT +public: + GUIEditorWindow(QWidget *parent = 0); + + ~GUIEditorWindow(); + + QUndoStack *undoStack() const; + + Q_SIGNALS: + +public Q_SLOTS: + void open(); + +private Q_SLOTS: + +private: + void createMenus(); + + void readSettings(); + + void writeSettings(); + + void parseGUIWidgets(); + void parseGUIWidget( const QString &file ); + void parseGUIWidgetXML( QFile &file ); + QString parseGUIWidgetHeader( QXmlStreamReader &reader ); + void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ); + + QUndoStack *m_undoStack; + + Ui::GUIEditorWindow m_ui; + CWidgetProperties *widgetProps; + LinkEditor *linkEditor; + ProcEditor *procEditor; + + CPropBrowserCtrl browserCtrl; + }; + +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui new file mode 100644 index 000000000..6b0a0f7c3 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui @@ -0,0 +1,33 @@ + + + GUIEditorWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp new file mode 100644 index 000000000..7a028f649 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp @@ -0,0 +1,33 @@ +// 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 "link_editor.h" + +namespace GUIEditor +{ + LinkEditor::LinkEditor( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + } + + LinkEditor::~LinkEditor() + { + } +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h new file mode 100644 index 000000000..93b7fb348 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h @@ -0,0 +1,35 @@ +// 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 LINK_EDITOR_H +#define LINK_EDITOR_H + +#include "ui_link_editor.h" + +namespace GUIEditor +{ + class LinkEditor : public QWidget, public Ui::LinkEditor + { + Q_OBJECT + public: + LinkEditor( QWidget *parent = NULL ); + ~LinkEditor(); + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui new file mode 100644 index 000000000..af2c24f72 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui @@ -0,0 +1,101 @@ + + + LinkEditor + + + + 0 + 0 + 545 + 340 + + + + Link Editor + + + + + + Expression + + + + + + + expression + + + + + + + When the condition is met + + + + + + + Activate group + + + + + + + Run Action Handler + + + + + + + Group or action handler + + + + + + + Action Handler parameters + + + + + + + + + Qt::Horizontal + + + + 348 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml new file mode 100644 index 000000000..987a43432 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml @@ -0,0 +1,10 @@ + + ovqt_plugin_gui_editor + GUI Editor + 0.0.1 + Ryzom Core + GUI Editor plugin. + + + + \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp new file mode 100644 index 000000000..c9c728603 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp @@ -0,0 +1,39 @@ +// 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 "proc_editor.h" +#include "action_editor.h" + + +namespace GUIEditor +{ + ProcEditor::ProcEditor( QWidget *parent ) + { + setupUi( this ); + actionEditor = new ActionEditor; + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( editButton, SIGNAL( clicked( bool ) ), actionEditor, SLOT( show() ) ); + + } + + ProcEditor::~ProcEditor() + { + delete actionEditor; + actionEditor = NULL; + } +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h new file mode 100644 index 000000000..b7ee0bff2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h @@ -0,0 +1,40 @@ +// 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 PROC_EDITOR_H +#define PROC_EDITOR_H + +#include "ui_proc_editor.h" + +namespace GUIEditor +{ + class ActionEditor; + + class ProcEditor : public QWidget, public Ui::ProcEditor + { + Q_OBJECT + public: + ProcEditor( QWidget *parent = NULL ); + ~ProcEditor(); + + private: + ActionEditor *actionEditor; + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui new file mode 100644 index 000000000..f8c17af54 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui @@ -0,0 +1,115 @@ + + + ProcEditor + + + + 0 + 0 + 424 + 327 + + + + Proc Editor + + + + + + + action1 + + + + + action2 + + + + + action3 + + + + + + + + Move Up + + + + + + + Move Down + + + + + + + Add + + + + + + + Remove + + + + + + + Edit + + + + + + + Qt::Vertical + + + + 20 + 132 + + + + + + + + OK + + + + + + + Cancel + + + + + + + Qt::Horizontal + + + + 197 + 20 + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp new file mode 100644 index 000000000..3a8dafd99 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -0,0 +1,65 @@ +// 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 "property_browser_ctrl.h" +#include "../../3rdparty/qtpropertybrowser/QtVariantPropertyManager" +#include "../../3rdparty/qtpropertybrowser/QtTreePropertyBrowser" + +namespace GUIEditor +{ + CPropBrowserCtrl::CPropBrowserCtrl() + { + browser = NULL; + propertyMgr = new QtVariantPropertyManager; + } + + CPropBrowserCtrl::~CPropBrowserCtrl() + { + delete propertyMgr; + propertyMgr = NULL; + browser = NULL; + } + + void CPropBrowserCtrl::setBrowser( QtTreePropertyBrowser *b ) + { + browser = b; + } + + void CPropBrowserCtrl::setup() + { + if( browser == NULL ) + return; + + QtVariantProperty *p; + + p = propertyMgr->addProperty( QVariant::String, "Id" ); + p->setValue( "ExampleId" ); + browser->addProperty( p ); + + p = propertyMgr->addProperty( QVariant::Bool, "Active" ); + p->setValue( true ); + browser->addProperty( p ); + + p = propertyMgr->addProperty( QVariant::String, "on_enter" ); + p->setValue( "on_enter_handler" ); + browser->addProperty( p ); + + p = propertyMgr->addProperty( QVariant::String, "on_enter_params" ); + p->setValue( "someparams" ); + browser->addProperty( p ); + } +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h new file mode 100644 index 000000000..f8549205a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h @@ -0,0 +1,48 @@ +// 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 PROP_BROWSER_CTRL +#define PROP_BROWSER_CTRL + +#include + +class QtTreePropertyBrowser; +class QtVariantPropertyManager; + +namespace GUIEditor +{ + + /// This class controls the Widget property browser widget. + /// It receives signals from the widget that draws/manages the Nel GUI widgets, and handles them. + class CPropBrowserCtrl : public QObject + { + Q_OBJECT + + public: + CPropBrowserCtrl(); + ~CPropBrowserCtrl(); + void setBrowser( QtTreePropertyBrowser *b ); + void setup(); + + private: + QtTreePropertyBrowser *browser; + QtVariantPropertyManager *propertyMgr; + }; + +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp new file mode 100644 index 000000000..6bcd5cf0a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp @@ -0,0 +1,31 @@ +// 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_hierarchy.h" + +namespace GUIEditor +{ + WidgetHierarchy::WidgetHierarchy( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + } + + WidgetHierarchy::~WidgetHierarchy() + { + } +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h new file mode 100644 index 000000000..17fde2c29 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h @@ -0,0 +1,34 @@ +// 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 WIDGET_HA_H +#define WIDGET_HA_H + +#include "ui_widget_hierarchy.h" + +namespace GUIEditor +{ + class WidgetHierarchy : public QWidget, public Ui::WidgetHierarchyTree + { + Q_OBJECT + public: + WidgetHierarchy( QWidget *parent = NULL ); + ~WidgetHierarchy(); + + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui new file mode 100644 index 000000000..d0c1d9db5 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui @@ -0,0 +1,90 @@ + + + WidgetHierarchyTree + + + + 0 + 0 + 497 + 434 + + + + Widget Hieararchy + + + + + + + Widgets + + + + + root + + + + container1 + + + + group1 + + + + group3 + + + + + group4 + + + + button1 + + + + + button2 + + + + + text1 + + + + + bitmap1 + + + + + + + group2 + + + + + + container2 + + + + + container3 + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h new file mode 100644 index 000000000..684cbc8ca --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h @@ -0,0 +1,62 @@ +// 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 WIDGET_INFO_H +#define WIDGET_INFO_H + +#include +#include + +namespace GUIEditor +{ + 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; + } + }; + + struct SWidgetInfo + { + std::string name; + std::string GUIName; + std::string ancestor; + std::string description; + bool isAbstract; + std::string icon; + bool resolved; + + std::vector< SPropEntry > props; + + SWidgetInfo() + { + resolved = false; + isAbstract = true; + } + }; +} + +#endif 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..802dcd591 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp @@ -0,0 +1,74 @@ +// 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" + +namespace GUIEditor{ + CWidgetProperties::CWidgetProperties( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + connect( closeButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) ); + } + + CWidgetProperties::~CWidgetProperties() + { + } + + void CWidgetProperties::setupWidgetInfo( std::map< std::string, SWidgetInfo > *info ) + { + widgetInfo = info; + for( std::map< std::string, SWidgetInfo >::iterator itr = info->begin(); itr != info->end(); ++itr ){ + widgetList->addItem( itr->first.c_str() ); + } + + onListSelectionChanged( 0 ); + connect( widgetList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onListSelectionChanged( int ) ) ); + } + + 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, SWidgetInfo >::iterator itr = + widgetInfo->find( name ); + + if( itr == widgetInfo->end() ) + return; + + widgetPropTree->clear(); + + std::vector< SPropEntry > &v = itr->second.props; + 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..4ab026401 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h @@ -0,0 +1,47 @@ +// 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" +#include "widget_info.h" +#include +#include +#include + +namespace GUIEditor +{ + class CWidgetProperties : public QWidget, public Ui::WidgetProperties + { + Q_OBJECT + + public: + CWidgetProperties( QWidget *parent = NULL ); + ~CWidgetProperties(); + void setupWidgetInfo( std::map< std::string, SWidgetInfo > *info ); + + private Q_SLOTS: + void onListSelectionChanged( int i ); + + private: + void setPropsOf( const char *name ); + std::map< std::string, SWidgetInfo > *widgetInfo; + }; +} + +#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 + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp new file mode 100644 index 000000000..dc2b016c7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp @@ -0,0 +1,272 @@ +// 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_parser.h" +#include +#include +#include "nel/misc/debug.h" + +using namespace NLMISC; + +namespace GUIEditor +{ + void CWidgetPropParser::parseGUIWidgets() + { + QDir d( "widgets" ); + if( !d.exists() ) + { + nlwarning( "GUI widgets directory doesn't exist!" ); + return; + } + + QStringList nameFilters; + nameFilters.push_back( "*.xml" ); + + QStringList files = d.entryList( nameFilters, QDir::Files ); + if( files.empty() ) + { + nlwarning( "GUI widgets directory has no files!" ); + return; + } + + QStringListIterator itr( files ); + while( itr.hasNext() ) + parseGUIWidget( "widgets/" + itr.next() ); + + resolveInheritance(); + + widgetInfo = NULL; + } + + void CWidgetPropParser::parseGUIWidget( const QString &file ) + { + QFile f( file ); + if( f.open( QIODevice::ReadOnly ) ) + { + parseGUIWidgetXML( f ); + f.close(); + } + else + nlwarning( QString( "File %1 cannot be opened!" ).arg( file ).toStdString().c_str() ); + } + + void CWidgetPropParser::parseGUIWidgetXML( QFile &file ) + { + QXmlStreamReader reader; + reader.setDevice( &file ); + + reader.readNext(); + if( reader.atEnd() ) + return; + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "widget" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "header" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + QString name = parseGUIWidgetHeader( reader ); + if( name.isEmpty() ) + { + nlwarning( "malformed XML." ); + return; + } + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "properties" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + parseGUIWidgetProperties( reader, name ); + } + + QString CWidgetPropParser::parseGUIWidgetHeader( QXmlStreamReader &reader ) + { + reader.readNext(); + if( reader.atEnd() ) + return QString( "" ); + + SWidgetInfo info; + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "header" ) ) ) + { + if( reader.isStartElement() ) + { + QString key = reader.name().toString(); + QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + + if( !reader.hasError() ) + { + if( key == "name" ) + info.name = value.toStdString(); + else + if( key == "guiname" ) + info.GUIName = value.toStdString(); + else + if( key == "ancestor" ) + info.ancestor = value.toStdString(); + else + if( key == "description" ) + info.description = value.toStdString(); + else + if( key == "icon" ) + info.icon == value.toStdString(); + else + if( key == "abstract" ) + { + info.isAbstract = false; + if( value == "true" ) + info.isAbstract = true; + } + else + nlwarning( "Malformed XML." ); + } + } + + reader.readNext(); + } + if( reader.atEnd() ) + return QString( "" ); + if( info.name.empty() ) + return QString( "" ); + + (*widgetInfo)[ info.name.c_str() ] = info; + return QString( info.name.c_str() ); + } + + void CWidgetPropParser::parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ) + { + reader.readNext(); + if( reader.atEnd() ) + return; + + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo->find( widgetName.toStdString() ); + if( itr == widgetInfo->end() ) + return; + + std::vector< SPropEntry > &v = itr->second.props; + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "properties" ) ) ) + { + if( reader.isStartElement() && reader.name() == "property" ) + { + SPropEntry prop; + reader.readNext(); + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "property" ) ) ) + { + if( reader.isStartElement() ) + { + QString key = reader.name().toString(); + QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + + if( !reader.hasError() ) + { + if( key == "name" ) + prop.propName = value.toStdString(); + else + if( key == "type" ) + prop.propType = value.toStdString(); + else + if( key == "default" ) + prop.propDefault = value.toStdString(); + else + nlwarning( QString( "Unknown tag %1 within a property" ).arg( key ).toStdString().c_str() ); + + } + else + nlwarning( "Malformed XML." ); + } + + reader.readNext(); + } + if( reader.atEnd() ) + return; + + v.push_back( prop ); + } + + reader.readNext(); + } + } + + bool propCompare( const SPropEntry &left, const SPropEntry &right ) + { + return left.propName < right.propName; + } + + void CWidgetPropParser::resolveInheritance() + { + for( std::map< std::string, SWidgetInfo >::iterator itr = widgetInfo->begin(); itr != widgetInfo->end(); ++itr ) + { + resolveInheritanceFor( itr->first ); + std::sort( itr->second.props.begin(), itr->second.props.end(), propCompare ); + } + + } + + void CWidgetPropParser::resolveInheritanceFor( const std::string name ) + { + if( name.empty() ) + return; + + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo->find( name ); + if( itr == widgetInfo->end() ) + return; + + SWidgetInfo *info = &(itr->second); + if( info->resolved ) + return; + + if( info->ancestor.empty() ) + return; + + std::vector< SPropEntry > &props = info->props; + + std::map< std::string, SWidgetInfo >::iterator itr2 = + widgetInfo->find( info->ancestor ); + if( itr2 == widgetInfo->end() ) + return; + SWidgetInfo *info2 = &(itr2->second); + + do + { + for( std::vector< SPropEntry >::iterator propItr = info2->props.begin(); propItr != info2->props.end(); ++propItr ) + props.push_back( *propItr ); + + if( !info2->resolved && !info2->ancestor.empty() ) + { + itr2 = widgetInfo->find( info2->ancestor ); + if( itr2 != widgetInfo->end() ) + info2 = &(itr2->second); + else + info2 = NULL; + } + } + while( ( info2 != NULL ) && !info2->resolved && !info2->ancestor.empty() ); + + info->resolved = true; + } +} + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h new file mode 100644 index 000000000..4dcbffacf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h @@ -0,0 +1,51 @@ +// 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 WIDGET_PROP_PARSER +#define WIDGET_PROP_PARSER + +#include "widget_info.h" +#include +#include +#include +#include + +namespace GUIEditor +{ + /// Parser for the widget properties XML files + class CWidgetPropParser + { + public: + CWidgetPropParser(){} + ~CWidgetPropParser(){} + + void setWidgetPropMap( std::map< std::string, SWidgetInfo > *info ){ widgetInfo = info; } + void parseGUIWidgets(); + + private: + void parseGUIWidget( const QString &file ); + void parseGUIWidgetXML( QFile &file ); + QString parseGUIWidgetHeader( QXmlStreamReader &reader ); + void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ); + void resolveInheritance(); + void resolveInheritanceFor( const std::string name ); + + std::map< std::string, SWidgetInfo > *widgetInfo; + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml new file mode 100644 index 000000000..809ccacfd --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml @@ -0,0 +1,22 @@ + +
+ CtrlBase + cb + InterfaceElement + + true + +
+ + + on_tooltip + string + handler + + + on_tooltip_params + string + params + + +
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml new file mode 100644 index 000000000..e8a3f0aa2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml @@ -0,0 +1,21 @@ + +
+ InterfaceElement + ie + + true + +
+ + + id + string + ie + + + active + bool + true + + +
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml new file mode 100644 index 000000000..d11ceb180 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml @@ -0,0 +1,22 @@ + +
+ InterfaceGroup + ig + CtrlBase + + false + +
+ + + on_enter + string + handler + + + on_enter_params + string + params + + +