mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 21:56:13 +00:00
MODIFIED: #1471 Widget template changes can now be saved.
This commit is contained in:
parent
86a2e259e9
commit
677358df6d
8 changed files with 215 additions and 28 deletions
|
@ -0,0 +1,77 @@
|
||||||
|
// 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_info_serializer.h"
|
||||||
|
#include "widget_info_tree.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
void CWidgetInfoSerializer::serialize( CWidgetInfoTree *tree )
|
||||||
|
{
|
||||||
|
tree->accept( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWidgetInfoSerializer::visit( CWidgetInfoTreeNode *node )
|
||||||
|
{
|
||||||
|
std::fstream f;
|
||||||
|
std::string filename = "widgets/" + node->getInfo().name + ".xml";
|
||||||
|
SWidgetInfo &info = node->getInfo();
|
||||||
|
|
||||||
|
f.open( filename.c_str(), std::ios_base::out );
|
||||||
|
if( !f.is_open() )
|
||||||
|
{
|
||||||
|
nlinfo( "Failed to open %s for writing!\n", filename.c_str() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
f << "<widget>" << std::endl;
|
||||||
|
f << "\t<header>" << std::endl;
|
||||||
|
f << "\t\t<name>" << info.name << "</name>" << std::endl;
|
||||||
|
f << "\t\t<guiname>" << info.GUIName << "</guiname>" << std::endl;
|
||||||
|
f << "\t\t<ancestor>" << info.ancestor << "</ancestor>" << std::endl;
|
||||||
|
f << "\t\t<description>" << info.description << "</description>" << std::endl;
|
||||||
|
|
||||||
|
if( info.isAbstract )
|
||||||
|
f << "\t\t<abstract>" << "true" << "</abstract>" << std::endl;
|
||||||
|
else
|
||||||
|
f << "\t\t<abstract>" << "false" << "</abstract>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t\t<icon>" << info.icon << "</icon>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t</header>" << std::endl;
|
||||||
|
f << "\t<properties>" << std::endl;
|
||||||
|
|
||||||
|
for( std::vector< SPropEntry >::const_iterator itr = info.props.begin(); itr != info.props.end(); ++itr )
|
||||||
|
{
|
||||||
|
f << "\t\t<property>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t\t\t<name>" << itr->propName << "</name>" << std::endl;
|
||||||
|
f << "\t\t\t<type>" << itr->propType << "</type>" << std::endl;
|
||||||
|
f << "\t\t\t<default>" << itr->propDefault << "</default>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t\t</property>" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
f << "\t</properties>" << std::endl;
|
||||||
|
f << "</widget>" << std::endl;
|
||||||
|
f << std::endl;
|
||||||
|
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
// 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_SERIALIZER_H
|
||||||
|
#define WIDGET_INFO_SERIALIZER_H
|
||||||
|
|
||||||
|
#include "widget_info_tree_visitor.h"
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
class CWidgetInfoTree;
|
||||||
|
|
||||||
|
class CWidgetInfoSerializer : public CWidgetInfoTreeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void serialize( CWidgetInfoTree *tree );
|
||||||
|
void visit( CWidgetInfoTreeNode *node );
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -100,6 +100,13 @@ namespace GUIEditor
|
||||||
root->getNames( v );
|
root->getNames( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Accepts a visitor
|
||||||
|
void accept( CWidgetInfoTreeVisitor *visitor )
|
||||||
|
{
|
||||||
|
root->accept( visitor );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CWidgetInfoTreeNode *root;
|
CWidgetInfoTreeNode *root;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define WIDGET_INFO_TREE_NODE
|
#define WIDGET_INFO_TREE_NODE
|
||||||
|
|
||||||
#include "widget_info.h"
|
#include "widget_info.h"
|
||||||
|
#include "widget_info_tree_visitor.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -221,6 +222,14 @@ namespace GUIEditor
|
||||||
( *itr )->getNames( v );
|
( *itr )->getNames( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Accepts a visitor to itself and to the children nodes
|
||||||
|
void accept( CWidgetInfoTreeVisitor *visitor )
|
||||||
|
{
|
||||||
|
visitor->visit( this );
|
||||||
|
for( std::vector< CWidgetInfoTreeNode* >::iterator itr = children.begin(); itr != children.end(); ++itr )
|
||||||
|
( *itr )->accept( visitor );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWidgetInfo info;
|
SWidgetInfo info;
|
||||||
CWidgetInfoTreeNode *parent;
|
CWidgetInfoTreeNode *parent;
|
||||||
|
|
|
@ -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_INFO_TREE_VISITOR_H
|
||||||
|
#define WIDGET_INFO_TREE_VISITOR_H
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
class CWidgetInfoTreeNode;
|
||||||
|
|
||||||
|
/// Visitor base class for CWidgetInfoTree
|
||||||
|
class CWidgetInfoTreeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Visits a node
|
||||||
|
virtual void visit( CWidgetInfoTreeNode *node ) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
#include "widget_properties.h"
|
#include "widget_properties.h"
|
||||||
#include "widget_info_tree.h"
|
#include "widget_info_tree.h"
|
||||||
|
#include "widget_info_serializer.h"
|
||||||
#include "new_property_widget.h"
|
#include "new_property_widget.h"
|
||||||
#include "new_widget_widget.h"
|
#include "new_widget_widget.h"
|
||||||
#include <qmessagebox.h>
|
#include <qmessagebox>
|
||||||
|
|
||||||
namespace GUIEditor{
|
namespace GUIEditor{
|
||||||
CWidgetProperties::CWidgetProperties( QWidget *parent ) :
|
CWidgetProperties::CWidgetProperties( QWidget *parent ) :
|
||||||
|
@ -32,6 +33,7 @@ namespace GUIEditor{
|
||||||
connect( rmPButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemovePButtonClicked() ) );
|
connect( rmPButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemovePButtonClicked() ) );
|
||||||
connect( addPButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddPButtonClicked() ) );
|
connect( addPButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddPButtonClicked() ) );
|
||||||
connect( addWButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddWButtonClicked() ) );
|
connect( addWButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddWButtonClicked() ) );
|
||||||
|
connect( saveButton, SIGNAL( clicked( bool ) ), this, SLOT( onSaveButtonClicked() ) );
|
||||||
connect( newPropertyWidget, SIGNAL( propertyAdded() ), this, SLOT( onPropertyAdded() ) );
|
connect( newPropertyWidget, SIGNAL( propertyAdded() ), this, SLOT( onPropertyAdded() ) );
|
||||||
connect( newWidgetWidget, SIGNAL( widgetAdded() ), this, SLOT( onWidgetAdded() ) );
|
connect( newWidgetWidget, SIGNAL( widgetAdded() ), this, SLOT( onWidgetAdded() ) );
|
||||||
}
|
}
|
||||||
|
@ -139,6 +141,13 @@ namespace GUIEditor{
|
||||||
newPropertyWidget->show();
|
newPropertyWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CWidgetProperties::onSaveButtonClicked()
|
||||||
|
{
|
||||||
|
CWidgetInfoSerializer serializer;
|
||||||
|
serializer.serialize( tree );
|
||||||
|
}
|
||||||
|
|
||||||
void CWidgetProperties::onPropertyAdded()
|
void CWidgetProperties::onPropertyAdded()
|
||||||
{
|
{
|
||||||
onListSelectionChanged( widgetList->currentRow() );
|
onListSelectionChanged( widgetList->currentRow() );
|
||||||
|
|
|
@ -56,6 +56,9 @@ namespace GUIEditor
|
||||||
/// Adds a widget property to the list
|
/// Adds a widget property to the list
|
||||||
void onAddPButtonClicked();
|
void onAddPButtonClicked();
|
||||||
|
|
||||||
|
/// Saves the widgets
|
||||||
|
void onSaveButtonClicked();
|
||||||
|
|
||||||
void onPropertyAdded();
|
void onPropertyAdded();
|
||||||
void onWidgetAdded();
|
void onWidgetAdded();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<string>Widget Properties</string>
|
<string>Widget Properties</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="widgetList"/>
|
<widget class="QListWidget" name="widgetList"/>
|
||||||
|
@ -41,38 +41,49 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addWButton">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addWButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="rmWButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="saveButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="rmWButton">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Remove</string>
|
<widget class="QPushButton" name="addPButton">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Add</string>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<widget class="QPushButton" name="rmPButton">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QPushButton" name="addPButton">
|
<string>Remove</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Add</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="rmPButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue