Advertisement
Guest User

Untitled

a guest
Mar 9th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "imageeditor.h"
  2.  
  3. #include "../../resources/layers/imagelayer.h"
  4.  
  5. #include "../fields/intfield.h"
  6. #include "../fields/pointfield.h"
  7. #include "../fields/booleanfield.h"
  8. #include "../fields/pixmapfield.h"
  9.  
  10. ImageEditor::ImageEditor(Layer *l, QWidget *parent)
  11.     : Editor(l, parent)
  12. {
  13.     // Cast layer
  14.     ImageLayer *nl = dynamic_cast<ImageLayer *>(l);
  15.  
  16.     // Set up fields widgets and add them to layout
  17.     // z (short)
  18.     IntField *f_z = new IntField("z", nl->z(), this, -32768, 32767);
  19.     m_layout->addWidget(f_z);
  20.     // subz (short)
  21.     IntField *f_subz = new IntField("subz", nl->subz(), this, -32768, 32767);
  22.     m_layout->addWidget(f_subz);
  23.     // id (short)
  24.     IntField *f_id = new IntField("id", nl->id(), this, -32768, 32767);
  25.     m_layout->addWidget(f_id);
  26.     // o (coord16)
  27.     PointField *f_o = new PointField("o", nl->o(), true, this);
  28.     m_layout->addWidget(f_o);
  29.     // nooff
  30.     BooleanField *f_nooff = new BooleanField("nooff", nl->nooff(), this);
  31.     m_layout->addWidget(f_nooff);
  32.     // image
  33.     PixmapField *f_image = new PixmapField("image", nl->image(), this);
  34.     m_layout->addWidget(f_image);
  35.  
  36.     // Add connections for fields
  37.     connect(f_z, &IntField::fieldChanged, [nl, f_z, this](){nl->setZ(f_z->getValue()); this->onFieldChanged();});
  38.     connect(f_subz, &IntField::fieldChanged, [nl, f_subz, this](){nl->setSubz(f_subz->getValue()); this->onFieldChanged();});
  39.     connect(f_id, &IntField::fieldChanged, [nl, f_id, this](){nl->setId(f_id->getValue()); this->onFieldChanged();});
  40.     connect(f_o, &IntField::fieldChanged, [nl, f_o, this](){nl->setO(f_o->getValue()); this->onFieldChanged();});
  41.     connect(f_nooff, &BooleanField::fieldChanged, [nl, f_nooff, this](){nl->setNooff(f_nooff->getValue()); this->onFieldChanged();});
  42.     connect(f_image, &PixmapField::fieldChanged, [nl, f_image, this](){nl->setImage(f_image->getValue()); this->onFieldChanged();});
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement