Merging GUI library changes.

This commit is contained in:
dfighter1985 2012-07-18 04:09:25 +02:00
commit 8e903dff0c
35 changed files with 2087 additions and 0 deletions

View file

@ -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.

View file

@ -0,0 +1,72 @@
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR}
${QT_INCLUDES})
FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_PLUGIN_GUI_EDITOR_HDR
gui_editor_plugin.h
gui_editor_window.h
gui_editor_context.h
widget_properties.h
widget_hierarchy.h
action_editor.h
link_editor.h
proc_editor.h
property_browser_ctrl.h
)
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
gui_editor_window.ui
widget_properties.ui
widget_hierarchy.ui
action_editor.ui
link_editor.ui
proc_editor.ui
)
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)
QT4_ADD_RESOURCES(OVQT_PLUGIN_GUI_EDITOR_RC_SRCS ${OVQT_PLUGIN_GUI_EDITOR_RCS})
QT4_WRAP_CPP(OVQT_PLUGIN_GUI_EDITOR_MOC_SRC ${OVQT_PLUGIN_GUI_EDITOR_HDR})
QT4_WRAP_UI(OVQT_PLUGIN_GUI_EDITOR_UI_HDRS ${OVQT_PLUGIN_GUI_EDITOR_UIS})
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_GUI_EDITOR_UIS})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_GUI_EDITOR_UI_HDRS})
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_GUI_EDITOR_MOC_SRC} OVQT_PLUGIN_GUI_EDITOR_RC_SRCS)
SOURCE_GROUP("GUI Editor Plugin" FILES ${SRC})
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(ovqt_plugin_gui_editor MODULE ${SRC}
${OVQT_PLUGIN_GUI_EDITOR_MOC_SRC}
${OVQT_EXT_SYS_SRC}
${OVQT_PLUGIN_GUI_EDITOR_UI_HDRS}
${OVQT_PLUGIN_GUI_EDITOR_RC_SRCS}
)
TARGET_LINK_LIBRARIES(
ovqt_plugin_gui_editor
ovqt_plugin_core
nelmisc
nel3d
nelgui
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARY}
qt_property_browser
${LUA_LIBRARIES}
${LUABIND_LIBRARIES}
)
NL_DEFAULT_PROPS(ovqt_plugin_gui_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: GUI Editor")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_gui_editor)
NL_ADD_LIB_SUFFIX(ovqt_plugin_gui_editor)
ADD_DEFINITIONS(-DGUI_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
INSTALL(TARGETS ovqt_plugin_gui_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)

View file

@ -0,0 +1,32 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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()
{
}
}

View file

@ -0,0 +1,34 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ActionEditor</class>
<widget class="QWidget" name="ActionEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>111</height>
</rect>
</property>
<property name="windowTitle">
<string>Action Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Handler</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="handlerEdit">
<property name="text">
<string>Handler</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Parameters</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="paramsEdit">
<property name="text">
<string>Parameters</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>38</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,33 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -0,0 +1,46 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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;
}
}

View file

@ -0,0 +1,56 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GUI_EDITOR_CONTEXT_H
#define GUI_EDITOR_CONTEXT_H
#include "../core/icontext.h"
#include "nel/misc/app_context.h"
#include <QtCore/QObject>
#include <QtGui/QIcon>
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

View file

@ -0,0 +1,30 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GUI_EDITOR_GLOBAL_H
#define GUI_EDITOR_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined( GUI_EDITOR_LIBRARY )
# define GUI_EDITOR_EXPORT Q_DECL_EXPORT
#else
# define GUI_EDITOR_EXPORT Q_DECL_IMPORT
#endif
#endif

View file

