Skip to content

Commit

Permalink
Add Update button to bottom of playlist panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Feb 7, 2015
1 parent c7f4aa2 commit 6960af2
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 38 deletions.
Binary file added icons/dark/32x32/dialog-ok.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/light/32x32/dialog-ok.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/oxygen/32x32/actions/dialog-ok.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions icons/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,8 @@
<file>light/32x32/bookmarks.png</file>
<file>dark/32x32/bookmarks.png</file>
<file>oxygen/32x32/places/bookmarks.png</file>
<file>dark/32x32/dialog-ok.png</file>
<file>light/32x32/dialog-ok.png</file>
<file>oxygen/32x32/actions/dialog-ok.png</file>
</qresource>
</RCC>
3 changes: 3 additions & 0 deletions src/docks/filtersdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ void FiltersDock::clearCurrentFilter()
{
m_qview.rootContext()->setContextProperty("metadata", 0);
QMetaObject::invokeMethod(m_qview.rootObject(), "clearCurrentFilter");
disconnect(this, SIGNAL(changed()));
}

void FiltersDock::setCurrentFilter(QmlFilter* filter, QmlMetadata* meta, int index)
{
m_qview.rootContext()->setContextProperty("filter", filter);
m_qview.rootContext()->setContextProperty("metadata", meta);
QMetaObject::invokeMethod(m_qview.rootObject(), "setCurrentFilter", Q_ARG(QVariant, QVariant(index)));
if (filter)
connect(filter, SIGNAL(changed()), SIGNAL(changed()));
}

void FiltersDock::setFadeInDuration(int duration)
Expand Down
1 change: 1 addition & 0 deletions src/docks/filtersdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FiltersDock : public QDockWidget

signals:
void currentFilterRequested(int attachedIndex);
void changed(); /// Notifies when a filter parameter changes.

public slots:
void clearCurrentFilter();
Expand Down
77 changes: 56 additions & 21 deletions src/docks/playlistdock.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012 Meltytech, LLC
* Copyright (c) 2012-2015 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -25,9 +25,12 @@
#include <QMenu>
#include <QDebug>

static const char* kPlaylistIndexProperty = "_shotcut:playlistIndex";

PlaylistDock::PlaylistDock(QWidget *parent) :
QDockWidget(parent),
ui(new Ui::PlaylistDock)
ui(new Ui::PlaylistDock),
m_doubleClicked(false)
{
qDebug() << "begin";
ui->setupUi(this);
Expand Down Expand Up @@ -97,8 +100,10 @@ void PlaylistDock::incrementIndex()
index = m_model.createIndex(0, 0);
else
index = m_model.incrementIndex(index);
if (index.isValid())
if (index.isValid()) {
ui->tableView->setCurrentIndex(index);
on_tableView_clicked(index);
}
}

void PlaylistDock::decrementIndex()
Expand All @@ -108,15 +113,19 @@ void PlaylistDock::decrementIndex()
index = m_model.createIndex(0, 0);
else
index = m_model.decrementIndex(index);
if (index.isValid())
if (index.isValid()) {
ui->tableView->setCurrentIndex(index);
on_tableView_clicked(index);
}
}

void PlaylistDock::setIndex(int row)
{
QModelIndex index = m_model.createIndex(row, 0);
if (index.isValid())
if (index.isValid()) {
ui->tableView->setCurrentIndex(index);
on_tableView_clicked(index);
}
}

void PlaylistDock::moveClipUp()
Expand Down Expand Up @@ -144,12 +153,11 @@ void PlaylistDock::on_menuButton_clicked()
menu.addAction(ui->actionInsertCut);
menu.addAction(ui->actionOpen);

Mlt::ClipInfo* info = m_model.playlist()->clip_info(index.row());
if (info && info->resource && MLT.producer()->get("resource")
&& !strcmp(info->resource, MLT.producer()->get("resource"))) {
menu.addAction(ui->actionUpdate);
QScopedPointer<Mlt::ClipInfo> info(m_model.playlist()->clip_info(index.row()));
if (info && MLT.producer()->get_int(kPlaylistIndexProperty) == index.row() + 1) {
if (MLT.producer()->get_in() != info->frame_in || MLT.producer()->get_out() != info->frame_out)
menu.addAction(ui->actionUpdate);
}
delete info;

menu.addAction(ui->actionRemove);
menu.addSeparator();
Expand Down Expand Up @@ -248,6 +256,7 @@ void PlaylistDock::on_actionUpdate_triggered()
}
else {
emit showStatusMessage(tr("This clip does not match the selected cut in the playlist!"));
ui->updateButton->setEnabled(false);
}
delete info;
}
Expand All @@ -267,6 +276,11 @@ void PlaylistDock::on_removeButton_clicked()
}
}

