Text justification can now be set using an enum property editor.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-06-20 17:07:27 +02:00
parent 9e36082ff0
commit 1afe2d4a17
3 changed files with 70 additions and 8 deletions

View file

@ -35,6 +35,13 @@ namespace GUIEditor
BUTTON_TYPE_RADIO = 2 BUTTON_TYPE_RADIO = 2
}; };
enum NELTxtJustification
{
TEXT_CLIPWORD,
TEXT_DONTCLIPWORD,
TEXT_JUSTIFIED
};
CPropBrowserCtrl::CPropBrowserCtrl() CPropBrowserCtrl::CPropBrowserCtrl()
{ {
browser = NULL; browser = NULL;
@ -145,7 +152,7 @@ namespace GUIEditor
if( e == NULL ) if( e == NULL )
return; return;
if( ( value < 0 ) || ( value > 2 ) ) if( ( value < BUTTON_TYPE_PUSH ) || ( value > BUTTON_TYPE_RADIO ) )
return; return;
std::string v; std::string v;
@ -157,6 +164,26 @@ namespace GUIEditor
case BUTTON_TYPE_RADIO: v = "radio_button"; break; case BUTTON_TYPE_RADIO: v = "radio_button"; break;
} }
e->setProperty( propName.toUtf8().constData(), v );
}
else
if( propName == "justification" )
{
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
if( e == NULL )
return;
if( ( value < TEXT_CLIPWORD ) || ( value > TEXT_JUSTIFIED ) )
return;
std::string v;
switch( value )
{
case TEXT_CLIPWORD: v = "clip_word"; break;
case TEXT_DONTCLIPWORD: v = "dont_clip_word"; break;
case TEXT_JUSTIFIED: v = "justified"; break;
}
e->setProperty( propName.toUtf8().constData(), v ); e->setProperty( propName.toUtf8().constData(), v );
} }
} }
@ -209,11 +236,6 @@ namespace GUIEditor
if( btype.empty() ) if( btype.empty() )
return; return;
QStringList enums;
enums.push_back( "push_button" );
enums.push_back( "toggle_button" );
enums.push_back( "radio_button" );
int e = -1; int e = -1;
if( btype == "push_button" ) if( btype == "push_button" )
e = BUTTON_TYPE_PUSH; e = BUTTON_TYPE_PUSH;
@ -231,12 +253,52 @@ namespace GUIEditor
if( pp == NULL ) if( pp == NULL )
return; return;
QStringList enums;
enums.push_back( "push_button" );
enums.push_back( "toggle_button" );
enums.push_back( "radio_button" );
enumMgr->setEnumNames( pp, enums ); enumMgr->setEnumNames( pp, enums );
enumMgr->setValue( pp, e ); enumMgr->setValue( pp, e );
browser->addProperty( pp ); browser->addProperty( pp );
return; return;
} }
else else
if( prop.propType == "text_justification" )
{
std::string j = element->getProperty( prop.propName );
if( j.empty() )
return;
int e = -1;
if( j == "clip_word" )
e = TEXT_CLIPWORD;
else
if( j == "dont_clip_word" )
e = TEXT_DONTCLIPWORD;
else
if( j == "justified" )
e = TEXT_JUSTIFIED;
if( e == -1 )
return;
QtProperty *pp = enumMgr->addProperty( prop.propName.c_str() );
if( pp == NULL )
return;
QStringList enums;
enums.push_back( "clip_word" );
enums.push_back( "dont_clip_word" );
enums.push_back( "justified" );
enumMgr->setEnumNames( pp, enums );
enumMgr->setValue( pp, e );
browser->addProperty( pp );
return;
}
else
if( prop.propType == "string" ) if( prop.propType == "string" )
{ {
p = propertyMgr->addProperty( QVariant::String, prop.propName.c_str() ); p = propertyMgr->addProperty( QVariant::String, prop.propName.c_str() );

View file

@ -145,7 +145,7 @@
</property> </property>
<property> <property>
<name>justification</name> <name>justification</name>
<type>string</type> <type>text_justification</type>
<default>dont_clip_word</default> <default>dont_clip_word</default>
</property> </property>
<property> <property>

View file

@ -40,7 +40,7 @@
</property> </property>
<property> <property>
<name>justification</name> <name>justification</name>
<type>string</type> <type>text_justification</type>
<default>dont_clip_word</default> <default>dont_clip_word</default>
</property> </property>
<property> <property>