Cleanup track actions, add "Select all clips in a track" and "Select all clips...

Cleanup track actions, add "Select all clips in a track" and "Select all clips in timeline" actions:
http://kdenlive.org/mantis/view.php?id=1950
parent c3e7b5a7
......@@ -6343,6 +6343,29 @@ void CustomTrackView::slotSelectTrack(int ix)
viewport()->update();
}
void CustomTrackView::slotSelectClipsInTrack()
{
QRectF rect(0, m_selectedTrack * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), m_tracksHeight / 2 - 1);
QList<QGraphicsItem *> selection = m_scene->items(rect);
m_scene->clearSelection();
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
selection.at(i)->setSelected(true);
}
}
}
void CustomTrackView::slotSelectAllClips()
{
QList<QGraphicsItem *> selection = m_scene->items();
m_scene->clearSelection();
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
selection.at(i)->setSelected(true);
}
}
}
void CustomTrackView::selectClip(bool add, bool group, int track, int pos)
{
QRectF rect;
......
......@@ -262,6 +262,10 @@ public slots:
* @param effect The new effect xml
* @param ix The track index */
void slotAddTrackEffect(const QDomElement &effect, int ix);
/** @brief Select all clips in selected track. */
void slotSelectClipsInTrack();
/** @brief Select all clips in timeline. */
void slotSelectAllClips();
/** @brief Update the list of snap points (sticky timeline hotspots).
* @param selected The currently selected clip if any
......@@ -454,6 +458,7 @@ private slots:
/** @brief A Filter job producer results. */
void slotGotFilterJobResults(const QString &id, int startPos, int track, const QString &filter, stringMap filterParams);
signals:
void cursorMoved(int, int);
void zoomIn();
......
......@@ -33,7 +33,7 @@
#include <QTimer>
#include <QDomDocument>
HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent) :
HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QList <QAction *> actions, QWidget *parent) :
QWidget(parent),
m_index(index),
m_type(info.type),
......@@ -88,18 +88,8 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent)
//horizontalSpacer;
}
setContextMenuPolicy(Qt::DefaultContextMenu); //Qt::ActionsContextMenu);
QAction *insertAction = new QAction(i18n("Insert Track"), this);
m_menu.addAction(insertAction);
connect(insertAction, SIGNAL(triggered()), this, SLOT(slotAddTrack()));
QAction *removeAction = new QAction(KIcon("edit-delete"), i18n("Delete Track"), this);
m_menu.addAction(removeAction);
connect(removeAction, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
QAction *configAction = new QAction(KIcon("configure"), i18n("Configure Track"), this);
m_menu.addAction(configAction);
connect(configAction, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
setContextMenuPolicy(Qt::ActionsContextMenu);
addActions(actions);
}
/*HeaderTrack::~HeaderTrack()
......@@ -129,23 +119,13 @@ void HeaderTrack::mousePressEvent(QMouseEvent * event)
QWidget::mousePressEvent(event);
}
// virtual
void HeaderTrack::contextMenuEvent(QContextMenuEvent * event)
{
if (track_number->hasFocus()) {
track_number->clearFocus();
return;
}
m_menu.popup(event->globalPos());
}
void HeaderTrack::mouseDoubleClickEvent(QMouseEvent* event)
{
if (track_number->hasFocus()) {
track_number->clearFocus();
return;
}
slotConfigTrack();
emit configTrack(m_index);
QWidget::mouseDoubleClickEvent(event);
}
......@@ -248,25 +228,11 @@ void HeaderTrack::slotDeleteTrack()
QTimer::singleShot(500, this, SLOT(deleteTrack()));
}
void HeaderTrack::deleteTrack()
{
emit deleteTrack(m_index);
}
void HeaderTrack::slotAddTrack()
{
emit insertTrack(m_index);
}
void HeaderTrack::slotRenameTrack()
{
if (m_name != track_number->text()) emit renameTrack(m_index, track_number->text());
}
void HeaderTrack::slotConfigTrack()
{
emit configTrack(m_index);
}
#include "headertrack.moc"
......@@ -32,7 +32,7 @@ class HeaderTrack : public QWidget, public Ui::TrackHeader_UI
Q_OBJECT
public:
HeaderTrack(int index, TrackInfo info, int height, QWidget *parent = 0);
HeaderTrack(int index, TrackInfo info, int height, QList <QAction *> actions, QWidget *parent = 0);
//virtual ~HeaderTrack();
void setLock(bool lock);
void adjustSize(int height);
......@@ -43,7 +43,6 @@ public:
protected:
virtual void mousePressEvent(QMouseEvent * event);
virtual void mouseDoubleClickEvent(QMouseEvent * event);
virtual void contextMenuEvent(QContextMenuEvent * event);
virtual void dropEvent(QDropEvent * event);
virtual void dragEnterEvent(QDragEnterEvent *event);
......@@ -51,25 +50,19 @@ private:
int m_index;
TRACKTYPE m_type;
bool m_isSelected;
QMenu m_menu;
QString m_name;
private slots:
void switchAudio();
void switchVideo();
void slotDeleteTrack();
void deleteTrack();
void slotAddTrack();
void slotRenameTrack();
void slotConfigTrack();
void switchLock(bool emitSignal = true);
signals:
void switchTrackAudio(int);
void switchTrackVideo(int);
void switchTrackLock(int);
void insertTrack(int);
void deleteTrack(int);
void renameTrack(int, QString);
void selectTrack(int);
void configTrack(int);
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<gui name="kdenlive" version="68">
<gui name="kdenlive" version="69">
<ToolBar name="extraToolBar" >
<text>Extra Toolbar</text>
<Action name="project_render" />
......@@ -38,6 +38,9 @@
<Action name="insert_track" />
<Action name="delete_track" />
<Action name="config_tracks" />
<Separator />
<Action name="select_track" />
<Action name="select_all_tracks" />
</Menu>
<Separator />
<Action name="stopmotion" />
......
......@@ -479,6 +479,9 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
/*ScriptingPart* sp = new ScriptingPart(this, QStringList());
guiFactory()->addClient(sp);*/
QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
if (saveLayout)
......@@ -1542,18 +1545,29 @@ void MainWindow::setupActions()
collection.addAction("delete_space", removeSpace);
connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
collection.addAction("insert_track", insertTrack);
m_tracksActionCollection = new KActionCollection(m_tracksActionCollection, KGlobal::mainComponent());
m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
m_tracksActionCollection->addAction("insert_track", insertTrack);
connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
collection.addAction("delete_track", deleteTrack);
KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
m_tracksActionCollection->addAction("delete_track", deleteTrack);
connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
collection.addAction("config_tracks", configTracks);
KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
m_tracksActionCollection->addAction("config_tracks", configTracks);
connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
m_tracksActionCollection->addAction("select_track", selectTrack);
QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_tracksActionCollection->addAction("select_all_tracks", selectAll);
KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
collection.addAction("add_guide", addGuide);
connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
......@@ -1883,7 +1897,7 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
if (!ok) {
// MLT is broken
......@@ -2138,7 +2152,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
qApp->processEvents();
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
connectDocument(trackView, doc);
progressDialog.progressBar()->setValue(3);
qApp->processEvents();
......@@ -2503,8 +2517,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
......@@ -2538,8 +2550,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
//connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
......@@ -2600,9 +2610,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
m_activeTimeline = trackView;
if (m_renderWidget) {
slotCheckRenderStatus();
......@@ -2653,6 +2661,7 @@ void MainWindow::slotEditKeys()
KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
dialog.configure();
}
......@@ -2952,8 +2961,10 @@ void MainWindow::slotRemoveSpace()
void MainWindow::slotInsertTrack(int ix)
{
m_projectMonitor->activateMonitor();
if (m_activeTimeline)
if (m_activeTimeline) {
if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
m_activeTimeline->projectView()->slotInsertTrack(ix);
}
if (m_activeDocument)
m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
}
......@@ -2961,8 +2972,10 @@ void MainWindow::slotInsertTrack(int ix)
void MainWindow::slotDeleteTrack(int ix)
{
m_projectMonitor->activateMonitor();
if (m_activeTimeline)
if (m_activeTimeline) {
if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
m_activeTimeline->projectView()->slotDeleteTrack(ix);
}
if (m_activeDocument)
m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
}
......@@ -2976,6 +2989,21 @@ void MainWindow::slotConfigTrack(int ix)
m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
}
void MainWindow::slotSelectTrack()
{
m_projectMonitor->activateMonitor();
if (m_activeTimeline) {
m_activeTimeline->projectView()->slotSelectClipsInTrack();
}
}
void MainWindow::slotSelectAllTracks()
{
m_projectMonitor->activateMonitor();
if (m_activeTimeline)
m_activeTimeline->projectView()->slotSelectAllClips();
}
void MainWindow::slotEditGuide()
{
if (m_activeTimeline)
......
......@@ -260,6 +260,7 @@ private:
StatusBarMessageLabel *m_messageLabel;
QActionGroup *m_clipTypeGroup;
KActionCollection *m_effectsActionCollection;
KActionCollection *m_tracksActionCollection;
bool m_findActivated;
QString m_findString;
......@@ -453,10 +454,14 @@ private slots:
void slotResizeItemStart();
void slotResizeItemEnd();
void configureNotifications();
void slotInsertTrack(int ix = 0);
void slotDeleteTrack(int ix = 0);
void slotInsertTrack(int ix = -1);
void slotDeleteTrack(int ix = -1);
/** @brief Shows the configure tracks dialog and updates transitions afterwards. */
void slotConfigTrack(int ix = -1);
/** @brief Select all clips in active track. */
void slotSelectTrack();
/** @brief Select all clips in timeline. */
void slotSelectAllTracks();
void slotGetNewLumaStuff();
void slotGetNewTitleStuff();
void slotGetNewRenderStuff();
......
......@@ -39,14 +39,14 @@
#include <QScrollBar>
#include <QInputDialog>
TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
TrackView::TrackView(KdenliveDoc *doc, QList <QAction*> actions, bool *ok, QWidget *parent) :
QWidget(parent),
m_scale(1.0),
m_projectTracks(0),
m_doc(doc),
m_verticalZoom(1)
{
m_trackActions << actions;
setupUi(this);
// ruler_frame->setMaximumHeight();
// size_frame->setMaximumHeight();
......@@ -550,15 +550,13 @@ void TrackView::slotRebuildTrackHeaders()
frame->setFixedHeight(1);
headers_container->layout()->addWidget(frame);
TrackInfo info = list.at(max - i - 1);
header = new HeaderTrack(i, info, height, headers_container);
header = new HeaderTrack(i, info, height, m_trackActions, headers_container);
header->setPalette(p);
header->setSelectedIndex(m_trackview->selectedTrack());
connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
connect(header, SIGNAL(selectTrack(int)), m_trackview, SLOT(slotSelectTrack(int)));
connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
connect(header, SIGNAL(renameTrack(int, QString)), this, SLOT(slotRenameTrack(int, QString)));
connect(header, SIGNAL(configTrack(int)), this, SIGNAL(configTrack(int)));
connect(header, SIGNAL(addTrackInfo(const QDomElement, int)), m_trackview, SLOT(slotAddTrackEffect(const QDomElement, int)));
......
......@@ -51,7 +51,7 @@ class TrackView : public QWidget, public Ui::TimeLine_UI
Q_OBJECT
public:
explicit TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent = 0);
explicit TrackView(KdenliveDoc *doc, QList <QAction *> actions, bool *ok, QWidget *parent = 0);
virtual ~ TrackView();
void setEditMode(const QString & editMode);
const QString & editMode() const;
......@@ -103,6 +103,8 @@ private:
KdenliveDoc *m_doc;
int m_verticalZoom;
QString m_documentErrors;
QList <QAction *> m_trackActions;
void parseDocument(QDomDocument doc);
int slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNodeList producers);
DocClipBase *getMissingProducer(const QString id) const;
......@@ -141,8 +143,6 @@ signals:
void mousePosition(int);
void cursorMoved();
void zoneMoved(int, int);
void insertTrack(int);
void deleteTrack(int);
void configTrack(int);
void updateTracksInfo();
void setZoom(int);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment