folder support added
This commit is contained in:
+17
-1
@@ -10,6 +10,7 @@
|
||||
#include <QtMath>
|
||||
#include <QDebug>
|
||||
|
||||
#define AUDIO_MONITOR_PEAK_HEIGHT 15
|
||||
#define AUDIO_MONITOR_GAP 3
|
||||
|
||||
extern "C" {
|
||||
@@ -39,24 +40,39 @@ void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
QPainter p(this);
|
||||
int channel_x = AUDIO_MONITOR_GAP;
|
||||
int channel_count = av_get_channel_layout_nb_channels(sequence->audio_layout);
|
||||
if (peaks.size() != channel_count) {
|
||||
peaks.resize(channel_count);
|
||||
peaks.fill(false);
|
||||
}
|
||||
int channel_width = (width()/channel_count) - AUDIO_MONITOR_GAP;
|
||||
long playhead_offset = -1;
|
||||
int i;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
QRect r(channel_x, 0, channel_width, height());
|
||||
QRect r(channel_x, AUDIO_MONITOR_PEAK_HEIGHT + AUDIO_MONITOR_GAP, channel_width, height());
|
||||
p.fillRect(r, gradient);
|
||||
|
||||
if (sample_cache_offset != -1) {
|
||||
playhead_offset = (panel_timeline->playhead - sample_cache_offset) * channel_count;
|
||||
if (playhead_offset >= 0 && playhead_offset < sample_cache.size()) {
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset+i) / 32768.0); // 16-bit int divided to float
|
||||
if (multiplier == (double) 0) {
|
||||
peaks[i] = true;
|
||||
}
|
||||
r.setHeight(r.height()*multiplier);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
QRect peak_rect(channel_x, 0, channel_width, AUDIO_MONITOR_PEAK_HEIGHT);
|
||||
if (peaks.at(i)) {
|
||||
p.fillRect(peak_rect, QColor(255, 0, 0));
|
||||
} else {
|
||||
p.fillRect(peak_rect, QColor(64, 0, 0));
|
||||
}
|
||||
|
||||
p.fillRect(r, QColor(0, 0, 0, 160));
|
||||
|
||||
channel_x += channel_width + AUDIO_MONITOR_GAP;
|
||||
}
|
||||
if (playhead_offset > -1) {
|
||||
|
||||
@@ -22,6 +22,7 @@ public slots:
|
||||
|
||||
private:
|
||||
QLinearGradient gradient;
|
||||
QVector<bool> peaks;
|
||||
};
|
||||
|
||||
#endif // AUDIOMONITOR_H
|
||||
|
||||
+31
-9
@@ -13,14 +13,9 @@
|
||||
|
||||
SourceTable::SourceTable(QWidget* parent) : QTreeWidget(parent) {
|
||||
sortByColumn(0, Qt::AscendingOrder);
|
||||
setAcceptDrops(true);
|
||||
editing_item = NULL;
|
||||
rename_timer.setInterval(500);
|
||||
connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval()));
|
||||
connect(this, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(item_click(QTreeWidgetItem*,int)));
|
||||
// connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(stop_rename_timer()));
|
||||
|
||||
// connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, )
|
||||
}
|
||||
|
||||
void SourceTable::stop_rename_timer() {
|
||||
@@ -50,9 +45,8 @@ void SourceTable::mouseDoubleClickEvent(QMouseEvent* ) {
|
||||
panel_project->import_dialog();
|
||||
} else if (selectedItems().count() == 1) {
|
||||
QTreeWidgetItem* item = selectedItems().at(0);
|
||||
Media* m = reinterpret_cast<Media*>(item->data(0, Qt::UserRole + 1).value<quintptr>());
|
||||
if (m->type == MEDIA_TYPE_SEQUENCE) {
|
||||
set_sequence(m->sequence);
|
||||
if (panel_project->get_type_from_tree(item) == MEDIA_TYPE_SEQUENCE) {
|
||||
set_sequence(panel_project->get_sequence_from_tree(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,7 +69,6 @@ void SourceTable::dragMoveEvent(QDragMoveEvent *event) {
|
||||
|
||||
void SourceTable::dropEvent(QDropEvent* event) {
|
||||
const QMimeData* mimeData = event->mimeData();
|
||||
|
||||
if (mimeData->hasUrls()) {
|
||||
QList<QUrl> urls = mimeData->urls();
|
||||
if (!urls.isEmpty()) {
|
||||
@@ -87,5 +80,34 @@ void SourceTable::dropEvent(QDropEvent* event) {
|
||||
panel_project->process_file_list(paths);
|
||||
}
|
||||
event->acceptProposedAction();
|
||||
} else {
|
||||
QTreeWidgetItem* item = itemAt(event->pos());
|
||||
if (item == NULL || (item != NULL && panel_project->get_type_from_tree(item) == MEDIA_TYPE_FOLDER)) {
|
||||
QList<QTreeWidgetItem*> items = selectedItems();
|
||||
for (int i=0;i<items.size();i++) {
|
||||
QTreeWidgetItem* s = items.at(i);
|
||||
bool ignore = false;
|
||||
if (s->parent() == NULL) {
|
||||
takeTopLevelItem(indexOfTopLevelItem(s));
|
||||
} else {
|
||||
// if child belongs to a selected parent, assume the user is just moving the parent and ignore the child
|
||||
for (int j=0;j<items.size();j++) {
|
||||
if (s->parent() == items.at(j)) {
|
||||
ignore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ignore) s->parent()->takeChild(s->parent()->indexOfChild(s));
|
||||
}
|
||||
if (!ignore) {
|
||||
if (item == NULL) {
|
||||
addTopLevelItem(s);
|
||||
} else {
|
||||
item->addChild(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-21
@@ -59,27 +59,29 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
panel_timeline->drag_frame_start = entry_point + panel_timeline->getFrameFromScreenPoint(50);
|
||||
panel_timeline->drag_track_start = (bottom_align) ? -1 : 0;
|
||||
for (int i=0;i<items.size();i++) {
|
||||
bool ignore_infinite_length = false;
|
||||
Media* m = panel_project->get_media_from_tree(items.at(i));
|
||||
Ghost g;
|
||||
g.clip = -1;
|
||||
g.media = m;
|
||||
g.old_clip_in = g.clip_in = 0;
|
||||
g.in = entry_point;
|
||||
entry_point += m->get_length_in_frames(sequence->frame_rate);
|
||||
g.out = entry_point;
|
||||
g.trimming = false;
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
g.track = j;
|
||||
g.media_stream = m->audio_tracks.at(j);
|
||||
ignore_infinite_length = true;
|
||||
panel_timeline->ghosts.append(g);
|
||||
}
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
g.track = -1-j;
|
||||
g.media_stream = m->video_tracks.at(j);
|
||||
if (m->video_tracks[j]->infinite_length && !ignore_infinite_length) g.out = g.in + 100;
|
||||
panel_timeline->ghosts.append(g);
|
||||
QTreeWidgetItem* item = items.at(i);
|
||||
if (panel_project->get_type_from_tree(item) == MEDIA_TYPE_FOOTAGE) {
|
||||
Media* m = panel_project->get_media_from_tree(item);
|
||||
bool ignore_infinite_length = (m->audio_tracks.size() > 0);
|
||||
Ghost g;
|
||||
g.clip = -1;
|
||||
g.media = m;
|
||||
g.old_clip_in = g.clip_in = 0;
|
||||
g.in = entry_point;
|
||||
entry_point += m->get_length_in_frames(sequence->frame_rate);
|
||||
g.out = entry_point;
|
||||
g.trimming = false;
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
g.track = j;
|
||||
g.media_stream = m->audio_tracks.at(j);
|
||||
panel_timeline->ghosts.append(g);
|
||||
}
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
g.track = -1-j;
|
||||
g.media_stream = m->video_tracks.at(j);
|
||||
if (m->video_tracks[j]->infinite_length && !ignore_infinite_length) g.out = g.in + 100;
|
||||
panel_timeline->ghosts.append(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i=0;i<panel_timeline->ghosts.size();i++) {
|
||||
|
||||
Reference in New Issue
Block a user