added clip renaming
This commit is contained in:
+3
-3
@@ -86,17 +86,17 @@ void clear_audio_ibuffer() {
|
||||
|
||||
int get_buffer_offset_from_frame(Sequence* s, long frame) {
|
||||
// currently debugging this function. since it has a high potential of failure and isn't actually fatal, we only assert on debug mode
|
||||
#ifdef QT_DEBUG
|
||||
/*#ifdef QT_DEBUG
|
||||
Q_ASSERT(frame >= audio_ibuffer_frame);
|
||||
return qFloor(av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(s->audio_layout), qRound(((frame-audio_ibuffer_frame)/s->frame_rate)*s->audio_frequency), AV_SAMPLE_FMT_S16, 1)/4)*4;
|
||||
#else
|
||||
#else*/
|
||||
if (frame >= audio_ibuffer_frame) {
|
||||
return qFloor(av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(s->audio_layout), qRound(((frame-audio_ibuffer_frame)/s->frame_rate)*s->audio_frequency), AV_SAMPLE_FMT_S16, 1)/4)*4;
|
||||
} else {
|
||||
dout << "[WARNING] Invalid values passed to get_buffer_offset_from_frame";
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
AudioSenderThread::AudioSenderThread() : close(false) {
|
||||
|
||||
+18
-1
@@ -1745,8 +1745,25 @@ void RemoveClipsFromClipboard::undo() {
|
||||
}
|
||||
|
||||
void RemoveClipsFromClipboard::redo() {
|
||||
qDebug() << "removed" << pos << "from clipboard";
|
||||
clip = panel_timeline->clip_clipboard.at(pos);
|
||||
panel_timeline->clip_clipboard.removeAt(pos);
|
||||
done = true;
|
||||
}
|
||||
|
||||
RenameClipCommand::RenameClipCommand() :
|
||||
old_project_changed(mainWindow->isWindowModified())
|
||||
{}
|
||||
|
||||
void RenameClipCommand::undo() {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
clips.at(i)->name = old_names.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
void RenameClipCommand::redo() {
|
||||
old_names.resize(clips.size());
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
old_names[i] = clips.at(i)->name;
|
||||
clips.at(i)->name = new_name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,4 +570,16 @@ private:
|
||||
bool done;
|
||||
};
|
||||
|
||||
class RenameClipCommand : public QUndoCommand {
|
||||
public:
|
||||
RenameClipCommand();
|
||||
QVector<Clip*> clips;
|
||||
QString new_name;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
QVector<QString> old_names;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
+40
-13
@@ -35,6 +35,7 @@
|
||||
#include <QScrollBar>
|
||||
#include <QMimeData>
|
||||
#include <QToolTip>
|
||||
#include <QInputDialog>
|
||||
|
||||
#define MAX_TEXT_WIDTH 20
|
||||
|
||||
@@ -83,7 +84,16 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
redoAction->setEnabled(undo_stack.canRedo());
|
||||
menu.addSeparator();
|
||||
|
||||
if (sequence->selections.size() == 0) {
|
||||
// collect all the selected clips
|
||||
QVector<Clip*> selected_clips;
|
||||
for (int i=0;i<sequence->clips.size();i++) {
|
||||
Clip* c = sequence->clips.at(i);
|
||||
if (c != NULL && panel_timeline->is_clip_selected(c, true)) {
|
||||
selected_clips.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
if (selected_clips.size() == 0) {
|
||||
// no clips are selected
|
||||
|
||||
panel_timeline->cursor_frame = panel_timeline->getTimelineFrameFromScreenPoint(pos.x());
|
||||
@@ -114,14 +124,13 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
}
|
||||
|
||||
if (can_ripple_delete && !at_end_of_sequence) {
|
||||
QAction* ripple_delete_action = menu.addAction("&Ripple Delete");
|
||||
QAction* ripple_delete_action = menu.addAction("R&ipple Delete");
|
||||
connect(ripple_delete_action, SIGNAL(triggered(bool)), this, SLOT(right_click_ripple()));
|
||||
}
|
||||
|
||||
menu.addAction("Sequence settings coming soon...");
|
||||
} else {
|
||||
// clips are selected
|
||||
|
||||
QAction* cutAction = menu.addAction("C&ut");
|
||||
connect(cutAction, SIGNAL(triggered(bool)), mainWindow, SLOT(cut()));
|
||||
QAction* copyAction = menu.addAction("Cop&y");
|
||||
@@ -135,15 +144,6 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
autoscaleAction->setCheckable(true);
|
||||
connect(autoscaleAction, SIGNAL(triggered(bool)), this, SLOT(toggle_autoscale()));
|
||||
|
||||
// collect all the selected clips
|
||||
QVector<Clip*> selected_clips;
|
||||
for (int i=0;i<sequence->clips.size();i++) {
|
||||
Clip* c = sequence->clips.at(i);
|
||||
if (c != NULL && panel_timeline->is_clip_selected(c, true)) {
|
||||
selected_clips.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
// set autoscale arbitrarily to the first selected clip
|
||||
autoscaleAction->setChecked(selected_clips.at(0)->autoscale);
|
||||
|
||||
@@ -160,8 +160,10 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
if (same_media) {
|
||||
QAction* revealInProjectAction = menu.addAction("&Reveal in Project");
|
||||
connect(revealInProjectAction, SIGNAL(triggered(bool)), this, SLOT(reveal_media()));
|
||||
|
||||
}
|
||||
|
||||
QAction* rename = menu.addAction("R&ename");
|
||||
connect(rename, SIGNAL(triggered(bool)), this, SLOT(rename_clip()));
|
||||
}
|
||||
|
||||
menu.exec(mapToGlobal(pos));
|
||||
@@ -198,6 +200,31 @@ void TimelineWidget::tooltip_timer_timeout() {
|
||||
tooltip_timer.stop();
|
||||
}
|
||||
|
||||
void TimelineWidget::rename_clip() {
|
||||
QVector<Clip*> selected_clips;
|
||||
for (int i=0;i<sequence->clips.size();i++) {
|
||||
Clip* c = sequence->clips.at(i);
|
||||
if (c != NULL && panel_timeline->is_clip_selected(c, true)) {
|
||||
selected_clips.append(c);
|
||||
}
|
||||
}
|
||||
if (selected_clips.size() > 0) {
|
||||
QString s = QInputDialog::getText(this,
|
||||
(selected_clips.size() == 1) ? "Rename '" + selected_clips.at(0)->name + "'" : "Rename multiple clips",
|
||||
"Enter a new name for this clip:",
|
||||
QLineEdit::Normal,
|
||||
selected_clips.at(0)->name
|
||||
);
|
||||
if (!s.isEmpty()) {
|
||||
RenameClipCommand* rcc = new RenameClipCommand();
|
||||
rcc->new_name = s;
|
||||
rcc->clips = selected_clips;
|
||||
undo_stack.push(rcc);
|
||||
update_ui(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool same_sign(int a, int b) {
|
||||
return (a < 0) == (b < 0);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ private slots:
|
||||
void show_context_menu(const QPoint& pos);
|
||||
void toggle_autoscale();
|
||||
void tooltip_timer_timeout();
|
||||
void rename_clip();
|
||||
};
|
||||
|
||||
#endif // TIMELINEWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user