Skip to content

Commit

Permalink
Video spec changes
Browse files Browse the repository at this point in the history
Also add some checks and more info in 'handleNewVideoClip'.
  • Loading branch information
rodlie committed Jul 19, 2024
1 parent b8c8a86 commit 216a156
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
29 changes: 25 additions & 4 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,14 +2076,35 @@ void MainWindow::writeRecentFiles()

void MainWindow::handleNewVideoClip(const VideoBox::VideoSpecs &specs)
{
if (specs.fps < 1 || specs.dim.height() < 1 || specs.dim.width() < 1) { return; }

const auto scene = *mDocument.fActiveScene;
if (!scene) { return; }

// only continue if this is the only clip
if (scene->getContainedBoxes().count() != 1) { return; }

// is identical?
if (scene->getCanvasSize() == specs.dim &&
scene->getFps() == specs.fps &&
scene->getFrameRange().fMax == specs.range.fMax) { return; }

const auto reply = QMessageBox::question(this,
tr("Adjust scene?"),
tr("Adjust scene to new video clip?"));
tr("Adjust scene to clip?"),
tr("Video clip and scene do not match, adjust scene to clip?\n\n"
"Clip: %1x%2 Fps: %3 Frames: %4\n\n"
"Scene: %5x%6 Fps: %7 Frames: %8")
.arg(QString::number(specs.dim.width()),
QString::number(specs.dim.height()),
QString::number(specs.fps),
QString::number(specs.range.fMax),
QString::number(scene->getCanvasWidth()),
QString::number(scene->getCanvasHeight()),
QString::number(scene->getFps()),
QString::number(scene->getFrameRange().fMax)));
if (reply != QMessageBox::Yes) { return; }
scene->setCanvasSize(specs.width, specs.height);
scene->setCanvasSize(specs.dim.width(),
specs.dim.height());
scene->setFps(specs.fps);
scene->setFrameRange({0, specs.frames - 1});
scene->setFrameRange(specs.range);
}
6 changes: 3 additions & 3 deletions src/core/Boxes/videobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ const VideoBox::VideoSpecs VideoBox::getSpecs()
VideoSpecs specs;
const auto h = mFileHandler->getFrameHandler();
if (!h) { return specs; }
specs.frames = h->getFrameCount();
int frames = h->getFrameCount();
specs.range = FrameRange{0, frames <= 1 ? 0 : frames - 1};
specs.fps = h->getFps();
specs.height = h->getDim().height();
specs.width = h->getDim().width();
specs.dim = h->getDim();
return specs;
}

Expand Down
5 changes: 2 additions & 3 deletions src/core/Boxes/videobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ class CORE_EXPORT VideoBox : public AnimationBox {
QDomElement prp_writePropertyXEV_impl(const XevExporter& exp) const;
public:
struct VideoSpecs {
int width;
int height;
int frames;
QSize dim;
qreal fps;
FrameRange range;
};
void changeSourceFile();

Expand Down

0 comments on commit 216a156

Please sign in to comment.