@ -0,0 +1,76 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 <QtCore/QObject>
namespace GUIEditor
{
GUIEditorPlugin::~GUIEditorPlugin()
{
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
{
m_plugMan->removeObject(obj);
}
qDeleteAll(m_autoReleaseObjects);
m_autoReleaseObjects.clear();
}
bool GUIEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
m_plugMan = pluginManager;
addAutoReleasedObject(new GUIEditorContext(this));
return true;
}
void GUIEditorPlugin::extensionsInitialized()
{
}
void GUIEditorPlugin::shutdown()
{
}
void GUIEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
{
#ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // NL_OS_WINDOWS
m_libContext = new NLMISC::CLibraryContext(*nelContext);
}
void GUIEditorPlugin::addAutoReleasedObject(QObject *obj)
{
m_plugMan->addObject(obj);
m_autoReleaseObjects.prepend(obj);
}
}
Q_EXPORT_PLUGIN(GUIEditor::GUIEditorPlugin)

View file

@ -0,0 +1,69 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 <QtCore/QObject>
#include <QtGui/QIcon>
namespace NLMISC
{
class CLibraryContext;
}
namespace ExtensionSystem
{
class IPluginSpec;
}
namespace GUIEditor
{
class GUIEditorWindow;
class GUIEditorPlugin : public QObject, public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin)
public:
virtual ~GUIEditorPlugin();
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
void extensionsInitialized();
void shutdown();
void setNelContext(NLMISC::INelContext *nelContext);
void addAutoReleasedObject(QObject *obj);
protected:
NLMISC::CLibraryContext *m_libContext;
private:
ExtensionSystem::IPluginManager *m_plugMan;
QList<QObject *> m_autoReleaseObjects;
};
}
#endif

View file

@ -0,0 +1,145 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "gui_editor_window.h"
#include "gui_editor_constants.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/core.h"
#include "../core/menu_manager.h"
#include <nel/misc/debug.h>
#include <QtCore/QSettings>
#include <QtGui/QFileDialog>
#include <QDockWidget>
#include "../../3rdparty/qtpropertybrowser/QtTreePropertyBrowser"
#include "widget_properties.h"
#include "widget_properties_parser.h"
#include "widget_hierarchy.h"
#include "link_editor.h"
#include "proc_editor.h"
namespace GUIEditor
{
QString _lastDir;
std::map< std::string, SWidgetInfo > widgetInfo;
GUIEditorWindow::GUIEditorWindow(QWidget *parent) :
QMainWindow(parent)
{
m_ui.setupUi(this);
m_undoStack = new QUndoStack(this);
widgetProps = new CWidgetProperties;
linkEditor = new LinkEditor;
procEditor = new ProcEditor;
createMenus();
readSettings();
CWidgetPropParser parser;
parser.setWidgetPropMap( &widgetInfo );
parser.parseGUIWidgets();
widgetProps->setupWidgetInfo( &widgetInfo );
QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this );
dock->setAllowedAreas( Qt::LeftDockWidgetArea );
WidgetHierarchy *ha = new WidgetHierarchy;
dock->setWidget( ha );
addDockWidget( Qt::LeftDockWidgetArea, dock );
dock = new QDockWidget( "Widget Properties", this );
dock->setAllowedAreas( Qt::RightDockWidgetArea );
QtTreePropertyBrowser *tb = new QtTreePropertyBrowser;
browserCtrl.setBrowser( tb );
browserCtrl.setup();
dock->setWidget( tb );
addDockWidget( Qt::RightDockWidgetArea, dock );
}
GUIEditorWindow::~GUIEditorWindow()
{
writeSettings();
delete widgetProps;
widgetProps = NULL;
delete linkEditor;
linkEditor = NULL;
delete procEditor;
procEditor = NULL;
}
QUndoStack *GUIEditorWindow::undoStack() const
{
return m_undoStack;
}
void GUIEditorWindow::open()
{
QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open GUI XML files"),
_lastDir,
tr("All XML files (*.xml)"));
setCursor(Qt::WaitCursor);
if(!fileNames.isEmpty())
{
QStringList list = fileNames;
_lastDir = QFileInfo(list.front()).absolutePath();
}
setCursor(Qt::ArrowCursor);
}
void GUIEditorWindow::createMenus()
{
Core::MenuManager *mm = Core::ICore::instance()->menuManager();
QMenu *menu = mm->menu( Core::Constants::M_TOOLS );
if( menu != NULL )
{
QAction *a = new QAction( "Widget Properties", this );
connect( a, SIGNAL( triggered( bool ) ), widgetProps, SLOT( show() ) );
menu->addAction( a );
a = new QAction( "Link Editor", this );
connect( a, SIGNAL( triggered( bool ) ), linkEditor, SLOT( show() ) );
menu->addAction( a );
a = new QAction( "Proc Editor", this );
connect( a, SIGNAL( triggered( bool ) ), procEditor, SLOT( show() ) );
menu->addAction( a );
}
}
void GUIEditorWindow::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::GUI_EDITOR_SECTION);
settings->endGroup();
}
void GUIEditorWindow::writeSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::GUI_EDITOR_SECTION);
settings->endGroup();
settings->sync();
}
}

