Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
importpositiondialog.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#include "importpositiondialog.h"
18#include "ui_importpositiondialog.h"
19
20#include <QSettings>
21#include <QStandardItemModel>
22#include "editor.h"
23#include "layermanager.h"
24
25ImportPositionDialog::ImportPositionDialog(Editor* editor, QWidget *parent) :
26 QDialog(parent),
27 ui(new Ui::ImportPositionDialog), mEditor(editor)
28{
29 ui->setupUi(this);
30
31 ui->cbImagePosition->addItem(tr("Center of current view"));
32 ui->cbImagePosition->addItem(tr("Center of canvas (0,0)"));
33 ui->cbImagePosition->addItem(tr("Center of camera, current frame"));
34 ui->cbImagePosition->addItem(tr("Center of camera, follow camera"));
35
36 if (mEditor->layers()->getCameraLayerBelow(mEditor->currentLayerIndex()) == nullptr) {
37 auto model = dynamic_cast<QStandardItemModel*>(ui->cbImagePosition->model());
38 model->item(2, 0)->setEnabled(false);
39 model->item(3, 0)->setEnabled(false);
40 }
41
42 connect(ui->cbImagePosition, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ImportPositionDialog::didChangeComboBoxIndex);
43 connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ImportPositionDialog::changeImportView);
44
45 QSettings settings(PENCIL2D, PENCIL2D);
46 int value = settings.value(IMPORT_REPOSITION_TYPE).toInt();
47
48 ui->cbImagePosition->setCurrentIndex(value);
49 didChangeComboBoxIndex(value);
50}
51
52ImportPositionDialog::~ImportPositionDialog()
53{
54 delete ui;
55}
56
57void ImportPositionDialog::didChangeComboBoxIndex(const int index)
58{
59 mImportConfig.positionType = getTypeFromIndex(index);
60}
61
62void ImportPositionDialog::changeImportView()
63{
64 if (mImportConfig.positionType == ImportImageConfig::CenterOfCamera) {
65 mImportConfig.importFrame = mEditor->currentFrame();
66 }
67
68 QSettings settings(PENCIL2D, PENCIL2D);
69 settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
70}
Editor
Definition: editor.h:71
ImportPositionDialog
Definition: importpositiondialog.h:31
QComboBox
QComboBox::currentIndexChanged
void currentIndexChanged(int index)
QDialog
QDialogButtonBox::accepted
void accepted()
QSettings
QStandardItem::setEnabled
void setEnabled(bool enabled)
QStandardItemModel
QStandardItemModel::item
QStandardItem * item(int row, int column) const const
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39