make square version of thumb for icon view
This commit is contained in:
@@ -128,6 +128,7 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) {
|
||||
QFile f(thumb_path);
|
||||
if (f.exists() && ms->video_preview.load(thumb_path)) {
|
||||
//dout << "loaded thumb" << ms->file_index << "from" << thumb_path;
|
||||
ms->make_square_thumb();
|
||||
ms->preview_done = true;
|
||||
} else {
|
||||
found = false;
|
||||
@@ -263,7 +264,7 @@ void PreviewGenerator::generate_waveform() {
|
||||
static_cast<AVPixelFormat>(temp_frame->format),
|
||||
dstW,
|
||||
dstH,
|
||||
static_cast<AVPixelFormat>(AV_PIX_FMT_RGB24),
|
||||
static_cast<AVPixelFormat>(AV_PIX_FMT_RGBA),
|
||||
SWS_FAST_BILINEAR,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -274,7 +275,8 @@ void PreviewGenerator::generate_waveform() {
|
||||
linesize[0] = dstW*3;
|
||||
sws_scale(sws_ctx, temp_frame->data, temp_frame->linesize, 0, temp_frame->height, &data, linesize);
|
||||
|
||||
s->video_preview = QImage(data, dstW, dstH, linesize[0], QImage::Format_RGB888);
|
||||
s->video_preview = QImage(data, dstW, dstH, linesize[0], QImage::Format_RGBA8888);
|
||||
s->make_square_thumb();
|
||||
|
||||
// is video interlaced?
|
||||
s->video_auto_interlacing = (temp_frame->interlaced_frame) ? ((temp_frame->top_field_first) ? VIDEO_TOP_FIELD_FIRST : VIDEO_BOTTOM_FIELD_FIRST) : VIDEO_PROGRESSIVE;
|
||||
|
||||
+9
-9
@@ -130,15 +130,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
layout()->invalidate();
|
||||
|
||||
// TODO maybe replace these with non-pointers later on?
|
||||
panel_sequence_viewer = new Viewer(this);
|
||||
panel_footage_viewer = new Viewer(this);
|
||||
panel_project = new Project(this);
|
||||
panel_effect_controls = new EffectControls(this);
|
||||
panel_timeline = new Timeline(this);
|
||||
|
||||
setup_layout(false);
|
||||
|
||||
connect(ui->menuWindow, SIGNAL(aboutToShow()), this, SLOT(windowMenu_About_To_Be_Shown()));
|
||||
connect(ui->menu_View, SIGNAL(aboutToShow()), this, SLOT(viewMenu_About_To_Be_Shown()));
|
||||
connect(ui->menu_Tools, SIGNAL(aboutToShow()), this, SLOT(toolMenu_About_To_Be_Shown()));
|
||||
@@ -215,6 +206,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
// TODO maybe replace these with non-pointers later on?
|
||||
panel_sequence_viewer = new Viewer(this);
|
||||
panel_footage_viewer = new Viewer(this);
|
||||
panel_project = new Project(this);
|
||||
panel_effect_controls = new EffectControls(this);
|
||||
panel_timeline = new Timeline(this);
|
||||
|
||||
setup_layout(false);
|
||||
|
||||
init_audio();
|
||||
|
||||
connect(ui->action_Undo, SIGNAL(triggered(bool)), this, SLOT(undo()));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtMath>
|
||||
#include <QPainter>
|
||||
#include "io/previewgenerator.h"
|
||||
|
||||
extern "C" {
|
||||
@@ -55,3 +56,16 @@ FootageStream* Footage::get_stream_from_file_index(bool video, int index) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void FootageStream::make_square_thumb() {
|
||||
// generate square version for QListView?
|
||||
int square_size = qMax(video_preview.width(), video_preview.height());
|
||||
QPixmap pixmap(square_size, square_size);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter p(&pixmap);
|
||||
int diff = (video_preview.width() - video_preview.height())>>1;
|
||||
int sqx = (diff < 0) ? -diff : 0;
|
||||
int sqy = (diff > 0) ? diff : 0;
|
||||
p.drawImage(sqx, sqy, video_preview);
|
||||
video_preview_square = QIcon(pixmap);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QVariant>
|
||||
#include <QMutex>
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
|
||||
#define VIDEO_PROGRESSIVE 0
|
||||
#define VIDEO_TOP_FIELD_FIRST 1
|
||||
@@ -32,7 +33,9 @@ struct FootageStream {
|
||||
// preview thumbnail/waveform
|
||||
bool preview_done;
|
||||
QImage video_preview;
|
||||
QIcon video_preview_square;
|
||||
QVector<char> audio_preview;
|
||||
void make_square_thumb();
|
||||
};
|
||||
|
||||
struct Footage {
|
||||
|
||||
+4
-3
@@ -8,6 +8,8 @@
|
||||
#include "panels/project.h"
|
||||
#include "projectmodel.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
extern "C" {
|
||||
@@ -253,12 +255,11 @@ QVariant Media::data(int column, int role) {
|
||||
switch (role) {
|
||||
case Qt::DecorationRole:
|
||||
if (column == 0) {
|
||||
if (config.project_view_type == PROJECT_VIEW_ICON
|
||||
&& get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
if (get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
Footage* f = to_footage();
|
||||
if (f->video_tracks.size() > 0
|
||||
&& f->video_tracks.at(0)->preview_done) {
|
||||
return QIcon(QPixmap::fromImage(f->video_tracks.at(0)->video_preview));
|
||||
return f->video_tracks.at(0)->video_preview_square;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "otreeview.h"
|
||||
|
||||
OTreeView::OTreeView(QWidget *parent) : QTreeView(parent) {
|
||||
setSortingEnabled(true);
|
||||
sortByColumn(0, Qt::AscendingOrder);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
|
||||
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef OTREEVIEW_H
|
||||
#define OTREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
#include "ui/sourcetable.h"
|
||||
|
||||
class OTreeView : public QTreeView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OTreeView(QWidget* parent = 0);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // OTREEVIEW_H
|
||||
Reference in New Issue
Block a user