View file

@ -0,0 +1,76 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GUI_EDITOR_WINDOW_H
#define GUI_EDITOR_WINDOW_H
#include "ui_gui_editor_window.h"
#include <QtGui/QUndoStack>
#include <QXmlStreamReader>
#include <QFile>
#include "widget_info.h"
#include "property_browser_ctrl.h"
namespace GUIEditor
{
class CWidgetProperties;
class LinkEditor;
class ProcEditor;
class GUIEditorWindow: public QMainWindow
{
Q_OBJECT
public:
GUIEditorWindow(QWidget *parent = 0);
~GUIEditorWindow();
QUndoStack *undoStack() const;
Q_SIGNALS:
public Q_SLOTS:
void open();
private Q_SLOTS:
private:
void createMenus();
void readSettings();
void writeSettings();
void parseGUIWidgets();
void parseGUIWidget( const QString &file );
void parseGUIWidgetXML( QFile &file );
QString parseGUIWidgetHeader( QXmlStreamReader &reader );
void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName );
QUndoStack *m_undoStack;
Ui::GUIEditorWindow m_ui;
CWidgetProperties *widgetProps;
LinkEditor *linkEditor;
ProcEditor *procEditor;
CPropBrowserCtrl browserCtrl;
};
}
#endif

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GUIEditorWindow</class>
<widget class="QMainWindow" name="GUIEditorWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,33 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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()
{
}
}

View file

@ -0,0 +1,35 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LinkEditor</class>
<widget class="QWidget" name="LinkEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>340</height>
</rect>
</property>
<property name="windowTitle">
<string>Link Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Expression</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="expressionEdit">
<property name="plainText">
<string>expression</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>When the condition is met</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="groupCB">
<property name="text">
<string>Activate group</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="ahCB">
<property name="text">
<string>Run Action Handler</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ahEdit">
<property name="text">
<string>Group or action handler</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ahParamEdit">
<property name="text">
<string>Action Handler parameters</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>348</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,10 @@
<plugin-spec>
<library-name>ovqt_plugin_gui_editor</library-name>
<name>GUI Editor</name>
<version>0.0.1</version>
<vendor>Ryzom Core</vendor>
<description>GUI Editor plugin.</description>
<dependencies>
<dependency plugin-name="Core" version="0.8"/>
</dependencies>
</plugin-spec>

View file

@ -0,0 +1,39 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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;
}
}

View file

@ -0,0 +1,40 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProcEditor</class>
<widget class="QWidget" name="ProcEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>327</height>
</rect>
</property>
<property name="windowTitle">
<string>Proc Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="6" colspan="3">
<widget class="QListWidget" name="actionList">
<item>
<property name="text">
<string>action1</string>
</property>
</item>
<item>
<property name="text">
<string>action2</string>
</property>
</item>
<item>
<property name="text">
<string>action3</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="upButton">
<property name="text">
<string>Move Up</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="downButton">
<property name="text">
<string>Move Down</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="5" column="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>132</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>197</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,65 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 );
}
}

View file

@ -0,0 +1,48 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef PROP_BROWSER_CTRL
#define PROP_BROWSER_CTRL
#include <QObject>
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

View file

@ -0,0 +1,31 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "widget_hierarchy.h"
namespace GUIEditor
{
WidgetHierarchy::WidgetHierarchy( QWidget *parent ) :
QWidget( parent )
{
setupUi( this );
}
WidgetHierarchy::~WidgetHierarchy()
{
}
}

View file

@ -0,0 +1,34 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WidgetHierarchyTree</class>
<widget class="QWidget" name="WidgetHierarchyTree">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>497</width>
<height>434</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget Hieararchy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="widgetHT">
<column>
<property name="text">
<string>Widgets</string>
</property>
</column>
<item>
<property name="text">
<string>root</string>
</property>
<item>
<property name="text">
<string>container1</string>
</property>
<item>
<property name="text">
<string>group1</string>
</property>
<item>
<property name="text">
<string>group3</string>
</property>
</item>
<item>
<property name="text">
<string>group4</string>
</property>
<item>
<property name="text">
<string>button1</string>
</property>
</item>
<item>
<property name="text">
<string>button2</string>
</property>
</item>
<item>
<property name="text">
<string>text1</string>
</property>
</item>
<item>
<property name="text">
<string>bitmap1</string>
</property>
</item>
</item>
</item>
<item>
<property name="text">
<string>group2</string>
</property>
</item>
</item>
<item>
<property name="text">
<string>container2</string>
</property>
</item>
<item>
<property name="text">
<string>container3</string>
</property>
</item>
</item>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,62 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef WIDGET_INFO_H
#define WIDGET_INFO_H
#include <string>
#include <vector>
namespace GUIEditor
{
struct SPropEntry
{
std::string propName;
std::string propType;
std::string propDefault;
static SPropEntry create( const char *propname, const char *proptype, const char *propdefault )
{
SPropEntry entry;
entry.propName = propname;
entry.propType = proptype;
entry.propDefault = propdefault;
return entry;
}
};
struct SWidgetInfo
{
std::string name;
std::string GUIName;
std::string ancestor;
std::string description;
bool isAbstract;
std::string icon;
bool resolved;
std::vector< SPropEntry > props;
SWidgetInfo()
{
resolved = false;
isAbstract = true;
}
};
}
#endif

View file

@ -0,0 +1,74 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "widget_properties.h"
namespace GUIEditor{
CWidgetProperties::CWidgetProperties( QWidget *parent ) :
QWidget( parent )
{
setupUi( this );
connect( closeButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) );
}
CWidgetProperties::~CWidgetProperties()
{
}
void CWidgetProperties::setupWidgetInfo( std::map< std::string, SWidgetInfo > *info )
{
widgetInfo = info;
for( std::map< std::string, SWidgetInfo >::iterator itr = info->begin(); itr != info->end(); ++itr ){
widgetList->addItem( itr->first.c_str() );
}
onListSelectionChanged( 0 );
connect( widgetList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onListSelectionChanged( int ) ) );
}
void CWidgetProperties::onListSelectionChanged( int i )
{
if( i >= widgetList->count() )
return;
QListWidgetItem *item = widgetList->item( i );
setPropsOf( item->text().toStdString().c_str() );
}
void CWidgetProperties::setPropsOf( const char *name )
{
std::map< std::string, SWidgetInfo >::iterator itr =
widgetInfo->find( name );
if( itr == widgetInfo->end() )
return;
widgetPropTree->clear();
std::vector< SPropEntry > &v = itr->second.props;
for( std::vector< SPropEntry >::iterator itr2 = v.begin(); itr2 != v.end(); ++itr2 )
{
SPropEntry e = *itr2;
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText( 0, e.propName.c_str() );
item->setText( 1, e.propType.c_str() );
item->setText( 2, e.propDefault.c_str() );
widgetPropTree->addTopLevelItem( item );
}
}
}

View file

@ -0,0 +1,47 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef WIDGETPROPS_H
#define WIDGETPROPS_H
#include "ui_widget_properties.h"
#include "widget_info.h"
#include <map>
#include <vector>
#include <string>
namespace GUIEditor
{
class CWidgetProperties : public QWidget, public Ui::WidgetProperties
{
Q_OBJECT
public:
CWidgetProperties( QWidget *parent = NULL );
~CWidgetProperties();
void setupWidgetInfo( std::map< std::string, SWidgetInfo > *info );
private Q_SLOTS:
void onListSelectionChanged( int i );
private:
void setPropsOf( const char *name );
std::map< std::string, SWidgetInfo > *widgetInfo;
};
}
#endif