void PlaylistDock::setUpdateButtonEnabled(bool modified)
{
ui->updateButton->setEnabled(modified);
}

void PlaylistDock::on_actionOpen_triggered()
{
QModelIndex index = ui->tableView->currentIndex();
Expand All @@ -275,9 +289,9 @@ void PlaylistDock::on_actionOpen_triggered()
if (i) {
QString xml = MLT.XML(i->producer);
Mlt::Producer* p = new Mlt::Producer(MLT.profile(), "xml-string", xml.toUtf8().constData());
if (MLT.isImageProducer(p))
p->set_in_and_out(i->frame_in, i->frame_out);
emit clipOpened(p, i->frame_in, i->frame_out);
p->set_in_and_out(i->frame_in, i->frame_out);
p->set(kPlaylistIndexProperty, index.row() + 1);
emit clipOpened(p);
delete i;
}
}
Expand All @@ -292,20 +306,34 @@ void PlaylistDock::on_tableView_customContextMenuRequested(const QPoint &pos)
menu.addAction(ui->actionInsertCut);
menu.addAction(ui->actionOpen);

Mlt::ClipInfo* info = m_model.playlist()->clip_info(index.row());
if (info && info->resource && MLT.producer()->get("resource")
&& !strcmp(info->resource, MLT.producer()->get("resource"))) {
menu.addAction(ui->actionUpdate);
QScopedPointer<Mlt::ClipInfo> info(m_model.playlist()->clip_info(index.row()));
if (info && MLT.producer()->get_int(kPlaylistIndexProperty) == index.row() + 1) {
if (MLT.producer()->get_in() != info->frame_in || MLT.producer()->get_out() != info->frame_out)
menu.addAction(ui->actionUpdate);
}
delete info;

menu.addAction(ui->actionRemove);
menu.exec(mapToGlobal(pos));
}
}

void PlaylistDock::on_tableView_clicked(const QModelIndex& index)
{
if (!m_doubleClicked) {
bool enabled = false;
QScopedPointer<Mlt::ClipInfo> info(m_model.playlist()->clip_info(index.row()));
if (info && MLT.producer()->get_int(kPlaylistIndexProperty) == index.row() + 1) {
if (MLT.producer()->get_in() != info->frame_in || MLT.producer()->get_out() != info->frame_out)
enabled = true;
}
ui->updateButton->setEnabled(enabled);
}
m_doubleClicked = false;
}

