mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 21:11:39 +00:00
MODIFIED: #1471 Adding new widget now works in the widget property dialog.
This commit is contained in:
parent
2f18aec5d4
commit
e8d3255990
6 changed files with 254 additions and 1 deletions
|
@ -57,6 +57,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
|
|||
nel3d_widget.h
|
||||
nelgui_widget.h
|
||||
new_property_widget.h
|
||||
new_widget_widget.h
|
||||
)
|
||||
|
||||
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
||||
|
@ -70,6 +71,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
|||
action_editor.ui
|
||||
project_window.ui
|
||||
new_property_widget.ui
|
||||
new_widget_widget.ui
|
||||
)
|
||||
|
||||
SET(QT_USE_QTGUI TRUE)
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
// 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 "new_widget_widget.h"
|
||||
#include "widget_info_tree.h"
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
NewWidgetWidget::NewWidgetWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
widgetInfoTree = NULL;
|
||||
setupUi( this );
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) );
|
||||
}
|
||||
|
||||
NewWidgetWidget::~NewWidgetWidget()
|
||||
{
|
||||
widgetInfoTree = NULL;
|
||||
}
|
||||
|
||||
void NewWidgetWidget::fillWidgetList( std::vector< std::string > &widgets )
|
||||
{
|
||||
ancestorCB->clear();
|
||||
|
||||
std::vector< std::string >::const_iterator itr = widgets.begin();
|
||||
while( itr != widgets.end() )
|
||||
{
|
||||
ancestorCB->addItem( QString( itr->c_str() ) );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NewWidgetWidget::onAddClicked()
|
||||
{
|
||||
if( !checkNameField() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( !checkNameDuplicate() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addNewWidget();
|
||||
hide();
|
||||
Q_EMIT widgetAdded();
|
||||
}
|
||||
|
||||
|
||||
bool NewWidgetWidget::checkNameField()
|
||||
{
|
||||
if( nameEdit->text().toStdString().empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NewWidgetWidget::checkNameDuplicate()
|
||||
{
|
||||
if( widgetInfoTree == NULL )
|
||||
return false;
|
||||
|
||||
CWidgetInfoTreeNode *node = widgetInfoTree->findNodeByName( nameEdit->text().toStdString() );
|
||||
if( node != NULL )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void NewWidgetWidget::addNewWidget()
|
||||
{
|
||||
CWidgetInfoTreeNode *node = widgetInfoTree->findNodeByName( ancestorCB->currentText().toStdString() );
|
||||
if( node == NULL )
|
||||
{
|
||||
nlerror( "Ancestor %s doesn't exist! Aborting addition!", ancestorCB->currentText().toStdString().c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
SWidgetInfo info;
|
||||
info.ancestor = ancestorCB->currentText().toStdString();
|
||||
info.name = nameEdit->text().toStdString();
|
||||
info.GUIName = "C" + info.name;
|
||||
info.isAbstract = false;
|
||||
info.resolved = true;
|
||||
node->addChild( info );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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/>.
|
||||
|
||||
|
||||
#ifndef NEW_WIDGET_WIDGET_H
|
||||
#define NEW_WIDGET_WIDGET_H
|
||||
|
||||
#include "ui_new_widget_widget.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
class CWidgetInfoTree;
|
||||
|
||||
class NewWidgetWidget : public QWidget, public Ui::NewWidgetWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NewWidgetWidget( QWidget *parent = NULL );
|
||||
~NewWidgetWidget();
|
||||
|
||||
/// Fills the widget list with the widget names
|
||||
void fillWidgetList( std::vector< std::string > &widgets );
|
||||
|
||||
/// Sets the widget info tree so we can add new widgets
|
||||
void setWidgetInfoTree( CWidgetInfoTree *tree ){ widgetInfoTree = tree; }
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
|
||||
private:
|
||||
/// Checks if the name is valid
|
||||
bool checkNameField();
|
||||
|
||||
/// Checks if the name is not a duplicate
|
||||
bool checkNameDuplicate();
|
||||
|
||||
/// Adds the new widget
|
||||
void addNewWidget();
|
||||
|
||||
CWidgetInfoTree *widgetInfoTree;
|
||||
|
||||
Q_SIGNALS:
|
||||
void widgetAdded();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewWidgetWidget</class>
|
||||
<widget class="QWidget" name="NewWidgetWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>249</width>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Widget</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nameEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Ancestor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="ancestorCB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -17,6 +17,7 @@
|
|||
#include "widget_properties.h"
|
||||
#include "widget_info_tree.h"
|
||||
#include "new_property_widget.h"
|
||||
#include "new_widget_widget.h"
|
||||
#include <qmessagebox.h>
|
||||
|
||||
namespace GUIEditor{
|
||||
|
@ -24,18 +25,23 @@ namespace GUIEditor{
|
|||
QWidget( parent )
|
||||
{
|
||||
newPropertyWidget = new NewPropertyWidget();
|
||||
newWidgetWidget = new NewWidgetWidget();
|
||||
|
||||
setupUi( this );
|
||||
connect( rmWButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveWButtonClicked() ) );
|
||||
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( newPropertyWidget, SIGNAL( propertyAdded() ), this, SLOT( onPropertyAdded() ) );
|
||||
connect( newWidgetWidget, SIGNAL( widgetAdded() ), this, SLOT( onWidgetAdded() ) );
|
||||
}
|
||||
|
||||
CWidgetProperties::~CWidgetProperties()
|
||||
{
|
||||
delete newPropertyWidget;
|
||||
newPropertyWidget = NULL;
|
||||
delete newWidgetWidget;
|
||||
newWidgetWidget = NULL;
|
||||
tree = NULL;
|
||||
}
|
||||
|
||||
|
@ -112,6 +118,9 @@ namespace GUIEditor{
|
|||
|
||||
void CWidgetProperties::onAddWButtonClicked()
|
||||
{
|
||||
newWidgetWidget->setWidgetInfoTree( tree );
|
||||
newWidgetWidget->fillWidgetList( widgetNames );
|
||||
newWidgetWidget->show();
|
||||
}
|
||||
|
||||
void CWidgetProperties::onAddPButtonClicked()
|
||||
|
@ -135,10 +144,15 @@ namespace GUIEditor{
|
|||
onListSelectionChanged( widgetList->currentRow() );
|
||||
}
|
||||
|
||||
void CWidgetProperties::onWidgetAdded()
|
||||
{
|
||||
buildWidgetList();
|
||||
}
|
||||
|
||||
void CWidgetProperties::buildWidgetList()
|
||||
{
|
||||
widgetList->clear();
|
||||
std::vector< std::string > widgetNames;
|
||||
widgetNames.clear();
|
||||
tree->getNames( widgetNames );
|
||||
std::sort( widgetNames.begin(), widgetNames.end() );
|
||||
for( std::vector< std::string >::const_iterator itr = widgetNames.begin(); itr != widgetNames.end(); ++itr )
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace GUIEditor
|
|||
{
|
||||
class CWidgetInfoTree;
|
||||
class NewPropertyWidget;
|
||||
class NewWidgetWidget;
|
||||
|
||||
/// Widget that shows all available GUI widgets and their properties,
|
||||
/// Also allows the user to add / remove widgets and properties
|
||||
|
@ -56,6 +57,7 @@ namespace GUIEditor
|
|||
void onAddPButtonClicked();
|
||||
|
||||
void onPropertyAdded();
|
||||
void onWidgetAdded();
|
||||
|
||||
private:
|
||||
/// Builds the widget list
|
||||
|
@ -64,8 +66,11 @@ namespace GUIEditor
|
|||
/// Builds the property list for the currently selected widget
|
||||
void setPropsOf( const char *name );
|
||||
|
||||
std::vector< std::string > widgetNames;
|
||||
|
||||
CWidgetInfoTree *tree;
|
||||
NewPropertyWidget *newPropertyWidget;
|
||||
NewWidgetWidget *newWidgetWidget;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue