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
exportimagedialog.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
18#include "exportimagedialog.h"
19#include "ui_exportimageoptions.h"
20#include "util.h"
21
22ExportImageDialog::ExportImageDialog(QWidget* parent, FileType eFileType) :
23 ImportExportDialog(parent, ImportExportDialog::Export, eFileType),
24 ui(new Ui::ExportImageOptions)
25{
26 ui->setupUi(getOptionsGroupBox());
27 if (eFileType == FileType::IMAGE_SEQUENCE)
28 {
29 setWindowTitle(tr("Export image sequence"));
30 }
31 else
32 {
33 setWindowTitle(tr("Export image"));
34 ui->frameRangeGroupBox->hide();
35 }
36
37 connect(ui->formatComboBox, &QComboBox::currentTextChanged, this, &ExportImageDialog::formatChanged);
38 formatChanged(getExportFormat()); // Make sure file extension matches format combobox
39}
40
41ExportImageDialog::~ExportImageDialog()
42{
43 delete ui;
44}
45
46void ExportImageDialog::setCamerasInfo(const std::vector<std::pair<QString, QSize>>& cameraInfo)
47{
48 Q_ASSERT(ui->cameraCombo);
49
50 ui->cameraCombo->clear();
51 for (const std::pair<QString, QSize>& it : cameraInfo)
52 {
53 ui->cameraCombo->addItem(it.first, it.second);
54 }
55
56 const auto indexChanged = static_cast<void(QComboBox::*)(int i)>(&QComboBox::currentIndexChanged);
57 connect(ui->cameraCombo, indexChanged, this, &ExportImageDialog::cameraComboChanged);
58
59 cameraComboChanged(0);
60}
61
62void ExportImageDialog::setDefaultRange(int startFrame, int endFrame, int endFrameWithSounds)
63{
64 mEndFrame = endFrame;
65 mEndFrameWithSounds = endFrameWithSounds;
66
67 QSignalBlocker b1( ui->startSpinBox );
68 QSignalBlocker b2( ui->endSpinBox );
69
70 ui->startSpinBox->setValue( startFrame );
71 ui->endSpinBox->setValue( endFrame );
72
73 connect(ui->frameCheckBox, &QCheckBox::clicked, this, &ExportImageDialog::frameCheckboxClicked);
74}
75
76int ExportImageDialog::getStartFrame() const
77{
78 return ui->startSpinBox->value();
79}
80
81int ExportImageDialog::getEndFrame() const
82{
83 return ui->endSpinBox->value();
84}
85
86void ExportImageDialog::frameCheckboxClicked(bool checked)
87{
88 int e = (checked) ? mEndFrameWithSounds : mEndFrame;
89 ui->endSpinBox->setValue(e);
90}
91
92void ExportImageDialog::setExportSize(QSize size)
93{
94 ui->imgWidthSpinBox->setValue(size.width());
95 ui->imgHeightSpinBox->setValue(size.height());
96}
97
98QSize ExportImageDialog::getExportSize() const
99{
100 return QSize(ui->imgWidthSpinBox->value(), ui->imgHeightSpinBox->value());
101}
102
103bool ExportImageDialog::getTransparency() const
104{
105 return ui->cbTransparency->checkState() == Qt::Checked;
106}
107
108bool ExportImageDialog::getExportKeyframesOnly() const
109{
110 return ui->cbExportKeyframesOnly->checkState() == Qt::Checked;
111}
112
113QString ExportImageDialog::getExportFormat() const
114{
115 return ui->formatComboBox->currentText();
116}
117
118QString ExportImageDialog::getCameraLayerName() const
119{
120 return ui->cameraCombo->currentText();
121}
122
123void ExportImageDialog::formatChanged(const QString& format)
124{
125 setFileExtension(format.toLower());
126 setTransparencyOptionVisibility(format);
127}
128
129void ExportImageDialog::cameraComboChanged(int index)
130{
131 const QSize cameraSize = ui->cameraCombo->itemData(index).toSize();
132
133 ui->imgWidthSpinBox->setValue(cameraSize.width());
134 ui->imgHeightSpinBox->setValue(cameraSize.height());
135}
136
137void ExportImageDialog::setTransparencyOptionVisibility(const QString &format)
138{
139 if (format == "JPG" || format == "BMP")
140 ui->cbTransparency->setDisabled(true);
141 else
142 ui->cbTransparency->setDisabled(false);
143}
ImportExportDialog
Definition: importexportdialog.h:32
QAbstractButton::clicked
void clicked(bool checked)
QComboBox
QComboBox::currentIndexChanged
void currentIndexChanged(int index)
QComboBox::currentTextChanged
void currentTextChanged(const QString &text)
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QSignalBlocker
QSize
QSize::height
int height() const const
QSize::width
int width() const const
QString
QString::toLower
QString toLower() const const
Qt::Checked
Checked
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
QWidget::size
size
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39