void PlaylistDock::on_tableView_doubleClicked(const QModelIndex &index)
{
m_doubleClicked = true;
if (!m_model.playlist()) return;
Mlt::ClipInfo* i = m_model.playlist()->clip_info(index.row());
if (i) {
Expand All @@ -314,9 +342,9 @@ void PlaylistDock::on_tableView_doubleClicked(const QModelIndex &index)
} else {
QString xml = MLT.XML(i->producer);
Mlt::Producer* p = new Mlt::Producer(MLT.profile(), "xml-string", xml.toUtf8().constData());
if (MLT.isImageProducer(p))
p->set_in_and_out(i->frame_in, i->frame_out);
emit clipOpened(p, i->frame_in, i->frame_out);
p->set_in_and_out(i->frame_in, i->frame_out);
p->set(kPlaylistIndexProperty, index.row() + 1);
emit clipOpened(p);
}
delete i;
} else {
Expand Down Expand Up @@ -348,6 +376,7 @@ void PlaylistDock::on_actionClose_triggered()
void PlaylistDock::onPlaylistCreated()
{
ui->removeButton->setEnabled(true);
ui->updateButton->setEnabled(false);
ui->menuButton->setEnabled(true);
ui->stackedWidget->setCurrentIndex(1);
}
Expand All @@ -361,6 +390,7 @@ void PlaylistDock::onPlaylistLoaded()
void PlaylistDock::onPlaylistCleared()
{
ui->removeButton->setEnabled(false);
ui->updateButton->setEnabled(false);
ui->menuButton->setEnabled(false);
ui->stackedWidget->setCurrentIndex(0);
}
Expand Down Expand Up @@ -482,3 +512,8 @@ void PlaylistDock::on_actionAddToTimeline_triggered()
{
emit addAllTimeline(m_model.playlist());
}

void PlaylistDock::on_updateButton_clicked()
{
on_actionUpdate_triggered();
}
8 changes: 7 additions & 1 deletion src/docks/playlistdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PlaylistDock : public QDockWidget
int position();

signals:
void clipOpened(void* producer, int in, int out);
void clipOpened(void* producer);
void itemActivated(int start);
void showStatusMessage(QString);
void addAllTimeline(Mlt::Playlist*);
Expand All @@ -56,6 +56,7 @@ public slots:
void on_actionAppendCut_triggered();
void on_actionUpdate_triggered();
void on_removeButton_clicked();
void setUpdateButtonEnabled(bool modified);

private slots:
void on_menuButton_clicked();
Expand All @@ -66,6 +67,8 @@ private slots:

void on_tableView_customContextMenuRequested(const QPoint &pos);

void on_tableView_clicked(const QModelIndex &index);

void on_tableView_doubleClicked(const QModelIndex &index);

void on_actionGoto_triggered();
Expand Down Expand Up @@ -100,10 +103,13 @@ private slots:

void on_actionAddToTimeline_triggered();

void on_updateButton_clicked();

private:
Ui::PlaylistDock *ui;
PlaylistModel m_model;
int m_defaultRowHeight;
bool m_doubleClicked;
};

#endif // PLAYLISTDOCK_H
17 changes: 17 additions & 0 deletions src/docks/playlistdock.ui
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ selected cut.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="updateButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Update</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="dialog-ok" resource="../../icons/resources.qrc">
<normaloff>:/icons/oxygen/32x32/actions/dialog-ok.png</normaloff>:/icons/oxygen/32x32/actions/dialog-ok.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="menuButton">
<property name="enabled">
Expand Down
5 changes: 2 additions & 3 deletions src/docks/timelinedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ void TimelineDock::openClip(int trackIndex, int clipIndex)
if (info) {
QString xml = MLT.XML(info->producer);
Mlt::Producer* p = new Mlt::Producer(MLT.profile(), "xml-string", xml.toUtf8().constData());
if (MLT.isImageProducer(p))
p->set_in_and_out(info->frame_in, info->frame_out);
emit clipOpened(p, info->frame_in, info->frame_out);
p->set_in_and_out(info->frame_in, info->frame_out);
emit clipOpened(p);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/docks/timelinedock.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TimelineDock : public QDockWidget
signals:
void seeked(int position);
void positionChanged();
void clipOpened(void* producer, int in, int out);
void clipOpened(void* producer);
void dragging(const QPointF& pos, int duration);
void dropped();
void dropAccepted(const QString &xml);
Expand Down
30 changes: 20 additions & 10 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ MainWindow::MainWindow()
ui->menuView->addAction(m_playlistDock->toggleViewAction());
connect(m_playlistDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onPlaylistDockTriggered(bool)));
connect(ui->actionPlaylist, SIGNAL(triggered()), this, SLOT(onPlaylistDockTriggered()));
connect(m_playlistDock, SIGNAL(clipOpened(void*,int,int)), this, SLOT(openCut(void*, int, int)));
connect(m_playlistDock, SIGNAL(clipOpened(void*)), this, SLOT(openCut(void*)));
connect(m_playlistDock, SIGNAL(itemActivated(int)), this, SLOT(seekPlaylist(int)));
connect(m_playlistDock, SIGNAL(showStatusMessage(QString)), this, SLOT(showStatusMessage(QString)));
connect(m_playlistDock->model(), SIGNAL(created()), this, SLOT(onPlaylistCreated()));
Expand All @@ -224,7 +224,7 @@ MainWindow::MainWindow()
connect(m_timelineDock->model(), SIGNAL(closed()), SLOT(onMultitrackClosed()));
connect(m_timelineDock->model(), SIGNAL(modified()), SLOT(onMultitrackModified()));
connect(m_timelineDock->model(), SIGNAL(modified()), SLOT(updateAutoSave()));
connect(m_timelineDock, SIGNAL(clipOpened(void*,int,int)), SLOT(openCut(void*, int, int)));
connect(m_timelineDock, SIGNAL(clipOpened(void*)), SLOT(openCut(void*)));
connect(m_timelineDock->model(), SIGNAL(seeked(int)), SLOT(seekTimeline(int)));
connect(m_playlistDock, SIGNAL(addAllTimeline(Mlt::Playlist*)), SLOT(onTimelineDockTriggered()));
connect(m_playlistDock, SIGNAL(addAllTimeline(Mlt::Playlist*)), m_timelineDock, SLOT(appendFromPlaylist(Mlt::Playlist*)));
Expand All @@ -242,8 +242,8 @@ MainWindow::MainWindow()
connect(m_filterController, SIGNAL(currentFilterChanged(QmlFilter*, QmlMetadata*, int)), m_filtersDock, SLOT(setCurrentFilter(QmlFilter*, QmlMetadata*, int)), Qt::QueuedConnection);
connect(m_filterController, SIGNAL(currentFilterAboutToChange()), m_filtersDock, SLOT(clearCurrentFilter()));
connect(this, SIGNAL(producerOpened()), m_filterController, SLOT(setProducer()));
connect(m_filterController->attachedModel(), SIGNAL(changed(bool)), SLOT(setWindowModified(bool)));
connect(m_filterController->attachedModel(), SIGNAL(changed()), SLOT(updateAutoSave()));
connect(m_filterController->attachedModel(), SIGNAL(changed()), SLOT(onFilterModelChanged()));
connect(m_filtersDock, SIGNAL(changed()), SLOT(onFilterModelChanged()));
connect(m_filterController, SIGNAL(statusChanged(QString)), this, SLOT(showStatusMessage(QString)));
connect(m_timelineDock, SIGNAL(fadeInChanged(int)), m_filtersDock, SLOT(setFadeInDuration(int)));
connect(m_timelineDock, SIGNAL(fadeOutChanged(int)), m_filtersDock, SLOT(setFadeOutDuration(int)));
Expand Down Expand Up @@ -601,6 +601,7 @@ void MainWindow::open(Mlt::Producer* producer)
if (!MLT.setProducer(producer))
emit producerOpened();
m_player->setFocus();
m_playlistDock->setUpdateButtonEnabled(false);

