MODIFIED: #1471 Widget template changes can now be saved.
This commit is contained in:
parent
6343ce5750
commit
1667365842
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 );
|
||||
}
|
||||
|
||||
|
||||
/// Accepts a visitor
|
||||
void accept( CWidgetInfoTreeVisitor *visitor )
|
||||
{
|
||||
root->accept( visitor );
|
||||
}
|
||||
|
||||
private:
|
||||
CWidgetInfoTreeNode *root;
|
||||
};
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define WIDGET_INFO_TREE_NODE
|
||||
|
||||
#include "widget_info.h"
|
||||
#include "widget_info_tree_visitor.h"
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
|
@ -221,6 +222,14 @@ namespace GUIEditor
|
|||
( *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:
|
||||
SWidgetInfo info;
|
||||
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_info_tree.h"
|
||||
#include "widget_info_serializer.h"
|
||||
#include "new_property_widget.h"
|
||||
#include "new_widget_widget.h"
|
||||
#include <qmessagebox.h>
|
||||
#include <qmessagebox>
|
||||
|
||||
namespace GUIEditor{
|
||||
CWidgetProperties::CWidgetProperties( QWidget *parent ) :
|
||||
|
@ -32,6 +33,7 @@ namespace GUIEditor{
|
|||
connect( rmPButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemovePButtonClicked() ) );
|
||||
connect( addPButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddPButtonClicked() ) );
|
||||
connect( addWButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddWButtonClicked() ) );
|
||||
connect( saveButton, SIGNAL( clicked( bool ) ), this, SLOT( onSaveButtonClicked() ) );
|
||||
connect( newPropertyWidget, SIGNAL( propertyAdded() ), this, SLOT( onPropertyAdded() ) );
|
||||
connect( newWidgetWidget, SIGNAL( widgetAdded() ), this, SLOT( onWidgetAdded() ) );
|
||||
}
|
||||
|
@ -139,6 +141,13 @@ namespace GUIEditor{
|
|||
newPropertyWidget->show();
|
||||
}
|
||||
|
||||
|
||||
void CWidgetProperties::onSaveButtonClicked()
|
||||
{
|
||||
CWidgetInfoSerializer serializer;
|
||||
serializer.serialize( tree );
|
||||
}
|
||||
|
||||
void CWidgetProperties::onPropertyAdded()
|
||||
{
|
||||
onListSelectionChanged( widgetList->currentRow() );
|
||||
|
|
|
@ -56,6 +56,9 @@ namespace GUIEditor
|
|||
/// Adds a widget property to the list
|
||||
void onAddPButtonClicked();
|
||||
|
||||
/// Saves the widgets
|
||||
void onSaveButtonClicked();
|
||||
|
||||
void onPropertyAdded();
|
||||
void onWidgetAdded();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<string>Widget Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="widgetList"/>
|
||||
|
@ -41,6 +41,8 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addWButton">
|
||||
|
@ -58,7 +60,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item>
|
||||
<widget class="QPushButton" name="saveButton">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addPButton">
|
||||
|
@ -77,6 +86,8 @@
|
|||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Reference in a new issue