mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
Added GUI for widget adding.
--HG-- branch : gsoc2012-gui-editor
This commit is contained in:
parent
a0af49fd40
commit
c91e7492bb
12 changed files with 246 additions and 5 deletions
|
@ -60,6 +60,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
|
||||||
nelgui_widget.h
|
nelgui_widget.h
|
||||||
new_property_widget.h
|
new_property_widget.h
|
||||||
new_widget_widget.h
|
new_widget_widget.h
|
||||||
|
add_widget_widget.h
|
||||||
editor_selection_watcher.h
|
editor_selection_watcher.h
|
||||||
editor_message_processor.h
|
editor_message_processor.h
|
||||||
)
|
)
|
||||||
|
@ -76,6 +77,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
||||||
project_window.ui
|
project_window.ui
|
||||||
new_property_widget.ui
|
new_property_widget.ui
|
||||||
new_widget_widget.ui
|
new_widget_widget.ui
|
||||||
|
add_widget_widget.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(QT_USE_QTGUI TRUE)
|
SET(QT_USE_QTGUI TRUE)
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "add_widget_widget.h"
|
||||||
|
#include "widget_info_tree.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
AddWidgetWidget::AddWidgetWidget( QWidget *parent ) :
|
||||||
|
QWidget( parent )
|
||||||
|
{
|
||||||
|
setupUi( this );
|
||||||
|
setupConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddWidgetWidget::~AddWidgetWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddWidgetWidget::setCurrentGroup( const QString &g )
|
||||||
|
{
|
||||||
|
groupEdit->setText( g );
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddWidgetWidget::setupWidgetInfo( const CWidgetInfoTree *tree )
|
||||||
|
{
|
||||||
|
std::vector< std::string > names;
|
||||||
|
tree->getNames( names, false );
|
||||||
|
|
||||||
|
widgetCB->clear();
|
||||||
|
|
||||||
|
std::sort( names.begin(), names.end() );
|
||||||
|
|
||||||
|
std::vector< std::string >::const_iterator itr = names.begin();
|
||||||
|
while( itr != names.end() )
|
||||||
|
{
|
||||||
|
widgetCB->addItem( QString( itr->c_str() ) );
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddWidgetWidget::setupConnections()
|
||||||
|
{
|
||||||
|
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( close() ) );
|
||||||
|
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddWidgetWidget::onAddClicked()
|
||||||
|
{
|
||||||
|
if( nameEdit->text().isEmpty() )
|
||||||
|
{
|
||||||
|
QMessageBox::warning( NULL,
|
||||||
|
tr( "WARNING" ),
|
||||||
|
tr( "You need to specify a name for your new widget!" ),
|
||||||
|
QMessageBox::Ok );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef ADD_WIDGET_WIDGET_H
|
||||||
|
#define ADD_WIDGET_WIDGET_H
|
||||||
|
|
||||||
|
#include "ui_add_widget_widget.h"
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
class CWidgetInfoTree;
|
||||||
|
|
||||||
|
class AddWidgetWidget : public QWidget, public Ui::AddWidgetWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AddWidgetWidget( QWidget *parent = NULL );
|
||||||
|
~AddWidgetWidget();
|
||||||
|
|
||||||
|
void setCurrentGroup( const QString &g );
|
||||||
|
void setupWidgetInfo( const CWidgetInfoTree *tree );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupConnections();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onAddClicked();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddWidgetWidget</class>
|
||||||
|
<widget class="QWidget" name="AddWidgetWidget">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>318</width>
|
||||||
|
<height>132</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Add 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>Group</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="groupEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Widget</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="widgetCB"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="nameEdit"/>
|
||||||
|
</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>
|
|
@ -43,6 +43,7 @@
|
||||||
#include "nelgui_widget.h"
|
#include "nelgui_widget.h"
|
||||||
#include "editor_selection_watcher.h"
|
#include "editor_selection_watcher.h"
|
||||||
#include "editor_message_processor.h"
|
#include "editor_message_processor.h"
|
||||||
|
#include "add_widget_widget.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -61,6 +62,7 @@ namespace GUIEditor
|
||||||
linkList = new LinkList;
|
linkList = new LinkList;
|
||||||
procList = new ProcList;
|
procList = new ProcList;
|
||||||
projectWindow = new ProjectWindow;
|
projectWindow = new ProjectWindow;
|
||||||
|
addWidgetWidget = new AddWidgetWidget;
|
||||||
connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) );
|
connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) );
|
||||||
viewPort = new NelGUIWidget;
|
viewPort = new NelGUIWidget;
|
||||||
setCentralWidget( viewPort );
|
setCentralWidget( viewPort );
|
||||||
|
@ -76,6 +78,7 @@ namespace GUIEditor
|
||||||
parser.setWidgetInfoTree( widgetInfoTree );
|
parser.setWidgetInfoTree( widgetInfoTree );
|
||||||
parser.parseGUIWidgets();
|
parser.parseGUIWidgets();
|
||||||
widgetProps->setupWidgetInfo( widgetInfoTree );
|
widgetProps->setupWidgetInfo( widgetInfoTree );
|
||||||
|
addWidgetWidget->setupWidgetInfo( widgetInfoTree );
|
||||||
|
|
||||||
QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this );
|
QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this );
|
||||||
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||||
|
@ -95,6 +98,7 @@ namespace GUIEditor
|
||||||
viewPort->init();
|
viewPort->init();
|
||||||
|
|
||||||
connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) );
|
connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) );
|
||||||
|
connect( widgetProps, SIGNAL( treeChanged() ), this, SLOT( onTreeChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIEditorWindow::~GUIEditorWindow()
|
GUIEditorWindow::~GUIEditorWindow()
|
||||||
|
@ -119,6 +123,9 @@ namespace GUIEditor
|
||||||
delete viewPort;
|
delete viewPort;
|
||||||
viewPort = NULL;
|
viewPort = NULL;
|
||||||
|
|
||||||
|
delete addWidgetWidget;
|
||||||
|
addWidgetWidget = NULL;
|
||||||
|
|
||||||
// no deletion needed for these, since dockwidget owns them
|
// no deletion needed for these, since dockwidget owns them
|
||||||
hierarchyView = NULL;
|
hierarchyView = NULL;
|
||||||
propBrowser = NULL;
|
propBrowser = NULL;
|
||||||
|
@ -309,6 +316,20 @@ namespace GUIEditor
|
||||||
connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
|
connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIEditorWindow::onAddWidgetClicked()
|
||||||
|
{
|
||||||
|
QString g;
|
||||||
|
hierarchyView->getCurrentGroup( g );
|
||||||
|
|
||||||
|
addWidgetWidget->setCurrentGroup( g );
|
||||||
|
addWidgetWidget->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUIEditorWindow::onTreeChanged()
|
||||||
|
{
|
||||||
|
addWidgetWidget->setupWidgetInfo( widgetInfoTree );
|
||||||
|
}
|
||||||
|
|
||||||
void GUIEditorWindow::createMenus()
|
void GUIEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
Core::MenuManager *mm = Core::ICore::instance()->menuManager();
|
Core::MenuManager *mm = Core::ICore::instance()->menuManager();
|
||||||
|
@ -352,6 +373,10 @@ namespace GUIEditor
|
||||||
a = new QAction( "Project Window", this );
|
a = new QAction( "Project Window", this );
|
||||||
connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) );
|
connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) );
|
||||||
m->addAction( a );
|
m->addAction( a );
|
||||||
|
|
||||||
|
a = new QAction( "Add Widget", this );
|
||||||
|
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) );
|
||||||
|
m->addAction( a );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace GUIEditor
|
||||||
class NelGUIWidget;
|
class NelGUIWidget;
|
||||||
class CWidgetInfoTree;
|
class CWidgetInfoTree;
|
||||||
class CEditorMessageProcessor;
|
class CEditorMessageProcessor;
|
||||||
|
class AddWidgetWidget;
|
||||||
|
|
||||||
class GUIEditorWindow: public QMainWindow
|
class GUIEditorWindow: public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -60,6 +61,8 @@ public Q_SLOTS:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onProjectFilesChanged();
|
void onProjectFilesChanged();
|
||||||
void onGUILoaded();
|
void onGUILoaded();
|
||||||
|
void onAddWidgetClicked();
|
||||||
|
void onTreeChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createMenus();
|
void createMenus();
|
||||||
|
@ -80,6 +83,7 @@ private:
|
||||||
NelGUIWidget *viewPort;
|
NelGUIWidget *viewPort;
|
||||||
CWidgetInfoTree *widgetInfoTree;
|
CWidgetInfoTree *widgetInfoTree;
|
||||||
CEditorMessageProcessor *messageProcessor;
|
CEditorMessageProcessor *messageProcessor;
|
||||||
|
AddWidgetWidget *addWidgetWidget;
|
||||||
|
|
||||||
CPropBrowserCtrl browserCtrl;
|
CPropBrowserCtrl browserCtrl;
|
||||||
QString currentProject;
|
QString currentProject;
|
||||||
|
|
|
@ -187,6 +187,38 @@ namespace GUIEditor
|
||||||
widgetHierarchyMap.erase( itr );
|
widgetHierarchyMap.erase( itr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WidgetHierarchy::getCurrentGroup( QString &g )
|
||||||
|
{
|
||||||
|
std::string s = CWidgetManager::getInstance()->getCurrentEditorSelection();
|
||||||
|
if( s.empty() )
|
||||||
|
{
|
||||||
|
g = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLGUI::CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( s );
|
||||||
|
if( e == NULL )
|
||||||
|
{
|
||||||
|
g = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( e->isGroup() )
|
||||||
|
{
|
||||||
|
g = e->getId().c_str();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLGUI::CInterfaceGroup *p = e->getParent();
|
||||||
|
if( p == NULL )
|
||||||
|
{
|
||||||
|
g = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g = p->getId().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
void WidgetHierarchy::onGUILoaded()
|
void WidgetHierarchy::onGUILoaded()
|
||||||
{
|
{
|
||||||
if( masterGroup.empty() )
|
if( masterGroup.empty() )
|
||||||
|
|
|
@ -44,6 +44,8 @@ namespace GUIEditor
|
||||||
|
|
||||||
void onWidgetDeleted( const std::string &id );
|
void onWidgetDeleted( const std::string &id );
|
||||||
|
|
||||||
|
void getCurrentGroup( QString &g );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
|
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,11 @@ namespace GUIEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the node names and put them into the vector
|
/// Get the node names and put them into the vector
|
||||||
void getNames( std::vector< std::string > &v ) const
|
void getNames( std::vector< std::string > &v, bool includeAbstract = true ) const
|
||||||
{
|
{
|
||||||
if( root == NULL )
|
if( root == NULL )
|
||||||
return;
|
return;
|
||||||
root->getNames( v );
|
root->getNames( v, includeAbstract );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -215,11 +215,13 @@ namespace GUIEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the node names and put them into the vector
|
/// Get the node names and put them into the vector
|
||||||
void getNames( std::vector< std::string > &v ) const
|
void getNames( std::vector< std::string > &v, bool includeAbstract = true ) const
|
||||||
{
|
{
|
||||||
v.push_back( info.name );
|
if( !info.isAbstract || ( info.isAbstract && includeAbstract ) )
|
||||||
|
v.push_back( info.name );
|
||||||
|
|
||||||
for( std::vector< CWidgetInfoTreeNode* >::const_iterator itr = children.begin(); itr != children.end(); ++itr )
|
for( std::vector< CWidgetInfoTreeNode* >::const_iterator itr = children.begin(); itr != children.end(); ++itr )
|
||||||
( *itr )->getNames( v );
|
( *itr )->getNames( v, includeAbstract );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accepts a visitor to itself and to the children nodes
|
/// Accepts a visitor to itself and to the children nodes
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace GUIEditor{
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tree->removeNode( widgetName.toUtf8().constData() );
|
tree->removeNode( widgetName.toUtf8().constData() );
|
||||||
|
Q_EMIT treeChanged();
|
||||||
widgetPropTree->clear();
|
widgetPropTree->clear();
|
||||||
buildWidgetList();
|
buildWidgetList();
|
||||||
}
|
}
|
||||||
|
@ -156,6 +157,7 @@ namespace GUIEditor{
|
||||||
void CWidgetProperties::onWidgetAdded()
|
void CWidgetProperties::onWidgetAdded()
|
||||||
{
|
{
|
||||||
buildWidgetList();
|
buildWidgetList();
|
||||||
|
Q_EMIT treeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWidgetProperties::buildWidgetList()
|
void CWidgetProperties::buildWidgetList()
|
||||||
|
|
|
@ -74,6 +74,9 @@ namespace GUIEditor
|
||||||
CWidgetInfoTree *tree;
|
CWidgetInfoTree *tree;
|
||||||
NewPropertyWidget *newPropertyWidget;
|
NewPropertyWidget *newPropertyWidget;
|
||||||
NewWidgetWidget *newWidgetWidget;
|
NewWidgetWidget *newWidgetWidget;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void treeChanged();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue