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

This commit is contained in:
dfighter1985 2012-07-04 06:27:40 +02:00
parent 0b01fec846
commit a04280c7ef
6 changed files with 257 additions and 3 deletions

View file

@ -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_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.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_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 ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui widget_properties.ui )
SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE) SET(QT_USE_QTOPENGL TRUE)

View file

@ -19,12 +19,16 @@
#include "../core/icore.h" #include "../core/icore.h"
#include "../core/core_constants.h" #include "../core/core_constants.h"
#include "../core/core.h"
#include "../core/menu_manager.h"
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include "widget_properties.h"
namespace GUIEditor namespace GUIEditor
{ {
QString _lastDir; QString _lastDir;
@ -34,6 +38,7 @@ namespace GUIEditor
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
m_undoStack = new QUndoStack(this); m_undoStack = new QUndoStack(this);
widgetProps = new CWidgetProperties;
createMenus(); createMenus();
readSettings(); readSettings();
} }
@ -41,6 +46,8 @@ namespace GUIEditor
GUIEditorWindow::~GUIEditorWindow() GUIEditorWindow::~GUIEditorWindow()
{ {
writeSettings(); writeSettings();
delete widgetProps;
widgetProps = NULL;
} }
QUndoStack *GUIEditorWindow::undoStack() const QUndoStack *GUIEditorWindow::undoStack() const
@ -66,6 +73,14 @@ namespace GUIEditor
void GUIEditorWindow::createMenus() 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() void GUIEditorWindow::readSettings()

View file

@ -18,11 +18,13 @@
#define GUI_EDITOR_WINDOW_H #define GUI_EDITOR_WINDOW_H
#include "ui_gui_editor_window.h" #include "ui_gui_editor_window.h"
#include <QtGui/QUndoStack> #include <QtGui/QUndoStack>
namespace GUIEditor namespace GUIEditor
{ {
class CWidgetProperties;
class GUIEditorWindow: public QMainWindow class GUIEditorWindow: public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -50,6 +52,7 @@ private:
QUndoStack *m_undoStack; QUndoStack *m_undoStack;
Ui::GUIEditorWindow m_ui; Ui::GUIEditorWindow m_ui;
CWidgetProperties *widgetProps;
}; };
} }

View file

@ -0,0 +1,111 @@
// 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"
#include <map>
#include <vector>
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 );
}
}
}

View file

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

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>