2012-01-05 16:32:41 +00:00
|
|
|
#include "baseform.h"
|
2012-01-05 19:41:10 +00:00
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
#include "inputdouble.h"
|
2012-01-06 16:09:03 +00:00
|
|
|
#include "inputint.h"
|
2012-02-12 17:26:17 +00:00
|
|
|
#include "inputboolean.h"
|
2012-01-05 19:41:10 +00:00
|
|
|
#include "inputcolor.h"
|
2012-01-07 16:53:23 +00:00
|
|
|
#include "inputcolorgradation.h"
|
|
|
|
#include "inputnoise.h"
|
2012-05-29 13:32:23 +00:00
|
|
|
#include "inputcurve.h"
|
2012-06-02 09:46:24 +00:00
|
|
|
#include "inputmaterial.h"
|
2012-06-23 21:47:12 +00:00
|
|
|
#include "inputenum.h"
|
2012-07-10 15:38:12 +00:00
|
|
|
#include "inputlayers.h"
|
2012-01-05 16:32:41 +00:00
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
2012-07-05 17:55:25 +00:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QInputDialog>
|
2013-08-23 22:50:56 +00:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QPushButton>
|
2012-01-05 16:32:41 +00:00
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
BaseForm::BaseForm(QWidget* parent, bool auto_apply, bool with_layers) : QWidget(parent)
|
2012-01-05 16:32:41 +00:00
|
|
|
{
|
2012-04-11 19:59:50 +00:00
|
|
|
QWidget* control;
|
|
|
|
QWidget* layers;
|
|
|
|
QLabel* label;
|
2012-01-05 16:32:41 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
this->_auto_apply = auto_apply;
|
|
|
|
this->_with_layers = with_layers;
|
2012-01-27 23:01:21 +00:00
|
|
|
|
2012-04-11 19:59:50 +00:00
|
|
|
setLayout(new QHBoxLayout());
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-04-11 19:59:50 +00:00
|
|
|
control = new QWidget(this);
|
|
|
|
control->setLayout(new QVBoxLayout());
|
2012-04-14 15:52:16 +00:00
|
|
|
control->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
2012-04-11 19:59:50 +00:00
|
|
|
layout()->addWidget(control);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_count = 0;
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
if (with_layers)
|
|
|
|
{
|
2012-04-11 19:59:50 +00:00
|
|
|
layers = new QWidget(this);
|
|
|
|
layers->setLayout(new QHBoxLayout());
|
|
|
|
layers->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
2012-02-05 11:31:16 +00:00
|
|
|
|
2012-04-11 19:59:50 +00:00
|
|
|
label = new QLabel(tr("Layers : "), layers);
|
|
|
|
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
layers->layout()->addWidget(label);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_list = new QComboBox(layers);
|
|
|
|
layers->layout()->addWidget(_layer_list);
|
|
|
|
QObject::connect(_layer_list, SIGNAL(currentIndexChanged(int)), this, SLOT(layerListChanged()));
|
|
|
|
|
2013-04-17 12:29:51 +00:00
|
|
|
_layer_new = new QPushButton(QIcon(getDataPath("images/layer_add.png")), "", layers);
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_new->setToolTip(tr("Add layer"));
|
|
|
|
_layer_new->setMaximumSize(30, 30);
|
|
|
|
layers->layout()->addWidget(_layer_new);
|
|
|
|
QObject::connect(_layer_new, SIGNAL(clicked()), this, SLOT(layerAddClicked()));
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2013-04-17 12:29:51 +00:00
|
|
|
_layer_del = new QPushButton(QIcon(getDataPath("images/layer_del.png")), "", layers);
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_del->setToolTip(tr("Delete layer"));
|
|
|
|
_layer_del->setMaximumSize(30, 30);
|
|
|
|
layers->layout()->addWidget(_layer_del);
|
|
|
|
QObject::connect(_layer_del, SIGNAL(clicked()), this, SLOT(layerDelClicked()));
|
|
|
|
|
2013-04-17 12:29:51 +00:00
|
|
|
_layer_rename = new QPushButton(QIcon(getDataPath("images/layer_rename.png")), "", layers);
|
2012-07-05 17:55:25 +00:00
|
|
|
_layer_rename->setToolTip(tr("Rename layer"));
|
|
|
|
_layer_rename->setMaximumSize(30, 30);
|
|
|
|
layers->layout()->addWidget(_layer_rename);
|
|
|
|
QObject::connect(_layer_rename, SIGNAL(clicked()), this, SLOT(layerRenameClicked()));
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2013-04-17 12:29:51 +00:00
|
|
|
_layer_up = new QPushButton(QIcon(getDataPath("images/layer_up.png")), "", layers);
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_up->setToolTip(tr("Move layer upward"));
|
|
|
|
_layer_up->setMaximumSize(30, 30);
|
|
|
|
layers->layout()->addWidget(_layer_up);
|
|
|
|
QObject::connect(_layer_up, SIGNAL(clicked()), this, SLOT(layerUpClicked()));
|
|
|
|
|
2013-04-17 12:29:51 +00:00
|
|
|
_layer_down = new QPushButton(QIcon(getDataPath("images/layer_down.png")), "", layers);
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_down->setToolTip(tr("Move layer downward"));
|
|
|
|
_layer_down->setMaximumSize(30, 30);
|
|
|
|
layers->layout()->addWidget(_layer_down);
|
|
|
|
QObject::connect(_layer_down, SIGNAL(clicked()), this, SLOT(layerDownClicked()));
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-04-11 19:59:50 +00:00
|
|
|
control->layout()->addWidget(layers);
|
2012-07-05 11:37:50 +00:00
|
|
|
control->layout()->setAlignment(_buttons, Qt::AlignTop);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
2012-01-05 16:32:41 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_previews = new QWidget(this);
|
|
|
|
_previews->setLayout(new QVBoxLayout());
|
|
|
|
_previews->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
layout()->addWidget(_previews);
|
|
|
|
layout()->setAlignment(_previews, Qt::AlignTop);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_form = new QWidget(this);
|
|
|
|
_form->setLayout(new QHBoxLayout());
|
|
|
|
control->layout()->addWidget(_form);
|
|
|
|
control->layout()->setAlignment(_form, Qt::AlignTop);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_form_labels = new QWidget(_form);
|
|
|
|
_form_labels->setLayout(new QVBoxLayout());
|
|
|
|
_form->layout()->addWidget(_form_labels);
|
2012-01-05 16:32:41 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_form_previews = new QWidget(_form);
|
|
|
|
_form_previews->setLayout(new QVBoxLayout());
|
|
|
|
_form->layout()->addWidget(_form_previews);
|
2012-04-14 15:52:16 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_form_controls = new QWidget(_form);
|
|
|
|
_form_controls->setLayout(new QVBoxLayout());
|
|
|
|
_form->layout()->addWidget(_form_controls);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_buttons = new QWidget(this);
|
|
|
|
_buttons->setLayout(new QHBoxLayout());
|
|
|
|
control->layout()->addWidget(_buttons);
|
|
|
|
control->layout()->setAlignment(_buttons, Qt::AlignBottom);
|
|
|
|
|
|
|
|
_button_revert = addButton(tr("Revert"));
|
2013-04-17 12:29:51 +00:00
|
|
|
_button_revert->setIcon(QIcon(getDataPath("images/cancel.png")));
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_revert->setEnabled(false);
|
|
|
|
connect(_button_revert, SIGNAL(clicked()), this, SLOT(revertConfig()));
|
2012-08-13 19:19:19 +00:00
|
|
|
_button_apply = addButton(tr("Apply"));
|
2013-04-17 12:29:51 +00:00
|
|
|
_button_apply->setIcon(QIcon(getDataPath("images/apply.png")));
|
2012-08-13 19:19:19 +00:00
|
|
|
_button_apply->setEnabled(false);
|
|
|
|
connect(_button_apply, SIGNAL(clicked()), this, SLOT(applyConfig()));
|
2012-11-19 20:40:57 +00:00
|
|
|
_button_preset = addButton(tr("Load preset"));
|
2013-04-17 12:29:51 +00:00
|
|
|
_button_preset->setIcon(QIcon(getDataPath("images/auto.png")));
|
2012-11-19 20:40:57 +00:00
|
|
|
_button_preset->hide();
|
|
|
|
connect(_button_preset, SIGNAL(clicked()), this, SLOT(presetChoiceClicked()));
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_auto_update_previews = true;
|
2012-01-27 23:01:21 +00:00
|
|
|
|
|
|
|
if (auto_apply)
|
|
|
|
{
|
2012-06-02 09:46:24 +00:00
|
|
|
hideButtons();
|
2012-01-27 23:01:21 +00:00
|
|
|
}
|
2012-01-05 16:32:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 09:46:24 +00:00
|
|
|
void BaseForm::hideButtons()
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->hide();
|
|
|
|
_button_revert->hide();
|
2012-06-02 09:46:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-27 10:30:00 +00:00
|
|
|
void BaseForm::savePack(PackStream* stream)
|
|
|
|
{
|
|
|
|
// Save previews status
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _previews_list.size(); i++)
|
2012-06-27 10:30:00 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_previews_list[i]->savePack(stream);
|
2012-06-27 10:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseForm::loadPack(PackStream* stream)
|
|
|
|
{
|
|
|
|
// Load previews status
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _previews_list.size(); i++)
|
2012-06-27 10:30:00 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_previews_list[i]->loadPack(stream);
|
2012-06-27 10:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-25 22:32:06 +00:00
|
|
|
void BaseForm::configChangeEvent()
|
2012-01-05 16:32:41 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_auto_apply)
|
2012-01-27 23:01:21 +00:00
|
|
|
{
|
|
|
|
applyConfig();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(true);
|
|
|
|
_button_revert->setEnabled(true);
|
2012-01-27 23:01:21 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _inputs_list.size(); i++)
|
2012-06-23 22:11:25 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_with_layers && _layer_list->count() == 0)
|
2012-06-27 14:03:19 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_inputs_list[i]->checkVisibility(false);
|
2012-06-27 14:03:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_inputs_list[i]->checkVisibility(true);
|
2012-06-27 14:03:19 +00:00
|
|
|
}
|
2012-06-23 22:11:25 +00:00
|
|
|
}
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_auto_update_previews)
|
2012-01-05 16:32:41 +00:00
|
|
|
{
|
2012-06-27 13:28:12 +00:00
|
|
|
updatePreviews();
|
2012-01-05 16:32:41 +00:00
|
|
|
}
|
2012-01-05 18:39:17 +00:00
|
|
|
}
|
2012-01-05 16:32:41 +00:00
|
|
|
|
2012-11-19 20:40:57 +00:00
|
|
|
void BaseForm::autoPresetSelected(int)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _inputs_list.size(); i++)
|
|
|
|
{
|
|
|
|
_inputs_list[i]->revert();
|
|
|
|
}
|
|
|
|
updatePreviews();
|
|
|
|
configChangeEvent();
|
|
|
|
}
|
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
void BaseForm::revertConfig()
|
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _inputs_list.size(); i++)
|
2012-01-05 16:32:41 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_inputs_list[i]->revert();
|
2012-01-05 16:32:41 +00:00
|
|
|
}
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_with_layers)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 17:05:03 +00:00
|
|
|
rebuildLayerList();
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_layer_list->currentIndex() < 0 && _layer_list->count() > 0)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
_layer_list->setCurrentIndex(0);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-05 18:39:17 +00:00
|
|
|
|
2013-01-16 15:56:17 +00:00
|
|
|
for (int i = 0; i < _inputs_list.size(); i++)
|
|
|
|
{
|
|
|
|
if (_with_layers && _layer_list->count() == 0)
|
|
|
|
{
|
|
|
|
_inputs_list[i]->checkVisibility(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_inputs_list[i]->checkVisibility(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-27 13:28:12 +00:00
|
|
|
updatePreviews();
|
2012-07-04 09:50:06 +00:00
|
|
|
//configChangeEvent();
|
2012-01-10 20:51:27 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(false);
|
|
|
|
_button_revert->setEnabled(false);
|
2012-01-05 16:32:41 +00:00
|
|
|
}
|
|
|
|
|
2012-01-06 16:09:03 +00:00
|
|
|
void BaseForm::applyConfig()
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(false);
|
|
|
|
_button_revert->setEnabled(false);
|
2012-01-27 23:01:21 +00:00
|
|
|
|
2012-01-26 22:30:20 +00:00
|
|
|
emit(configApplied());
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
void BaseForm::rebuildLayerList()
|
|
|
|
{
|
|
|
|
if (_with_layers)
|
|
|
|
{
|
|
|
|
int selected = _layer_list->currentIndex();
|
|
|
|
_layer_list->clear();
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 17:05:03 +00:00
|
|
|
_layer_names = getLayers();
|
|
|
|
_layer_count = _layer_names.count();
|
2012-07-05 11:37:50 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < _layer_count; i++)
|
|
|
|
{
|
2012-07-05 17:05:03 +00:00
|
|
|
_layer_list->addItem(QString(tr("Layer %1 - %2")).arg(i + 1).arg(_layer_names[i]));
|
2012-07-05 11:37:50 +00:00
|
|
|
}
|
|
|
|
if (selected >= 0)
|
|
|
|
{
|
|
|
|
if (selected >= _layer_count)
|
|
|
|
{
|
|
|
|
_layer_list->setCurrentIndex(_layer_count - 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_layer_list->setCurrentIndex(selected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
void BaseForm::layerAddClicked()
|
|
|
|
{
|
|
|
|
layerAddedEvent();
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
rebuildLayerList();
|
|
|
|
_layer_list->setCurrentIndex(_layer_list->count() - 1);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(true);
|
|
|
|
_button_revert->setEnabled(true);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BaseForm::layerDelClicked()
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_layer_list->currentIndex() >= 0)
|
|
|
|
{
|
|
|
|
layerDeletedEvent(_layer_list->currentIndex());
|
|
|
|
|
|
|
|
rebuildLayerList();
|
|
|
|
|
|
|
|
_button_apply->setEnabled(true);
|
|
|
|
_button_revert->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
void BaseForm::layerUpClicked()
|
|
|
|
{
|
|
|
|
if (_layer_list->currentIndex() < _layer_count - 1)
|
|
|
|
{
|
|
|
|
layerMovedEvent(_layer_list->currentIndex(), _layer_list->currentIndex() + 1);
|
|
|
|
|
|
|
|
rebuildLayerList();
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 15:50:46 +00:00
|
|
|
_layer_list->setCurrentIndex(_layer_list->currentIndex() + 1);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(true);
|
|
|
|
_button_revert->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseForm::layerDownClicked()
|
|
|
|
{
|
|
|
|
if (_layer_list->currentIndex() > 0)
|
|
|
|
{
|
|
|
|
layerMovedEvent(_layer_list->currentIndex(), _layer_list->currentIndex() - 1);
|
|
|
|
|
|
|
|
rebuildLayerList();
|
|
|
|
|
2012-07-05 15:50:46 +00:00
|
|
|
_layer_list->setCurrentIndex(_layer_list->currentIndex() - 1);
|
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(true);
|
|
|
|
_button_revert->setEnabled(true);
|
|
|
|
}
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 17:55:25 +00:00
|
|
|
void BaseForm::layerRenameClicked()
|
|
|
|
{
|
|
|
|
int layer = _layer_list->currentIndex();
|
|
|
|
if (layer >= 0)
|
|
|
|
{
|
|
|
|
QString new_name = QInputDialog::getText(this, tr("Rename layer"), tr("New name: "), QLineEdit::Normal, _layer_names[layer]);
|
|
|
|
if (not new_name.isEmpty())
|
|
|
|
{
|
|
|
|
layerRenamedEvent(layer, new_name);
|
|
|
|
|
|
|
|
_button_apply->setEnabled(true);
|
|
|
|
_button_revert->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
void BaseForm::layerListChanged()
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
bool changed = _button_apply->isEnabled();
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
layerSelectedEvent(_layer_list->currentIndex());
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_button_apply->setEnabled(changed);
|
|
|
|
_button_revert->setEnabled(changed);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 20:40:57 +00:00
|
|
|
void BaseForm::presetChoiceClicked()
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
QString item = QInputDialog::getItem(this, tr("Choose a preset"), tr("Preset settings : "), _preset_list, 0, false, &ok);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-11-19 20:40:57 +00:00
|
|
|
if (ok && !item.isEmpty())
|
|
|
|
{
|
|
|
|
int preset = _preset_list.indexOf(item);
|
|
|
|
if (preset >= 0)
|
|
|
|
{
|
|
|
|
autoPresetSelected(preset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-21 13:41:02 +00:00
|
|
|
void BaseForm::addPreview(BasePreview* preview, QString label)
|
2012-01-05 16:32:41 +00:00
|
|
|
{
|
2012-04-03 19:33:40 +00:00
|
|
|
QLabel* label_widget;
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
label_widget = new QLabel(label, _previews);
|
2012-04-03 19:33:40 +00:00
|
|
|
label_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_previews->layout()->addWidget(label_widget);
|
|
|
|
_previews->layout()->addWidget(preview);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 18:14:51 +00:00
|
|
|
_previews_list.append(preview);
|
2012-01-05 16:32:41 +00:00
|
|
|
}
|
|
|
|
|
2012-01-06 16:09:03 +00:00
|
|
|
QPushButton* BaseForm::addButton(QString label)
|
|
|
|
{
|
|
|
|
QPushButton* button = new QPushButton(label);
|
2012-07-05 11:37:50 +00:00
|
|
|
_buttons->layout()->addWidget(button);
|
2012-01-06 16:09:03 +00:00
|
|
|
return button;
|
|
|
|
}
|
2012-11-19 20:40:57 +00:00
|
|
|
|
|
|
|
void BaseForm::addAutoPreset(QString label)
|
|
|
|
{
|
|
|
|
_preset_list.append(label);
|
|
|
|
_button_preset->show();
|
|
|
|
}
|
2012-01-06 16:09:03 +00:00
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInput(BaseInput* input)
|
2012-01-05 16:32:41 +00:00
|
|
|
{
|
2012-04-14 15:52:16 +00:00
|
|
|
int row_height = 30;
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-07-05 11:37:50 +00:00
|
|
|
_form_labels->layout()->addWidget(input->label());
|
|
|
|
_form_previews->layout()->addWidget(input->preview());
|
|
|
|
_form_controls->layout()->addWidget(input->control());
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-04-14 15:52:16 +00:00
|
|
|
input->label()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
|
|
input->label()->setMinimumSize(150, row_height);
|
|
|
|
input->label()->setMaximumSize(250, row_height);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-01-07 16:53:23 +00:00
|
|
|
input->preview()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2012-04-14 15:52:16 +00:00
|
|
|
input->preview()->setMinimumSize(100, row_height);
|
|
|
|
input->preview()->setMaximumSize(250, row_height);
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-01-07 16:53:23 +00:00
|
|
|
input->control()->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
2012-04-14 15:52:16 +00:00
|
|
|
input->control()->setMinimumSize(280, row_height);
|
|
|
|
input->control()->setMaximumSize(700, row_height);
|
2012-01-07 16:53:23 +00:00
|
|
|
|
2012-01-25 22:32:06 +00:00
|
|
|
connect(input, SIGNAL(valueChanged()), this, SLOT(configChangeEvent()));
|
2012-01-06 16:09:03 +00:00
|
|
|
|
2012-07-05 18:14:51 +00:00
|
|
|
_inputs_list.append(input);
|
2012-01-08 10:31:01 +00:00
|
|
|
input->revert();
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
return input;
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputInt(QString label, int* value, int min, int max, int small_step, int large_step)
|
2012-01-06 16:09:03 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputInt(_form, label, value, min, max, small_step, large_step));
|
2012-01-05 18:39:17 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step)
|
2012-01-05 18:39:17 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputDouble(_form, label, value, min, max, small_step, large_step));
|
2012-01-05 16:32:41 +00:00
|
|
|
}
|
2012-01-05 19:41:10 +00:00
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputBoolean(QString label, int* value)
|
2012-02-12 17:26:17 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputBoolean(_form, label, value));
|
2012-02-12 17:26:17 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputColor(QString label, Color* value)
|
2012-01-05 19:41:10 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputColor(_form, label, value));
|
2012-01-05 19:41:10 +00:00
|
|
|
}
|
2012-01-07 16:53:23 +00:00
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputColorGradation(QString label, ColorGradation* value)
|
2012-01-07 16:53:23 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputColorGradation(_form, label, value));
|
2012-01-07 16:53:23 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputNoise(QString label, NoiseGenerator* value)
|
2012-01-07 16:53:23 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputNoise(_form, label, value));
|
2012-01-07 16:53:23 +00:00
|
|
|
}
|
2012-02-05 11:31:16 +00:00
|
|
|
|
2012-06-27 12:49:51 +00:00
|
|
|
BaseInput* BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel)
|
2012-05-29 13:32:23 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputCurve(_form, label, value, xmin, xmax, ymin, ymax, xlabel, ylabel));
|
2012-05-29 13:32:23 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputMaterial(QString label, SurfaceMaterial* material)
|
2012-06-02 09:46:24 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputMaterial(_form, label, material));
|
2012-06-02 09:46:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:11:25 +00:00
|
|
|
BaseInput* BaseForm::addInputEnum(QString label, int* value, const QStringList& values)
|
2012-06-23 21:47:12 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return addInput(new InputEnum(_form, label, value, values));
|
2012-06-23 21:47:12 +00:00
|
|
|
}
|
|
|
|
|
2012-07-10 19:39:12 +00:00
|
|
|
BaseInput* BaseForm::addInputLayers(QString label, Layers* value, FormLayerBuilder form_builder)
|
2012-07-10 15:38:12 +00:00
|
|
|
{
|
2012-07-10 19:39:12 +00:00
|
|
|
return addInput(new InputLayers(_form, label, value, form_builder));
|
2012-07-10 15:38:12 +00:00
|
|
|
}
|
|
|
|
|
2012-06-27 13:28:12 +00:00
|
|
|
void BaseForm::updatePreviews()
|
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _previews_list.size(); i++)
|
2012-06-27 13:28:12 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_previews_list[i]->redraw();
|
2012-06-27 13:28:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseForm::disablePreviewsUpdate()
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
_auto_update_previews = false;
|
2012-06-27 13:28:12 +00:00
|
|
|
}
|
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
int BaseForm::currentLayer()
|
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
if (_with_layers)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 11:37:50 +00:00
|
|
|
return _layer_list->currentIndex();
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-05 17:05:03 +00:00
|
|
|
QStringList BaseForm::getLayers()
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 17:05:03 +00:00
|
|
|
return QStringList();
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
void BaseForm::layerAddedEvent()
|
|
|
|
{
|
2012-07-05 17:05:03 +00:00
|
|
|
rebuildLayerList();
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 17:05:03 +00:00
|
|
|
void BaseForm::layerDeletedEvent(int)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 17:05:03 +00:00
|
|
|
rebuildLayerList();
|
2012-07-05 11:37:50 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 17:05:03 +00:00
|
|
|
void BaseForm::layerMovedEvent(int, int)
|
2012-07-05 11:37:50 +00:00
|
|
|
{
|
2012-07-05 17:05:03 +00:00
|
|
|
rebuildLayerList();
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 17:55:25 +00:00
|
|
|
void BaseForm::layerRenamedEvent(int, QString)
|
|
|
|
{
|
|
|
|
rebuildLayerList();
|
|
|
|
}
|
|
|
|
|
2012-02-05 11:31:16 +00:00
|
|
|
void BaseForm::layerSelectedEvent(int layer)
|
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _inputs_list.size(); i++)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_inputs_list[i]->revert();
|
|
|
|
_inputs_list[i]->checkVisibility(layer >= 0);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 18:14:51 +00:00
|
|
|
for (int i = 0; i < _previews_list.size(); i++)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2012-07-05 18:14:51 +00:00
|
|
|
_previews_list[i]->redraw();
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-08-02 19:26:22 +00:00
|
|
|
_layer_del->setEnabled(layer >= 0);
|
|
|
|
_layer_rename->setEnabled(layer >= 0);
|
|
|
|
_layer_down->setEnabled(layer > 0);
|
|
|
|
_layer_up->setEnabled(layer >= 0 and layer < _layer_count - 1);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|