From c3aff5dc6b1e6a54746e4dd09046792db5070f98 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 27 May 2012 21:52:02 +0200 Subject: [PATCH 1/9] ADDED: #1471 OVQT GUI Editor plugin skeleton code. --- .../src/plugins/CMakeLists.txt | 1 + .../src/plugins/gui_editor/CMakeLists.txt | 43 ++++++++ .../plugins/gui_editor/gui_editor_constants.h | 33 ++++++ .../plugins/gui_editor/gui_editor_context.cpp | 46 ++++++++ .../plugins/gui_editor/gui_editor_context.h | 56 ++++++++++ .../plugins/gui_editor/gui_editor_global.h | 30 +++++ .../plugins/gui_editor/gui_editor_plugin.cpp | 103 ++++++++++++++++++ .../plugins/gui_editor/gui_editor_plugin.h | 79 ++++++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 86 +++++++++++++++ .../plugins/gui_editor/gui_editor_window.h | 57 ++++++++++ .../plugins/gui_editor/gui_editor_window.ui | 36 ++++++ .../gui_editor/ovqt_plugin_gui_editor.xml | 7 ++ 12 files changed, 577 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml 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..769561d34 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -0,0 +1,43 @@ +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 ) +SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.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 ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) + +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/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..04088f046 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp @@ -0,0 +1,103 @@ +// 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); + } + + QString GUIEditorPlugin::name() const + { + return tr("GUIEditor"); + } + + QString GUIEditorPlugin::version() const + { + return "0.0.1"; + } + + QString GUIEditorPlugin::vendor() const + { + return "Ryzom Core"; + } + + QString GUIEditorPlugin::description() const + { + return "GUI Editor ovqt plugin."; + } + + QStringList GUIEditorPlugin::dependencies() const + { + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + return list; + } + + 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..20ec0a96e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h @@ -0,0 +1,79 @@ +// 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); + + QString name() const; + + QString version() const; + + QString vendor() const; + + QString description() const; + + QStringList dependencies() const; + + 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..bd0b97d14 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -0,0 +1,86 @@ +// 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 + +#include +#include + +namespace GUIEditor +{ + QString _lastDir; + + GUIEditorWindow::GUIEditorWindow(QWidget *parent) : + QMainWindow(parent) + { + m_ui.setupUi(this); + m_undoStack = new QUndoStack(this); + createMenus(); + readSettings(); + } + + GUIEditorWindow::~GUIEditorWindow() + { + writeSettings(); + } + + 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() + { + } + + 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..943a21655 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -0,0 +1,57 @@ +// 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 + +namespace GUIEditor +{ + 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(); + + QUndoStack *m_undoStack; + + Ui::GUIEditorWindow m_ui; + }; + +} + +#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..baf1f01f4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui @@ -0,0 +1,36 @@ + + + GUIEditorWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + 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..9b4efca08 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml @@ -0,0 +1,7 @@ + + ovqt_plugin_gui_editor + GUI Editor + 0.0.1 + Ryzom Core + GUI Editor plugin. + \ No newline at end of file From 4053fe6f8dfa120a6353ebf82387b2e9d965086a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 27 May 2012 23:35:46 +0200 Subject: [PATCH 2/9] CHANGED: #1471 According to dnk-88 these methods are no longer needed, the XML description file is enough for the plugins. --- .../plugins/gui_editor/gui_editor_plugin.cpp | 29 +------------------ .../plugins/gui_editor/gui_editor_plugin.h | 10 ------- .../gui_editor/ovqt_plugin_gui_editor.xml | 3 ++ 3 files changed, 4 insertions(+), 38 deletions(-) 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 index 04088f046..d135dde9a 100644 --- 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 @@ -64,34 +64,7 @@ namespace GUIEditor #endif // NL_OS_WINDOWS m_libContext = new NLMISC::CLibraryContext(*nelContext); } - - QString GUIEditorPlugin::name() const - { - return tr("GUIEditor"); - } - - QString GUIEditorPlugin::version() const - { - return "0.0.1"; - } - - QString GUIEditorPlugin::vendor() const - { - return "Ryzom Core"; - } - - QString GUIEditorPlugin::description() const - { - return "GUI Editor ovqt plugin."; - } - - QStringList GUIEditorPlugin::dependencies() const - { - QStringList list; - list.append(Core::Constants::OVQT_CORE_PLUGIN); - return list; - } - + void GUIEditorPlugin::addAutoReleasedObject(QObject *obj) { m_plugMan->addObject(obj); 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 index 20ec0a96e..3b9fac2e7 100644 --- 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 @@ -55,16 +55,6 @@ namespace GUIEditor void setNelContext(NLMISC::INelContext *nelContext); - QString name() const; - - QString version() const; - - QString vendor() const; - - QString description() const; - - QStringList dependencies() const; - void addAutoReleasedObject(QObject *obj); protected: 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 index 9b4efca08..987a43432 100644 --- 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 @@ -4,4 +4,7 @@ 0.0.1 Ryzom Core GUI Editor plugin. + + + \ No newline at end of file From a04280c7ef1989e619f914eedfb6e7436c6c1841 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 4 Jul 2012 06:27:40 +0200 Subject: [PATCH 3/9] 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 + + + + + + + + + + From 27fd3ae6337e000c80de2ebcdc0bb375c8df287d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jul 2012 07:22:28 +0200 Subject: [PATCH 4/9] CHANGED: #1471 The GUI widget properties are now read from the GUI XML files ( widget inheritance is not yet supported ). --- .../plugins/gui_editor/gui_editor_window.cpp | 182 +++++++++++++++++- .../plugins/gui_editor/gui_editor_window.h | 8 + .../plugins/gui_editor/widget_properties.cpp | 67 ++----- .../plugins/gui_editor/widget_properties.h | 33 ++++ 4 files changed, 237 insertions(+), 53 deletions(-) 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 6faca8363..b2b53328d 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 @@ -32,6 +32,7 @@ namespace GUIEditor { QString _lastDir; + std::map< std::string, SWidgetInfo > widgetInfo; GUIEditorWindow::GUIEditorWindow(QWidget *parent) : QMainWindow(parent) @@ -41,6 +42,8 @@ namespace GUIEditor widgetProps = new CWidgetProperties; createMenus(); readSettings(); + parseGUIWidgets(); + widgetProps->setupWidgetInfo( &widgetInfo ); } GUIEditorWindow::~GUIEditorWindow() @@ -97,5 +100,182 @@ namespace GUIEditor settings->endGroup(); settings->sync(); } - + + void GUIEditorWindow::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() ); + } + + void GUIEditorWindow::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 GUIEditorWindow::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 GUIEditorWindow::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 == "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 GUIEditorWindow::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(); + } + } } 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 a6883aa2f..8faa6b790 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 @@ -19,6 +19,8 @@ #include "ui_gui_editor_window.h" #include +#include +#include namespace GUIEditor { @@ -49,6 +51,12 @@ private: 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; 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 index 053f77d20..802dcd591 100644 --- 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 @@ -15,67 +15,30 @@ // 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::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() ) @@ -87,15 +50,15 @@ namespace GUIEditor{ void CWidgetProperties::setPropsOf( const char *name ) { - std::map< std::string, std::vector< SPropEntry > >::iterator itr = - props.find( name ); + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo->find( name ); - if( itr == props.end() ) + if( itr == widgetInfo->end() ) return; widgetPropTree->clear(); - std::vector< SPropEntry > &v = itr->second; + std::vector< SPropEntry > &v = itr->second.props; for( std::vector< SPropEntry >::iterator itr2 = v.begin(); itr2 != v.end(); ++itr2 ) { SPropEntry e = *itr2; 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 index c691806a2..9346a6df2 100644 --- 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 @@ -19,9 +19,40 @@ #define WIDGETPROPS_H #include "ui_widget_properties.h" +#include +#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 description; + bool isAbstract; + std::string icon; + + std::vector< SPropEntry > props; + }; + + class CWidgetProperties : public QWidget, public Ui::WidgetProperties { Q_OBJECT @@ -29,12 +60,14 @@ namespace GUIEditor 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; }; } From 7538396dbe23bebc1e54ba89e9afc42f16c66a29 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jul 2012 07:30:41 +0200 Subject: [PATCH 5/9] CHANGED: #1471 Ups, forgot to commit the example XML files. --- .../gui_editor/widgets/ControlBase.xml | 21 +++++++++++++++++++ .../gui_editor/widgets/InterfaceElement.xml | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml 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..3f092e135 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml @@ -0,0 +1,21 @@ + +
+ CtrlBase + cb + + 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 + + +
From 30eef5ddef4d39b915d41514c019e54214c79dac Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jul 2012 08:18:33 +0200 Subject: [PATCH 6/9] CHANGED: #1471 Little bit of refactoring, moved the parser code from GUIEditorWindow to a new class CWidgetPropParser. --- .../plugins/gui_editor/gui_editor_window.cpp | 185 +--------------- .../plugins/gui_editor/gui_editor_window.h | 1 + .../src/plugins/gui_editor/widget_info.h | 54 +++++ .../plugins/gui_editor/widget_properties.h | 29 +-- .../gui_editor/widget_properties_parser.cpp | 208 ++++++++++++++++++ .../gui_editor/widget_properties_parser.h | 49 +++++ 6 files changed, 319 insertions(+), 207 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h 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 b2b53328d..832c39fe9 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 @@ -28,6 +28,7 @@ #include #include "widget_properties.h" +#include "widget_properties_parser.h" namespace GUIEditor { @@ -42,7 +43,11 @@ namespace GUIEditor widgetProps = new CWidgetProperties; createMenus(); readSettings(); - parseGUIWidgets(); + + CWidgetPropParser parser; + + parser.setWidgetPropMap( &widgetInfo ); + parser.parseGUIWidgets(); widgetProps->setupWidgetInfo( &widgetInfo ); } @@ -100,182 +105,4 @@ namespace GUIEditor settings->endGroup(); settings->sync(); } - - void GUIEditorWindow::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() ); - } - - void GUIEditorWindow::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 GUIEditorWindow::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 GUIEditorWindow::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 == "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 GUIEditorWindow::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(); - } - } } 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 8faa6b790..ee0db991b 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 @@ -21,6 +21,7 @@ #include #include #include +#include "widget_info.h" namespace GUIEditor { 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..3fed78733 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h @@ -0,0 +1,54 @@ +// 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 description; + bool isAbstract; + std::string icon; + + std::vector< SPropEntry > props; + }; +} + +#endif 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 index 9346a6df2..4ab026401 100644 --- 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 @@ -19,40 +19,13 @@ #define WIDGETPROPS_H #include "ui_widget_properties.h" +#include "widget_info.h" #include #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 description; - bool isAbstract; - std::string icon; - - std::vector< SPropEntry > props; - }; - - class CWidgetProperties : public QWidget, public Ui::WidgetProperties { Q_OBJECT 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..8f5b64191 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp @@ -0,0 +1,208 @@ +// 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() ); + + 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 == "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(); + } + } +} + + 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..b3dc403ca --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h @@ -0,0 +1,49 @@ +// 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 ); + + std::map< std::string, SWidgetInfo > *widgetInfo; + }; +} + +#endif From 042e9e0000a9af5622ffac9352ca4bdae493ed7e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 6 Jul 2012 03:15:15 +0200 Subject: [PATCH 7/9] CHANGED: #1471 Widget definition inheritance is now supported in the GUI editor. www.youtube.com/watch?v=VG_TnZiGjBk --- .../src/plugins/gui_editor/widget_info.h | 8 +++ .../gui_editor/widget_properties_parser.cpp | 66 ++++++++++++++++++- .../gui_editor/widget_properties_parser.h | 2 + .../gui_editor/widgets/ControlBase.xml | 1 + .../gui_editor/widgets/InterfaceGroup.xml | 22 +++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml 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 index 3fed78733..684cbc8ca 100644 --- 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 @@ -43,11 +43,19 @@ namespace GUIEditor { 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; + } }; } 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 index 8f5b64191..dc2b016c7 100644 --- 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 @@ -47,6 +47,8 @@ namespace GUIEditor while( itr.hasNext() ) parseGUIWidget( "widgets/" + itr.next() ); + resolveInheritance(); + widgetInfo = NULL; } @@ -119,6 +121,9 @@ namespace GUIEditor if( key == "guiname" ) info.GUIName = value.toStdString(); else + if( key == "ancestor" ) + info.ancestor = value.toStdString(); + else if( key == "description" ) info.description = value.toStdString(); else @@ -202,7 +207,66 @@ namespace GUIEditor 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 index b3dc403ca..4dcbffacf 100644 --- 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 @@ -41,6 +41,8 @@ namespace GUIEditor 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; }; 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 index 3f092e135..809ccacfd 100644 --- 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 @@ -2,6 +2,7 @@
CtrlBase cb + InterfaceElement 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 + + +
From aa352b2f30c524281855b818d9d04e73b13b07ab Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 6 Jul 2012 06:10:20 +0200 Subject: [PATCH 8/9] ADDED: #1471 Created ActionEditor, LinkEditor, ProcEditor, WidgetHierarchy dialogs for the GUI editor, altough obviously they are just an empty shell for now. http://www.youtube.com/watch?v=nOhlliU6tCE --- .../src/plugins/gui_editor/CMakeLists.txt | 21 +++- .../src/plugins/gui_editor/action_editor.cpp | 32 +++++ .../src/plugins/gui_editor/action_editor.h | 34 ++++++ .../src/plugins/gui_editor/action_editor.ui | 88 ++++++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 27 ++++ .../plugins/gui_editor/gui_editor_window.h | 4 + .../plugins/gui_editor/gui_editor_window.ui | 7 +- .../src/plugins/gui_editor/link_editor.cpp | 33 +++++ .../src/plugins/gui_editor/link_editor.h | 35 ++++++ .../src/plugins/gui_editor/link_editor.ui | 101 +++++++++++++++ .../src/plugins/gui_editor/proc_editor.cpp | 39 ++++++ .../src/plugins/gui_editor/proc_editor.h | 40 ++++++ .../src/plugins/gui_editor/proc_editor.ui | 115 ++++++++++++++++++ .../plugins/gui_editor/widget_hierarchy.cpp | 31 +++++ .../src/plugins/gui_editor/widget_hierarchy.h | 34 ++++++ .../plugins/gui_editor/widget_hierarchy.ui | 90 ++++++++++++++ 16 files changed, 724 insertions(+), 7 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.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 9a24e2c3f..e9350bbf2 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,25 @@ 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 widget_properties.h ) -SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui widget_properties.ui ) +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 + ) + +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) 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_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 832c39fe9..672df715a 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 @@ -26,9 +26,13 @@ #include #include +#include #include "widget_properties.h" #include "widget_properties_parser.h" +#include "widget_hierarchy.h" +#include "link_editor.h" +#include "proc_editor.h" namespace GUIEditor { @@ -41,6 +45,8 @@ namespace GUIEditor m_ui.setupUi(this); m_undoStack = new QUndoStack(this); widgetProps = new CWidgetProperties; + linkEditor = new LinkEditor; + procEditor = new ProcEditor; createMenus(); readSettings(); @@ -49,13 +55,26 @@ namespace GUIEditor 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 ); } GUIEditorWindow::~GUIEditorWindow() { writeSettings(); + delete widgetProps; widgetProps = NULL; + + delete linkEditor; + linkEditor = NULL; + + delete procEditor; + procEditor = NULL; } QUndoStack *GUIEditorWindow::undoStack() const @@ -88,6 +107,14 @@ namespace GUIEditor 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 ); } } 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 ee0db991b..0418a12e5 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 @@ -27,6 +27,8 @@ namespace GUIEditor { class CWidgetProperties; + class LinkEditor; + class ProcEditor; class GUIEditorWindow: public QMainWindow { @@ -62,6 +64,8 @@ private: Ui::GUIEditorWindow m_ui; CWidgetProperties *widgetProps; + LinkEditor *linkEditor; + ProcEditor *procEditor; }; } 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 index baf1f01f4..6b0a0f7c3 100644 --- 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 @@ -14,11 +14,7 @@ MainWindow - - - - - + @@ -32,5 +28,6 @@ + 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/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/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 + + + + + + + + + + From c641c67c8e90c554dbd5f9169208fa2ea2f77600 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 7 Jul 2012 05:01:32 +0200 Subject: [PATCH 9/9] ADDED: #1471 Qt property browser, for browsing and editing the selected widget's properties ( this is an empty shell as well for now ) --- .../src/plugins/gui_editor/CMakeLists.txt | 3 +- .../plugins/gui_editor/gui_editor_window.cpp | 10 +++ .../plugins/gui_editor/gui_editor_window.h | 3 + .../gui_editor/property_browser_ctrl.cpp | 65 +++++++++++++++++++ .../gui_editor/property_browser_ctrl.h | 48 ++++++++++++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h 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 e9350bbf2..4d2aebd0b 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 @@ -18,6 +18,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR action_editor.h link_editor.h proc_editor.h + property_browser_ctrl.h ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS @@ -49,7 +50,7 @@ ADD_LIBRARY(ovqt_plugin_gui_editor MODULE ${SRC} ${OVQT_PLUGIN_GUI_EDITOR_RC_SRCS} ) -TARGET_LINK_LIBRARIES(ovqt_plugin_gui_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) +TARGET_LINK_LIBRARIES(ovqt_plugin_gui_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} qt_property_browser) NL_DEFAULT_PROPS(ovqt_plugin_gui_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: GUI Editor") NL_ADD_RUNTIME_FLAGS(ovqt_plugin_gui_editor) 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 672df715a..094d780be 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 @@ -27,6 +27,7 @@ #include #include #include +#include "../../3rdparty/qtpropertybrowser/QtTreePropertyBrowser" #include "widget_properties.h" #include "widget_properties_parser.h" @@ -61,6 +62,15 @@ namespace GUIEditor 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() 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 0418a12e5..25f454fb4 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 @@ -22,6 +22,7 @@ #include #include #include "widget_info.h" +#include "property_browser_ctrl.h" namespace GUIEditor { @@ -66,6 +67,8 @@ private: CWidgetProperties *widgetProps; LinkEditor *linkEditor; ProcEditor *procEditor; + + CPropBrowserCtrl browserCtrl; }; } 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