17#include "importpositiondialog.h"
18#include "ui_importpositiondialog.h"
21#include <QStandardItemModel>
23#include "layercamera.h"
24#include "viewmanager.h"
25#include "layermanager.h"
26#include "scribblearea.h"
28ImportPositionDialog::ImportPositionDialog(
Editor* editor,
QWidget *parent) :
34 ui->cbImagePosition->addItem(tr(
"Center of current view"));
35 ui->cbImagePosition->addItem(tr(
"Center of canvas (0,0)"));
36 ui->cbImagePosition->addItem(tr(
"Center of camera, current frame"));
37 ui->cbImagePosition->addItem(tr(
"Center of camera, follow camera"));
39 if (mEditor->layers()->getCameraLayerBelow(mEditor->currentLayerIndex()) ==
nullptr) {
42 model->item(3, 0)->setEnabled(
false);
49 int value = settings.value(IMPORT_REPOSITION_TYPE).toInt();
51 ui->cbImagePosition->setCurrentIndex(value);
52 didChangeComboBoxIndex(value);
55ImportPositionDialog::~ImportPositionDialog()
60void ImportPositionDialog::didChangeComboBoxIndex(
const int index)
62 mImportOption = ImportPosition::getTypeFromIndex(index);
65void ImportPositionDialog::changeImportView()
67 mEditor->view()->setImportFollowsCamera(
false);
69 if (mImportOption == ImportPosition::Type::CenterOfView)
71 QPointF centralPoint = mEditor->getScribbleArea()->getCentralPoint();
72 transform = transform.
fromTranslate(centralPoint.
x(), centralPoint.
y());
73 mEditor->view()->setImportView(transform);
75 settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
78 else if (mImportOption == ImportPosition::Type::CenterOfCanvas)
81 mEditor->view()->setImportView(transform);
83 settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
86 else if (mImportOption == ImportPosition::Type::CenterOfCamera)
88 LayerCamera* layerCam =
static_cast<LayerCamera*
>(mEditor->layers()->getCameraLayerBelow(mEditor->currentLayerIndex()));
90 QRectF cameraRect = layerCam->getViewRect();
92 mEditor->view()->setImportView(transform);
94 settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
98 Q_ASSERT(mImportOption == ImportPosition::Type::CenterOfCameraFollowed);
99 mEditor->view()->setImportFollowsCamera(
true);
101 settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
void currentIndexChanged(int index)
QPointF center() const const
void setEnabled(bool enabled)
QStandardItem * item(int row, int column) const const