Commit 7be20047 authored by Nicolas Carion's avatar Nicolas Carion

Create a separate class to manage timeline tabs

parent b0f4f208
......@@ -163,8 +163,6 @@ void Core::initGUI(const QUrl &Url)
connect(m_producerQueue, SIGNAL(addClip(QString, QMap<QString, QString>)), m_binWidget, SLOT(slotAddUrl(QString, QMap<QString, QString>)));
connect(m_binController.get(), SIGNAL(createThumb(QDomElement, QString, int)), m_producerQueue, SLOT(getFileProperties(QDomElement, QString, int)));
connect(m_binWidget, &Bin::producerReady, m_producerQueue, &ProducerQueue::slotProcessingDone, Qt::DirectConnection);
m_timelineTab = new QTabWidget();
m_timelineTab->setTabBarAutoHide(true);
// TODO
/*connect(m_producerQueue, SIGNAL(removeInvalidProxy(QString,bool)), m_binWidget, SLOT(slotRemoveInvalidProxy(QString,bool)));*/
......@@ -178,15 +176,6 @@ void Core::initGUI(const QUrl &Url)
m_mainWindow->show();
}
QWidget *Core::timelineTabs()
{
return m_timelineTab;
}
void Core::addTimeline(QWidget *timeline, const QString &name)
{
m_timelineTab->addTab(timeline, name);
}
std::unique_ptr<Core> &Core::self()
{
......
......@@ -87,10 +87,6 @@ public:
ProducerQueue *producerQueue();
/** @brief Returns a pointer to the library. */
LibraryWidget *library();
/** @brief Returns a pointer to the timeline. */
QWidget *timelineTabs();
/** @brief Add a new timeline tab. */
void addTimeline(QWidget *timeline, const QString &name);
/** @brief Returns a pointer to MLT's repository */
std::unique_ptr<Mlt::Repository> &getMltRepository();
......@@ -118,7 +114,6 @@ private:
ProducerQueue *m_producerQueue;
Bin *m_binWidget;
LibraryWidget *m_library;
QTabWidget *m_timelineTab;
std::unique_ptr<MltConnection> m_mltConnection;
......
......@@ -61,6 +61,7 @@
#include "timeline/timeline.h"
#include "timeline/timelinesearch.h"
#include "timeline/track.h"
#include "timeline2/view/timelinetabs.hpp"
#include "timeline2/view/timelinewidget.h"
#include "titler/titlewidget.h"
#include "transitions/transitionlist/view/transitionlistwidget.hpp"
......@@ -200,19 +201,6 @@ void MainWindow::init()
stylesAction->addAction(a);
}
connect(stylesGroup, &QActionGroup::triggered, this, &MainWindow::slotChangeStyle);
// Color schemes
KActionMenu *themeAction = new KActionMenu(i18n("Theme"), this);
ThemeManager::instance()->setThemeMenuAction(themeAction);
ThemeManager::instance()->setCurrentTheme(KdenliveSettings::colortheme());
connect(ThemeManager::instance(), &ThemeManager::signalThemeChanged, this, &MainWindow::slotThemeChanged, Qt::DirectConnection);
if (!KdenliveSettings::widgetstyle().isEmpty() && QString::compare(desktopStyle, KdenliveSettings::widgetstyle(), Qt::CaseInsensitive) != 0) {
// User wants a custom widget style, init
doChangeStyle();
} else {
ThemeManager::instance()->slotChangePalette();
}
// QIcon::setThemeSearchPaths(QStringList() <<QStringLiteral(":/icons/"));
new RenderingAdaptor(this);
......@@ -255,7 +243,6 @@ void MainWindow::init()
fr->setMaximumHeight(1);
fr->setLineWidth(1);
ctnLay->addWidget(fr);
ctnLay->addWidget(pCore->timelineTabs());
setCentralWidget(m_timelineToolBarContainer);
setupActions();
......@@ -293,6 +280,22 @@ void MainWindow::init()
pCore->monitorManager()->initMonitors(m_clipMonitor, m_projectMonitor);
connect(m_clipMonitor, SIGNAL(addMasterEffect(QString, QDomElement)), pCore->bin(), SLOT(slotEffectDropped(QString, QDomElement)));
m_timelineTabs = new TimelineTabs(this);
ctnLay->addWidget(m_timelineTabs);
// Color schemes
KActionMenu *themeAction = new KActionMenu(i18n("Theme"), this);
ThemeManager::instance()->setThemeMenuAction(themeAction);
ThemeManager::instance()->setCurrentTheme(KdenliveSettings::colortheme());
connect(ThemeManager::instance(), &ThemeManager::signalThemeChanged, this, &MainWindow::slotThemeChanged, Qt::DirectConnection);
if (!KdenliveSettings::widgetstyle().isEmpty() && QString::compare(desktopStyle, KdenliveSettings::widgetstyle(), Qt::CaseInsensitive) != 0) {
// User wants a custom widget style, init
doChangeStyle();
} else {
ThemeManager::instance()->slotChangePalette();
}
// Audio spectrum scope
m_audioSpectrum = new AudioGraphSpectrum(pCore->monitorManager());
QDockWidget *spectrumDock = addDock(i18n("Audio Spectrum"), QStringLiteral("audiospectrum"), m_audioSpectrum);
......@@ -653,9 +656,7 @@ void MainWindow::slotThemeChanged(const QString &theme)
if (pCore->projectManager() && pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->updatePalette();
}
if (pCore->timelineTabs()) {
pCore->timelineTabs()->setPalette(plt);
}
m_timelineTabs->setPalette(plt);
#if KXMLGUI_VERSION_MINOR < 23 && KXMLGUI_VERSION_MAJOR == 5
// Not required anymore with auto colored icons since KF5 5.23
......@@ -2146,7 +2147,7 @@ void MainWindow::slotPreferences(int page, int option)
connect(dialog, &KdenliveSettingsDialog::checkTabPosition, this, &MainWindow::slotCheckTabPosition);
connect(dialog, &KdenliveSettingsDialog::restartKdenlive, this, &MainWindow::slotRestart);
connect(dialog, &KdenliveSettingsDialog::updateLibraryFolder, pCore.get(), &Core::updateLibraryPath);
connect(dialog, &KdenliveSettingsDialog::audioThumbFormatChanged, pCore->projectManager(), &ProjectManager::audioThumbFormatChanged);
connect(dialog, &KdenliveSettingsDialog::audioThumbFormatChanged, m_timelineTabs, &TimelineTabs::audioThumbFormatChanged);
dialog->show();
if (page != -1) {
......@@ -2208,9 +2209,7 @@ void MainWindow::slotSwitchSplitAudio(bool enable)
void MainWindow::slotSwitchVideoThumbs()
{
KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->showThumbnailsChanged();
}
m_timelineTabs->showThumbnailsChanged();
m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
}
......@@ -2218,9 +2217,7 @@ void MainWindow::slotSwitchAudioThumbs()
{
KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
pCore->binController()->checkAudioThumbs();
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->showAudioThumbnailsChanged();
}
m_timelineTabs->showThumbnailsChanged();
m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
}
......@@ -2262,9 +2259,7 @@ void MainWindow::slotDeleteItem()
}
// effect stack has no focus
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->deleteSelectedClips();
}
m_timelineTabs->getCurrentTimeline()->deleteSelectedClips();
}
}
......@@ -2767,9 +2762,7 @@ void MainWindow::slotSetZoom(int value, bool zoomOnMouse)
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->slotChangeZoom(value, -1, zoomOnMouse);
}
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->slotChangeZoom(value, zoomOnMouse);
}
m_timelineTabs->changeZoom(value, zoomOnMouse);
m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
slotUpdateZoomSliderToolTip(value);
......@@ -2835,9 +2828,7 @@ void MainWindow::slotActivateTransitionView(Transition *transition)
void MainWindow::slotSnapRewind()
{
if (m_projectMonitor->isActive()) {
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->gotoPreviousSnap();
}
m_timelineTabs->getCurrentTimeline()->gotoPreviousSnap();
} else {
m_clipMonitor->slotSeekToPreviousSnap();
}
......@@ -2846,9 +2837,7 @@ void MainWindow::slotSnapRewind()
void MainWindow::slotSnapForward()
{
if (m_projectMonitor->isActive()) {
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->gotoNextSnap();
}
m_timelineTabs->getCurrentTimeline()->gotoNextSnap();
} else {
m_clipMonitor->slotSeekToNextSnap();
}
......@@ -3074,16 +3063,12 @@ QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
void MainWindow::slotResizeItemStart()
{
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->setInPoint();
}
m_timelineTabs->getCurrentTimeline()->setInPoint();
}
void MainWindow::slotResizeItemEnd()
{
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->setOutPoint();
}
m_timelineTabs->getCurrentTimeline()->setOutPoint();
}
int MainWindow::getNewStuff(const QString &configFile)
......@@ -4156,6 +4141,11 @@ void MainWindow::setTrimMode(const QString &mode)
}
}
TimelineWidget *MainWindow::getMainTimeline() const
{
return m_timelineTabs->getMainTimeline();
}
#ifdef DEBUG_MAINW
#undef DEBUG_MAINW
#endif
......@@ -54,6 +54,8 @@ class Monitor;
class RenderWidget;
class Render;
class Transition;
class TimelineTabs;
class TimelineWidget;
class KIconLoader;
class /*KDENLIVECORE_EXPORT*/ MainWindow : public KXmlGuiWindow
......@@ -109,6 +111,9 @@ public:
/** @brief Returns true if docked widget is tabbed with another widget from its object name */
bool isTabbedWith(QDockWidget *widget, const QString &otherWidget);
/** @brief Returns a ptr to the main timeline widget of the project */
TimelineWidget *getMainTimeline() const;
protected:
/** @brief Closes the window.
* @return false if the user presses "Cancel" on a confirmation dialog or
......@@ -157,6 +162,8 @@ private:
KSelectAction *m_timeFormatButton;
KSelectAction *m_compositeAction;
TimelineTabs *m_timelineTabs;
/** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
QList<QDockWidget *> m_gfxScopesList;
......
......@@ -26,6 +26,7 @@ the Free Software Foundation, either version 3 of the License, or
#include "project/notesplugin.h"
#include "timeline/customtrackview.h"
#include "timeline/timeline.h"
#include "timeline2/model/builders/meltBuilder.hpp"
#include "timeline2/view/timelinewidget.h"
#include "transitionsettings.h"
#include "utils/KoIconUtils.h"
......@@ -52,7 +53,6 @@ ProjectManager::ProjectManager(QObject *parent)
, m_project(nullptr)
, m_trackView(nullptr)
, m_progressDialog(nullptr)
, m_timelineWidgetLoaded(false)
{
m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), pCore->window()->actionCollection());
m_fileRevert->setIcon(KoIconUtils::themedIcon(QStringLiteral("document-revert")));
......@@ -120,9 +120,6 @@ void ProjectManager::init(const QUrl &projectUrl, const QString &clipList)
void ProjectManager::newFile(bool showProjectSettings, bool force)
{
if (!pCore->timelineTabs()->isEnabled() && !force) {
return;
}
// fix mantis#3160
QUrl startFile = QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder() + QStringLiteral("/_untitled.kdenlive"));
if (checkForBackupFile(startFile)) {
......@@ -194,7 +191,6 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
documentMetadata = w->metadata();
delete w;
}
pCore->timelineTabs()->setEnabled(true);
bool openBackup;
m_notesPlugin->clear();
KdenliveDoc *doc = new KdenliveDoc(QUrl(), projectFolder, pCore->window()->m_commandStack, profileName, documentProperties, documentMetadata, projectTracks,
......@@ -520,9 +516,6 @@ void ProjectManager::openFile(const QUrl &url)
void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
{
Q_ASSERT(m_project == nullptr);
if (!pCore->timelineTabs()->isEnabled()) {
return;
}
m_fileRevert->setEnabled(true);
delete m_progressDialog;
......@@ -604,7 +597,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
m_trackView->setDuration(m_trackView->duration());*/
pCore->window()->slotGotProgressInfo(QString(), 100);
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_timelineWidget->duration() - 1);
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_mainTimelineModel->duration() - 1);
if (openBackup) {
slotOpenBackup(url);
}
......@@ -615,7 +608,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
void ProjectManager::adjustProjectDuration()
{
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_timelineWidget->duration() - 1);
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_mainTimelineModel->duration() - 1);
}
void ProjectManager::slotRevert()
......@@ -681,11 +674,6 @@ Timeline *ProjectManager::currentTimeline()
return m_trackView;
}
TimelineWidget *ProjectManager::currentTimelineWidget()
{
return m_timelineWidget;
}
KRecentFilesAction *ProjectManager::recentFilesAction()
{
return m_recentFilesAction;
......@@ -877,21 +865,6 @@ void ProjectManager::slotMoveFinished(KJob *job)
void ProjectManager::updateTimeline(Mlt::Tractor tractor)
{
if (!m_timelineWidgetLoaded) {
m_timelineWidgetLoaded = true;
qDebug() << "CONSTRUCTING TIMELINEWIDGET";
m_timelineWidget = new TimelineWidget(pCore->window()->actionCollection(), pCore->binController(), pCore->window());
m_timelineWidget->setModel(TimelineItemModel::construct(&pCore->getCurrentProfile()->profile(), m_project->commandStack()));
pCore->addTimeline(m_timelineWidget, m_project->url().fileName());
connect(pCore->monitorManager()->projectMonitor(), &Monitor::seekTimeline, m_timelineWidget, &TimelineWidget::seek, Qt::DirectConnection);
connect(m_timelineWidget, &TimelineWidget::seeked, pCore->monitorManager()->projectMonitor(), &Monitor::requestSeek, Qt::DirectConnection);
connect(pCore->monitorManager()->projectMonitor(), &Monitor::seekPosition, m_timelineWidget, &TimelineWidget::onSeeked, Qt::DirectConnection);
connect(m_timelineWidget, &TimelineWidget::focusProjectMonitor, pCore->monitorManager(), &MonitorManager::focusProjectMonitor);
pCore->monitorManager()->projectMonitor()->setProducer(m_timelineWidget->producer());
connect(m_timelineWidget, &TimelineWidget::zoomIn, pCore->window(), &MainWindow::slotZoomIn);
connect(m_timelineWidget, &TimelineWidget::zoomOut, pCore->window(), &MainWindow::slotZoomOut);
connect(m_timelineWidget, &TimelineWidget::durationChanged, this, &ProjectManager::adjustProjectDuration);
}
qDebug() << "FILLING TIMELINEWIDGET";
pCore->binController()->loadBinPlaylist(tractor);
const QStringList ids = pCore->binController()->getClipIds();
......@@ -906,14 +879,11 @@ void ProjectManager::updateTimeline(Mlt::Tractor tractor)
info.replaceProducer = true;
pCore->bin()->slotProducerReady(info, pCore->binController()->getController(id).get());
}
pCore->binController()->setBinPlaylist(m_timelineWidget->tractor());
m_timelineWidget->buildFromMelt(tractor);
m_timelineWidget->setUndoStack(m_project->commandStack());
pCore->binController()->setBinPlaylist(&tractor);
m_mainTimelineModel = TimelineItemModel::construct(&pCore->getCurrentProfile()->profile(), m_project->commandStack());
constructTimelineFromMelt(m_mainTimelineModel, tractor);
pCore->monitorManager()->projectMonitor()->setProducer(m_mainTimelineModel->producer());
pCore->window()->getMainTimeline()->setModel(m_mainTimelineModel);
m_mainTimelineModel->setUndoStack(m_project->commandStack());
}
void ProjectManager::audioThumbFormatChanged()
{
if (m_timelineWidget) {
m_timelineWidget->audioThumbFormatChanged();
}
}
......@@ -21,6 +21,7 @@ the Free Software Foundation, either version 3 of the License, or
#include "doc/docundostack.hpp"
#include "timeline/timeline.h"
#include "timeline2/model/timelineitemmodel.hpp"
#include <memory>
#include <unordered_map>
......@@ -28,7 +29,6 @@ the Free Software Foundation, either version 3 of the License, or
class Project;
class KdenliveDoc;
class TimelineWidget;
class NotesPlugin;
class QAction;
class QUrl;
......@@ -53,7 +53,6 @@ public:
/** @brief Returns a pointer to the currently opened project. A project should always be open. */
KdenliveDoc *current();
Timeline *currentTimeline();
TimelineWidget *currentTimelineWidget();
/** @brief Store command line args for later opening. */
void init(const QUrl &projectUrl, const QString &clipList);
......@@ -126,12 +125,11 @@ public slots:
/** @brief Un/Set current track as target */
void slotSwitchTrackTarget();
/** @brief Request repaint of audio thumbs */
void audioThumbFormatChanged();
/** @brief Set the text for current project's notes */
void setDocumentNotes(const QString &notes);
/** @brief Project's duration changed, adjust monitor, etc. */
void adjustProjectDuration();
private slots:
void slotRevert();
/** @brief Open the project's backupdialog. */
......@@ -141,8 +139,6 @@ private slots:
/** @brief Report progress of folder move operation. */
void slotMoveProgress(KJob *, unsigned long progress);
void slotMoveFinished(KJob *job);
/** @brief Project's duration changed, adjust monitor, etc. */
void adjustProjectDuration();
signals:
void docOpened(KdenliveDoc *document);
......@@ -161,8 +157,7 @@ private:
KdenliveDoc *m_project;
Timeline *m_trackView; // TODO delete this
TimelineWidget *m_timelineWidget;
bool m_timelineWidgetLoaded;
std::shared_ptr<TimelineItemModel> m_mainTimelineModel;
QTime m_lastSave;
QTimer m_autoSaveTimer;
QUrl m_startUrl;
......
......@@ -8,6 +8,7 @@ set(kdenlive_SRCS
timeline2/model/trackmodel.cpp
timeline2/model/snapmodel.cpp
timeline2/model/builders/meltBuilder.cpp
timeline2/view/timelinetabs.cpp
timeline2/view/timelinewidget.cpp
timeline2/view/qml/timelineitems.cpp
timeline2/view/qmltypes/thumbnailprovider.cpp
......
......@@ -1390,3 +1390,9 @@ void TimelineModel::setTimelineEffectsEnabled(bool enabled)
// TODO if we support track effects, they should be disabled here too
}
Mlt::Producer *TimelineModel::producer()
{
auto *prod = new Mlt::Producer(tractor());
return prod;
}
......@@ -128,6 +128,10 @@ public:
virtual ~TimelineModel();
Mlt::Tractor *tractor() const { return m_tractor.get(); }
/* @brief Returns the current tractor's producer, useful fo control seeking, playing, etc
*/
Mlt::Producer *producer();
Mlt::Profile *getProfile();
/* @brief returns the number of tracks */
......@@ -204,54 +208,45 @@ public:
*/
Q_INVOKABLE bool requestClipMove(int clipId, int trackId, int position, bool updateView = true, bool logUndo = true);
/* @brief Move a composition to a specific position
This action is undoable
Returns true on success. If it fails, nothing is modified.
If the clip is not in inserted in a track yet, it gets inserted for the first time.
If the clip is in a group, the call is deferred to requestGroupMove
@param transid is the ID of the composition
@param trackId is the ID of the track
*/
Q_INVOKABLE bool requestCompositionMove(int compoId, int trackId, int position, bool updateView = true, bool logUndo = true);
/* @brief Move a composition to a specific position This action is undoable
Returns true on success. If it fails, nothing is modified. If the clip is
not in inserted in a track yet, it gets inserted for the first time. If
the clip is in a group, the call is deferred to requestGroupMove @param
transid is the ID of the composition @param trackId is the ID of the
track */ Q_INVOKABLE bool
requestCompositionMove(int compoId, int trackId, int position, bool updateView = true, bool logUndo = true);
Q_INVOKABLE int getCompositionPosition(int compoId) const;
Q_INVOKABLE int suggestCompositionMove(int compoId, int trackId, int position);
int getCompositionPlaytime(int compoId) const;
protected:
/* Same function, but accumulates undo and redo, and doesn't check for group*/
protected: /* Same function, but accumulates undo and redo, and doesn't check
for group*/
bool requestClipMove(int clipId, int trackId, int position, bool updateView, Fun &undo, Fun &redo);
bool requestCompositionMove(int transid, int trackId, int position, bool updateView, Fun &undo, Fun &redo);
public:
/* @brief Given an intended move, try to suggest a more valid one (accounting for snaps and missing UI calls)
@param clipId id of the clip to move
@param trackId id of the target track
@param position target position of the clip
*/
public: /* @brief Given an intended move, try to suggest a more valid one
(accounting for snaps and missing UI calls) @param clipId id of the clip to
move @param trackId id of the target track @param position target position
of the clip */
Q_INVOKABLE int suggestClipMove(int clipId, int trackId, int position);
/* @brief Request clip insertion at given position.
This action is undoable
Returns true on success. If it fails, nothing is modified.
@param binClipId id of the clip in the bin
@param track Id of the track where to insert
@param Requested position
@param ID return parameter of the id of the inserted clip
@param logUndo if set to false, no undo object is stored
*/
bool requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo = true);
/* Same function, but accumulates undo and redo*/
/* @brief Request clip insertion at given position. This action is undoable
Returns true on success. If it fails, nothing is modified. @param
binClipId id of the clip in the bin @param track Id of the track where to
insert @param Requested position @param ID return parameter of the id of
the inserted clip @param logUndo if set to false, no undo object is
stored */ bool
requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo = true); /* Same function,
but accumulates undo and redo*/
bool requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, Fun &undo, Fun &redo);
/* @brief Deletes the given clip or composition from the timeline
This action is undoable
Returns true on success. If it fails, nothing is modified.
If the clip/composition is in a group, the call is deferred to requestGroupDeletion
@param clipId is the ID of the clip/composition
@param logUndo if set to false, no undo object is stored
*/
Q_INVOKABLE bool requestItemDeletion(int clipId, bool logUndo = true);
/* @brief Deletes the given clip or composition from the timeline This
action is undoable Returns true on success. If it fails, nothing is
modified. If the clip/composition is in a group, the call is deferred to
requestGroupDeletion @param clipId is the ID of the clip/composition
@param logUndo if set to false, no undo object is stored */ Q_INVOKABLE bool
requestItemDeletion(int clipId, bool logUndo = true);
/* Same function, but accumulates undo and redo, and doesn't check for group*/
bool requestClipDeletion(int clipId, Fun &undo, Fun &redo);
bool requestCompositionDeletion(int compositionId, Fun &undo, Fun &redo);
......
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "timelinetabs.hpp"
#include "core.h"
#include "mainwindow.h"
#include "monitor/monitor.h"
#include "monitor/monitormanager.h"
#include "project/projectmanager.h"
#include "timelinewidget.h"
TimelineTabs::TimelineTabs(QWidget *parent)
: QTabWidget(parent)
, m_mainTimeline(new TimelineWidget(pCore->window()->actionCollection(), pCore->binController(), this))
{
setTabBarAutoHide(true);
setTabsClosable(true);
addTab(m_mainTimeline, i18n("Main timeline"));
connectTimeline(m_mainTimeline);
// Resize to 0 the size of the close button of the main timeline, so that the user cannnot close it.
tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
}
TimelineWidget *TimelineTabs::getMainTimeline() const
{
return m_mainTimeline;
}
TimelineWidget *TimelineTabs::getCurrentTimeline() const
{
return static_cast<TimelineWidget *>(currentWidget());
}
void TimelineTabs::connectTimeline(TimelineWidget *timeline)
{
connect(pCore->monitorManager()->projectMonitor(), &Monitor::seekTimeline, timeline, &TimelineWidget::seek, Qt::DirectConnection);
connect(timeline, &TimelineWidget::seeked, pCore->monitorManager()->projectMonitor(), &Monitor::requestSeek, Qt::DirectConnection);
connect(pCore->monitorManager()->projectMonitor(), &Monitor::seekPosition, timeline, &TimelineWidget::onSeeked, Qt::DirectConnection);
connect(timeline, &TimelineWidget::focusProjectMonitor, pCore->monitorManager(), &MonitorManager::focusProjectMonitor);
connect(timeline, &TimelineWidget::zoomIn, pCore->window(), &MainWindow::slotZoomIn);
connect(timeline, &TimelineWidget::zoomOut, pCore->window(), &MainWindow::slotZoomOut);
connect(timeline, &TimelineWidget::durationChanged, pCore->projectManager(), &ProjectManager::adjustProjectDuration);
connect(this, &TimelineTabs::audioThumbFormatChanged, timeline, &TimelineWidget::audioThumbFormatChanged);
connect(this, &TimelineTabs::showThumbnailsChanged, timeline, &TimelineWidget::showThumbnailsChanged);
connect(this, &TimelineTabs::showAudioThumbnailsChanged, timeline, &TimelineWidget::showAudioThumbnailsChanged);
connect(this, &TimelineTabs::changeZoom, timeline, &TimelineWidget::slotChangeZoom);
}
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef TIMELINETABS_H
#define TIMELINETABS_H
#include <QTabWidget>
/* @brief This is a class that extends QTabWidget to provide additional functionnality related to timeline tabs
*/
class TimelineWidget;
class TimelineTabs : public QTabWidget
{
Q_OBJECT
public:
/* Construct the tabs as well as the widget for the main timeline */
TimelineTabs(QWidget *parent);
/* @brief Returns a pointer to the main timeline */
TimelineWidget *getMainTimeline() const;
/* @brief Returns a pointer to the current timeline */
TimelineWidget *getCurrentTimeline() const;
protected:
/** @brief Helper function to connect a timeline's signals/slots*/
void connectTimeline(TimelineWidget *timeline);
signals:
/** @brief Request repaint of audio thumbs
This is an input signal, forwarded to the timelines
*/
void audioThumbFormatChanged();
/** @brief The parameter controlling whether we show video thumbnails has changed
This is an input signal, forwarded to the timelines
*/
void showThumbnailsChanged();
/** @brief The parameter controlling whether we show audio thumbnails has changed
This is an input signal, forwarded to the timelines
*/
void showAudioThumbnailsChanged();
/** @brief Change the level of zoom
This is an input signal, forwarded to the timelines
*/
void changeZoom(int value, bool zoomOnMouse);
private:
TimelineWidget *m_mainTimeline;
};
#endif
......@@ -25,6 +25,7 @@
#include "core.h"
#include "doc/docundostack.hpp"
#include "kdenlivesettings.h"
#include "mainwindow.h"
#include "profiles/profilemodel.hpp"
#include "qml/timelineitems.h"
#include "qmltypes/thumbnailprovider.h"
......@@ -75,6 +76,7 @@ TimelineWidget::TimelineWidget(KActionCollection *actionCollection, std::shared_
void TimelineWidget::setModel(std::shared_ptr<TimelineItemModel> model)
{
m_thumbnailer->resetProject();
m_model = model;