ADDED: #1471 OVQT GUI Editor plugin skeleton code.

--HG--
branch : gsoc2012-gui-editor
This commit is contained in:
dfighter1985 2012-05-27 21:52:02 +02:00
parent 2db0a5d06e
commit f4781db64b
12 changed files with 577 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,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)

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,103 @@
// 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);
}
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)

View file

@ -0,0 +1,79 @@
// 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);
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<QObject *> m_autoReleaseObjects;
};
}
#endif

View file

@ -0,0 +1,86 @@
// 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 <nel/misc/debug.h>
#include <QtCore/QSettings>
#include <QtGui/QFileDialog>
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();
}
}

View file

@ -0,0 +1,57 @@
// 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>
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

View file

@ -0,0 +1,36 @@
<?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">
<item row="0" column="0">
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</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>
<connections/>
</ui>

View file

@ -0,0 +1,7 @@
<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>
</plugin-spec>