Changed the Shader widget a little.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent a57bb57c58
commit 128c2a3270

@ -78,13 +78,12 @@ namespace MaterialEditor
void ShaderEditorWidget::onOKClicked()
{
close();
Q_EMIT okClicked();
accept();
}
void ShaderEditorWidget::onCancelClicked()
{
close();
reject();
}
void ShaderEditorWidget::reset()
@ -94,6 +93,7 @@ namespace MaterialEditor
descriptionEdit->setPlainText( empty );
vsEdit->setPlainText( empty );
fsEdit->setPlainText( empty );
setResult( QDialog::Rejected );
}
}

@ -45,9 +45,6 @@ namespace MaterialEditor
void onOKClicked();
void onCancelClicked();
Q_SIGNALS:
void okClicked();
private:
void setupConnections();
};

@ -53,11 +53,9 @@ namespace MaterialEditor
bool ShaderWidget::nameExists( const QString &name )
{
QTreeWidgetItem *item = NULL;
for( int i = 0; i < shaderListWidget->topLevelItemCount(); i++ )
for( int i = 0; i < shaderList->count(); i++ )
{
item = shaderListWidget->topLevelItem( i );
if( item->text( 0 ) == name )
if( shaderList->item( i )->text() == name )
return true;
}
@ -100,28 +98,13 @@ namespace MaterialEditor
return;
}
QString fn =
QFileDialog::getSaveFileName(
this,
tr( "Shader filename" ),
tr( "/" ),
tr( "Nel shader files ( *.nelshdr )" )
);
if( fn.isEmpty() )
return;
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText( 0, name );
item->setText( 1, fn );
shaderListWidget->addTopLevelItem( item );
shaderList->addItem( name );
}
void ShaderWidget::onRemoveClicked()
{
QTreeWidgetItem *item = shaderListWidget->currentItem();
if( item == NULL )
int i = shaderList->currentRow();
if( i < 0 )
return;
int selection =
@ -134,25 +117,32 @@ namespace MaterialEditor
);
if( selection == QMessageBox::Yes )
{
QListWidgetItem *item = shaderList->takeItem( i );
delete item;
}
}
void ShaderWidget::onEditClicked()
{
QTreeWidgetItem *item = shaderListWidget->currentItem();
if( item == NULL )
int i = shaderList->currentRow();
if( i < 0 )
return;
QString name = item->text( 0 );
QString name = shaderList->item( i )->text();
shaderEditorWidget->reset();
shaderEditorWidget->setName( name );
QString sname;
bool ok;
int res;
do{
ok = true;
shaderEditorWidget->exec();
res = shaderEditorWidget->exec();
if( res == QDialog::Rejected )
return;
shaderEditorWidget->getName( sname );
if( sname != name )
@ -166,7 +156,7 @@ namespace MaterialEditor
}while( !ok );
item->setText( 0, sname );
shaderList->item( i )->setText( sname );
// save

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>502</width>
<height>467</height>
<height>401</height>
</rect>
</property>
<property name="windowTitle">
@ -25,18 +25,7 @@
</widget>
</item>
<item row="1" column="0" rowspan="4" colspan="2">
<widget class="QTreeWidget" name="shaderListWidget">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Path</string>
</property>
</column>
</widget>
<widget class="QListWidget" name="shaderList"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="addButton">
@ -84,7 +73,7 @@
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2">
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description</string>

Loading…
Cancel
Save