From f427e37f461e2f44c1335d8ae1b9b9aaa6b751e4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 17 Nov 2018 12:56:00 +1100 Subject: [PATCH] tweaked merge --- io/media.h | 2 +- io/previewgenerator.cpp | 4 +--- ui/timelinewidget.cpp | 13 ++++--------- ui/viewerwidget.cpp | 20 +++++++++++--------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/io/media.h b/io/media.h index 4eebc45e8..32db5f11f 100644 --- a/io/media.h +++ b/io/media.h @@ -37,7 +37,7 @@ struct MediaStream { // preview thumbnail/waveform bool preview_done; - QPixmap video_preview; // TODO change to QPixmap + QPixmap video_preview; QVector audio_preview; }; diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index 7c5bd662f..937559c08 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -439,9 +439,7 @@ void PreviewGenerator::run() { // save preview to file for (int i=0;ivideo_tracks.size();i++) { MediaStream* ms = media->video_tracks.at(i); - if (ms->video_preview.save(get_thumbnail_path(hash, ms), "PNG")) { - //dout << "saved" << ms->file_index << "thumb to" << get_thumbnail_path(hash, ms); - } + ms->video_preview.save(get_thumbnail_path(hash, ms), "PNG"); } for (int i=0;iaudio_tracks.size();i++) { MediaStream* ms = media->audio_tracks.at(i); diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 806c3ce53..b0abc5dca 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -2085,7 +2085,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { // draw thumbnail int thumb_y = p.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; if (thumb_x < width() && thumb_y < height()) { - int space_for_thumb = clip_rect.width(); + int space_for_thumb = clip_rect.width()-1; if (clip->opening_transition != NULL) { int ot_width = getScreenPointFromFrame(panel_timeline->zoom, clip->opening_transition->length); thumb_x += ot_width; @@ -2099,14 +2099,9 @@ void TimelineWidget::paintEvent(QPaintEvent*) { if (thumb_x + thumb_width >= 0 && thumb_height > thumb_y && thumb_y + thumb_height >= 0 - && space_for_thumb > thumb_width / 4){ //don't show thumbnail if 1/4 is only showing - if (space_for_thumb < thumb_width){ - p.setClipping(true); - p.setClipRegion(QRegion(thumb_x, clip_rect.y()+thumb_y, clip_rect.width()-1, thumb_height)); - p.drawPixmap(thumb_x,clip_rect.y()+thumb_y, ms->video_preview.scaledToHeight(thumb_height)); - p.setClipping(false); - } else - p.drawPixmap(thumb_x,clip_rect.y()+thumb_y, ms->video_preview.scaledToHeight(thumb_height)); + && space_for_thumb > MAX_TEXT_WIDTH) { + int thumb_clip_width = qMin(thumb_width, space_for_thumb); + p.drawPixmap(QRect(thumb_x, clip_rect.y()+thumb_y, thumb_clip_width, thumb_height), ms->video_preview, QRect(0, 0, thumb_clip_width*((double)ms->video_preview.width()/(double)thumb_width), ms->video_preview.height())); } } } else if (clip_rect.height() > TRACK_MIN_HEIGHT) { diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 34ae91af5..ff2fa8a27 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -69,16 +69,18 @@ void ViewerWidget::show_context_menu() { } void ViewerWidget::save_frame() { - QString fn = QFileDialog::getSaveFileName(this, "Save Frame", QString(), "Portable Network Graphic (*.png);;JPEG (*.jpg *.jpeg);;Windows Bitmap (*.bmp);;Portable Pixmap (*.ppm);;X11 Bitmap (*.xbm);;X11 Pixmap (*.xpm)"); + QFileDialog fd(this); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setFileMode(QFileDialog::AnyFile); + fd.setWindowTitle("Save Frame"); + fd.setNameFilter("Portable Network Graphic (*.png);;JPEG (*.jpg);;Windows Bitmap (*.bmp);;Portable Pixmap (*.ppm);;X11 Bitmap (*.xbm);;X11 Pixmap (*.xpm)"); - if (!fn.isEmpty()) { - if (!(fn.endsWith("png", Qt::CaseInsensitive) - ||fn.endsWith("jpeg", Qt::CaseInsensitive) - ||fn.endsWith("jpg", Qt::CaseInsensitive) - ||fn.endsWith("bmp", Qt::CaseInsensitive) - ||fn.endsWith("ppm", Qt::CaseInsensitive) - ||fn.endsWith("xbm", Qt::CaseInsensitive) - ||fn.endsWith("xpm", Qt::CaseInsensitive))) fn.append(".png"); + if (fd.exec()) { + QString fn = fd.selectedFiles().at(0); + QString selected_ext = fd.selectedNameFilter().mid(fd.selectedNameFilter().indexOf(QRegExp("\\*.[a-z][a-z][a-z]")) + 1, 4); + if (!fn.endsWith(selected_ext, Qt::CaseInsensitive)) { + fn += selected_ext; + } QOpenGLFramebufferObject fbo(viewer->seq->width, viewer->seq->height, QOpenGLFramebufferObject::CombinedDepthStencil, GL_TEXTURE_RECTANGLE); rendering = true;