2012-06-02 09:46:24 +00:00
|
|
|
#include "dialogmaterial.h"
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
/**************** Dialog form ****************/
|
2012-06-02 14:17:01 +00:00
|
|
|
DialogMaterial::DialogMaterial(QWidget *parent, SurfaceMaterial* material) : DialogWithPreview(parent)
|
2012-06-02 09:46:24 +00:00
|
|
|
{
|
|
|
|
QPushButton* button;
|
|
|
|
QWidget* buttons;
|
|
|
|
|
|
|
|
setLayout(new QVBoxLayout());
|
|
|
|
|
|
|
|
_form = new FormMaterial(this, material);
|
|
|
|
_form->hideButtons();
|
|
|
|
layout()->addWidget(_form);
|
2012-06-02 14:17:01 +00:00
|
|
|
|
2012-06-02 09:46:24 +00:00
|
|
|
buttons = new QWidget(this);
|
|
|
|
buttons->setLayout(new QHBoxLayout());
|
|
|
|
layout()->addWidget(buttons);
|
|
|
|
layout()->setAlignment(buttons, Qt::AlignBottom);
|
|
|
|
|
2012-08-13 19:19:19 +00:00
|
|
|
button = new QPushButton(tr("Cancel"), buttons);
|
|
|
|
button->setIcon(QIcon("images/cancel.png"));
|
2012-06-02 09:46:24 +00:00
|
|
|
buttons->layout()->addWidget(button);
|
2012-08-13 19:19:19 +00:00
|
|
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));
|
2012-06-02 09:46:24 +00:00
|
|
|
|
2012-08-13 19:19:19 +00:00
|
|
|
button = new QPushButton(tr("Revert"), buttons);
|
|
|
|
button->setIcon(QIcon("images/revert.png"));
|
2012-06-02 09:46:24 +00:00
|
|
|
buttons->layout()->addWidget(button);
|
|
|
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
|
|
|
|
|
2012-08-13 19:19:19 +00:00
|
|
|
button = new QPushButton(tr("Validate"), buttons);
|
|
|
|
button->setIcon(QIcon("images/apply.png"));
|
2012-06-02 09:46:24 +00:00
|
|
|
buttons->layout()->addWidget(button);
|
2012-08-13 19:19:19 +00:00
|
|
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
2012-06-02 09:46:24 +00:00
|
|
|
|
|
|
|
setWindowTitle(tr("Paysages 3D - Material editor"));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DialogMaterial::getMaterial(QWidget* parent, SurfaceMaterial* material)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
DialogMaterial* dialog = new DialogMaterial(parent, material);
|
|
|
|
result = dialog->exec();
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
dialog->_form->getMaterial(material);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete dialog;
|
|
|
|
|
|
|
|
return (result != 0) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogMaterial::accept()
|
|
|
|
{
|
|
|
|
_form->applyConfig();
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogMaterial::revert()
|
|
|
|
{
|
|
|
|
_form->revertConfig();
|
|
|
|
}
|