// Needed on Windows. Upon first file open, window is deactivated, perhaps OpenGL-related.
activateWindow();
Expand Down Expand Up @@ -766,13 +767,12 @@ void MainWindow::openVideo()
}
}

void MainWindow::openCut(void* producer, int in, int out)
void MainWindow::openCut(void* producer)
{
m_player->setPauseAfterOpen(true);
open((Mlt::Producer*) producer);
m_player->setIn(in);
m_player->setOut(out);
MLT.seek(in);
Mlt::Producer* p = (Mlt::Producer*) producer;
open(p);
MLT.seek(p->get_in());
}

void MainWindow::showStatusMessage(QString message)
Expand Down Expand Up @@ -1595,10 +1595,20 @@ void MainWindow::onMultitrackModified()

void MainWindow::onCutModified()
{
if (!playlist()) {
if (!playlist() && !multitrack()) {
setWindowModified(true);
updateAutoSave();
}
if (playlist())
m_playlistDock->setUpdateButtonEnabled(true);
}

void MainWindow::onFilterModelChanged()
{
setWindowModified(true);
updateAutoSave();
if (playlist())
m_playlistDock->setUpdateButtonEnabled(true);
}

void MainWindow::updateMarkers()
Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public slots:
void updateAutoSave();
void open(QString url, const Mlt::Properties* = 0);
void openVideo();
void openCut(void*, int in, int out);
void openCut(void*);
void showStatusMessage(QString);
void seekPlaylist(int start);
void seekTimeline(int position);
Expand Down Expand Up @@ -172,6 +172,7 @@ private slots:
void onMultitrackClosed();
void onMultitrackModified();
void onCutModified();
void onFilterModelChanged();
void updateMarkers();
void updateThumbnails();
void on_actionUndo_triggered();
Expand Down

0 comments on commit 6960af2

Please sign in to comment.