View file

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WidgetProperties</class>
<widget class="QWidget" name="WidgetProperties">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>618</width>
<height>308</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="widgetList"/>
</item>
<item>
<widget class="QTreeWidget" name="widgetPropTree">
<column>
<property name="text">
<string>Property</string>
</property>
</column>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>56</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>428</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,272 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "widget_properties_parser.h"
#include <QDir>
#include <QStringList>
#include "nel/misc/debug.h"
using namespace NLMISC;
namespace GUIEditor
{
void CWidgetPropParser::parseGUIWidgets()
{
QDir d( "widgets" );
if( !d.exists() )
{
nlwarning( "GUI widgets directory doesn't exist!" );
return;
}
QStringList nameFilters;
nameFilters.push_back( "*.xml" );
QStringList files = d.entryList( nameFilters, QDir::Files );
if( files.empty() )
{
nlwarning( "GUI widgets directory has no files!" );
return;
}
QStringListIterator itr( files );
while( itr.hasNext() )
parseGUIWidget( "widgets/" + itr.next() );
resolveInheritance();
widgetInfo = NULL;
}
void CWidgetPropParser::parseGUIWidget( const QString &file )
{
QFile f( file );
if( f.open( QIODevice::ReadOnly ) )
{
parseGUIWidgetXML( f );
f.close();
}
else
nlwarning( QString( "File %1 cannot be opened!" ).arg( file ).toStdString().c_str() );
}
void CWidgetPropParser::parseGUIWidgetXML( QFile &file )
{
QXmlStreamReader reader;
reader.setDevice( &file );
reader.readNext();
if( reader.atEnd() )
return;
while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "widget" ) ) )
reader.readNext();
if( reader.atEnd() )
return;
while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "header" ) ) )
reader.readNext();
if( reader.atEnd() )
return;
QString name = parseGUIWidgetHeader( reader );
if( name.isEmpty() )
{
nlwarning( "malformed XML." );
return;
}
while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "properties" ) ) )
reader.readNext();
if( reader.atEnd() )
return;
parseGUIWidgetProperties( reader, name );
}
QString CWidgetPropParser::parseGUIWidgetHeader( QXmlStreamReader &reader )
{
reader.readNext();
if( reader.atEnd() )
return QString( "" );
SWidgetInfo info;
while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "header" ) ) )
{
if( reader.isStartElement() )
{
QString key = reader.name().toString();
QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
if( !reader.hasError() )
{
if( key == "name" )
info.name = value.toStdString();
else
if( key == "guiname" )
info.GUIName = value.toStdString();
else
if( key == "ancestor" )
info.ancestor = value.toStdString();
else
if( key == "description" )
info.description = value.toStdString();
else
if( key == "icon" )
info.icon == value.toStdString();
else
if( key == "abstract" )
{
info.isAbstract = false;
if( value == "true" )
info.isAbstract = true;
}
else
nlwarning( "Malformed XML." );
}
}
reader.readNext();
}
if( reader.atEnd() )
return QString( "" );
if( info.name.empty() )
return QString( "" );
(*widgetInfo)[ info.name.c_str() ] = info;
return QString( info.name.c_str() );
}
void CWidgetPropParser::parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName )
{
reader.readNext();
if( reader.atEnd() )
return;
std::map< std::string, SWidgetInfo >::iterator itr =
widgetInfo->find( widgetName.toStdString() );
if( itr == widgetInfo->end() )
return;
std::vector< SPropEntry > &v = itr->second.props;
while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "properties" ) ) )
{
if( reader.isStartElement() && reader.name() == "property" )
{
SPropEntry prop;
reader.readNext();
while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "property" ) ) )
{
if( reader.isStartElement() )
{
QString key = reader.name().toString();
QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
if( !reader.hasError() )
{
if( key == "name" )
prop.propName = value.toStdString();
else
if( key == "type" )
prop.propType = value.toStdString();
else
if( key == "default" )
prop.propDefault = value.toStdString();
else
nlwarning( QString( "Unknown tag %1 within a property" ).arg( key ).toStdString().c_str() );
}
else
nlwarning( "Malformed XML." );
}
reader.readNext();
}
if( reader.atEnd() )
return;
v.push_back( prop );
}
reader.readNext();
}
}
bool propCompare( const SPropEntry &left, const SPropEntry &right )
{
return left.propName < right.propName;
}
void CWidgetPropParser::resolveInheritance()
{
for( std::map< std::string, SWidgetInfo >::iterator itr = widgetInfo->begin(); itr != widgetInfo->end(); ++itr )
{
resolveInheritanceFor( itr->first );
std::sort( itr->second.props.begin(), itr->second.props.end(), propCompare );
}
}
void CWidgetPropParser::resolveInheritanceFor( const std::string name )
{
if( name.empty() )
return;
std::map< std::string, SWidgetInfo >::iterator itr =
widgetInfo->find( name );
if( itr == widgetInfo->end() )
return;
SWidgetInfo *info = &(itr->second);
if( info->resolved )
return;
if( info->ancestor.empty() )
return;
std::vector< SPropEntry > &props = info->props;
std::map< std::string, SWidgetInfo >::iterator itr2 =
widgetInfo->find( info->ancestor );
if( itr2 == widgetInfo->end() )
return;
SWidgetInfo *info2 = &(itr2->second);
do
{
for( std::vector< SPropEntry >::iterator propItr = info2->props.begin(); propItr != info2->props.end(); ++propItr )
props.push_back( *propItr );
if( !info2->resolved && !info2->ancestor.empty() )
{
itr2 = widgetInfo->find( info2->ancestor );
if( itr2 != widgetInfo->end() )
info2 = &(itr2->second);
else
info2 = NULL;
}
}
while( ( info2 != NULL ) && !info2->resolved && !info2->ancestor.empty() );
info->resolved = true;
}
}

View file

@ -0,0 +1,51 @@
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef WIDGET_PROP_PARSER
#define WIDGET_PROP_PARSER
#include "widget_info.h"
#include <map>
#include <QString>
#include <QFile>
#include <QXmlStreamReader>
namespace GUIEditor
{
/// Parser for the widget properties XML files
class CWidgetPropParser
{
public:
CWidgetPropParser(){}
~CWidgetPropParser(){}
void setWidgetPropMap( std::map< std::string, SWidgetInfo > *info ){ widgetInfo = info; }
void parseGUIWidgets();
private:
void parseGUIWidget( const QString &file );
void parseGUIWidgetXML( QFile &file );
QString parseGUIWidgetHeader( QXmlStreamReader &reader );
void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName );
void resolveInheritance();
void resolveInheritanceFor( const std::string name );
std::map< std::string, SWidgetInfo > *widgetInfo;
};
}
#endif

View file

@ -0,0 +1,22 @@
<widget>
<header>
<name>CtrlBase</name>
<guiname>cb</guiname>
<ancestor>InterfaceElement</ancestor>
<description></description>
<abstract>true</abstract>
<icon></icon>
</header>
<properties>
<property>
<name>on_tooltip</name>
<type>string</type>
<default>handler</default>
</property>
<property>
<name>on_tooltip_params</name>
<type>string</type>
<default>params</default>
</property>
</properties>
</widget>

View file

@ -0,0 +1,21 @@
<widget>
<header>
<name>InterfaceElement</name>
<guiname>ie</guiname>
<description></description>
<abstract>true</abstract>
<icon></icon>
</header>
<properties>
<property>
<name>id</name>
<type>string</type>
<default>ie</default>
</property>
<property>
<name>active</name>
<type>bool</type>
<default>true</default>
</property>
</properties>
</widget>

View file

@ -0,0 +1,22 @@
<widget>
<header>
<name>InterfaceGroup</name>
<guiname>ig</guiname>
<ancestor>CtrlBase</ancestor>
<description></description>
<abstract>false</abstract>
<icon></icon>
</header>
<properties>
<property>
<name>on_enter</name>
<type>string</type>
<default>handler</default>
</property>
<property>
<name>on_enter_params</name>
<type>string</type>
<default>params</default>
</property>
</properties>
</widget>